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

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

* empty log message *

File size: 22.7 KB
Line 
1/* $Id: pmframe.cpp,v 1.7 2000-01-07 17:38:47 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 //update the client rect
484 RECTL rectl;
485
486 WinQueryWindowRect(win32wnd->getOS2WindowHandle(),&rectl);
487 mapOS2ToWin32Rect(win32wnd->getOS2WindowHandle(),WinQueryWindow(hwnd,QW_PARENT),(PRECTLOS2)&rectl,win32wnd->getClientRectPtr());
488
489 //calls WM_FORMATFRAME if SWP_SIZE is set
490 RestoreOS2TIB();
491 rc = OldFrameProc(hwnd,msg,mp1,mp2);
492 return rc;
493 }
494
495 case WM_CALCVALIDRECTS:
496 {
497 PRECTL oldRect = (PRECTL)mp1,newRect = oldRect+1;
498 UINT res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
499
500//CB: todo: use WM_NCCALCSIZE result
501 if (win32wnd->getWindowClass())
502 {
503 DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
504
505 if ((dwStyle & CS_HREDRAW_W) && (newRect->xRight-newRect->xLeft != oldRect->xRight-oldRect->xLeft))
506 res |= CVR_REDRAW;
507 else if ((dwStyle & CS_VREDRAW_W) && (newRect->yTop-newRect->yBottom != oldRect->yTop-oldRect->yBottom))
508 res |= CVR_REDRAW;
509 } else res |= CVR_REDRAW;
510
511 //CB: PM sets client window position
512 RestoreOS2TIB();
513 OldFrameProc(hwnd,msg,mp1,mp2);
514 SetWin32TIB();
515
516 RestoreOS2TIB();
517 return (MRESULT)res;
518 }
519
520 case WM_ACTIVATE:
521 {
522 HWND hwndTitle;
523 USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
524
525 if (win32wnd->IsWindowCreated())
526 {
527 WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),WM_ACTIVATE,mp1,mp2);
528 WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
529
530 //CB: show owner behind the dialog
531 if (win32wnd->IsModalDialog())
532 {
533 Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
534
535 if (topOwner) WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
536 }
537 } else
538 {
539 WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
540 }
541
542 RestoreOS2TIB();
543 return 0;
544 }
545
546 case WM_DESTROY:
547 dprintf(("PMFRAME: WM_DESTROY %x",hwnd));
548 WinSubclassWindow(hwnd,OldFrameProc);
549 win32wnd->setOldFrameProc(NULL);
550 goto RunDefFrameProc;
551
552 default:
553 RestoreOS2TIB();
554 return OldFrameProc(hwnd,msg,mp1,mp2);
555 }
556
557 RestoreOS2TIB();
558 return (MRESULT)FALSE;
559
560RunDefFrameProc:
561 RestoreOS2TIB();
562 return OldFrameProc(hwnd,msg,mp1,mp2);
563
564RunDefWndProc:
565 RestoreOS2TIB();
566 return WinDefWindowProc(hwnd,msg,mp1,mp2);
567}
568
569PVOID FrameSubclassFrameWindow(Win32BaseWindow *win32wnd)
570{
571 return WinSubclassWindow(win32wnd->getOS2FrameWindowHandle(),PFNWP(Win32FrameProc));
572}
573
574VOID FrameGetBorderSize(Win32BaseWindow *win32wnd,PWPOINT pSize)
575{
576 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_QUERYBORDERSIZE,(MPARAM)pSize,(MPARAM)0);
577}
578
579VOID FrameSetBorderSize(Win32BaseWindow *win32wnd,BOOL resize)
580{
581 POINTL point;
582
583 if (!resize)
584 {
585 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight());
586
587 return;
588 }
589
590 FrameGetBorderSize(win32wnd,&point);
591 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight());
592 if ((point.x != win32wnd->getBorderWidth()) || (point.y != win32wnd->getBorderHeight()))
593 {
594 INT xDiff = win32wnd->getBorderWidth()-point.x;
595 INT yDiff = win32wnd->getBorderHeight()-point.y;
596 SWP swp;
597
598 WinQueryWindowPos(win32wnd->getOS2FrameWindowHandle(),&swp);
599 swp.x += xDiff;
600 swp.y += yDiff;
601 swp.cx -= 2*xDiff;
602 swp.cy -= 2*yDiff;
603 WinSetWindowPos(win32wnd->getOS2FrameWindowHandle(),0,swp.x,swp.y,swp.cx,swp.cy,SWP_MOVE | SWP_SIZE);
604 }
605}
606
607UINT FrameGetDefSizeBorderSize(VOID)
608{
609 return WinQuerySysValue(HWND_DESKTOP,SV_CXSIZEBORDER);
610}
611
612BOOL FrameCreateScrollBars(Win32BaseWindow *win32wnd,BOOL createHorz,BOOL createVert,BOOL updateFrame,DWORD *flags)
613{
614 HWND hwndHScroll = 0,hwndVScroll = 0;
615 ULONG updateFlags = 0;
616
617 if (createHorz)
618 {
619 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);
620 if (hwndHScroll) win32wnd->setHorzScrollHandle(hwndHScroll);
621 else return FALSE;
622 updateFlags = FCF_HORZSCROLL;
623 }
624
625 if (createVert)
626 {
627 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);
628 if (hwndVScroll) win32wnd->setVertScrollHandle(hwndVScroll); else
629 {
630 if (hwndHScroll) WinDestroyWindow(hwndHScroll);
631
632 return FALSE;
633 }
634 updateFlags |= FCF_VERTSCROLL;
635 }
636
637 win32wnd->subclassScrollBars(hwndHScroll,hwndVScroll);
638
639 if (updateFrame && updateFlags) WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)0,(MPARAM)0);
640 if (flags) *flags = updateFlags;
641
642 return TRUE;
643}
644
645VOID FrameGetScrollBarHandles(Win32BaseWindow *win32wnd,BOOL getHorz,BOOL getVert)
646{
647 if (getHorz) win32wnd->setHorzScrollHandle(WinWindowFromID(win32wnd->getOS2FrameWindowHandle(),FID_HORZSCROLL));
648 if (getVert) win32wnd->setVertScrollHandle(WinWindowFromID(win32wnd->getOS2FrameWindowHandle(),FID_VERTSCROLL));
649}
650
651BOOL FrameShowScrollBars(Win32BaseWindow *win32wnd,BOOL changeHorz,BOOL changeVert,BOOL fShow,BOOL updateFrame,DWORD *flags)
652{
653 HWND hwndObj = WinQueryObjectWindow(HWND_DESKTOP);
654 ULONG updateFlags = 0;
655
656 if (changeHorz)
657 {
658 HWND hwndCurPar = WinQueryWindow(win32wnd->getHorzScrollHandle(),QW_PARENT);
659
660 if ((fShow && (hwndCurPar == hwndObj)) || (!fShow && (hwndCurPar != hwndObj)))
661 {
662 WinSetParent(win32wnd->getHorzScrollHandle(),fShow ? win32wnd->getOS2FrameWindowHandle():HWND_OBJECT,FALSE);
663 updateFlags |= FCF_HORZSCROLL;
664 }
665 }
666
667 if (changeVert)
668 {
669 HWND hwndCurPar = WinQueryWindow(win32wnd->getVertScrollHandle(),QW_PARENT);
670
671 if ((fShow && (hwndCurPar == hwndObj)) || (!fShow && (hwndCurPar != hwndObj)))
672 {
673 WinSetParent(win32wnd->getVertScrollHandle(),fShow ? win32wnd->getOS2FrameWindowHandle():HWND_OBJECT,FALSE);
674 updateFlags |= FCF_VERTSCROLL;
675 }
676 }
677
678 if (updateFrame && updateFlags) WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)updateFlags,(MPARAM)0);
679 if (flags) *flags = updateFlags;
680
681 return TRUE;
682}
683
684VOID FrameUpdateFrame(Win32BaseWindow *win32wnd,DWORD flags)
685{
686 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)flags,(MPARAM)0);
687}
688
689DWORD FrameHitTest(Win32BaseWindow *win32wnd,INT x,INT y)
690{
691 POINTL point;
692 HWND hwnd = win32wnd->getOS2FrameWindowHandle(),child;
693
694 if (hwnd == win32wnd->getOS2WindowHandle()) return HTCLIENT_W;
695 if (win32wnd->getOS2WindowHandle() == WinQueryCapture(HWND_DESKTOP)) return HTCLIENT_W;
696 point.x = x;
697 point.y = mapScreenY(y);
698 WinMapWindowPoints(HWND_DESKTOP,hwnd,&point,1);
699 child = WinWindowFromPoint(hwnd,&point,FALSE);
700
701 if (child == 0) return HTERROR_W;
702 if (child == win32wnd->getOS2FrameWindowHandle())
703 {
704 RECTL client,frame;
705
706 if (CanDrawSizeBox(win32wnd))
707 {
708 RECTL rect;
709
710 GetSizeBox(win32wnd,&rect);
711 if (WinPtInRect(GetThreadHAB(),&rect,&point)) return HTGROWBOX_W;
712 }
713 //somewhere in the border
714 INT w = WinQuerySysValue(HWND_DESKTOP,SV_CXMINMAXBUTTON);
715 INT h = WinQuerySysValue(HWND_DESKTOP,SV_CXMINMAXBUTTON);
716 WinQueryWindowRect(hwnd,&frame);
717
718 if (point.y < h)
719 {
720 if (point.x < w) return HTBOTTOMLEFT_W;
721 if (point.x > frame.xRight-1-w) return HTBOTTOMRIGHT_W;
722 return HTBOTTOM_W;
723 }
724 if (point.y > frame.yTop-1-h)
725 {
726 if (point.x < w) return HTTOPLEFT_W;
727 if (point.x > frame.xRight-1-w) return HTTOPRIGHT_W;
728 return HTTOP_W;
729 }
730 return HTBORDER_W;
731 } else
732 {
733 if (child == WinWindowFromID(hwnd,FID_CLIENT)) return HTCLIENT_W;
734 if (child == WinWindowFromID(hwnd,FID_VERTSCROLL)) return HTVSCROLL_W;
735 if (child == WinWindowFromID(hwnd,FID_HORZSCROLL)) return HTHSCROLL_W;
736 if (child == WinWindowFromID(hwnd,FID_SYSMENU)) return HTSYSMENU_W;
737 if (child == WinWindowFromID(hwnd,FID_TITLEBAR)) return HTCAPTION_W;
738 if (child == WinWindowFromID(hwnd,FID_MENU)) return HTMENU_W;
739 if (child == WinWindowFromID(hwnd,FID_MINMAX))
740 {
741 //CB: close, reduce or zoom
742 return HTZOOM_W;
743 }
744
745 return HTERROR_W;
746 }
747}
Note: See TracBrowser for help on using the repository browser.