source: trunk/src/user32/win32wbasenonclient.cpp@ 2529

Last change on this file since 2529 was 2529, checked in by cbratschi, 26 years ago

WINE code clean-up

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