source: trunk/src/user32/new/win32wbasenonclient.cpp@ 2449

Last change on this file since 2449 was 2449, checked in by sandervl, 26 years ago

put back original frame drawing code

File size: 39.6 KB
Line 
1/* $Id: win32wbasenonclient.cpp,v 1.11 2000-01-15 16:37:12 sandervl Exp $ */
2/*
3 * Win32 Window Base Class for OS/2 (non-client methods)
4 *
5 * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch)
6 *
7 * Based on Wine code (windows\nonclient.c)
8 *
9 * Copyright 1994 Alexandre Julliard
10 *
11 * TODO: Not thread/process safe
12 *
13 * Project Odin Software License can be found in LICENSE.TXT
14 *
15 */
16#include <os2win.h>
17#include <win.h>
18#include <stdlib.h>
19#include <string.h>
20#include <stdarg.h>
21#include <assert.h>
22#include <misc.h>
23#include <heapstring.h>
24#include <win32wbase.h>
25#include <winres.h>
26#include "wndmsg.h"
27#include "pmframe.h"
28#include "oslibwin.h"
29#include "oslibmsg.h"
30#include "oslibutil.h"
31#include "oslibgdi.h"
32#include "oslibres.h"
33#include "oslibdos.h"
34#include "syscolor.h"
35#include "win32wndhandle.h"
36#include "dc.h"
37#include "win32wdesktop.h"
38#include "controls.h"
39#include <menu.h>
40
41#define SC_ABOUTODIN (SC_SCREENSAVE+1)
42#define SC_PUTMARK (SC_SCREENSAVE+2)
43
44/* bits in the dwKeyData */
45#define KEYDATA_ALT 0x2000
46#define KEYDATA_PREVSTATE 0x4000
47
48static HBITMAP hbitmapClose = 0;
49static HBITMAP hbitmapCloseD = 0;
50static HBITMAP hbitmapMinimize = 0;
51static HBITMAP hbitmapMinimizeD = 0;
52static HBITMAP hbitmapMaximize = 0;
53static HBITMAP hbitmapMaximizeD = 0;
54static HBITMAP hbitmapRestore = 0;
55static HBITMAP hbitmapRestoreD = 0;
56
57BYTE lpGrayMask[] = { 0xAA, 0xA0,
58 0x55, 0x50,
59 0xAA, 0xA0,
60 0x55, 0x50,
61 0xAA, 0xA0,
62 0x55, 0x50,
63 0xAA, 0xA0,
64 0x55, 0x50,
65 0xAA, 0xA0,
66 0x55, 0x50};
67
68static INT (* WINAPI ShellAboutA)(HWND,LPCSTR,LPCSTR,HICON) = 0;
69
70//******************************************************************************
71//******************************************************************************
72LONG Win32BaseWindow::HandleNCActivate(WPARAM wParam)
73{
74 WORD wStateChange;
75
76 //CB: only caption is changed on activation
77 if (!(dwStyle & WS_CAPTION)) return TRUE;
78
79 if( wParam ) wStateChange = !(flags & WIN_NCACTIVATED);
80 else wStateChange = flags & WIN_NCACTIVATED;
81
82 if( wStateChange )
83 {
84 if (wParam) flags |= WIN_NCACTIVATED;
85 else flags &= ~WIN_NCACTIVATED;
86
87 if(!(dwStyle & WS_MINIMIZE))
88 DoNCPaint((HRGN)1,FALSE);
89 }
90
91 return TRUE;
92}
93//******************************************************************************
94//******************************************************************************
95VOID Win32BaseWindow::TrackMinMaxBox(WORD wParam)
96{
97 MSG msg;
98 HDC hdc;
99 BOOL pressed = TRUE;
100 UINT state;
101
102 if (wParam == HTMINBUTTON)
103 {
104 /* If the style is not present, do nothing */
105 if (!(dwStyle & WS_MINIMIZEBOX))
106 return;
107 /* Check if the sysmenu item for minimize is there */
108 state = GetMenuState(hSysMenu,SC_MINIMIZE,MF_BYCOMMAND);
109 } else
110 {
111 /* If the style is not present, do nothing */
112 if (!(dwStyle & WS_MAXIMIZEBOX))
113 return;
114 /* Check if the sysmenu item for maximize is there */
115 state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
116 }
117 SetCapture(Win32Hwnd);
118 hdc = GetWindowDC(Win32Hwnd);
119 if (wParam == HTMINBUTTON)
120 DrawMinButton(hdc,NULL,TRUE,FALSE);
121 else
122 DrawMaxButton(hdc,NULL,TRUE,FALSE);
123 do
124 {
125 BOOL oldstate = pressed;
126
127 GetMessageA(&msg,Win32Hwnd,0,0);
128 pressed = (HandleNCHitTest(msg.pt) == wParam);
129 if (pressed != oldstate)
130 {
131 if (wParam == HTMINBUTTON)
132 DrawMinButton(hdc,NULL,pressed,FALSE);
133 else
134 DrawMaxButton(hdc,NULL,pressed,FALSE);
135 }
136 } while (msg.message != WM_LBUTTONUP);
137 if (wParam == HTMINBUTTON)
138 DrawMinButton(hdc,NULL,FALSE,FALSE);
139 else
140 DrawMaxButton(hdc,NULL,FALSE,FALSE);
141 ReleaseCapture();
142 ReleaseDC(Win32Hwnd,hdc);
143 /* If the item minimize or maximize of the sysmenu are not there */
144 /* or if the style is not present, do nothing */
145 if ((!pressed) || (state == 0xFFFFFFFF))
146 return;
147 if (wParam == HTMINBUTTON)
148 SendInternalMessageA(WM_SYSCOMMAND,SC_MINIMIZE,*(LPARAM*)&msg.pt);
149 else
150 SendInternalMessageA(WM_SYSCOMMAND,IsZoomed(Win32Hwnd) ? SC_RESTORE:SC_MAXIMIZE,*(LPARAM*)&msg.pt);
151}
152//******************************************************************************
153//******************************************************************************
154VOID Win32BaseWindow::TrackCloseButton(WORD wParam)
155{
156 MSG msg;
157 HDC hdc;
158 BOOL pressed = TRUE;
159 UINT state;
160
161 if (hSysMenu == 0)
162 return;
163 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
164 /* If the item close of the sysmenu is disabled or not there do nothing */
165 if((state & MF_DISABLED) || (state & MF_GRAYED) || (state == 0xFFFFFFFF))
166 return;
167 hdc = GetWindowDC(Win32Hwnd);
168 SetCapture(Win32Hwnd);
169 DrawCloseButton(hdc,NULL,TRUE,FALSE);
170 do
171 {
172 BOOL oldstate = pressed;
173
174 GetMessageA(&msg,Win32Hwnd,0,0);
175 pressed = (HandleNCHitTest(msg.pt) == wParam);
176 if (pressed != oldstate)
177 DrawCloseButton(hdc,NULL,pressed,FALSE);
178 } while (msg.message != WM_LBUTTONUP);
179 DrawCloseButton(hdc,NULL,FALSE,FALSE);
180 ReleaseCapture();
181 ReleaseDC(Win32Hwnd,hdc);
182 if (!pressed) return;
183 SendInternalMessageA(WM_SYSCOMMAND,SC_CLOSE,*(LPARAM*)&msg.pt);
184}
185//******************************************************************************
186//******************************************************************************
187VOID Win32BaseWindow::TrackScrollBar(WPARAM wParam,POINT pt)
188{
189 INT scrollbar;
190 MSG msg;
191
192 if ((wParam & 0xfff0) == SC_HSCROLL)
193 {
194 if ((wParam & 0x0f) != HTHSCROLL) return;
195 scrollbar = SB_HORZ;
196 } else /* SC_VSCROLL */
197 {
198 if ((wParam & 0x0f) != HTVSCROLL) return;
199 scrollbar = SB_VERT;
200 }
201
202 pt.x -= rectWindow.left;
203 pt.y -= rectWindow.top;
204 SCROLL_HandleScrollEvent(Win32Hwnd,0,MAKELONG(pt.x,pt.y),scrollbar,WM_LBUTTONDOWN);
205 if (GetCapture() != Win32Hwnd) return;
206 do
207 {
208 GetMessageA(&msg, 0, 0, 0);
209 if(msg.hwnd == getWindowHandle())
210 {
211 switch(msg.message)
212 {
213 case WM_LBUTTONUP:
214 case WM_MOUSEMOVE:
215 pt.x = msg.pt.x-rectWindow.left;
216 pt.y = msg.pt.y-rectWindow.top;
217 msg.lParam = MAKELONG(pt.x,pt.y);
218
219 case WM_SYSTIMER:
220 SCROLL_HandleScrollEvent(Win32Hwnd,msg.wParam,msg.lParam,scrollbar,msg.message);
221 break;
222
223 default:
224 TranslateMessage(&msg);
225 DispatchMessageA(&msg);
226 break;
227 }
228 }
229 else {
230 TranslateMessage(&msg);
231 DispatchMessageA(&msg);
232 }
233 if (!IsWindow())
234 {
235 ReleaseCapture();
236 break;
237 }
238 } while (msg.message != WM_LBUTTONUP);
239}
240//******************************************************************************
241//******************************************************************************
242LONG Win32BaseWindow::HandleNCLButtonDown(WPARAM wParam,LPARAM lParam)
243{
244 switch(wParam) /* Hit test */
245 {
246 case HTCAPTION:
247 if (GetActiveWindow() != Win32Hwnd)
248 SetActiveWindow();
249
250 if (GetActiveWindow() == Win32Hwnd)
251 SendInternalMessageA(WM_SYSCOMMAND,SC_MOVE+HTCAPTION,lParam);
252 break;
253
254 case HTSYSMENU:
255 if(dwStyle & WS_SYSMENU )
256 {
257 SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTSYSMENU,lParam);
258 }
259 break;
260
261 case HTMENU:
262 SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU,lParam);
263 break;
264
265 case HTHSCROLL:
266 SendInternalMessageA(WM_SYSCOMMAND,SC_HSCROLL+HTHSCROLL,lParam);
267 break;
268
269 case HTVSCROLL:
270 SendInternalMessageA(WM_SYSCOMMAND,SC_VSCROLL+HTVSCROLL,lParam);
271 break;
272
273 case HTMINBUTTON:
274 case HTMAXBUTTON:
275 TrackMinMaxBox(wParam);
276 break;
277
278 case HTCLOSE:
279 TrackCloseButton(wParam);
280 break;
281
282 case HTLEFT:
283 case HTRIGHT:
284 case HTTOP:
285 case HTTOPLEFT:
286 case HTTOPRIGHT:
287 case HTBOTTOM:
288 case HTBOTTOMLEFT:
289 case HTBOTTOMRIGHT:
290 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
291 SendInternalMessageA(WM_SYSCOMMAND,SC_SIZE+wParam-2,lParam);
292 break;
293 case HTBORDER:
294 break;
295 }
296
297 return 0;
298}
299//******************************************************************************
300//******************************************************************************
301BOOL Win32BaseWindow::WindowNeedsWMBorder()
302{
303 if (!(dwStyle & WS_CHILD) &&
304 //Options.managed && //CB: to check
305 !(dwExStyle & WS_EX_TOOLWINDOW) &&
306 ( ((dwStyle & WS_CAPTION) == WS_CAPTION) ||
307 (dwStyle & WS_THICKFRAME)))
308 return TRUE;
309 if (dwExStyle & WS_EX_TRAYWINDOW)
310 return TRUE;
311 return FALSE;
312}
313//******************************************************************************
314//******************************************************************************
315VOID Win32BaseWindow::AdjustRectOuter(LPRECT rect,BOOL menu)
316{
317 if(dwStyle & WS_ICONIC) return;
318
319 /* Decide if the window will be managed (see CreateWindowEx) */
320 //if (!WindowNeedsWMBorder()) //CB: check Options.managed
321 {
322 if (HAS_THICKFRAME(dwStyle,dwExStyle ))
323 InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
324 else
325 if (HAS_DLGFRAME( dwStyle, dwExStyle ))
326 InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
327 else
328 if (HAS_THINFRAME( dwStyle ))
329 InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
330
331 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
332 {
333 if (dwExStyle & WS_EX_TOOLWINDOW)
334 rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
335 else
336 rect->top -= GetSystemMetrics(SM_CYCAPTION);
337 }
338 }
339
340 if (menu)
341 rect->top -= GetSystemMetrics(SM_CYMENU);
342}
343//******************************************************************************
344//******************************************************************************
345VOID Win32BaseWindow::AdjustRectInner(LPRECT rect)
346{
347 if(dwStyle & WS_ICONIC) return;
348
349 if (dwExStyle & WS_EX_CLIENTEDGE)
350 InflateRect (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
351
352 if (dwExStyle & WS_EX_STATICEDGE)
353 InflateRect (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
354
355 if (dwStyle & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
356 if (dwStyle & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
357}
358//******************************************************************************
359//******************************************************************************
360LONG Win32BaseWindow::HandleNCCalcSize(BOOL calcValidRects,RECT *winRect)
361{
362 RECT tmpRect = { 0, 0, 0, 0 };
363 LONG result = 0;
364 UINT style;
365
366 if (!calcValidRects) return 0;
367
368 style = (UINT) GetClassLongA(Win32Hwnd,GCL_STYLE);
369
370 if (style & CS_VREDRAW) result |= WVR_VREDRAW;
371 if (style & CS_HREDRAW) result |= WVR_HREDRAW;
372
373 if(!(dwStyle & WS_MINIMIZE))
374 {
375 AdjustRectOuter(&tmpRect,FALSE);
376
377 winRect->left -= tmpRect.left;
378 winRect->top -= tmpRect.top;
379 winRect->right -= tmpRect.right;
380 winRect->bottom -= tmpRect.bottom;
381
382 if (HAS_MENU())
383 {
384 winRect->top +=
385 MENU_GetMenuBarHeight(Win32Hwnd,
386 winRect->right - winRect->left,
387 -tmpRect.left, -tmpRect.top ) + 1;
388 }
389
390 SetRect (&tmpRect, 0, 0, 0, 0);
391 AdjustRectInner(&tmpRect);
392 winRect->left -= tmpRect.left;
393 winRect->top -= tmpRect.top;
394 winRect->right -= tmpRect.right;
395 winRect->bottom -= tmpRect.bottom;
396 }
397
398 return result;
399}
400//******************************************************************************
401//******************************************************************************
402LONG Win32BaseWindow::HandleNCHitTest(POINT pt)
403{
404 RECT rect = rectWindow;
405
406 if (!PtInRect(&rect,pt)) return HTNOWHERE;
407
408 if (dwStyle & WS_MINIMIZE) return HTCAPTION;
409
410 if (!(flags & WIN_MANAGED))
411 {
412 /* Check borders */
413 if (HAS_THICKFRAME(dwStyle,dwExStyle))
414 {
415 InflateRect(&rect,-GetSystemMetrics(SM_CXFRAME),-GetSystemMetrics(SM_CYFRAME));
416 if (!PtInRect(&rect,pt))
417 {
418 /* Check top sizing border */
419 if (pt.y < rect.top)
420 {
421 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
422 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
423 return HTTOP;
424 }
425 /* Check bottom sizing border */
426 if (pt.y >= rect.bottom)
427 {
428 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
429 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
430 return HTBOTTOM;
431 }
432 /* Check left sizing border */
433 if (pt.x < rect.left)
434 {
435 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
436 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
437 return HTLEFT;
438 }
439 /* Check right sizing border */
440 if (pt.x >= rect.right)
441 {
442 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
443 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
444 return HTRIGHT;
445 }
446 }
447 } else /* No thick frame */
448 {
449 if (HAS_DLGFRAME(dwStyle,dwExStyle))
450 InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
451 else if (HAS_THINFRAME(dwStyle ))
452 InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
453 if (!PtInRect( &rect, pt )) return HTBORDER;
454 }
455
456 /* Check caption */
457
458 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
459 {
460 if (dwExStyle & WS_EX_TOOLWINDOW)
461 rect.top += GetSystemMetrics(SM_CYSMCAPTION)-1;
462 else
463 rect.top += GetSystemMetrics(SM_CYCAPTION)-1;
464 if (!PtInRect(&rect,pt))
465 {
466 /* Check system menu */
467 if(dwStyle & WS_SYSMENU)
468 {
469 /* Check if there is an user icon */
470 HICON hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
471 if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
472
473 /* If there is an icon associated with the window OR */
474 /* If there is no hIcon specified and this is not a modal dialog, */
475 /* there is a system menu icon. */
476 if((hIcon != 0) || (!(dwStyle & DS_MODALFRAME)))
477 rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
478 }
479 if (pt.x < rect.left) return HTSYSMENU;
480
481 /* Check close button */
482 if (dwStyle & WS_SYSMENU)
483 rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
484 if (pt.x > rect.right) return HTCLOSE;
485
486 /* Check maximize box */
487 /* In win95 there is automatically a Maximize button when there is a minimize one*/
488 if ((dwStyle & WS_MAXIMIZEBOX)|| (dwStyle & WS_MINIMIZEBOX))
489 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
490 if (pt.x > rect.right) return HTMAXBUTTON;
491
492 /* Check minimize box */
493 /* In win95 there is automatically a Maximize button when there is a Maximize one*/
494 if ((dwStyle & WS_MINIMIZEBOX)||(dwStyle & WS_MAXIMIZEBOX))
495 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
496
497 if (pt.x > rect.right) return HTMINBUTTON;
498 return HTCAPTION;
499 }
500 }
501 }
502
503 /* Check client area */
504
505 ScreenToClient(Win32Hwnd,&pt);
506 getClientRect(&rect);
507 if (PtInRect(&rect,pt)) return HTCLIENT;
508
509 /* Check vertical scroll bar */
510
511 if (dwStyle & WS_VSCROLL)
512 {
513 rect.right += GetSystemMetrics(SM_CXVSCROLL);
514 if (PtInRect( &rect, pt )) return HTVSCROLL;
515 }
516
517 /* Check horizontal scroll bar */
518
519 if (dwStyle & WS_HSCROLL)
520 {
521 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
522 if (PtInRect( &rect, pt ))
523 {
524 /* Check size box */
525 if ((dwStyle & WS_VSCROLL) &&
526 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
527 return (dwStyle & WS_CHILD) ? HTSIZE:HTBOTTOMRIGHT;
528 return HTHSCROLL;
529 }
530 }
531
532 /* Check menu bar */
533
534 if (HAS_MENU())
535 {
536 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
537 return HTMENU;
538 }
539
540 /* Should never get here */
541 return HTERROR;
542}
543
544//******************************************************************************
545//******************************************************************************
546VOID Win32BaseWindow::GetInsideRect(RECT *rect)
547{
548 rect->top = rect->left = 0;
549 rect->right = rectWindow.right - rectWindow.left;
550 rect->bottom = rectWindow.bottom - rectWindow.top;
551
552 if ((dwStyle & WS_ICONIC) || (flags & WIN_MANAGED)) return;
553
554 /* Remove frame from rectangle */
555 if (HAS_THICKFRAME(dwStyle,dwExStyle))
556 {
557 InflateRect( rect, -GetSystemMetrics(SM_CXSIZEFRAME), -GetSystemMetrics(SM_CYSIZEFRAME) );
558 }
559 else if (HAS_DLGFRAME(dwStyle,dwExStyle ))
560 {
561 InflateRect( rect, -GetSystemMetrics(SM_CXFIXEDFRAME), -GetSystemMetrics(SM_CYFIXEDFRAME));
562 }
563 else if (HAS_THINFRAME(dwStyle))
564 {
565 InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) );
566 }
567
568 /* We have additional border information if the window
569 * is a child (but not an MDI child) */
570 if ( (dwStyle & WS_CHILD) &&
571 ( (dwExStyle & WS_EX_MDICHILD) == 0 ) )
572 {
573 if (dwExStyle & WS_EX_CLIENTEDGE)
574 InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));
575
576 if (dwExStyle & WS_EX_STATICEDGE)
577 InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
578 }
579}
580//******************************************************************************
581//******************************************************************************
582VOID Win32BaseWindow::DrawFrame(HDC hdc,RECT *rect,BOOL dlgFrame,BOOL active)
583{
584 INT width, height;
585 HBRUSH oldBrush;
586
587 if (dlgFrame)
588 {
589 width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
590 height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
591 }
592 else
593 {
594 width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXEDGE);
595 height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYEDGE);
596 }
597
598 oldBrush = SelectObject(hdc,GetSysColorBrush(active ? COLOR_ACTIVEBORDER:COLOR_INACTIVEBORDER));
599
600 /* Draw frame */
601 PatBlt(hdc,rect->left, rect->top, rect->right-rect->left, height,PATCOPY);
602 PatBlt(hdc,rect->left, rect->top, width, rect->bottom-rect->top,PATCOPY);
603 PatBlt(hdc,rect->left, rect->bottom-1, rect->right-rect->left,-height,PATCOPY);
604 PatBlt(hdc,rect->right-1,rect->top, -width, rect->bottom-rect->top,PATCOPY);
605 SelectObject(hdc,oldBrush);
606
607 InflateRect(rect,-width,-height);
608}
609//******************************************************************************
610//******************************************************************************
611BOOL Win32BaseWindow::DrawSysButton(HDC hdc,RECT *rect)
612{
613 if(!(flags & WIN_MANAGED))
614 {
615 HICON hIcon;
616 RECT r;
617
618 if (!rect) GetInsideRect(&r);
619 else r = *rect;
620
621 hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
622 if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
623
624 /* If there is no hIcon specified or this is not a modal dialog, */
625 /* get the default one. */
626 if(hIcon == 0)
627 if (!(dwStyle & DS_MODALFRAME))
628 hIcon = LoadImageA(0, MAKEINTRESOURCEA(OIC_ODINICON), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
629
630 if (hIcon)
631 DrawIconEx(hdc,r.left+2,r.top+2,hIcon,
632 GetSystemMetrics(SM_CXSMICON),
633 GetSystemMetrics(SM_CYSMICON),
634 0, 0, DI_NORMAL);
635
636 return (hIcon != 0);
637 }
638 return FALSE;
639}
640//******************************************************************************
641//******************************************************************************
642BOOL Win32BaseWindow::GetSysPopupPos(RECT* rect)
643{
644 if(hSysMenu)
645 {
646 if(dwStyle & WS_MINIMIZE )
647 *rect = rectWindow;
648 else
649 {
650 GetInsideRect(rect );
651 OffsetRect( rect, rectWindow.left, rectWindow.top);
652 if ((dwStyle & WS_CHILD) && getParent())
653 ClientToScreen(getParent()->getWindowHandle(), (POINT *)rect );
654 rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
655 rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
656 }
657 return TRUE;
658 }
659 return FALSE;
660}
661//******************************************************************************
662//******************************************************************************
663BOOL Win32BaseWindow::DrawGrayButton(HDC hdc,int x,int y)
664{
665 HBITMAP hMaskBmp;
666 HDC hdcMask = CreateCompatibleDC (0);
667 HBRUSH hOldBrush;
668 hMaskBmp = CreateBitmap (12, 10, 1, 1, lpGrayMask);
669
670 if(hMaskBmp == 0)
671 return FALSE;
672
673 SelectObject (hdcMask, hMaskBmp);
674
675 /* Draw the grayed bitmap using the mask */
676 hOldBrush = SelectObject (hdc, RGB(128, 128, 128));
677 BitBlt (hdc, x, y, 12, 10,
678 hdcMask, 0, 0, 0xB8074A);
679
680 /* Clean up */
681 SelectObject (hdc, hOldBrush);
682 DeleteObject(hMaskBmp);
683 DeleteDC (hdcMask);
684
685 return TRUE;
686}
687//******************************************************************************
688//******************************************************************************
689VOID Win32BaseWindow::DrawCloseButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
690{
691 RECT r;
692 HDC hdcMem;
693
694 if( !(flags & WIN_MANAGED) )
695 {
696 BITMAP bmp;
697 HBITMAP hBmp, hOldBmp;
698
699 if (!rect) GetInsideRect(&r);
700 else r = *rect;
701
702 hdcMem = CreateCompatibleDC( hdc );
703 hBmp = down ? hbitmapCloseD : hbitmapClose;
704 hOldBmp = SelectObject (hdcMem, hBmp);
705 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
706
707 BitBlt (hdc, r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
708 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
709 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY);
710
711 if(bGrayed)
712 DrawGrayButton(hdc,r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,
713 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
714
715 SelectObject (hdcMem, hOldBmp);
716 DeleteDC (hdcMem);
717 }
718}
719//******************************************************************************
720//******************************************************************************
721VOID Win32BaseWindow::DrawMaxButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
722{
723 RECT r;
724 HDC hdcMem;
725
726 if( !(flags & WIN_MANAGED))
727 {
728 BITMAP bmp;
729 HBITMAP hBmp,hOldBmp;
730
731 if (!rect) GetInsideRect(&r);
732 else r = *rect;
733 hdcMem = CreateCompatibleDC( hdc );
734 hBmp = IsZoomed(Win32Hwnd) ?
735 (down ? hbitmapRestoreD : hbitmapRestore ) :
736 (down ? hbitmapMaximizeD: hbitmapMaximize);
737 hOldBmp=SelectObject( hdcMem, hBmp );
738 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
739
740 if (dwStyle & WS_SYSMENU)
741 r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
742
743 BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
744 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
745 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
746
747 if(bGrayed)
748 DrawGrayButton(hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
749 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
750
751
752 SelectObject (hdcMem, hOldBmp);
753 DeleteDC( hdcMem );
754 }
755}
756//******************************************************************************
757//******************************************************************************
758VOID Win32BaseWindow::DrawMinButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
759{
760 RECT r;
761 HDC hdcMem;
762
763 if( !(flags & WIN_MANAGED))
764
765 {
766 BITMAP bmp;
767 HBITMAP hBmp,hOldBmp;
768
769 if (!rect) GetInsideRect(&r);
770 else r = *rect;
771
772 hdcMem = CreateCompatibleDC( hdc );
773 hBmp = down ? hbitmapMinimizeD : hbitmapMinimize;
774 hOldBmp= SelectObject( hdcMem, hBmp );
775 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
776
777 if (dwStyle & WS_SYSMENU)
778 r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
779
780 /* In win 95 there is always a Maximize box when there is a Minimize one */
781 if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
782 r.right -= bmp.bmWidth;
783
784 BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
785 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
786 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
787
788 if(bGrayed)
789 DrawGrayButton(hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
790 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
791
792
793 SelectObject (hdcMem, hOldBmp);
794 DeleteDC( hdcMem );
795 }
796}
797//******************************************************************************
798// redrawText: only redraws text
799//******************************************************************************
800VOID Win32BaseWindow::DrawCaption(HDC hdc,RECT *rect,BOOL active,BOOL redrawText)
801{
802 RECT r = *rect,r2;
803 char buffer[256];
804 HPEN hPrevPen;
805 HDC memDC;
806 HBITMAP memBmp,oldBmp;
807
808 if (flags & WIN_MANAGED) return;
809
810 memDC = CreateCompatibleDC(hdc);
811 r.right -= r.left;
812 r.bottom -= r.top;
813 r.left = r.top = 0;
814 r2 = r;
815 memBmp = CreateCompatibleBitmap(hdc,r.right,r.bottom);
816 oldBmp = SelectObject(memDC,memBmp);
817
818 hPrevPen = SelectObject(memDC,GetSysColorPen(COLOR_3DFACE));
819 MoveToEx(memDC,r.left,r.bottom-1,NULL);
820 LineTo(memDC,r.right,r.bottom-1);
821 SelectObject(memDC,hPrevPen);
822 r.bottom--;
823
824 if (SYSCOLOR_GetUseWinColors())
825 {
826 COLORREF startColor = GetSysColor(active ? COLOR_ACTIVECAPTION:COLOR_INACTIVECAPTION),endColor = GetSysColor(active ? COLOR_GRADIENTACTIVECAPTION:COLOR_GRADIENTINACTIVECAPTION);
827
828 if (startColor == endColor)
829 FillRect(memDC,&r,GetSysColorBrush(startColor));
830 else
831 {
832 INT rDiff = GetRValue(endColor)-GetRValue(startColor);
833 INT gDiff = GetGValue(endColor)-GetGValue(startColor);
834 INT bDiff = GetBValue(endColor)-GetBValue(startColor);
835 INT steps = MAX(MAX(abs(rDiff),abs(gDiff)),abs(bDiff));
836 INT w = r.right-r.left;
837 RECT r2;
838
839 if (w < steps) steps = w;
840 r2.left = r2.right = r.left;
841 r2.top = r.top;
842 r2.bottom = r.bottom;
843 for (INT x = 0;x <= steps;x++)
844 {
845 COLORREF color = RGB(GetRValue(startColor)+rDiff*x/steps,GetGValue(startColor)+gDiff*x/steps,GetBValue(startColor)+bDiff*x/steps);
846 HBRUSH brush = CreateSolidBrush(color);
847
848 r2.left = r2.right;
849 r2.right = r.left+w*x/steps;
850 FillRect(memDC,&r2,brush);
851 DeleteObject(brush);
852 }
853 }
854 } else FillRect(memDC,&r,GetSysColorBrush(active ? COLOR_ACTIVECAPTION:COLOR_INACTIVECAPTION));
855
856 if (!hbitmapClose)
857 {
858 if (!(hbitmapClose = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSE)))) return;
859 hbitmapCloseD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSED));
860 hbitmapMinimize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCE));
861 hbitmapMinimizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCED));
862 hbitmapMaximize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOM));
863 hbitmapMaximizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOMD));
864 hbitmapRestore = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORE));
865 hbitmapRestoreD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORED));
866 }
867
868 if ((dwStyle & WS_SYSMENU) && !(dwExStyle & WS_EX_TOOLWINDOW))
869 {
870 if (redrawText || DrawSysButton(memDC,&r))
871 r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
872 }
873
874 if (dwStyle & WS_SYSMENU)
875 {
876 UINT state;
877
878 if (!redrawText)
879 {
880 /* Go get the sysmenu */
881 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
882
883 /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
884 DrawCloseButton(memDC,&r2,FALSE,
885 ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
886 }
887 r.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
888
889 if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
890 {
891 /* In win95 the two buttons are always there */
892 /* But if the menu item is not in the menu they're disabled*/
893
894 if (!redrawText)
895 DrawMaxButton(memDC,&r2,FALSE,(!(dwStyle & WS_MAXIMIZEBOX)));
896 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
897
898 if (!redrawText)
899 DrawMinButton(memDC,&r2,FALSE, (!(dwStyle & WS_MINIMIZEBOX)));
900 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
901 }
902 }
903
904 if (GetWindowTextA(buffer, sizeof(buffer) ))
905 {
906 NONCLIENTMETRICSA nclm;
907 HFONT hFont, hOldFont;
908
909 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
910 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
911 if (dwExStyle & WS_EX_TOOLWINDOW)
912 hFont = CreateFontIndirectA (&nclm.lfSmCaptionFont);
913 else
914 hFont = CreateFontIndirectA (&nclm.lfCaptionFont);
915 hOldFont = SelectObject (memDC, hFont);
916 SetTextColor(memDC,GetSysColor(active ? COLOR_CAPTIONTEXT:COLOR_INACTIVECAPTIONTEXT));
917 SetBkMode(memDC, TRANSPARENT );
918 r.left += 2;
919 DrawTextA(memDC, buffer, -1, &r,
920 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
921 DeleteObject (SelectObject (memDC, hOldFont));
922 }
923
924 BitBlt(hdc,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,memDC,0,0,SRCCOPY);
925 SelectObject(memDC,oldBmp);
926 DeleteObject(memBmp);
927 DeleteDC(memDC);
928}
929//******************************************************************************
930//******************************************************************************
931VOID Win32BaseWindow::UpdateCaptionText()
932{
933 BOOL active = flags & WIN_NCACTIVATED;
934 HDC hdc;
935 RECT rect,r;
936 HRGN hrgn;
937
938 if (!((dwStyle & WS_CAPTION) == WS_CAPTION)) return;
939
940 rect.top = rect.left = 0;
941 rect.right = rectWindow.right - rectWindow.left;
942 rect.bottom = rectWindow.bottom - rectWindow.top;
943 if(!(flags & WIN_MANAGED))
944 {
945 if (HAS_BIGFRAME( dwStyle, dwExStyle))
946 {
947 InflateRect(&rect,-2,-2);
948 }
949
950 if (HAS_THICKFRAME(dwStyle,dwExStyle))
951 {
952 INT width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXEDGE);
953 INT height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYEDGE);
954
955 InflateRect(&rect,-width,-height);
956 }
957 else if (HAS_DLGFRAME(dwStyle,dwExStyle))
958 {
959 INT width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
960 INT height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
961
962 InflateRect(&rect,-width,-height);
963 }
964 else if (HAS_THINFRAME(dwStyle))
965 {
966 }
967
968 r = rect;
969 if (dwExStyle & WS_EX_TOOLWINDOW)
970 {
971 r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
972 }
973 else
974 {
975 r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
976 }
977
978 //clip the buttons
979 if ((dwStyle & WS_SYSMENU) && !(dwExStyle & WS_EX_TOOLWINDOW))
980 {
981 HICON hIcon;
982
983 hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
984 if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
985 if (hIcon)
986 rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
987 }
988 if (dwStyle & WS_SYSMENU)
989 {
990 rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
991
992 if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
993 {
994 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
995 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
996 }
997 }
998
999 hrgn = CreateRectRgnIndirect(&rect);
1000 hdc = GetDCEx(Win32Hwnd,hrgn,DCX_USESTYLE | DCX_WINDOW | DCX_INTERSECTRGN);
1001 SelectObject(hdc,GetSysColorPen(COLOR_WINDOWFRAME));
1002 DrawCaption(hdc,&r,active,TRUE);
1003 DeleteObject(hrgn);
1004 ReleaseDC(Win32Hwnd,hdc);
1005 }
1006}
1007//******************************************************************************
1008//******************************************************************************
1009VOID Win32BaseWindow::DoNCPaint(HRGN clip,BOOL suppress_menupaint)
1010{
1011 BOOL active = flags & WIN_NCACTIVATED;
1012 HDC hdc;
1013 RECT rect,rectClip,rfuzz;
1014
1015 /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in
1016 the call to GetDCEx implying that it is allowed not to use it either.
1017 However, the suggested GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN)
1018 will cause clipRgn to be deleted after ReleaseDC().
1019 Now, how is the "system" supposed to tell what happened?
1020 */
1021
1022 if (!(hdc = GetDCEx( Win32Hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1023 ((clip > 1) ?(DCX_INTERSECTRGN /*| DCX_KEEPCLIPRGN*/) : 0) ))) return;
1024
1025 rect.top = rect.left = 0;
1026 rect.right = rectWindow.right - rectWindow.left;
1027 rect.bottom = rectWindow.bottom - rectWindow.top;
1028
1029 if( clip > 1 )
1030 {
1031 //CB: unknown WINE handling (clip == 1), clip client?
1032 GetRgnBox( clip, &rectClip );
1033 } else
1034 {
1035 clip = 0;
1036 rectClip = rect;
1037 }
1038
1039 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
1040
1041 if(!(flags & WIN_MANAGED))
1042 {
1043 if (HAS_BIGFRAME( dwStyle, dwExStyle))
1044 {
1045 DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST);
1046 }
1047 if (HAS_THICKFRAME( dwStyle, dwExStyle ))
1048 DrawFrame(hdc, &rect, FALSE, active );
1049 else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
1050 DrawFrame( hdc, &rect, TRUE, active );
1051 else if (HAS_THINFRAME( dwStyle ))
1052 {
1053 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1054 Rectangle( hdc, 0, 0, rect.right, rect.bottom );
1055 }
1056
1057 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
1058 {
1059 RECT r = rect;
1060 if (dwExStyle & WS_EX_TOOLWINDOW)
1061 {
1062 r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
1063 rect.top += GetSystemMetrics(SM_CYSMCAPTION);
1064 }
1065 else
1066 {
1067 r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
1068 rect.top += GetSystemMetrics(SM_CYCAPTION);
1069 }
1070 if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
1071 DrawCaption(hdc,&r,active,FALSE);
1072 }
1073 }
1074 if (HAS_MENU())
1075 {
1076 RECT r = rect;
1077 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
1078
1079 rect.top += MENU_DrawMenuBar(hdc,&r,Win32Hwnd,suppress_menupaint)+1;
1080 }
1081
1082 if (dwExStyle & WS_EX_CLIENTEDGE)
1083 DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
1084
1085 if (dwExStyle & WS_EX_STATICEDGE)
1086 DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
1087
1088 /* Draw the scroll-bars */
1089 if (dwStyle & WS_VSCROLL)
1090 SCROLL_DrawScrollBar(Win32Hwnd,hdc,SB_VERT,TRUE,TRUE);
1091 if (dwStyle & WS_HSCROLL)
1092 SCROLL_DrawScrollBar(Win32Hwnd,hdc,SB_HORZ,TRUE,TRUE);
1093
1094 /* Draw the "size-box" */
1095 if ((dwStyle & WS_VSCROLL) && (dwStyle & WS_HSCROLL))
1096 {
1097 RECT r = rect;
1098 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1099 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
1100 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
1101 if (!(dwStyle & WS_CHILD))
1102 {
1103 POINT p1,p2;
1104 HPEN penDark = GetSysColorPen(COLOR_3DSHADOW);
1105 HPEN penWhite = GetSysColorPen(COLOR_3DHILIGHT);
1106 HPEN oldPen = SelectObject(hdc,penDark);
1107 INT x;
1108
1109 p1.x = r.right-1;
1110 p1.y = r.bottom;
1111 p2.x = r.right;
1112 p2.y = r.bottom-1;
1113 for (x = 0;x < 3;x++)
1114 {
1115 SelectObject(hdc,penDark);
1116 MoveToEx(hdc,p1.x,p1.y,NULL);
1117 LineTo(hdc,p2.x,p2.y);
1118 p1.x--;
1119 p2.y--;
1120 MoveToEx(hdc,p1.x,p1.y,NULL);
1121 LineTo(hdc,p2.x,p2.y);
1122 SelectObject(hdc,penWhite);
1123 p1.x--;
1124 p2.y--;
1125 MoveToEx(hdc,p1.x,p1.y,NULL);
1126 LineTo(hdc,p2.x,p2.y);
1127 p1.x -= 2;
1128 p2.y -= 2;
1129 }
1130
1131 SelectObject(hdc,oldPen);
1132 }
1133 }
1134
1135 ReleaseDC(Win32Hwnd,hdc);
1136}
1137//******************************************************************************
1138//******************************************************************************
1139LONG Win32BaseWindow::HandleNCPaint(HRGN clip)
1140{
1141//CB: ignore it for now (SetWindowPos in WM_CREATE)
1142// if (!(dwStyle & WS_VISIBLE)) return 0;
1143
1144 if (dwStyle & WS_MINIMIZE) return 0;
1145
1146 DoNCPaint(clip,FALSE);
1147
1148 return 0;
1149}
1150/***********************************************************************
1151 * NC_HandleNCLButtonDblClk
1152 *
1153 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
1154 */
1155LONG Win32BaseWindow::HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam)
1156{
1157 /*
1158 * if this is an icon, send a restore since we are handling
1159 * a double click
1160 */
1161 if (dwStyle & WS_MINIMIZE)
1162 {
1163 SendInternalMessageA(WM_SYSCOMMAND,SC_RESTORE,lParam);
1164 return 0;
1165 }
1166
1167 switch(wParam) /* Hit test */
1168 {
1169 case HTCAPTION:
1170 /* stop processing if WS_MAXIMIZEBOX is missing */
1171 if (dwStyle & WS_MAXIMIZEBOX)
1172 SendInternalMessageA(WM_SYSCOMMAND,
1173 (dwStyle & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE,
1174 lParam);
1175 break;
1176
1177 case HTSYSMENU:
1178 if (!(GetClassWord(Win32Hwnd,GCW_STYLE) & CS_NOCLOSE))
1179 SendInternalMessageA(WM_SYSCOMMAND,SC_CLOSE,lParam);
1180 break;
1181
1182 case HTHSCROLL:
1183 SendInternalMessageA(WM_SYSCOMMAND,SC_HSCROLL+HTHSCROLL,lParam);
1184 break;
1185
1186 case HTVSCROLL:
1187 SendInternalMessageA(WM_SYSCOMMAND,SC_VSCROLL+HTVSCROLL,lParam);
1188 break;
1189 }
1190
1191 return 0;
1192}
1193//******************************************************************************
1194//******************************************************************************
1195LONG Win32BaseWindow::HandleNCRButtonUp(WPARAM wParam,LPARAM lParam)
1196{
1197 if (wParam == HTCAPTION)
1198 {
1199 if (GetActiveWindow() != Win32Hwnd)
1200 SetActiveWindow();
1201
1202 if ((GetActiveWindow() == Win32Hwnd) && (dwStyle & WS_SYSMENU))
1203 {
1204 SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTCAPTION,lParam);
1205 }
1206 }
1207
1208 return 0;
1209}
1210/***********************************************************************
1211 * NC_HandleSysCommand
1212 *
1213 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
1214 *
1215 */
1216LONG Win32BaseWindow::HandleSysCommand(WPARAM wParam,POINT *pt32)
1217{
1218 UINT uCommand = wParam & 0xFFF0;
1219
1220 switch (uCommand)
1221 {
1222
1223 case SC_SIZE:
1224 {
1225 DWORD flags = 0;
1226
1227 switch ((wParam & 0xF)+2)
1228 {
1229 case HTLEFT:
1230 flags = TFOS_LEFT;
1231 break;
1232
1233 case HTRIGHT:
1234 flags = TFOS_RIGHT;
1235 break;
1236
1237 case HTTOP:
1238 flags = TFOS_TOP;
1239 break;
1240
1241 case HTTOPLEFT:
1242 flags = TFOS_TOP | TFOS_LEFT;
1243 break;
1244
1245 case HTTOPRIGHT:
1246 flags = TFOS_TOP | TFOS_RIGHT;
1247 break;
1248
1249 case HTBOTTOM:
1250 flags = TFOS_BOTTOM;
1251 break;
1252
1253 case HTBOTTOMLEFT:
1254 flags = TFOS_BOTTOM | TFOS_LEFT;
1255 break;
1256
1257 case HTBOTTOMRIGHT:
1258 flags = TFOS_BOTTOM | TFOS_RIGHT;
1259 break;
1260 }
1261 if (flags) FrameTrackFrame(this,flags);
1262 break;
1263 }
1264
1265 case SC_MOVE:
1266 FrameTrackFrame(this,TFOS_MOVE);
1267 break;
1268
1269 case SC_MINIMIZE:
1270 ShowWindow(SW_MINIMIZE);
1271 break;
1272
1273 case SC_MAXIMIZE:
1274 ShowWindow(SW_MAXIMIZE);
1275 break;
1276
1277 case SC_RESTORE:
1278 ShowWindow(SW_RESTORE);
1279 break;
1280
1281 case SC_CLOSE:
1282 return SendInternalMessageA(WM_CLOSE,0,0);
1283
1284 case SC_VSCROLL:
1285 case SC_HSCROLL:
1286 TrackScrollBar(wParam,*pt32);
1287 break;
1288
1289 case SC_MOUSEMENU:
1290 MENU_TrackMouseMenuBar(Win32Hwnd,wParam & 0x000F,*pt32);
1291 break;
1292
1293 case SC_KEYMENU:
1294 MENU_TrackKbdMenuBar(Win32Hwnd,wParam,pt32->x);
1295 break;
1296
1297 case SC_TASKLIST:
1298 OSLibWinShowTaskList(getOS2FrameWindowHandle());
1299 break;
1300
1301 case SC_SCREENSAVE:
1302 if (wParam == SC_ABOUTODIN) {
1303 if(ShellAboutA == 0) {
1304 HINSTANCE hShell32 = LoadLibraryA("SHELL32");
1305 if(hShell32 == 0)
1306 break;
1307 *(VOID **)&ShellAboutA = (VOID *)GetProcAddress(hShell32, "ShellAboutA");
1308 }
1309 ShellAboutA(Win32Hwnd,"Odin","Odin alpha release compiled with IBM VAC++",0);
1310 }
1311 else
1312 if (wParam == SC_PUTMARK)
1313 dprintf(("Mark requested by user\n"));
1314 break;
1315
1316 case SC_HOTKEY:
1317 case SC_ARRANGE:
1318 case SC_NEXTWINDOW:
1319 case SC_PREVWINDOW:
1320 break;
1321 }
1322 return 0;
1323}
1324//******************************************************************************
1325//******************************************************************************
Note: See TracBrowser for help on using the repository browser.