source: trunk/src/user32/new/pmframe.cpp@ 2340

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

* empty log message *

File size: 22.5 KB
Line 
1/* $Id: pmframe.cpp,v 1.6 2000-01-06 17:05:52 cbratschi Exp $ */
2/*
3 * Win32 Frame Managment Code for OS/2
4 *
5 * Copyright 1999 by Christoph Bratschi (cbratschi@datacomm.ch)
6 *
7 *
8 * Project Odin Software License can be found in LICENSE.TXT
9 *
10 */
11
12#define INCL_WIN
13#define INCL_GPI
14
15#include <os2.h> /* PM header file */
16#include <os2wrap.h>
17#include <stdlib.h>
18#include <string.h>
19#include "win32type.h"
20#include <misc.h>
21#include <win32wbase.h>
22#include "wprocess.h"
23#include "pmframe.h"
24#include "oslibutil.h"
25#include "oslibwin.h"
26#include "caret.h"
27#include "oslibmsg.h"
28
29#define PMFRAMELOG
30
31//******************************************************************************
32//******************************************************************************
33VOID Draw3DRect(HPS hps,RECTL rect,LONG colorBR,LONG colorTL)
34{
35 POINTL point;
36
37 GpiSetColor(hps,colorBR);
38 point.x = rect.xLeft;
39 point.y = rect.yBottom;
40 GpiMove(hps,&point);
41 point.x = rect.xRight-1;
42 GpiLine(hps,&point);
43 point.y = rect.yTop-1;
44 GpiLine(hps,&point);
45 GpiSetColor(hps,colorTL);
46 point.x--;
47 GpiMove(hps,&point);
48 point.x = rect.xLeft;
49 GpiLine(hps,&point);
50 point.y = rect.yBottom+1;
51 GpiLine(hps,&point);
52}
53//******************************************************************************
54//******************************************************************************
55inline VOID DeflateRect(RECTL *rect)
56{
57 rect->xLeft++;
58 rect->xRight--;
59 rect->yTop--;
60 rect->yBottom++;
61}
62//******************************************************************************
63//******************************************************************************
64VOID DrawFrame(HPS hps,RECTL *rect,Win32BaseWindow *win32wnd)
65{
66 LONG clrWhite,clrBlack,clrDark,clrLight;
67 POINTL point;
68 DWORD dwExStyle = win32wnd->getExStyle();
69 DWORD dwStyle = win32wnd->getStyle();
70
71 //CB: todo: switch to RGB mode and use win colors
72 clrWhite = CLR_WHITE;
73 clrBlack = CLR_BLACK;
74 clrLight = CLR_PALEGRAY;
75 clrDark = CLR_DARKGRAY;
76
77 if (dwExStyle & WS_EX_CLIENTEDGE_W)
78 {
79 Draw3DRect(hps,*rect,clrWhite,clrDark);
80 DeflateRect(rect);
81 Draw3DRect(hps,*rect,clrLight,clrBlack);
82 }
83 else if (dwExStyle & WS_EX_DLGMODALFRAME_W)
84 {
85 Draw3DRect(hps,*rect,clrBlack,clrLight);
86 DeflateRect(rect);
87 Draw3DRect(hps,*rect,clrDark,clrWhite);
88 DeflateRect(rect);
89 Draw3DRect(hps,*rect,clrLight,clrLight);
90 }
91 else if (dwExStyle & WS_EX_STATICEDGE_W)
92 {
93 Draw3DRect(hps,*rect,clrWhite,clrDark);
94 }
95 else if (dwExStyle & WS_EX_WINDOWEDGE_W);
96 else if (dwStyle & WS_BORDER_W)
97 {
98 Draw3DRect(hps,*rect,clrBlack,clrBlack);
99 }
100
101 DeflateRect(rect);
102}
103//******************************************************************************
104//******************************************************************************
105BOOL CanDrawSizeBox(Win32BaseWindow *win32wnd)
106{
107 return ((win32wnd->getStyle() & WS_SIZEBOX_W) && (WinQueryWindowULong(win32wnd->getOS2FrameWindowHandle(),QWL_STYLE) & FS_SIZEBORDER)
108 && win32wnd->getVertScrollHandle() && WinQueryWindow(win32wnd->getVertScrollHandle(),QW_PARENT) == win32wnd->getOS2FrameWindowHandle()
109 && win32wnd->getHorzScrollHandle() && WinQueryWindow(win32wnd->getHorzScrollHandle(),QW_PARENT) == win32wnd->getOS2FrameWindowHandle());
110}
111//******************************************************************************
112//******************************************************************************
113VOID GetSizeBox(Win32BaseWindow *win32wnd,RECTL *rect)
114{
115 SWP swpHorz,swpVert;
116
117 WinQueryWindowPos(win32wnd->getVertScrollHandle(),&swpVert);
118 WinQueryWindowPos(win32wnd->getHorzScrollHandle(),&swpHorz);
119 rect->xLeft = swpVert.x;
120 rect->xRight = swpVert.x+swpVert.cx;
121 rect->yTop = swpHorz.y+swpHorz.cy;
122 rect->yBottom = swpHorz.y;
123}
124//******************************************************************************
125//******************************************************************************
126BOOL InSizeBox(Win32BaseWindow *win32wnd,POINTS *points)
127{
128 if (CanDrawSizeBox(win32wnd))
129 {
130 RECTL rect;
131 POINTL point;
132
133 point.x = points->x;
134 point.y = points->y;
135 GetSizeBox(win32wnd,&rect);
136 return (WinPtInRect(GetThreadHAB(),&rect,&point));
137 }
138
139 return FALSE;
140}
141//******************************************************************************
142//******************************************************************************
143VOID DrawSizeBox(HPS hps,RECTL rect)
144{
145 POINTL p1,p2;
146 LONG clrDark = CLR_DARKGRAY,clrWhite = CLR_WHITE;
147 INT x;
148
149 //CB: todo: switch to RGB mode and use win colors
150 WinFillRect(hps,&rect,SYSCLR_DIALOGBACKGROUND);
151 p1.x = rect.xRight-2;
152 p1.y = rect.yBottom;
153 p2.x = rect.xRight-1;
154 p2.y = rect.yBottom+1;
155 for (x = 0;x < 3;x++)
156 {
157 GpiSetColor(hps,clrDark);
158 GpiMove(hps,&p1);
159 GpiLine(hps,&p2);
160 p1.x--;
161 p2.y++;
162 GpiMove(hps,&p1);
163 GpiLine(hps,&p2);
164 GpiSetColor(hps,clrWhite);
165 p1.x--;
166 p2.y++;
167 GpiMove(hps,&p1);
168 GpiLine(hps,&p2);
169 p1.x -= 2;
170 p2.y += 2;
171 }
172}
173//******************************************************************************
174//******************************************************************************
175void DrawActivate(Win32BaseWindow *win32wnd, HWND hwnd)
176{
177 if (!win32wnd->isChild())
178 {
179 if (CanDrawSizeBox(win32wnd))
180 {
181 HPS hps;
182 RECTL rect;
183
184 GetSizeBox(win32wnd,&rect);
185 hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
186 DrawSizeBox(hps,rect);
187 WinReleasePS(hps);
188
189 }
190 }
191 else
192 {
193 HPS hps;
194 RECTL rect;
195
196 WinQueryWindowRect(hwnd,&rect);
197 rect.xRight = rect.xRight-rect.xLeft;
198 rect.yTop = rect.yTop-rect.yBottom;
199 rect.xLeft = rect.yBottom = 0;
200 hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
201 DrawFrame(hps,&rect,win32wnd);
202 WinReleasePS(hps);
203 }
204}
205//******************************************************************************
206//******************************************************************************
207VOID FrameTrackFrame(Win32BaseWindow *win32wnd,DWORD flags)
208{
209 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_TRACKFRAME,(MPARAM)flags,(MPARAM)0);
210}
211//******************************************************************************
212//Win32 frame message handler
213//******************************************************************************
214MRESULT EXPENTRY Win32FrameProc(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
215{
216 Win32BaseWindow *win32wnd;
217 PFNWP OldFrameProc;
218 MRESULT rc;
219 THDB *thdb;
220 MSG *pWinMsg,winMsg;
221
222 SetWin32TIB();
223
224 thdb = GetThreadTHDB();
225 win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
226
227 if (!thdb || (win32wnd == NULL) || !win32wnd->getOldFrameProc())
228 {
229 dprintf(("Invalid win32wnd pointer for frame %x!!", hwnd));
230 goto RunDefWndProc;
231 }
232
233 if((thdb->msgstate & 1) == 0)
234 {//message that was sent directly to our window proc handler; translate it here
235 QMSG qmsg;
236
237 qmsg.msg = msg;
238 qmsg.hwnd = hwnd;
239 qmsg.mp1 = mp1;
240 qmsg.mp2 = mp2;
241 qmsg.time = WinQueryMsgTime(thdb->hab);
242 WinQueryMsgPos(thdb->hab, &qmsg.ptl);
243 qmsg.reserved = 0;
244
245 if(OS2ToWinMsgTranslate((PVOID)thdb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
246 {//message was not translated
247 memset(&winMsg, 0, sizeof(MSG));
248 }
249 pWinMsg = &winMsg;
250 }
251 else {
252 pWinMsg = &thdb->msg;
253 thdb->msgstate++;
254 }
255
256 OldFrameProc = (PFNWP)win32wnd->getOldFrameProc();
257
258 switch(msg)
259 {
260 case WM_FORMATFRAME:
261 {
262 PSWP pswp = (PSWP)mp1,swpClient;
263 RECTL *client = (PRECTL)mp2,rect;
264 RECT winRect;
265 INT ccount;
266
267 if (!win32wnd->IsWindowCreated()) goto RunDefFrameProc;
268 dprintf(("PMFRAME: WM_FORMATFRAME %x",hwnd));
269 RestoreOS2TIB();
270 ccount = (INT)OldFrameProc(hwnd,msg,mp1,mp2);
271 SetWin32TIB();
272 dprintf(("Frame size: %d %d",win32wnd->getWindowWidth(),win32wnd->getWindowHeight()));
273 win32wnd->MsgFormatFrame();
274 //CB: todo: use result for WM_CALCVALIDRECTS
275 mapWin32ToOS2Rect(WinQueryWindow(hwnd,QW_PARENT),win32wnd->getClientRectPtr(),(PRECTLOS2)&rect);
276 WinMapWindowPoints(WinQueryWindow(hwnd,QW_PARENT),hwnd,(PPOINTL)&rect,2);
277 dprintf(("New client position: %d %d %d %d",rect.xLeft,rect.yBottom,rect.xRight,rect.yTop));
278 swpClient = &pswp[ccount-1];
279 swpClient->x = rect.xLeft;
280 swpClient->y = rect.yBottom;
281 swpClient->cx = rect.xRight-rect.xLeft;
282 swpClient->cy = rect.yTop-rect.yBottom;
283 RestoreOS2TIB();
284 return (MRESULT)ccount;
285 }
286
287 case WM_MINMAXFRAME:
288 dprintf(("PMFRAME: WM_MINMAXFRAME %x",hwnd));
289 //CB: todo
290 goto RunDefFrameProc;
291
292 case WM_QUERYBORDERSIZE:
293 goto RunDefFrameProc;
294
295 case WM_BUTTON1DOWN:
296 case WM_BUTTON1UP:
297 case WM_BUTTON1DBLCLK:
298 case WM_BUTTON2DOWN:
299 case WM_BUTTON2UP:
300 case WM_BUTTON2DBLCLK:
301 case WM_BUTTON3DOWN:
302 case WM_BUTTON3UP:
303 case WM_BUTTON3DBLCLK:
304 {
305 SWP swp;
306
307 WinQueryWindowPos(hwnd,&swp);
308 if ((swp.fl & SWP_MINIMIZE) == SWP_MINIMIZE)
309 goto RunDefFrameProc;
310 if (win32wnd->IsWindowCreated())
311 {
312 win32wnd->MsgButton(pWinMsg);
313 RestoreOS2TIB();
314 }
315 return (MRESULT)TRUE;
316 }
317
318 case WM_BUTTON2MOTIONSTART:
319 case WM_BUTTON2MOTIONEND:
320 case WM_BUTTON2CLICK:
321 case WM_BUTTON1MOTIONSTART:
322 case WM_BUTTON1MOTIONEND:
323 case WM_BUTTON1CLICK:
324 case WM_BUTTON3MOTIONSTART:
325 case WM_BUTTON3MOTIONEND:
326 case WM_BUTTON3CLICK:
327 RestoreOS2TIB();
328 return (MRESULT)TRUE;
329
330 case WM_MOUSEMOVE:
331 {
332 SWP swp;
333
334 WinQueryWindowPos(hwnd,&swp);
335 if ((swp.fl & SWP_MINIMIZE) == SWP_MINIMIZE)
336 goto RunDefFrameProc;
337 //OS/2 Window coordinates -> Win32 Window coordinates
338 if (win32wnd->IsWindowCreated())
339 win32wnd->MsgMouseMove(pWinMsg);
340 RestoreOS2TIB();
341 return (MRESULT)TRUE;
342 }
343
344 case WM_HITTEST:
345 {
346 DWORD res;
347 SWP swp;
348
349 WinQueryWindowPos(hwnd,&swp);
350 if ((swp.fl & SWP_MINIMIZE) == SWP_MINIMIZE)
351 goto RunDefFrameProc;
352
353 // Only send this message if the window is enabled
354 if (!win32wnd->IsWindowCreated())
355 res = HT_NORMAL;
356 else if (!WinIsWindowEnabled(hwnd))
357 res = HT_ERROR;
358 else if (win32wnd->getIgnoreHitTest())
359 res = HT_NORMAL;
360 else
361 {
362 dprintf(("PMFRAME: WM_HITTEST %x (%d,%d)",hwnd,(*(POINTS *)&mp1).x,(*(POINTS *)&mp1).y));
363
364 //CB: WinWindowFromPoint: PM sends WM_HITTEST -> loop -> stack overflow
365 win32wnd->setIgnoreHitTest(TRUE);
366 res = win32wnd->MsgHitTest(pWinMsg);
367 win32wnd->setIgnoreHitTest(FALSE);
368 }
369 RestoreOS2TIB();
370 return (MRESULT)res;
371 }
372
373 case WM_PAINT:
374 {
375 SWP swp;
376
377 WinQueryWindowPos(hwnd,&swp);
378 if ((swp.fl & SWP_MINIMIZE) == SWP_MINIMIZE)
379 goto RunDefFrameProc;
380 dprintf(("PMFRAME: WM_PAINT"));
381 if (win32wnd->IsWindowCreated())
382 win32wnd->MsgNCPaint();
383 goto RunDefWndProc;
384 }
385
386 case WM_SIZE:
387 dprintf(("PMFRAME: WM_SIZE"));
388 goto RunDefFrameProc;
389
390 case WM_ADJUSTWINDOWPOS:
391 {
392 PSWP pswp = (PSWP)mp1;
393 SWP swpOld;
394 WINDOWPOS wp;
395 HWND hParent = NULLHANDLE, hwndAfter;
396
397 dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
398
399 //CB: show dialog in front of owner
400 if (win32wnd->IsModalDialogOwner())
401 {
402 pswp->fl |= SWP_ZORDER;
403 pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
404 if (pswp->fl & SWP_ACTIVATE)
405 {
406 pswp->fl &= ~SWP_ACTIVATE;
407 WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
408 }
409 }
410
411 if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
412 goto RunDefFrameProc;
413
414 if(!win32wnd->CanReceiveSizeMsgs())
415 break;
416
417 WinQueryWindowPos(hwnd, &swpOld);
418
419 if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
420 if (win32wnd->isChild()) {
421 if(win32wnd->getParent()) {
422 hParent = win32wnd->getParent()->getOS2WindowHandle();
423 }
424 else goto RunDefFrameProc;
425 }
426 }
427 hwndAfter = pswp->hwndInsertBehind;
428 OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
429
430 wp.hwnd = win32wnd->getWindowHandle();
431 if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
432 {
433 Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
434 if(wndAfter) wp.hwndInsertAfter = wndAfter->getWindowHandle();
435 }
436
437 //CB: problems with profmine titlebar tracking
438 if(win32wnd->MsgPosChanging((LPARAM)&wp) == 0)
439 {//app or default window handler changed wp
440 dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
441 dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
442
443 OSLibMapWINDOWPOStoSWPFrame(&wp, pswp, &swpOld, hParent, hwnd);
444 dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
445 pswp->fl |= SWP_NOADJUST;
446 pswp->hwndInsertBehind = hwndAfter;
447 pswp->hwnd = hwnd;
448
449 RestoreOS2TIB();
450 return (MRESULT)0xf;
451 }
452 goto RunDefFrameProc;
453 }
454
455 case WM_WINDOWPOSCHANGED:
456 {
457 PSWP pswp = (PSWP)mp1;
458 SWP swpOld = *(pswp + 1);
459 WINDOWPOS wp;
460 HWND hParent = NULLHANDLE;
461
462 dprintf(("PMFRAME: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
463
464 if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
465 goto PosChangedEnd;
466
467 if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
468 if (win32wnd->isChild()) {
469 if(win32wnd->getParent()) {
470 hParent = win32wnd->getParent()->getOS2WindowHandle();
471 }
472 else goto PosChangedEnd; //parent has just been destroyed
473 }
474 }
475 OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
476
477 win32wnd->setWindowRect(wp.x, wp.y, wp.x+wp.cx, wp.y+wp.cy);
478
479 if(win32wnd->CanReceiveSizeMsgs())
480 win32wnd->MsgPosChanged((LPARAM)&wp);
481
482PosChangedEnd:
483 //calls WM_FORMATFRAME if SWP_SIZE is set
484 RestoreOS2TIB();
485 rc = OldFrameProc(hwnd,msg,mp1,mp2);
486 SetWin32TIB();
487
488 RestoreOS2TIB();
489 return rc;
490 }
491
492 case WM_CALCVALIDRECTS:
493 {
494 PRECTL oldRect = (PRECTL)mp1,newRect = oldRect+1;
495 UINT res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
496
497//CB: todo: use WM_NCCALCSIZE result
498 if (win32wnd->getWindowClass())
499 {
500 DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
501
502 if ((dwStyle & CS_HREDRAW_W) && (newRect->xRight-newRect->xLeft != oldRect->xRight-oldRect->xLeft))
503 res |= CVR_REDRAW;
504 else if ((dwStyle & CS_VREDRAW_W) && (newRect->yTop-newRect->yBottom != oldRect->yTop-oldRect->yBottom))
505 res |= CVR_REDRAW;
506 } else res |= CVR_REDRAW;
507
508 //CB: PM sets client window position
509 RestoreOS2TIB();
510 OldFrameProc(hwnd,msg,mp1,mp2);
511 SetWin32TIB();
512
513 RestoreOS2TIB();
514 return (MRESULT)res;
515 }
516
517 case WM_ACTIVATE:
518 {
519 HWND hwndTitle;
520 USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
521
522 if (win32wnd->IsWindowCreated())
523 {
524 WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),WM_ACTIVATE,mp1,mp2);
525 WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
526
527 //CB: show owner behind the dialog
528 if (win32wnd->IsModalDialog())
529 {
530 Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
531
532 if (topOwner) WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
533 }
534 } else
535 {
536 WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
537 }
538
539 RestoreOS2TIB();
540 return 0;
541 }
542
543 case WM_DESTROY:
544 dprintf(("PMFRAME: WM_DESTROY %x",hwnd));
545 WinSubclassWindow(hwnd,OldFrameProc);
546 win32wnd->setOldFrameProc(NULL);
547 goto RunDefFrameProc;
548
549 default:
550 RestoreOS2TIB();
551 return OldFrameProc(hwnd,msg,mp1,mp2);
552 }
553
554 RestoreOS2TIB();
555 return (MRESULT)FALSE;
556
557RunDefFrameProc:
558 RestoreOS2TIB();
559 return OldFrameProc(hwnd,msg,mp1,mp2);
560
561RunDefWndProc:
562 RestoreOS2TIB();
563 return WinDefWindowProc(hwnd,msg,mp1,mp2);
564}
565
566PVOID FrameSubclassFrameWindow(Win32BaseWindow *win32wnd)
567{
568 return WinSubclassWindow(win32wnd->getOS2FrameWindowHandle(),PFNWP(Win32FrameProc));
569}
570
571VOID FrameGetBorderSize(Win32BaseWindow *win32wnd,PWPOINT pSize)
572{
573 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_QUERYBORDERSIZE,(MPARAM)pSize,(MPARAM)0);
574}
575
576VOID FrameSetBorderSize(Win32BaseWindow *win32wnd,BOOL resize)
577{
578 POINTL point;
579
580 if (!resize)
581 {
582 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight());
583
584 return;
585 }
586
587 FrameGetBorderSize(win32wnd,&point);
588 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight());
589 if ((point.x != win32wnd->getBorderWidth()) || (point.y != win32wnd->getBorderHeight()))
590 {
591 INT xDiff = win32wnd->getBorderWidth()-point.x;
592 INT yDiff = win32wnd->getBorderHeight()-point.y;
593 SWP swp;
594
595 WinQueryWindowPos(win32wnd->getOS2FrameWindowHandle(),&swp);
596 swp.x += xDiff;
597 swp.y += yDiff;
598 swp.cx -= 2*xDiff;
599 swp.cy -= 2*yDiff;
600 WinSetWindowPos(win32wnd->getOS2FrameWindowHandle(),0,swp.x,swp.y,swp.cx,swp.cy,SWP_MOVE | SWP_SIZE);
601 }
602}
603
604UINT FrameGetDefSizeBorderSize(VOID)
605{
606 return WinQuerySysValue(HWND_DESKTOP,SV_CXSIZEBORDER);
607}
608
609BOOL FrameCreateScrollBars(Win32BaseWindow *win32wnd,BOOL createHorz,BOOL createVert,BOOL updateFrame,DWORD *flags)
610{
611 HWND hwndHScroll = 0,hwndVScroll = 0;
612 ULONG updateFlags = 0;
613
614 if (createHorz)
615 {
616 hwndHScroll = WinCreateWindow(win32wnd->getOS2FrameWindowHandle(),WC_SCROLLBAR,"",WS_VISIBLE | WS_PARENTCLIP | WS_SYNCPAINT | SBS_HORZ,0,0,0,0,win32wnd->getOS2FrameWindowHandle(),HWND_TOP,FID_HORZSCROLL,NULL,NULL);
617 if (hwndHScroll) win32wnd->setHorzScrollHandle(hwndHScroll);
618 else return FALSE;
619 updateFlags = FCF_HORZSCROLL;
620 }
621
622 if (createVert)
623 {
624 hwndVScroll = WinCreateWindow(win32wnd->getOS2FrameWindowHandle(),WC_SCROLLBAR,"",WS_VISIBLE | WS_PARENTCLIP | WS_SYNCPAINT | SBS_VERT,0,0,0,0,win32wnd->getOS2FrameWindowHandle(),HWND_TOP,FID_VERTSCROLL,NULL,NULL);
625 if (hwndVScroll) win32wnd->setVertScrollHandle(hwndVScroll); else
626 {
627 if (hwndHScroll) WinDestroyWindow(hwndHScroll);
628
629 return FALSE;
630 }
631 updateFlags |= FCF_VERTSCROLL;
632 }
633
634 win32wnd->subclassScrollBars(hwndHScroll,hwndVScroll);
635
636 if (updateFrame && updateFlags) WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)0,(MPARAM)0);
637 if (flags) *flags = updateFlags;
638
639 return TRUE;
640}
641
642VOID FrameGetScrollBarHandles(Win32BaseWindow *win32wnd,BOOL getHorz,BOOL getVert)
643{
644 if (getHorz) win32wnd->setHorzScrollHandle(WinWindowFromID(win32wnd->getOS2FrameWindowHandle(),FID_HORZSCROLL));
645 if (getVert) win32wnd->setVertScrollHandle(WinWindowFromID(win32wnd->getOS2FrameWindowHandle(),FID_VERTSCROLL));
646}
647
648BOOL FrameShowScrollBars(Win32BaseWindow *win32wnd,BOOL changeHorz,BOOL changeVert,BOOL fShow,BOOL updateFrame,DWORD *flags)
649{
650 HWND hwndObj = WinQueryObjectWindow(HWND_DESKTOP);
651 ULONG updateFlags = 0;
652
653 if (changeHorz)
654 {
655 HWND hwndCurPar = WinQueryWindow(win32wnd->getHorzScrollHandle(),QW_PARENT);
656
657 if ((fShow && (hwndCurPar == hwndObj)) || (!fShow && (hwndCurPar != hwndObj)))
658 {
659 WinSetParent(win32wnd->getHorzScrollHandle(),fShow ? win32wnd->getOS2FrameWindowHandle():HWND_OBJECT,FALSE);
660 updateFlags |= FCF_HORZSCROLL;
661 }
662 }
663
664 if (changeVert)
665 {
666 HWND hwndCurPar = WinQueryWindow(win32wnd->getVertScrollHandle(),QW_PARENT);
667
668 if ((fShow && (hwndCurPar == hwndObj)) || (!fShow && (hwndCurPar != hwndObj)))
669 {
670 WinSetParent(win32wnd->getVertScrollHandle(),fShow ? win32wnd->getOS2FrameWindowHandle():HWND_OBJECT,FALSE);
671 updateFlags |= FCF_VERTSCROLL;
672 }
673 }
674
675 if (updateFrame && updateFlags) WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)updateFlags,(MPARAM)0);
676 if (flags) *flags = updateFlags;
677
678 return TRUE;
679}
680
681VOID FrameUpdateFrame(Win32BaseWindow *win32wnd,DWORD flags)
682{
683 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)flags,(MPARAM)0);
684}
685
686DWORD FrameHitTest(Win32BaseWindow *win32wnd,INT x,INT y)
687{
688 POINTL point;
689 HWND hwnd = win32wnd->getOS2FrameWindowHandle(),child;
690
691 if (hwnd == win32wnd->getOS2WindowHandle()) return HTCLIENT_W;
692 if (win32wnd->getOS2WindowHandle() == WinQueryCapture(HWND_DESKTOP)) return HTCLIENT_W;
693 point.x = x;
694 point.y = mapScreenY(y);
695 WinMapWindowPoints(HWND_DESKTOP,hwnd,&point,1);
696 child = WinWindowFromPoint(hwnd,&point,FALSE);
697
698 if (child == 0) return HTERROR_W;
699 if (child == win32wnd->getOS2FrameWindowHandle())
700 {
701 RECTL client,frame;
702
703 if (CanDrawSizeBox(win32wnd))
704 {
705 RECTL rect;
706
707 GetSizeBox(win32wnd,&rect);
708 if (WinPtInRect(GetThreadHAB(),&rect,&point)) return HTGROWBOX_W;
709 }
710 //somewhere in the border
711 INT w = WinQuerySysValue(HWND_DESKTOP,SV_CXMINMAXBUTTON);
712 INT h = WinQuerySysValue(HWND_DESKTOP,SV_CXMINMAXBUTTON);
713 WinQueryWindowRect(hwnd,&frame);
714
715 if (point.y < h)
716 {
717 if (point.x < w) return HTBOTTOMLEFT_W;
718 if (point.x > frame.xRight-1-w) return HTBOTTOMRIGHT_W;
719 return HTBOTTOM_W;
720 }
721 if (point.y > frame.yTop-1-h)
722 {
723 if (point.x < w) return HTTOPLEFT_W;
724 if (point.x > frame.xRight-1-w) return HTTOPRIGHT_W;
725 return HTTOP_W;
726 }
727 return HTBORDER_W;
728 } else
729 {
730 if (child == WinWindowFromID(hwnd,FID_CLIENT)) return HTCLIENT_W;
731 if (child == WinWindowFromID(hwnd,FID_VERTSCROLL)) return HTVSCROLL_W;
732 if (child == WinWindowFromID(hwnd,FID_HORZSCROLL)) return HTHSCROLL_W;
733 if (child == WinWindowFromID(hwnd,FID_SYSMENU)) return HTSYSMENU_W;
734 if (child == WinWindowFromID(hwnd,FID_TITLEBAR)) return HTCAPTION_W;
735 if (child == WinWindowFromID(hwnd,FID_MENU)) return HTMENU_W;
736 if (child == WinWindowFromID(hwnd,FID_MINMAX))
737 {
738 //CB: close, reduce or zoom
739 return HTZOOM_W;
740 }
741
742 return HTERROR_W;
743 }
744}
Note: See TracBrowser for help on using the repository browser.