1 | /* $Id: win32wbasenonclient.cpp,v 1.25 2000-10-17 17:11:08 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 | * Corel Version 20000212
|
---|
9 | *
|
---|
10 | * Copyright 1994 Alexandre Julliard
|
---|
11 | *
|
---|
12 | * TODO: Not thread/process safe
|
---|
13 | *
|
---|
14 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
15 | *
|
---|
16 | */
|
---|
17 | #include <os2win.h>
|
---|
18 | #include <win.h>
|
---|
19 | #include <stdlib.h>
|
---|
20 | #include <string.h>
|
---|
21 | #include <stdarg.h>
|
---|
22 | #include <assert.h>
|
---|
23 | #include <misc.h>
|
---|
24 | #include <heapstring.h>
|
---|
25 | #include <win32wbase.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 DBG_LOCALLOG DBG_win32wbasenonclient
|
---|
42 | #include "dbglocal.h"
|
---|
43 |
|
---|
44 | /* bits in the dwKeyData */
|
---|
45 | #define KEYDATA_ALT 0x2000
|
---|
46 | #define KEYDATA_PREVSTATE 0x4000
|
---|
47 |
|
---|
48 | static INT bitmapW = 16,bitmapH = 14;
|
---|
49 | static HBITMAP hbitmapClose = 0;
|
---|
50 | static HBITMAP hbitmapCloseD = 0;
|
---|
51 | static HBITMAP hbitmapMinimize = 0;
|
---|
52 | static HBITMAP hbitmapMinimizeD = 0;
|
---|
53 | static HBITMAP hbitmapMaximize = 0;
|
---|
54 | static HBITMAP hbitmapMaximizeD = 0;
|
---|
55 | static HBITMAP hbitmapRestore = 0;
|
---|
56 | static HBITMAP hbitmapRestoreD = 0;
|
---|
57 | static HBITMAP hbitmapContextHelp = 0;
|
---|
58 | static HBITMAP hbitmapContextHelpD = 0;
|
---|
59 |
|
---|
60 | BYTE lpGrayMask[] = { 0xAA, 0xA0,
|
---|
61 | 0x55, 0x50,
|
---|
62 | 0xAA, 0xA0,
|
---|
63 | 0x55, 0x50,
|
---|
64 | 0xAA, 0xA0,
|
---|
65 | 0x55, 0x50,
|
---|
66 | 0xAA, 0xA0,
|
---|
67 | 0x55, 0x50,
|
---|
68 | 0xAA, 0xA0,
|
---|
69 | 0x55, 0x50};
|
---|
70 |
|
---|
71 | static INT (* WINAPI ShellAboutA)(HWND,LPCSTR,LPCSTR,HICON) = 0;
|
---|
72 |
|
---|
73 | //******************************************************************************
|
---|
74 | //******************************************************************************
|
---|
75 | LONG Win32BaseWindow::HandleNCActivate(WPARAM wParam)
|
---|
76 | {
|
---|
77 | WORD wStateChange;
|
---|
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_CAPTION)) return TRUE;
|
---|
88 |
|
---|
89 | if(!(dwStyle & WS_MINIMIZE))
|
---|
90 | DoNCPaint((HRGN)1,FALSE);
|
---|
91 | }
|
---|
92 |
|
---|
93 | return TRUE;
|
---|
94 | }
|
---|
95 | //******************************************************************************
|
---|
96 | //******************************************************************************
|
---|
97 | VOID Win32BaseWindow::TrackMinMaxHelpBox(WORD wParam)
|
---|
98 | {
|
---|
99 | MSG msg;
|
---|
100 | HDC hdc;
|
---|
101 | BOOL pressed = TRUE;
|
---|
102 | UINT state;
|
---|
103 |
|
---|
104 | if (wParam == HTMINBUTTON)
|
---|
105 | {
|
---|
106 | /* If the style is not present, do nothing */
|
---|
107 | if (!(dwStyle & WS_MINIMIZEBOX))
|
---|
108 | return;
|
---|
109 | /* Check if the sysmenu item for minimize is there */
|
---|
110 | state = GetMenuState(hSysMenu,SC_MINIMIZE,MF_BYCOMMAND);
|
---|
111 | } else if (wParam == HTMAXBUTTON)
|
---|
112 | {
|
---|
113 | /* If the style is not present, do nothing */
|
---|
114 | if (!(dwStyle & WS_MAXIMIZEBOX))
|
---|
115 | return;
|
---|
116 | /* Check if the sysmenu item for maximize is there */
|
---|
117 | state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
|
---|
118 | } else state = 0;
|
---|
119 | SetCapture(Win32Hwnd);
|
---|
120 | hdc = GetWindowDC(Win32Hwnd);
|
---|
121 | if (wParam == HTMINBUTTON)
|
---|
122 | DrawMinButton(hdc,NULL,TRUE,FALSE);
|
---|
123 | else if (wParam == HTMAXBUTTON)
|
---|
124 | DrawMaxButton(hdc,NULL,TRUE,FALSE);
|
---|
125 | else
|
---|
126 | DrawContextHelpButton(hdc,NULL,TRUE,FALSE);
|
---|
127 | do
|
---|
128 | {
|
---|
129 | BOOL oldstate = pressed;
|
---|
130 |
|
---|
131 | GetMessageA(&msg,Win32Hwnd,0,0);
|
---|
132 | pressed = (HandleNCHitTest(msg.pt) == wParam);
|
---|
133 | if (pressed != oldstate)
|
---|
134 | {
|
---|
135 | if (wParam == HTMINBUTTON)
|
---|
136 | DrawMinButton(hdc,NULL,pressed,FALSE);
|
---|
137 | else if (wParam == HTMAXBUTTON)
|
---|
138 | DrawMaxButton(hdc,NULL,pressed,FALSE);
|
---|
139 | else
|
---|
140 | DrawContextHelpButton(hdc,NULL,pressed,FALSE);
|
---|
141 | }
|
---|
142 | } while (msg.message != WM_LBUTTONUP);
|
---|
143 | if (wParam == HTMINBUTTON)
|
---|
144 | DrawMinButton(hdc,NULL,FALSE,FALSE);
|
---|
145 | else if (wParam == HTMAXBUTTON)
|
---|
146 | DrawMaxButton(hdc,NULL,FALSE,FALSE);
|
---|
147 | else
|
---|
148 | DrawContextHelpButton(hdc,NULL,FALSE,FALSE);
|
---|
149 | ReleaseCapture();
|
---|
150 | ReleaseDC(Win32Hwnd,hdc);
|
---|
151 | /* If the item minimize or maximize of the sysmenu are not there */
|
---|
152 | /* or if the style is not present, do nothing */
|
---|
153 | if ((!pressed) || (state == 0xFFFFFFFF))
|
---|
154 | return;
|
---|
155 |
|
---|
156 | if (wParam == HTMINBUTTON)
|
---|
157 | SendInternalMessageA(WM_SYSCOMMAND,SC_MINIMIZE,*(LPARAM*)&msg.pt);
|
---|
158 | else if (wParam == HTMAXBUTTON)
|
---|
159 | SendInternalMessageA(WM_SYSCOMMAND,IsZoomed(Win32Hwnd) ? SC_RESTORE:SC_MAXIMIZE,*(LPARAM*)&msg.pt);
|
---|
160 | else
|
---|
161 | SendInternalMessageA(WM_SYSCOMMAND,SC_CONTEXTHELP,*(LPARAM*)&msg.pt);
|
---|
162 | }
|
---|
163 | //******************************************************************************
|
---|
164 | //******************************************************************************
|
---|
165 | VOID Win32BaseWindow::TrackCloseButton(WORD wParam)
|
---|
166 | {
|
---|
167 | MSG msg;
|
---|
168 | HDC hdc;
|
---|
169 | BOOL pressed = TRUE;
|
---|
170 | UINT state;
|
---|
171 |
|
---|
172 | if (hSysMenu == 0)
|
---|
173 | return;
|
---|
174 | state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
|
---|
175 | /* If the item close of the sysmenu is disabled or not there do nothing */
|
---|
176 | if((state & MF_DISABLED) || (state & MF_GRAYED) || (state == 0xFFFFFFFF))
|
---|
177 | return;
|
---|
178 | hdc = GetWindowDC(Win32Hwnd);
|
---|
179 | SetCapture(Win32Hwnd);
|
---|
180 | DrawCloseButton(hdc,NULL,TRUE,FALSE);
|
---|
181 | do
|
---|
182 | {
|
---|
183 | BOOL oldstate = pressed;
|
---|
184 |
|
---|
185 | GetMessageA(&msg,Win32Hwnd,0,0);
|
---|
186 | pressed = (HandleNCHitTest(msg.pt) == wParam);
|
---|
187 | if (pressed != oldstate)
|
---|
188 | DrawCloseButton(hdc,NULL,pressed,FALSE);
|
---|
189 | } while (msg.message != WM_LBUTTONUP);
|
---|
190 | DrawCloseButton(hdc,NULL,FALSE,FALSE);
|
---|
191 | ReleaseCapture();
|
---|
192 | ReleaseDC(Win32Hwnd,hdc);
|
---|
193 | if (!pressed) return;
|
---|
194 | SendInternalMessageA(WM_SYSCOMMAND,SC_CLOSE,*(LPARAM*)&msg.pt);
|
---|
195 | }
|
---|
196 | //******************************************************************************
|
---|
197 | //******************************************************************************
|
---|
198 | VOID Win32BaseWindow::TrackScrollBar(WPARAM wParam,POINT pt)
|
---|
199 | {
|
---|
200 | INT scrollbar;
|
---|
201 | MSG msg;
|
---|
202 |
|
---|
203 | if ((wParam & 0xfff0) == SC_HSCROLL)
|
---|
204 | {
|
---|
205 | if ((wParam & 0x0f) != HTHSCROLL) return;
|
---|
206 | scrollbar = SB_HORZ;
|
---|
207 | } else /* SC_VSCROLL */
|
---|
208 | {
|
---|
209 | if ((wParam & 0x0f) != HTVSCROLL) return;
|
---|
210 | scrollbar = SB_VERT;
|
---|
211 | }
|
---|
212 |
|
---|
213 | ScreenToClient(getWindowHandle(), &pt);
|
---|
214 | pt.x += rectClient.left;
|
---|
215 | pt.y += rectClient.top;
|
---|
216 |
|
---|
217 | SCROLL_HandleScrollEvent(getWindowHandle(),0,MAKELONG(pt.x,pt.y),scrollbar,WM_LBUTTONDOWN);
|
---|
218 | if (GetCapture() != Win32Hwnd) return;
|
---|
219 | do
|
---|
220 | {
|
---|
221 | GetMessageA(&msg, 0, 0, 0);
|
---|
222 | if(msg.hwnd == getWindowHandle())
|
---|
223 | {
|
---|
224 | switch(msg.message)
|
---|
225 | {
|
---|
226 | case WM_LBUTTONUP:
|
---|
227 | case WM_MOUSEMOVE:
|
---|
228 | pt.x = msg.pt.x;
|
---|
229 | pt.y = msg.pt.y;
|
---|
230 | ScreenToClient(getWindowHandle(), &pt);
|
---|
231 | pt.x += rectClient.left;
|
---|
232 | pt.y += rectClient.top;
|
---|
233 | msg.lParam = MAKELONG(pt.x,pt.y);
|
---|
234 |
|
---|
235 | case WM_SYSTIMER:
|
---|
236 | SCROLL_HandleScrollEvent(Win32Hwnd,msg.wParam,msg.lParam,scrollbar,msg.message);
|
---|
237 | break;
|
---|
238 |
|
---|
239 | default:
|
---|
240 | TranslateMessage(&msg);
|
---|
241 | DispatchMessageA(&msg);
|
---|
242 | break;
|
---|
243 | }
|
---|
244 | }
|
---|
245 | else {
|
---|
246 | TranslateMessage(&msg);
|
---|
247 | DispatchMessageA(&msg);
|
---|
248 | }
|
---|
249 | if (!IsWindow())
|
---|
250 | {
|
---|
251 | ReleaseCapture();
|
---|
252 | break;
|
---|
253 | }
|
---|
254 | } while (msg.message != WM_LBUTTONUP);
|
---|
255 | }
|
---|
256 | //******************************************************************************
|
---|
257 | //******************************************************************************
|
---|
258 | LONG Win32BaseWindow::HandleNCLButtonDown(WPARAM wParam,LPARAM lParam)
|
---|
259 | {
|
---|
260 | switch(wParam) /* Hit test */
|
---|
261 | {
|
---|
262 | case HTCAPTION:
|
---|
263 | {
|
---|
264 | Win32BaseWindow *topparent = GetTopParent();
|
---|
265 |
|
---|
266 | if (GetActiveWindow() != topparent->getWindowHandle())
|
---|
267 | {
|
---|
268 | //SvL: Calling topparent->SetActiveWindow() causes focus problems
|
---|
269 | // topparent->SetActiveWindow();
|
---|
270 | OSLibWinSetFocus(topparent->getOS2WindowHandle());
|
---|
271 | }
|
---|
272 |
|
---|
273 | if (GetActiveWindow() == topparent->getWindowHandle())
|
---|
274 | SendInternalMessageA(WM_SYSCOMMAND,SC_MOVE+HTCAPTION,lParam);
|
---|
275 | else dprintf(("ACtive window (%x) != toplevel wnd %x", OSLibWinQueryActiveWindow(), topparent->getWindowHandle()));
|
---|
276 | break;
|
---|
277 | }
|
---|
278 |
|
---|
279 | case HTSYSMENU:
|
---|
280 | if(dwStyle & WS_SYSMENU )
|
---|
281 | {
|
---|
282 | SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTSYSMENU,lParam);
|
---|
283 | }
|
---|
284 | break;
|
---|
285 |
|
---|
286 | case HTMENU:
|
---|
287 | SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU,lParam);
|
---|
288 | break;
|
---|
289 |
|
---|
290 | case HTHSCROLL:
|
---|
291 | SendInternalMessageA(WM_SYSCOMMAND,SC_HSCROLL+HTHSCROLL,lParam);
|
---|
292 | break;
|
---|
293 |
|
---|
294 | case HTVSCROLL:
|
---|
295 | SendInternalMessageA(WM_SYSCOMMAND,SC_VSCROLL+HTVSCROLL,lParam);
|
---|
296 | break;
|
---|
297 |
|
---|
298 | case HTMINBUTTON:
|
---|
299 | case HTMAXBUTTON:
|
---|
300 | case HTHELP:
|
---|
301 | TrackMinMaxHelpBox(wParam);
|
---|
302 | break;
|
---|
303 |
|
---|
304 | case HTCLOSE:
|
---|
305 | TrackCloseButton(wParam);
|
---|
306 | break;
|
---|
307 |
|
---|
308 | case HTLEFT:
|
---|
309 | case HTRIGHT:
|
---|
310 | case HTTOP:
|
---|
311 | case HTTOPLEFT:
|
---|
312 | case HTTOPRIGHT:
|
---|
313 | case HTBOTTOM:
|
---|
314 | case HTBOTTOMLEFT:
|
---|
315 | case HTBOTTOMRIGHT:
|
---|
316 | /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
|
---|
317 | SendInternalMessageA(WM_SYSCOMMAND,SC_SIZE+wParam-2,lParam);
|
---|
318 | break;
|
---|
319 | case HTBORDER:
|
---|
320 | break;
|
---|
321 | }
|
---|
322 |
|
---|
323 | return 0;
|
---|
324 | }
|
---|
325 | //******************************************************************************
|
---|
326 | //******************************************************************************
|
---|
327 | VOID Win32BaseWindow::AdjustMaximizedRect(LPRECT rect)
|
---|
328 | {
|
---|
329 | if (HAS_THICKFRAME(dwStyle,dwExStyle ))
|
---|
330 | InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
|
---|
331 | else
|
---|
332 | if (HAS_DLGFRAME( dwStyle, dwExStyle ))
|
---|
333 | InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
|
---|
334 | else
|
---|
335 | if (HAS_THINFRAME( dwStyle ))
|
---|
336 | InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
|
---|
337 | }
|
---|
338 | //******************************************************************************
|
---|
339 | //******************************************************************************
|
---|
340 | VOID Win32BaseWindow::AdjustTrackInfo(PPOINT minTrackSize,PPOINT maxTrackSize)
|
---|
341 | {
|
---|
342 | if ((dwStyle & WS_THICKFRAME) || !(dwStyle & (WS_POPUP | WS_CHILD)))
|
---|
343 | GetMinMaxInfo(NULL,NULL,minTrackSize,maxTrackSize);
|
---|
344 | }
|
---|
345 | //******************************************************************************
|
---|
346 | //******************************************************************************
|
---|
347 | VOID Win32BaseWindow::AdjustRectOuter(LPRECT rect,BOOL menu)
|
---|
348 | {
|
---|
349 | if(dwStyle & WS_ICONIC) return;
|
---|
350 |
|
---|
351 | if (HAS_THICKFRAME(dwStyle,dwExStyle ))
|
---|
352 | InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
|
---|
353 | else
|
---|
354 | if (HAS_DLGFRAME( dwStyle, dwExStyle ))
|
---|
355 | InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
|
---|
356 | else
|
---|
357 | if (HAS_THINFRAME( dwStyle ))
|
---|
358 | InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
|
---|
359 |
|
---|
360 | if ((dwStyle & WS_CAPTION) == WS_CAPTION)
|
---|
361 | {
|
---|
362 | if (dwExStyle & WS_EX_TOOLWINDOW)
|
---|
363 | rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
|
---|
364 | else
|
---|
365 | rect->top -= GetSystemMetrics(SM_CYCAPTION);
|
---|
366 | }
|
---|
367 |
|
---|
368 | if (menu)
|
---|
369 | rect->top -= GetSystemMetrics(SM_CYMENU);
|
---|
370 | }
|
---|
371 | //******************************************************************************
|
---|
372 | //******************************************************************************
|
---|
373 | VOID Win32BaseWindow::AdjustRectInner(LPRECT rect)
|
---|
374 | {
|
---|
375 | if(dwStyle & WS_ICONIC) return;
|
---|
376 |
|
---|
377 | if (dwExStyle & WS_EX_CLIENTEDGE)
|
---|
378 | InflateRect (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
|
---|
379 |
|
---|
380 | if (dwExStyle & WS_EX_STATICEDGE)
|
---|
381 | InflateRect (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
|
---|
382 |
|
---|
383 | if (dwStyle & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
|
---|
384 | if (dwStyle & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
|
---|
385 | }
|
---|
386 | //******************************************************************************
|
---|
387 | //******************************************************************************
|
---|
388 | LONG Win32BaseWindow::HandleNCCalcSize(BOOL calcValidRects,RECT *winRect)
|
---|
389 | {
|
---|
390 | RECT tmpRect = { 0, 0, 0, 0 };
|
---|
391 | LONG result = 0;
|
---|
392 | UINT style;
|
---|
393 |
|
---|
394 | dprintf(("Default WM_NCCALCSIZE handler"));
|
---|
395 |
|
---|
396 | if (!calcValidRects) return 0;
|
---|
397 |
|
---|
398 | style = (UINT) GetClassLongA(Win32Hwnd,GCL_STYLE);
|
---|
399 |
|
---|
400 | if (style & CS_VREDRAW) result |= WVR_VREDRAW;
|
---|
401 | if (style & CS_HREDRAW) result |= WVR_HREDRAW;
|
---|
402 |
|
---|
403 | if(!(dwStyle & WS_MINIMIZE))
|
---|
404 | {
|
---|
405 | AdjustRectOuter(&tmpRect,FALSE);
|
---|
406 |
|
---|
407 | winRect->left -= tmpRect.left;
|
---|
408 | winRect->top -= tmpRect.top;
|
---|
409 | winRect->right -= tmpRect.right;
|
---|
410 | winRect->bottom -= tmpRect.bottom;
|
---|
411 |
|
---|
412 | if (HAS_MENU())
|
---|
413 | {
|
---|
414 | winRect->top +=
|
---|
415 | MENU_GetMenuBarHeight(Win32Hwnd,
|
---|
416 | winRect->right - winRect->left,
|
---|
417 | -tmpRect.left, -tmpRect.top ) + 1;
|
---|
418 | }
|
---|
419 |
|
---|
420 | SetRect (&tmpRect, 0, 0, 0, 0);
|
---|
421 | AdjustRectInner(&tmpRect);
|
---|
422 | winRect->left -= tmpRect.left;
|
---|
423 | winRect->top -= tmpRect.top;
|
---|
424 | winRect->right -= tmpRect.right;
|
---|
425 | winRect->bottom -= tmpRect.bottom;
|
---|
426 | }
|
---|
427 |
|
---|
428 | return result;
|
---|
429 | }
|
---|
430 | //******************************************************************************
|
---|
431 | //******************************************************************************
|
---|
432 | LONG Win32BaseWindow::HandleNCHitTest(POINT pt)
|
---|
433 | {
|
---|
434 | RECT rect;
|
---|
435 |
|
---|
436 | if (dwStyle & WS_MINIMIZE) return HTCAPTION;
|
---|
437 |
|
---|
438 | GetWindowRect(getWindowHandle(), &rect);
|
---|
439 |
|
---|
440 | if (!PtInRect(&rect,pt)) return HTNOWHERE;
|
---|
441 |
|
---|
442 | /* Check borders */
|
---|
443 | if (HAS_THICKFRAME(dwStyle,dwExStyle))
|
---|
444 | {
|
---|
445 | InflateRect(&rect,-GetSystemMetrics(SM_CXFRAME),-GetSystemMetrics(SM_CYFRAME));
|
---|
446 | if (!PtInRect(&rect,pt))
|
---|
447 | {
|
---|
448 | /* Check top sizing border */
|
---|
449 | if (pt.y < rect.top)
|
---|
450 | {
|
---|
451 | if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
|
---|
452 | if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
|
---|
453 | return HTTOP;
|
---|
454 | }
|
---|
455 | /* Check bottom sizing border */
|
---|
456 | if (pt.y >= rect.bottom)
|
---|
457 | {
|
---|
458 | if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
|
---|
459 | if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
|
---|
460 | return HTBOTTOM;
|
---|
461 | }
|
---|
462 | /* Check left sizing border */
|
---|
463 | if (pt.x < rect.left)
|
---|
464 | {
|
---|
465 | if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
|
---|
466 | if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
|
---|
467 | return HTLEFT;
|
---|
468 | }
|
---|
469 | /* Check right sizing border */
|
---|
470 | if (pt.x >= rect.right)
|
---|
471 | {
|
---|
472 | if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
|
---|
473 | if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
|
---|
474 | return HTRIGHT;
|
---|
475 | }
|
---|
476 | }
|
---|
477 | } else /* No thick frame */
|
---|
478 | {
|
---|
479 | if (HAS_DLGFRAME(dwStyle,dwExStyle))
|
---|
480 | InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
|
---|
481 | else if (HAS_THINFRAME(dwStyle ))
|
---|
482 | InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
|
---|
483 | if (!PtInRect( &rect, pt )) return HTBORDER;
|
---|
484 | }
|
---|
485 |
|
---|
486 | /* Check caption */
|
---|
487 |
|
---|
488 | if ((dwStyle & WS_CAPTION) == WS_CAPTION)
|
---|
489 | {
|
---|
490 | if (dwExStyle & WS_EX_TOOLWINDOW)
|
---|
491 | rect.top += GetSystemMetrics(SM_CYSMCAPTION)-1;
|
---|
492 | else
|
---|
493 | rect.top += GetSystemMetrics(SM_CYCAPTION)-1;
|
---|
494 | if (!PtInRect(&rect,pt))
|
---|
495 | {
|
---|
496 | /* Check system menu */
|
---|
497 | if(dwStyle & WS_SYSMENU)
|
---|
498 | {
|
---|
499 | /* Check if there is an user icon */
|
---|
500 | if (IconForWindow(ICON_SMALL))
|
---|
501 | rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
|
---|
502 | }
|
---|
503 | if (pt.x < rect.left) return HTSYSMENU;
|
---|
504 |
|
---|
505 | /* Check close button */
|
---|
506 | if (dwStyle & WS_SYSMENU)
|
---|
507 | rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
|
---|
508 | if (pt.x > rect.right) return HTCLOSE;
|
---|
509 |
|
---|
510 | //Check context help
|
---|
511 | if (dwExStyle & WS_EX_CONTEXTHELP)
|
---|
512 | rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
|
---|
513 | if (pt.x > rect.right) return HTHELP;
|
---|
514 |
|
---|
515 | /* Check maximize box */
|
---|
516 | /* In win95 there is automatically a Maximize button when there is a minimize one*/
|
---|
517 | if ((dwStyle & WS_MAXIMIZEBOX)|| (dwStyle & WS_MINIMIZEBOX))
|
---|
518 | rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
|
---|
519 | if (pt.x > rect.right) return HTMAXBUTTON;
|
---|
520 |
|
---|
521 | /* Check minimize box */
|
---|
522 | /* In win95 there is automatically a Maximize button when there is a Maximize one*/
|
---|
523 | if ((dwStyle & WS_MINIMIZEBOX)||(dwStyle & WS_MAXIMIZEBOX))
|
---|
524 | rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
|
---|
525 |
|
---|
526 | if (pt.x > rect.right) return HTMINBUTTON;
|
---|
527 | return HTCAPTION;
|
---|
528 | }
|
---|
529 | }
|
---|
530 |
|
---|
531 | /* Check client area */
|
---|
532 |
|
---|
533 | ScreenToClient(Win32Hwnd,&pt);
|
---|
534 | getClientRect(&rect);
|
---|
535 | if (PtInRect(&rect,pt)) return HTCLIENT;
|
---|
536 |
|
---|
537 | /* Check vertical scroll bar */
|
---|
538 |
|
---|
539 | if (dwStyle & WS_VSCROLL)
|
---|
540 | {
|
---|
541 | rect.right += GetSystemMetrics(SM_CXVSCROLL);
|
---|
542 | if (PtInRect( &rect, pt )) return HTVSCROLL;
|
---|
543 | }
|
---|
544 |
|
---|
545 | /* Check horizontal scroll bar */
|
---|
546 |
|
---|
547 | if (dwStyle & WS_HSCROLL)
|
---|
548 | {
|
---|
549 | rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
|
---|
550 | if (PtInRect( &rect, pt ))
|
---|
551 | {
|
---|
552 | /* Check size box */
|
---|
553 | if ((dwStyle & WS_VSCROLL) &&
|
---|
554 | (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
|
---|
555 | return (dwStyle & WS_CHILD) ? HTSIZE:HTBOTTOMRIGHT;
|
---|
556 | return HTHSCROLL;
|
---|
557 | }
|
---|
558 | }
|
---|
559 |
|
---|
560 | /* Check menu bar */
|
---|
561 |
|
---|
562 | if (HAS_MENU())
|
---|
563 | {
|
---|
564 | if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
|
---|
565 | return HTMENU;
|
---|
566 | }
|
---|
567 |
|
---|
568 | /* Has to return HTNOWHERE if nothing was found
|
---|
569 | Could happen when a window has a customized non client area */
|
---|
570 | return HTNOWHERE;
|
---|
571 | }
|
---|
572 |
|
---|
573 | //******************************************************************************
|
---|
574 | //******************************************************************************
|
---|
575 | VOID Win32BaseWindow::GetInsideRect(RECT *rect)
|
---|
576 | {
|
---|
577 | rect->top = rect->left = 0;
|
---|
578 | rect->right = rectWindow.right - rectWindow.left;
|
---|
579 | rect->bottom = rectWindow.bottom - rectWindow.top;
|
---|
580 |
|
---|
581 | if (dwStyle & WS_ICONIC) return;
|
---|
582 |
|
---|
583 | /* Remove frame from rectangle */
|
---|
584 | if (HAS_THICKFRAME(dwStyle,dwExStyle))
|
---|
585 | {
|
---|
586 | InflateRect( rect, -GetSystemMetrics(SM_CXSIZEFRAME), -GetSystemMetrics(SM_CYSIZEFRAME) );
|
---|
587 | }
|
---|
588 | else if (HAS_DLGFRAME(dwStyle,dwExStyle ))
|
---|
589 | {
|
---|
590 | InflateRect( rect, -GetSystemMetrics(SM_CXFIXEDFRAME), -GetSystemMetrics(SM_CYFIXEDFRAME));
|
---|
591 | }
|
---|
592 | else if (HAS_THINFRAME(dwStyle))
|
---|
593 | {
|
---|
594 | InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) );
|
---|
595 | }
|
---|
596 |
|
---|
597 | /* We have additional border information if the window
|
---|
598 | * is a child (but not an MDI child) */
|
---|
599 | if ( (dwStyle & WS_CHILD) &&
|
---|
600 | ( (dwExStyle & WS_EX_MDICHILD) == 0 ) )
|
---|
601 | {
|
---|
602 | if (dwExStyle & WS_EX_CLIENTEDGE)
|
---|
603 | InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));
|
---|
604 |
|
---|
605 | if (dwExStyle & WS_EX_STATICEDGE)
|
---|
606 | InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
|
---|
607 | }
|
---|
608 | }
|
---|
609 | //******************************************************************************
|
---|
610 | //******************************************************************************
|
---|
611 | VOID Win32BaseWindow::DrawFrame(HDC hdc,RECT *rect,BOOL dlgFrame,BOOL active)
|
---|
612 | {
|
---|
613 | INT width, height;
|
---|
614 | HBRUSH oldBrush;
|
---|
615 |
|
---|
616 | if (dlgFrame)
|
---|
617 | {
|
---|
618 | width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
|
---|
619 | height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
|
---|
620 | }
|
---|
621 | else
|
---|
622 | {
|
---|
623 | width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXEDGE);
|
---|
624 | height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYEDGE);
|
---|
625 | }
|
---|
626 |
|
---|
627 | oldBrush = SelectObject(hdc,GetSysColorBrush(active ? COLOR_ACTIVEBORDER:COLOR_INACTIVEBORDER));
|
---|
628 |
|
---|
629 | /* Draw frame */
|
---|
630 | PatBlt(hdc,rect->left, rect->top, rect->right-rect->left, height,PATCOPY); //top
|
---|
631 | PatBlt(hdc,rect->left, rect->top, width, rect->bottom-rect->top,PATCOPY); //left
|
---|
632 | PatBlt(hdc,rect->left, rect->bottom-1, rect->right-rect->left,-height,PATCOPY); //bottom
|
---|
633 | PatBlt(hdc,rect->right-1,rect->top, -width, rect->bottom-rect->top,PATCOPY); //right
|
---|
634 | SelectObject(hdc,oldBrush);
|
---|
635 |
|
---|
636 | InflateRect(rect,-width,-height);
|
---|
637 | }
|
---|
638 | //******************************************************************************
|
---|
639 | //******************************************************************************
|
---|
640 | BOOL Win32BaseWindow::DrawSysButton(HDC hdc,RECT *rect)
|
---|
641 | {
|
---|
642 | HICON hSysIcon;
|
---|
643 | RECT r;
|
---|
644 |
|
---|
645 | if (!rect) GetInsideRect(&r);
|
---|
646 | else r = *rect;
|
---|
647 |
|
---|
648 | hSysIcon = IconForWindow(ICON_SMALL);
|
---|
649 |
|
---|
650 | //CB: todo: add icons (including Odin icon) to user32.rc
|
---|
651 | if (hSysIcon)
|
---|
652 | DrawIconEx(hdc,r.left+2,r.top+2,hSysIcon,
|
---|
653 | GetSystemMetrics(SM_CXSMICON),
|
---|
654 | GetSystemMetrics(SM_CYSMICON),
|
---|
655 | 0, 0, DI_NORMAL);
|
---|
656 |
|
---|
657 | return (hSysIcon != 0);
|
---|
658 | }
|
---|
659 | //******************************************************************************
|
---|
660 | //******************************************************************************
|
---|
661 | BOOL Win32BaseWindow::GetSysPopupPos(RECT* rect)
|
---|
662 | {
|
---|
663 | if(hSysMenu)
|
---|
664 | {
|
---|
665 | if(dwStyle & WS_MINIMIZE )
|
---|
666 | *rect = rectWindow;
|
---|
667 | else
|
---|
668 | {
|
---|
669 | GetInsideRect(rect );
|
---|
670 | OffsetRect( rect, rectWindow.left, rectWindow.top);
|
---|
671 | rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
|
---|
672 | rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
|
---|
673 | }
|
---|
674 | return TRUE;
|
---|
675 | }
|
---|
676 | return FALSE;
|
---|
677 | }
|
---|
678 | //******************************************************************************
|
---|
679 | //******************************************************************************
|
---|
680 | BOOL Win32BaseWindow::DrawGrayButton(HDC hdc,int x,int y)
|
---|
681 | {
|
---|
682 | HBITMAP hMaskBmp;
|
---|
683 | HDC hdcMask = CreateCompatibleDC (0);
|
---|
684 | HBRUSH hOldBrush;
|
---|
685 | hMaskBmp = CreateBitmap (12, 10, 1, 1, lpGrayMask);
|
---|
686 |
|
---|
687 | if(hMaskBmp == 0)
|
---|
688 | return FALSE;
|
---|
689 |
|
---|
690 | SelectObject (hdcMask, hMaskBmp);
|
---|
691 |
|
---|
692 | /* Draw the grayed bitmap using the mask */
|
---|
693 | hOldBrush = SelectObject (hdc, RGB(128, 128, 128));
|
---|
694 | BitBlt (hdc, x, y, 12, 10,
|
---|
695 | hdcMask, 0, 0, 0xB8074A);
|
---|
696 |
|
---|
697 | /* Clean up */
|
---|
698 | SelectObject (hdc, hOldBrush);
|
---|
699 | DeleteObject(hMaskBmp);
|
---|
700 | DeleteDC (hdcMask);
|
---|
701 |
|
---|
702 | return TRUE;
|
---|
703 | }
|
---|
704 | //******************************************************************************
|
---|
705 | //******************************************************************************
|
---|
706 | VOID Win32BaseWindow::DrawCloseButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
|
---|
707 | {
|
---|
708 | RECT r;
|
---|
709 | HDC hdcMem;
|
---|
710 | BITMAP bmp;
|
---|
711 | HBITMAP hBmp, hOldBmp;
|
---|
712 |
|
---|
713 | if (!rect) GetInsideRect(&r);
|
---|
714 | else r = *rect;
|
---|
715 |
|
---|
716 | /* A tool window has a smaller Close button */
|
---|
717 | if (dwExStyle & WS_EX_TOOLWINDOW)
|
---|
718 | {
|
---|
719 | RECT toolRect;
|
---|
720 | INT iBmpHeight = 11; /* Windows does not use SM_CXSMSIZE and SM_CYSMSIZE */
|
---|
721 | INT iBmpWidth = 11; /* it uses 11x11 for the close button in tool window */
|
---|
722 | INT iCaptionHeight = GetSystemMetrics(SM_CYSMCAPTION);
|
---|
723 |
|
---|
724 |
|
---|
725 | toolRect.top = r.top + (iCaptionHeight - 1 - iBmpHeight) / 2;
|
---|
726 | toolRect.left = r.right - (iCaptionHeight + 1 + iBmpWidth) / 2;
|
---|
727 | toolRect.bottom = toolRect.top + iBmpHeight;
|
---|
728 | toolRect.right = toolRect.left + iBmpWidth;
|
---|
729 | DrawFrameControl(hdc,&toolRect,
|
---|
730 | DFC_CAPTION,DFCS_CAPTIONCLOSE |
|
---|
731 | down ? DFCS_PUSHED : 0 |
|
---|
732 | bGrayed ? DFCS_INACTIVE : 0);
|
---|
733 | } else
|
---|
734 | {
|
---|
735 | hdcMem = CreateCompatibleDC( hdc );
|
---|
736 | hBmp = down ? hbitmapCloseD : hbitmapClose;
|
---|
737 | hOldBmp = SelectObject (hdcMem, hBmp);
|
---|
738 | GetObjectA (hBmp, sizeof(BITMAP), &bmp);
|
---|
739 |
|
---|
740 | BitBlt (hdc, r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
|
---|
741 | r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
|
---|
742 | bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY);
|
---|
743 |
|
---|
744 | if(bGrayed)
|
---|
745 | DrawGrayButton(hdc,r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,
|
---|
746 | r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
|
---|
747 |
|
---|
748 | SelectObject (hdcMem, hOldBmp);
|
---|
749 | DeleteDC (hdcMem);
|
---|
750 | }
|
---|
751 | }
|
---|
752 | //******************************************************************************
|
---|
753 | //******************************************************************************
|
---|
754 | VOID Win32BaseWindow::DrawMaxButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
|
---|
755 | {
|
---|
756 | RECT r;
|
---|
757 | HDC hdcMem;
|
---|
758 | BITMAP bmp;
|
---|
759 | HBITMAP hBmp,hOldBmp;
|
---|
760 |
|
---|
761 | if (!rect) GetInsideRect(&r);
|
---|
762 | else r = *rect;
|
---|
763 | hdcMem = CreateCompatibleDC( hdc );
|
---|
764 | hBmp = IsZoomed(Win32Hwnd) ?
|
---|
765 | (down ? hbitmapRestoreD : hbitmapRestore ) :
|
---|
766 | (down ? hbitmapMaximizeD: hbitmapMaximize);
|
---|
767 | hOldBmp = SelectObject( hdcMem, hBmp );
|
---|
768 | GetObjectA (hBmp, sizeof(BITMAP), &bmp);
|
---|
769 |
|
---|
770 | if (dwStyle & WS_SYSMENU)
|
---|
771 | r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
|
---|
772 |
|
---|
773 | if (dwExStyle & WS_EX_CONTEXTHELP)
|
---|
774 | r.right -= bmp.bmWidth;
|
---|
775 |
|
---|
776 | BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
|
---|
777 | r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
|
---|
778 | bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
|
---|
779 |
|
---|
780 | if(bGrayed)
|
---|
781 | DrawGrayButton(hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
|
---|
782 | r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
|
---|
783 |
|
---|
784 | SelectObject (hdcMem, hOldBmp);
|
---|
785 | DeleteDC( hdcMem );
|
---|
786 | }
|
---|
787 | //******************************************************************************
|
---|
788 | //******************************************************************************
|
---|
789 | VOID Win32BaseWindow::DrawMinButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
|
---|
790 | {
|
---|
791 | RECT r;
|
---|
792 | HDC hdcMem;
|
---|
793 | BITMAP bmp;
|
---|
794 | HBITMAP hBmp,hOldBmp;
|
---|
795 |
|
---|
796 | if (!rect) GetInsideRect(&r);
|
---|
797 | else r = *rect;
|
---|
798 |
|
---|
799 | hdcMem = CreateCompatibleDC( hdc );
|
---|
800 | hBmp = down ? hbitmapMinimizeD : hbitmapMinimize;
|
---|
801 | hOldBmp= SelectObject( hdcMem, hBmp );
|
---|
802 | GetObjectA (hBmp, sizeof(BITMAP), &bmp);
|
---|
803 |
|
---|
804 | if (dwStyle & WS_SYSMENU)
|
---|
805 | r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
|
---|
806 |
|
---|
807 | if (dwExStyle & WS_EX_CONTEXTHELP)
|
---|
808 | r.right -= bmp.bmWidth;
|
---|
809 |
|
---|
810 | /* In win 95 there is always a Maximize box when there is a Minimize one */
|
---|
811 | if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
|
---|
812 | r.right -= bmp.bmWidth;
|
---|
813 |
|
---|
814 | BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
|
---|
815 | r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
|
---|
816 | bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
|
---|
817 |
|
---|
818 | if(bGrayed)
|
---|
819 | DrawGrayButton(hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
|
---|
820 | r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
|
---|
821 |
|
---|
822 |
|
---|
823 | SelectObject (hdcMem, hOldBmp);
|
---|
824 | DeleteDC( hdcMem );
|
---|
825 | }
|
---|
826 | //******************************************************************************
|
---|
827 | //******************************************************************************
|
---|
828 | VOID Win32BaseWindow::DrawContextHelpButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
|
---|
829 | {
|
---|
830 | RECT r;
|
---|
831 | HDC hdcMem;
|
---|
832 | BITMAP bmp;
|
---|
833 | HBITMAP hBmp,hOldBmp;
|
---|
834 |
|
---|
835 | if (!rect) GetInsideRect(&r);
|
---|
836 | else r = *rect;
|
---|
837 |
|
---|
838 | hdcMem = CreateCompatibleDC(hdc);
|
---|
839 | hBmp = down ? hbitmapContextHelpD : hbitmapContextHelp;
|
---|
840 | hOldBmp = SelectObject(hdcMem,hBmp);
|
---|
841 | GetObjectA(hBmp,sizeof(BITMAP),&bmp);
|
---|
842 |
|
---|
843 | if (dwStyle & WS_SYSMENU)
|
---|
844 | r.right -= GetSystemMetrics(SM_CYCAPTION)+1;
|
---|
845 |
|
---|
846 | BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
|
---|
847 | r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
|
---|
848 | bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
|
---|
849 |
|
---|
850 | if(bGrayed)
|
---|
851 | DrawGrayButton(hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
|
---|
852 | r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
|
---|
853 |
|
---|
854 |
|
---|
855 | SelectObject (hdcMem, hOldBmp);
|
---|
856 | DeleteDC( hdcMem );
|
---|
857 | }
|
---|
858 | //******************************************************************************
|
---|
859 | //******************************************************************************
|
---|
860 | VOID Win32BaseWindow::DrawCaption(HDC hdc,RECT *rect,BOOL active)
|
---|
861 | {
|
---|
862 | RECT r = *rect,r2;
|
---|
863 | char buffer[256];
|
---|
864 | HPEN hPrevPen;
|
---|
865 | HDC memDC;
|
---|
866 | HBITMAP memBmp,oldBmp;
|
---|
867 |
|
---|
868 | memDC = CreateCompatibleDC(hdc);
|
---|
869 | r.right -= r.left;
|
---|
870 | r.bottom -= r.top;
|
---|
871 | r.left = r.top = 0;
|
---|
872 | r2 = r;
|
---|
873 | memBmp = CreateCompatibleBitmap(hdc,r.right,r.bottom);
|
---|
874 | oldBmp = SelectObject(memDC,memBmp);
|
---|
875 |
|
---|
876 | hPrevPen = SelectObject(memDC,GetSysColorPen(COLOR_3DFACE));
|
---|
877 | MoveToEx(memDC,r.left,r.bottom-1,NULL);
|
---|
878 | LineTo(memDC,r.right,r.bottom-1);
|
---|
879 | SelectObject(memDC,hPrevPen);
|
---|
880 | r.bottom--;
|
---|
881 |
|
---|
882 | if (SYSCOLOR_GetUseWinColors())
|
---|
883 | {
|
---|
884 | COLORREF startColor = GetSysColor(active ? COLOR_ACTIVECAPTION:COLOR_INACTIVECAPTION),endColor = GetSysColor(active ? COLOR_GRADIENTACTIVECAPTION:COLOR_GRADIENTINACTIVECAPTION);
|
---|
885 |
|
---|
886 | if (startColor == endColor)
|
---|
887 | FillRect(memDC,&r,GetSysColorBrush(startColor));
|
---|
888 | else
|
---|
889 | {
|
---|
890 | INT rDiff = GetRValue(endColor)-GetRValue(startColor);
|
---|
891 | INT gDiff = GetGValue(endColor)-GetGValue(startColor);
|
---|
892 | INT bDiff = GetBValue(endColor)-GetBValue(startColor);
|
---|
893 | INT steps = MAX(MAX(abs(rDiff),abs(gDiff)),abs(bDiff));
|
---|
894 | INT w = r.right-r.left;
|
---|
895 | RECT r2;
|
---|
896 |
|
---|
897 | if (w < steps) steps = w;
|
---|
898 | r2.left = r2.right = r.left;
|
---|
899 | r2.top = r.top;
|
---|
900 | r2.bottom = r.bottom;
|
---|
901 | for (INT x = 0;x <= steps;x++)
|
---|
902 | {
|
---|
903 | COLORREF color = RGB(GetRValue(startColor)+rDiff*x/steps,GetGValue(startColor)+gDiff*x/steps,GetBValue(startColor)+bDiff*x/steps);
|
---|
904 | HBRUSH brush = CreateSolidBrush(color);
|
---|
905 |
|
---|
906 | r2.left = r2.right;
|
---|
907 | r2.right = r.left+w*x/steps;
|
---|
908 | FillRect(memDC,&r2,brush);
|
---|
909 | DeleteObject(brush);
|
---|
910 | }
|
---|
911 | }
|
---|
912 | } else FillRect(memDC,&r,GetSysColorBrush(active ? COLOR_ACTIVECAPTION:COLOR_INACTIVECAPTION));
|
---|
913 |
|
---|
914 | if (!hbitmapClose)
|
---|
915 | {
|
---|
916 | if (!(hbitmapClose = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSE)))) return;
|
---|
917 | hbitmapCloseD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSED));
|
---|
918 | hbitmapMinimize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCE));
|
---|
919 | hbitmapMinimizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCED));
|
---|
920 | hbitmapMaximize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOM));
|
---|
921 | hbitmapMaximizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOMD));
|
---|
922 | hbitmapRestore = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORE));
|
---|
923 | hbitmapRestoreD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORED));
|
---|
924 | hbitmapContextHelp = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CONTEXTHELP));
|
---|
925 | hbitmapContextHelpD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CONTEXTHELPD));
|
---|
926 | }
|
---|
927 |
|
---|
928 | if ((dwStyle & WS_SYSMENU) && !(dwExStyle & WS_EX_TOOLWINDOW))
|
---|
929 | {
|
---|
930 | if (DrawSysButton(memDC,&r))
|
---|
931 | r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
|
---|
932 | }
|
---|
933 |
|
---|
934 | if (dwStyle & WS_SYSMENU)
|
---|
935 | {
|
---|
936 | UINT state;
|
---|
937 |
|
---|
938 | /* Go get the sysmenu */
|
---|
939 | state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
|
---|
940 |
|
---|
941 | /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
|
---|
942 | DrawCloseButton(memDC,&r2,FALSE,
|
---|
943 | ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
|
---|
944 | r.right -= GetSystemMetrics(SM_CYCAPTION)-1;
|
---|
945 |
|
---|
946 | if (dwExStyle & WS_EX_CONTEXTHELP)
|
---|
947 | {
|
---|
948 | DrawContextHelpButton(memDC,&r2,FALSE,FALSE);
|
---|
949 | r.right -= GetSystemMetrics(SM_CXSIZE)+1;
|
---|
950 | }
|
---|
951 |
|
---|
952 | if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
|
---|
953 | {
|
---|
954 | /* In win95 the two buttons are always there */
|
---|
955 | /* But if the menu item is not in the menu they're disabled*/
|
---|
956 |
|
---|
957 | DrawMaxButton(memDC,&r2,FALSE,(!(dwStyle & WS_MAXIMIZEBOX)));
|
---|
958 | r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
|
---|
959 |
|
---|
960 | DrawMinButton(memDC,&r2,FALSE, (!(dwStyle & WS_MINIMIZEBOX)));
|
---|
961 | r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
|
---|
962 | }
|
---|
963 | }
|
---|
964 |
|
---|
965 | if (GetWindowTextA(buffer, sizeof(buffer) ))
|
---|
966 | {
|
---|
967 | NONCLIENTMETRICSA nclm;
|
---|
968 | HFONT hFont, hOldFont;
|
---|
969 |
|
---|
970 | nclm.cbSize = sizeof(NONCLIENTMETRICSA);
|
---|
971 | SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
|
---|
972 | if (dwExStyle & WS_EX_TOOLWINDOW)
|
---|
973 | hFont = CreateFontIndirectA (&nclm.lfSmCaptionFont);
|
---|
974 | else
|
---|
975 | hFont = CreateFontIndirectA (&nclm.lfCaptionFont);
|
---|
976 | hOldFont = SelectObject (memDC, hFont);
|
---|
977 | SetTextColor(memDC,GetSysColor(active ? COLOR_CAPTIONTEXT:COLOR_INACTIVECAPTIONTEXT));
|
---|
978 | SetBkMode(memDC, TRANSPARENT );
|
---|
979 | r.left += 2;
|
---|
980 | DrawTextExA(memDC,buffer,-1,&r,DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT | DT_END_ELLIPSIS,NULL);
|
---|
981 | DeleteObject (SelectObject (memDC, hOldFont));
|
---|
982 | IncreaseLogCount();
|
---|
983 | dprintf(("DrawCaption %s %d", buffer, active));
|
---|
984 | DecreaseLogCount();
|
---|
985 | }
|
---|
986 |
|
---|
987 | BitBlt(hdc,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,memDC,0,0,SRCCOPY);
|
---|
988 | SelectObject(memDC,oldBmp);
|
---|
989 | DeleteObject(memBmp);
|
---|
990 | DeleteDC(memDC);
|
---|
991 | }
|
---|
992 | //******************************************************************************
|
---|
993 | //******************************************************************************
|
---|
994 | VOID Win32BaseWindow::DoNCPaint(HRGN clip,BOOL suppress_menupaint)
|
---|
995 | {
|
---|
996 | BOOL active = flags & WIN_NCACTIVATED;
|
---|
997 | HDC hdc;
|
---|
998 | RECT rect,rectClip,rfuzz;
|
---|
999 |
|
---|
1000 | /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in
|
---|
1001 | the call to GetDCEx implying that it is allowed not to use it either.
|
---|
1002 | However, the suggested GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN)
|
---|
1003 | will cause clipRgn to be deleted after ReleaseDC().
|
---|
1004 | Now, how is the "system" supposed to tell what happened?
|
---|
1005 | */
|
---|
1006 |
|
---|
1007 | dprintf(("DoNCPaint %x %x %d", getWindowHandle(), clip, suppress_menupaint));
|
---|
1008 | DecreaseLogCount();
|
---|
1009 |
|
---|
1010 | rect.top = rect.left = 0;
|
---|
1011 | rect.right = rectWindow.right - rectWindow.left;
|
---|
1012 | rect.bottom = rectWindow.bottom - rectWindow.top;
|
---|
1013 |
|
---|
1014 | if (clip > 1)
|
---|
1015 | {
|
---|
1016 | //only redraw caption
|
---|
1017 | GetRgnBox(clip,&rectClip);
|
---|
1018 | #if 1
|
---|
1019 | //SvL: I'm getting paint problems when clipping a dc created in GetDCEx
|
---|
1020 | // with a region that covers the entire window (RealPlayer 7 Update 1)
|
---|
1021 | // As we don't need to clip anything when that occurs, this workaround
|
---|
1022 | // solves the problem.
|
---|
1023 | if(rectClip.right == getWindowWidth() && rectClip.bottom == getWindowHeight())
|
---|
1024 | {
|
---|
1025 | clip = 0;
|
---|
1026 | rectClip = rect;
|
---|
1027 | }
|
---|
1028 | #endif
|
---|
1029 | }
|
---|
1030 | else
|
---|
1031 | {
|
---|
1032 | clip = 0;
|
---|
1033 | rectClip = rect;
|
---|
1034 | }
|
---|
1035 |
|
---|
1036 | if (!(hdc = GetDCEx( Win32Hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
|
---|
1037 | ((clip > 1) ?(DCX_INTERSECTRGN /*| DCX_KEEPCLIPRGN*/) : 0) ))) return;
|
---|
1038 |
|
---|
1039 | SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
|
---|
1040 |
|
---|
1041 | if (HAS_BIGFRAME( dwStyle, dwExStyle))
|
---|
1042 | {
|
---|
1043 | DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST);
|
---|
1044 | }
|
---|
1045 | if (HAS_THICKFRAME( dwStyle, dwExStyle ))
|
---|
1046 | DrawFrame(hdc, &rect, FALSE, active );
|
---|
1047 | else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
|
---|
1048 | DrawFrame( hdc, &rect, TRUE, active );
|
---|
1049 | else if (HAS_THINFRAME( dwStyle ))
|
---|
1050 | {
|
---|
1051 | SelectObject( hdc, GetStockObject(NULL_BRUSH) );
|
---|
1052 | Rectangle( hdc, 0, 0, rect.right, rect.bottom );
|
---|
1053 | }
|
---|
1054 |
|
---|
1055 | if ((dwStyle & WS_CAPTION) == WS_CAPTION)
|
---|
1056 | {
|
---|
1057 | RECT r = rect;
|
---|
1058 | if (dwExStyle & WS_EX_TOOLWINDOW)
|
---|
1059 | {
|
---|
1060 | r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
|
---|
1061 | rect.top += GetSystemMetrics(SM_CYSMCAPTION);
|
---|
1062 | }
|
---|
1063 | else
|
---|
1064 | {
|
---|
1065 | r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
|
---|
1066 | rect.top += GetSystemMetrics(SM_CYCAPTION);
|
---|
1067 | }
|
---|
1068 | if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
|
---|
1069 | DrawCaption(hdc,&r,active);
|
---|
1070 | }
|
---|
1071 |
|
---|
1072 | if (HAS_MENU())
|
---|
1073 | {
|
---|
1074 | RECT r = rect;
|
---|
1075 | r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
|
---|
1076 |
|
---|
1077 | rect.top += MENU_DrawMenuBar(hdc,&r,Win32Hwnd,suppress_menupaint)+1;
|
---|
1078 | }
|
---|
1079 |
|
---|
1080 | if (dwExStyle & WS_EX_CLIENTEDGE)
|
---|
1081 | DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
|
---|
1082 |
|
---|
1083 | if (dwExStyle & WS_EX_STATICEDGE)
|
---|
1084 | DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
|
---|
1085 |
|
---|
1086 | /* Draw the scroll-bars */
|
---|
1087 | if (dwStyle & WS_VSCROLL)
|
---|
1088 | SCROLL_DrawScrollBar(Win32Hwnd,hdc,SB_VERT,TRUE,TRUE);
|
---|
1089 | if (dwStyle & WS_HSCROLL)
|
---|
1090 | SCROLL_DrawScrollBar(Win32Hwnd,hdc,SB_HORZ,TRUE,TRUE);
|
---|
1091 |
|
---|
1092 | /* Draw the "size-box" */
|
---|
1093 | if ((dwStyle & WS_VSCROLL) && (dwStyle & WS_HSCROLL))
|
---|
1094 | {
|
---|
1095 | RECT r = rect;
|
---|
1096 | r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
|
---|
1097 | r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
|
---|
1098 | FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
|
---|
1099 | //CB: todo: child windows have sometimes a size grip (i.e. Notepad)
|
---|
1100 | // WS_SIZEBOX isn't set in these cases
|
---|
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(getWindowHandle(),hdc);
|
---|
1136 | IncreaseLogCount();
|
---|
1137 | dprintf(("**DoNCPaint %x DONE", getWindowHandle()));
|
---|
1138 | }
|
---|
1139 | //******************************************************************************
|
---|
1140 | //******************************************************************************
|
---|
1141 | LONG Win32BaseWindow::HandleNCPaint(HRGN clip)
|
---|
1142 | {
|
---|
1143 | //CB: ignore it for now (SetWindowPos in WM_CREATE)
|
---|
1144 | // if (!(dwStyle & WS_VISIBLE)) return 0;
|
---|
1145 |
|
---|
1146 | if (dwStyle & WS_MINIMIZE) return 0;
|
---|
1147 |
|
---|
1148 | DoNCPaint(clip,FALSE);
|
---|
1149 |
|
---|
1150 | return 0;
|
---|
1151 | }
|
---|
1152 | /***********************************************************************
|
---|
1153 | * NC_HandleNCLButtonDblClk
|
---|
1154 | *
|
---|
1155 | * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
|
---|
1156 | */
|
---|
1157 | LONG Win32BaseWindow::HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam)
|
---|
1158 | {
|
---|
1159 | /*
|
---|
1160 | * if this is an icon, send a restore since we are handling
|
---|
1161 | * a double click
|
---|
1162 | */
|
---|
1163 | if (dwStyle & WS_MINIMIZE)
|
---|
1164 | {
|
---|
1165 | SendInternalMessageA(WM_SYSCOMMAND,SC_RESTORE,lParam);
|
---|
1166 | return 0;
|
---|
1167 | }
|
---|
1168 |
|
---|
1169 | switch(wParam) /* Hit test */
|
---|
1170 | {
|
---|
1171 | case HTCAPTION:
|
---|
1172 | /* stop processing if WS_MAXIMIZEBOX is missing */
|
---|
1173 | if (dwStyle & WS_MAXIMIZEBOX)
|
---|
1174 | SendInternalMessageA(WM_SYSCOMMAND,
|
---|
1175 | (dwStyle & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE,
|
---|
1176 | lParam);
|
---|
1177 | break;
|
---|
1178 |
|
---|
1179 | case HTSYSMENU:
|
---|
1180 | if (!(GetClassWord(Win32Hwnd,GCW_STYLE) & CS_NOCLOSE))
|
---|
1181 | SendInternalMessageA(WM_SYSCOMMAND,SC_CLOSE,lParam);
|
---|
1182 | break;
|
---|
1183 |
|
---|
1184 | case HTHSCROLL:
|
---|
1185 | SendInternalMessageA(WM_SYSCOMMAND,SC_HSCROLL+HTHSCROLL,lParam);
|
---|
1186 | break;
|
---|
1187 |
|
---|
1188 | case HTVSCROLL:
|
---|
1189 | SendInternalMessageA(WM_SYSCOMMAND,SC_VSCROLL+HTVSCROLL,lParam);
|
---|
1190 | break;
|
---|
1191 | }
|
---|
1192 |
|
---|
1193 | return 0;
|
---|
1194 | }
|
---|
1195 | //******************************************************************************
|
---|
1196 | //******************************************************************************
|
---|
1197 | LONG Win32BaseWindow::HandleNCRButtonUp(WPARAM wParam,LPARAM lParam)
|
---|
1198 | {
|
---|
1199 | switch(wParam)
|
---|
1200 | {
|
---|
1201 | case HTCAPTION:
|
---|
1202 | if (GetActiveWindow() != Win32Hwnd)
|
---|
1203 | SetActiveWindow();
|
---|
1204 |
|
---|
1205 | if (((GetActiveWindow() == Win32Hwnd) || isMDIChild()) && (dwStyle & WS_SYSMENU))
|
---|
1206 | {
|
---|
1207 | SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTCAPTION,lParam);
|
---|
1208 | }
|
---|
1209 | break;
|
---|
1210 |
|
---|
1211 | default:
|
---|
1212 | break;
|
---|
1213 | }
|
---|
1214 |
|
---|
1215 | return 0;
|
---|
1216 | }
|
---|
1217 | /***********************************************************************
|
---|
1218 | * NC_HandleSysCommand
|
---|
1219 | *
|
---|
1220 | * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
|
---|
1221 | *
|
---|
1222 | */
|
---|
1223 | LONG Win32BaseWindow::HandleSysCommand(WPARAM wParam,POINT *pt32)
|
---|
1224 | {
|
---|
1225 | UINT uCommand = wParam & 0xFFF0;
|
---|
1226 |
|
---|
1227 | switch (uCommand)
|
---|
1228 | {
|
---|
1229 |
|
---|
1230 | case SC_SIZE:
|
---|
1231 | {
|
---|
1232 | DWORD flags;
|
---|
1233 |
|
---|
1234 | if (dwStyle & WS_MAXIMIZE) break;
|
---|
1235 |
|
---|
1236 | switch ((wParam & 0xF)+2)
|
---|
1237 | {
|
---|
1238 | case HTLEFT:
|
---|
1239 | flags = TFOS_LEFT;
|
---|
1240 | break;
|
---|
1241 |
|
---|
1242 | case HTRIGHT:
|
---|
1243 | flags = TFOS_RIGHT;
|
---|
1244 | break;
|
---|
1245 |
|
---|
1246 | case HTTOP:
|
---|
1247 | flags = TFOS_TOP;
|
---|
1248 | break;
|
---|
1249 |
|
---|
1250 | case HTTOPLEFT:
|
---|
1251 | flags = TFOS_TOP | TFOS_LEFT;
|
---|
1252 | break;
|
---|
1253 |
|
---|
1254 | case HTTOPRIGHT:
|
---|
1255 | flags = TFOS_TOP | TFOS_RIGHT;
|
---|
1256 | break;
|
---|
1257 |
|
---|
1258 | case HTBOTTOM:
|
---|
1259 | flags = TFOS_BOTTOM;
|
---|
1260 | break;
|
---|
1261 |
|
---|
1262 | case HTBOTTOMLEFT:
|
---|
1263 | flags = TFOS_BOTTOM | TFOS_LEFT;
|
---|
1264 | break;
|
---|
1265 |
|
---|
1266 | case HTBOTTOMRIGHT:
|
---|
1267 | flags = TFOS_BOTTOM | TFOS_RIGHT;
|
---|
1268 | break;
|
---|
1269 |
|
---|
1270 | default:
|
---|
1271 | flags = TFOS_BOTTOM | TFOS_RIGHT;
|
---|
1272 | break;
|
---|
1273 | }
|
---|
1274 | if (flags) FrameTrackFrame(this,flags);
|
---|
1275 | break;
|
---|
1276 | }
|
---|
1277 |
|
---|
1278 | case SC_MOVE:
|
---|
1279 | if (dwStyle & WS_MAXIMIZE) break;
|
---|
1280 | FrameTrackFrame(this,TFOS_MOVE);
|
---|
1281 | break;
|
---|
1282 |
|
---|
1283 | case SC_MINIMIZE:
|
---|
1284 | ShowWindow(SW_MINIMIZE);
|
---|
1285 | break;
|
---|
1286 |
|
---|
1287 | case SC_MAXIMIZE:
|
---|
1288 | ShowWindow(SW_MAXIMIZE);
|
---|
1289 | break;
|
---|
1290 |
|
---|
1291 | case SC_RESTORE:
|
---|
1292 | ShowWindow(SW_RESTORE);
|
---|
1293 | break;
|
---|
1294 |
|
---|
1295 | case SC_CLOSE:
|
---|
1296 | return SendInternalMessageA(WM_CLOSE,0,0);
|
---|
1297 |
|
---|
1298 | case SC_CONTEXTHELP:
|
---|
1299 | {
|
---|
1300 | //CB: todo
|
---|
1301 | break;
|
---|
1302 | }
|
---|
1303 |
|
---|
1304 | case SC_VSCROLL:
|
---|
1305 | case SC_HSCROLL:
|
---|
1306 | TrackScrollBar(wParam,*pt32);
|
---|
1307 | break;
|
---|
1308 |
|
---|
1309 | case SC_MOUSEMENU:
|
---|
1310 | MENU_TrackMouseMenuBar(Win32Hwnd,wParam & 0x000F,*pt32);
|
---|
1311 | break;
|
---|
1312 |
|
---|
1313 | case SC_KEYMENU:
|
---|
1314 | MENU_TrackKbdMenuBar(Win32Hwnd,wParam,pt32->x);
|
---|
1315 | break;
|
---|
1316 |
|
---|
1317 | case SC_TASKLIST:
|
---|
1318 | OSLibWinShowTaskList(getOS2WindowHandle());
|
---|
1319 | break;
|
---|
1320 |
|
---|
1321 | case SC_SCREENSAVE:
|
---|
1322 | if (wParam == SC_ABOUTODIN) {
|
---|
1323 | if(ShellAboutA == 0) {
|
---|
1324 | HINSTANCE hShell32 = LoadLibraryA("SHELL32");
|
---|
1325 | if(hShell32 == 0)
|
---|
1326 | break;
|
---|
1327 | *(VOID **)&ShellAboutA = (VOID *)GetProcAddress(hShell32, "ShellAboutA");
|
---|
1328 | }
|
---|
1329 | ShellAboutA(Win32Hwnd,"Odin","Odin alpha release compiled with IBM VAC++",0);
|
---|
1330 | }
|
---|
1331 | #ifdef DEBUG
|
---|
1332 | //SvL: Do NOT turn this into a dprintf.
|
---|
1333 | else
|
---|
1334 | if (wParam == SC_PUTMARK)
|
---|
1335 | WriteLog(("Mark requested by user\n"));
|
---|
1336 | else
|
---|
1337 | if (wParam == SC_DEBUGINT3)
|
---|
1338 | DebugInt3();
|
---|
1339 | #endif
|
---|
1340 | break;
|
---|
1341 |
|
---|
1342 | case SC_HOTKEY:
|
---|
1343 | case SC_ARRANGE:
|
---|
1344 | case SC_NEXTWINDOW:
|
---|
1345 | case SC_PREVWINDOW:
|
---|
1346 | break;
|
---|
1347 | }
|
---|
1348 | return 0;
|
---|
1349 | }
|
---|
1350 | /*****************************************************************************
|
---|
1351 | * Name : VOID WIN32API DrawCaption
|
---|
1352 | * Purpose : The DrawCaption function draws a window caption.
|
---|
1353 | * Parameters: HDC hdc handle of device context
|
---|
1354 | * LPRECT lprc address of bounding rectangle coordinates
|
---|
1355 | * HFONT hfont handle of font for caption
|
---|
1356 | * HICON hicon handle of icon in caption
|
---|
1357 | * LPSTR lpszText address of caption string
|
---|
1358 | * WORD wFlags drawing options
|
---|
1359 | * Variables :
|
---|
1360 | * Result :
|
---|
1361 | * Remark :
|
---|
1362 | * Status : UNTESTED STUB
|
---|
1363 | *
|
---|
1364 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
1365 | *****************************************************************************/
|
---|
1366 | BOOL WIN32API DrawCaption (HWND hwnd,HDC hdc,const RECT *lprc,UINT wFlags)
|
---|
1367 | {
|
---|
1368 | dprintf(("USER32: DrawCaption"));
|
---|
1369 |
|
---|
1370 | return DrawCaptionTempA(hwnd,hdc,lprc,0,0,NULL,wFlags & 0x1F);
|
---|
1371 | }
|
---|
1372 | //******************************************************************************
|
---|
1373 | // CB: this code is a subset of Win32BaseWindow::DrawCaption
|
---|
1374 | // todo: move Win32BaseWindow:DrawCaption to this function
|
---|
1375 | //******************************************************************************
|
---|
1376 | BOOL WIN32API DrawCaptionTemp(HWND hwnd,HDC hdc,const RECT *rect,HFONT hFont,HICON hIcon,LPWSTR str,UINT uFlags,BOOL unicode)
|
---|
1377 | {
|
---|
1378 | RECT rc = *rect;
|
---|
1379 |
|
---|
1380 | /* drawing background */
|
---|
1381 | if (uFlags & DC_INBUTTON)
|
---|
1382 | {
|
---|
1383 | FillRect (hdc, &rc, GetSysColorBrush (COLOR_3DFACE));
|
---|
1384 |
|
---|
1385 | if (uFlags & DC_ACTIVE)
|
---|
1386 | {
|
---|
1387 | HBRUSH hbr = SelectObject (hdc, GetPattern55AABrush ());
|
---|
1388 | PatBlt (hdc, rc.left, rc.top,
|
---|
1389 | rc.right-rc.left, rc.bottom-rc.top, 0xFA0089);
|
---|
1390 | SelectObject (hdc, hbr);
|
---|
1391 | }
|
---|
1392 | } else
|
---|
1393 | {
|
---|
1394 | FillRect (hdc, &rc, GetSysColorBrush ((uFlags & DC_ACTIVE) ?
|
---|
1395 | COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION));
|
---|
1396 | }
|
---|
1397 |
|
---|
1398 | /* drawing icon */
|
---|
1399 | if ((uFlags & DC_ICON) && !(uFlags & DC_SMALLCAP))
|
---|
1400 | {
|
---|
1401 | POINT pt;
|
---|
1402 |
|
---|
1403 | pt.x = rc.left + 2;
|
---|
1404 | pt.y = (rc.bottom + rc.top - GetSystemMetrics(SM_CYSMICON)) / 2;
|
---|
1405 |
|
---|
1406 | if (hIcon)
|
---|
1407 | {
|
---|
1408 | DrawIconEx (hdc, pt.x, pt.y, hIcon, GetSystemMetrics(SM_CXSMICON),
|
---|
1409 | GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
|
---|
1410 | } else
|
---|
1411 | {
|
---|
1412 | Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1413 |
|
---|
1414 | if (!win32wnd) return 0;
|
---|
1415 |
|
---|
1416 | DrawIconEx (hdc, pt.x, pt.y, win32wnd->IconForWindow(ICON_SMALL),
|
---|
1417 | GetSystemMetrics(SM_CXSMICON),
|
---|
1418 | GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
|
---|
1419 | }
|
---|
1420 |
|
---|
1421 | rc.left += (rc.bottom - rc.top);
|
---|
1422 | }
|
---|
1423 |
|
---|
1424 | /* drawing text */
|
---|
1425 | if (uFlags & DC_TEXT)
|
---|
1426 | {
|
---|
1427 | HFONT hOldFont;
|
---|
1428 |
|
---|
1429 | if (uFlags & DC_INBUTTON)
|
---|
1430 | SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
|
---|
1431 | else if (uFlags & DC_ACTIVE)
|
---|
1432 | SetTextColor (hdc, GetSysColor (COLOR_CAPTIONTEXT));
|
---|
1433 | else
|
---|
1434 | SetTextColor (hdc, GetSysColor (COLOR_INACTIVECAPTIONTEXT));
|
---|
1435 |
|
---|
1436 | SetBkMode (hdc, TRANSPARENT);
|
---|
1437 |
|
---|
1438 | if (hFont)
|
---|
1439 | hOldFont = SelectObject (hdc, hFont);
|
---|
1440 | else
|
---|
1441 | {
|
---|
1442 | NONCLIENTMETRICSA nclm;
|
---|
1443 | HFONT hNewFont;
|
---|
1444 |
|
---|
1445 | nclm.cbSize = sizeof(NONCLIENTMETRICSA);
|
---|
1446 | SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
|
---|
1447 | hNewFont = CreateFontIndirectA ((uFlags & DC_SMALLCAP) ?
|
---|
1448 | &nclm.lfSmCaptionFont : &nclm.lfCaptionFont);
|
---|
1449 | hOldFont = SelectObject (hdc, hNewFont);
|
---|
1450 | }
|
---|
1451 |
|
---|
1452 | if (str)
|
---|
1453 | {
|
---|
1454 | if (unicode)
|
---|
1455 | DrawTextW(hdc,str,-1,&rc,DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
|
---|
1456 | else
|
---|
1457 | DrawTextA(hdc,(LPSTR)str,-1,&rc,DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
|
---|
1458 | } else
|
---|
1459 | {
|
---|
1460 | CHAR szText[128];
|
---|
1461 | INT nLen;
|
---|
1462 |
|
---|
1463 | nLen = GetWindowTextA (hwnd, szText, 128);
|
---|
1464 | DrawTextA (hdc, szText, nLen, &rc,
|
---|
1465 | DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
|
---|
1466 | }
|
---|
1467 |
|
---|
1468 | if (hFont)
|
---|
1469 | SelectObject (hdc, hOldFont);
|
---|
1470 | else
|
---|
1471 | DeleteObject (SelectObject (hdc, hOldFont));
|
---|
1472 | }
|
---|
1473 |
|
---|
1474 | /* drawing focus ??? */
|
---|
1475 | //if (uFlags & 0x2000)
|
---|
1476 | // FIXME("undocumented flag (0x2000)!\n");
|
---|
1477 |
|
---|
1478 | return 0;
|
---|
1479 | }
|
---|
1480 | /***********************************************************************
|
---|
1481 | * DrawCaptionTemp32A [USER32.599]
|
---|
1482 | *
|
---|
1483 | * PARAMS
|
---|
1484 | *
|
---|
1485 | * RETURNS
|
---|
1486 | * Success:
|
---|
1487 | * Failure:
|
---|
1488 | */
|
---|
1489 | BOOL WIN32API DrawCaptionTempA(HWND hwnd,HDC hdc,const RECT *rect,HFONT hFont,HICON hIcon,LPCSTR str,UINT uFlags)
|
---|
1490 | {
|
---|
1491 | dprintf(("USER32: DrawCaptionTempA"));
|
---|
1492 |
|
---|
1493 | return DrawCaptionTemp(hwnd,hdc,rect,hFont,hIcon,(LPWSTR)str,uFlags,FALSE);
|
---|
1494 | }
|
---|
1495 | /***********************************************************************
|
---|
1496 | * DrawCaptionTemp32W [USER32.602]
|
---|
1497 | *
|
---|
1498 | * PARAMS
|
---|
1499 | *
|
---|
1500 | * RETURNS
|
---|
1501 | * Success:
|
---|
1502 | * Failure:
|
---|
1503 | */
|
---|
1504 | BOOL WIN32API DrawCaptionTempW (HWND hwnd,HDC hdc,const RECT *rect,HFONT hFont,HICON hIcon,LPCWSTR str,UINT uFlags)
|
---|
1505 | {
|
---|
1506 | dprintf(("USER32: DrawCaptionTempA"));
|
---|
1507 |
|
---|
1508 | return DrawCaptionTemp(hwnd,hdc,rect,hFont,hIcon,(LPWSTR)str,uFlags,TRUE);
|
---|
1509 | }
|
---|
1510 |
|
---|