| 1 | /* $Id: pmframe.cpp,v 1.55 2000-05-24 19:30:05 sandervl 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 <os2wrap.h>
|
|---|
| 16 | #include <stdlib.h>
|
|---|
| 17 | #include <string.h>
|
|---|
| 18 | #include <win32type.h>
|
|---|
| 19 | #include <winconst.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 DBG_LOCALLOG DBG_pmframe
|
|---|
| 30 | #include "dbglocal.h"
|
|---|
| 31 |
|
|---|
| 32 | #define PMFRAMELOG
|
|---|
| 33 |
|
|---|
| 34 | //******************************************************************************
|
|---|
| 35 | //******************************************************************************
|
|---|
| 36 | VOID FrameTrackFrame(Win32BaseWindow *win32wnd,DWORD flags)
|
|---|
| 37 | {
|
|---|
| 38 | WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_TRACKFRAME,(MPARAM)flags,(MPARAM)0);
|
|---|
| 39 | }
|
|---|
| 40 | //******************************************************************************
|
|---|
| 41 | //******************************************************************************
|
|---|
| 42 | VOID FrameUpdateChildPositions(HWND hwnd)
|
|---|
| 43 | {
|
|---|
| 44 | HENUM henum;
|
|---|
| 45 | HWND hchild;
|
|---|
| 46 | RECTL rectl;
|
|---|
| 47 |
|
|---|
| 48 | henum = WinBeginEnumWindows(hwnd);
|
|---|
| 49 | while ((hchild = WinGetNextWindow(henum)) != NULLHANDLE)
|
|---|
| 50 | {
|
|---|
| 51 | Win32BaseWindow *child = Win32BaseWindow::GetWindowFromOS2FrameHandle(hchild);
|
|---|
| 52 |
|
|---|
| 53 | if (child)
|
|---|
| 54 | {
|
|---|
| 55 | WinQueryWindowRect(child->getOS2FrameWindowHandle(),&rectl);
|
|---|
| 56 | mapOS2ToWin32Rect(child->getOS2FrameWindowHandle(),OSLIB_HWND_DESKTOP,(PRECTLOS2)&rectl,child->getWindowRect());
|
|---|
| 57 | FrameUpdateChildPositions(child->getOS2WindowHandle());
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|
| 60 | WinEndEnumWindows(henum);
|
|---|
| 61 | }
|
|---|
| 62 | //******************************************************************************
|
|---|
| 63 | //Win32 frame message handler
|
|---|
| 64 | //******************************************************************************
|
|---|
| 65 | MRESULT EXPENTRY Win32FrameProc(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
|
|---|
| 66 | {
|
|---|
| 67 | Win32BaseWindow *win32wnd;
|
|---|
| 68 | PFNWP OldFrameProc;
|
|---|
| 69 | MRESULT rc;
|
|---|
| 70 | THDB *thdb;
|
|---|
| 71 | MSG *pWinMsg,winMsg;
|
|---|
| 72 |
|
|---|
| 73 | SetWin32TIB();
|
|---|
| 74 |
|
|---|
| 75 | thdb = GetThreadTHDB();
|
|---|
| 76 | win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
|
|---|
| 77 |
|
|---|
| 78 | if (!thdb || (win32wnd == NULL) || !win32wnd->getOldFrameProc())
|
|---|
| 79 | {
|
|---|
| 80 | dprintf(("Invalid win32wnd pointer for frame %x!!", hwnd));
|
|---|
| 81 | goto RunDefWndProc;
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 | if((thdb->msgstate & 1) == 0)
|
|---|
| 85 | {//message that was sent directly to our window proc handler; translate it here
|
|---|
| 86 | QMSG qmsg;
|
|---|
| 87 |
|
|---|
| 88 | qmsg.msg = msg;
|
|---|
| 89 | qmsg.hwnd = hwnd;
|
|---|
| 90 | qmsg.mp1 = mp1;
|
|---|
| 91 | qmsg.mp2 = mp2;
|
|---|
| 92 | qmsg.time = WinQueryMsgTime(thdb->hab);
|
|---|
| 93 | WinQueryMsgPos(thdb->hab, &qmsg.ptl);
|
|---|
| 94 | qmsg.reserved = 0;
|
|---|
| 95 |
|
|---|
| 96 | if(OS2ToWinMsgTranslate((PVOID)thdb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
|
|---|
| 97 | {//message was not translated
|
|---|
| 98 | memset(&winMsg, 0, sizeof(MSG));
|
|---|
| 99 | }
|
|---|
| 100 | pWinMsg = &winMsg;
|
|---|
| 101 | }
|
|---|
| 102 | else {
|
|---|
| 103 | pWinMsg = &thdb->msg;
|
|---|
| 104 | thdb->msgstate++;
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | OldFrameProc = (PFNWP)win32wnd->getOldFrameProc();
|
|---|
| 108 |
|
|---|
| 109 | switch(msg)
|
|---|
| 110 | {
|
|---|
| 111 | case WM_FORMATFRAME:
|
|---|
| 112 | break;
|
|---|
| 113 |
|
|---|
| 114 | case WM_MINMAXFRAME:
|
|---|
| 115 | {
|
|---|
| 116 | PSWP swp = (PSWP)mp1;
|
|---|
| 117 |
|
|---|
| 118 | if (!win32wnd->IsWindowCreated()) goto RunDefFrameProc;
|
|---|
| 119 | dprintf(("PMFRAME: WM_MINMAXFRAME %x",hwnd));
|
|---|
| 120 | if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
|
|---|
| 121 | {
|
|---|
| 122 | win32wnd->setStyle((win32wnd->getStyle() & ~WS_MINIMIZE_W) | WS_MAXIMIZE_W);
|
|---|
| 123 |
|
|---|
| 124 | RECT rect;
|
|---|
| 125 |
|
|---|
| 126 | rect.left = rect.top = rect.right = rect.bottom = 0;
|
|---|
| 127 | win32wnd->AdjustMaximizedRect(&rect);
|
|---|
| 128 | swp->x += rect.left;
|
|---|
| 129 | swp->cx += rect.right-rect.left;
|
|---|
| 130 | swp->y -= rect.bottom;
|
|---|
| 131 | swp->cy += rect.bottom-rect.top;
|
|---|
| 132 | }
|
|---|
| 133 | else if ((swp->fl & SWP_MINIMIZE) == SWP_MINIMIZE)
|
|---|
| 134 | {
|
|---|
| 135 | win32wnd->setStyle((win32wnd->getStyle() & ~WS_MAXIMIZE_W) | WS_MINIMIZE_W);
|
|---|
| 136 | }
|
|---|
| 137 | else if ((swp->fl & SWP_RESTORE) == SWP_RESTORE)
|
|---|
| 138 | {
|
|---|
| 139 | win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MINIMIZE_W | WS_MAXIMIZE_W));
|
|---|
| 140 | }
|
|---|
| 141 | goto RunDefFrameProc;
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | case WM_QUERYTRACKINFO:
|
|---|
| 145 | {
|
|---|
| 146 | PTRACKINFO trackInfo = (PTRACKINFO)mp2;
|
|---|
| 147 |
|
|---|
| 148 | RestoreOS2TIB();
|
|---|
| 149 | OldFrameProc(hwnd,msg,mp1,mp2);
|
|---|
| 150 | SetWin32TIB();
|
|---|
| 151 | trackInfo->cxBorder = 4;
|
|---|
| 152 | trackInfo->cyBorder = 4;
|
|---|
| 153 | win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
|
|---|
| 154 | RestoreOS2TIB();
|
|---|
| 155 | return (MRESULT)TRUE;
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | case WM_QUERYBORDERSIZE:
|
|---|
| 159 | {
|
|---|
| 160 | PWPOINT size = (PWPOINT)mp1;
|
|---|
| 161 |
|
|---|
| 162 | size->x = 0;
|
|---|
| 163 | size->y = 0;
|
|---|
| 164 | RestoreOS2TIB();
|
|---|
| 165 | return (MRESULT)TRUE;
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | case WM_HITTEST:
|
|---|
| 169 | {
|
|---|
| 170 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 171 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 172 | }
|
|---|
| 173 | if(win32wnd && win32wnd->IsWindowCreated())
|
|---|
| 174 | {
|
|---|
| 175 | MRESULT rc;
|
|---|
| 176 |
|
|---|
| 177 | rc = (MRESULT)win32wnd->MsgHitTest(pWinMsg);
|
|---|
| 178 | RestoreOS2TIB();
|
|---|
| 179 | return rc;
|
|---|
| 180 | }
|
|---|
| 181 | return (MRESULT)HT_NORMAL;
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | case WM_BUTTON1DOWN:
|
|---|
| 185 | case WM_BUTTON1UP:
|
|---|
| 186 | case WM_BUTTON1DBLCLK:
|
|---|
| 187 | case WM_BUTTON2DOWN:
|
|---|
| 188 | case WM_BUTTON2UP:
|
|---|
| 189 | case WM_BUTTON2DBLCLK:
|
|---|
| 190 | case WM_BUTTON3DOWN:
|
|---|
| 191 | case WM_BUTTON3UP:
|
|---|
| 192 | case WM_BUTTON3DBLCLK:
|
|---|
| 193 | {
|
|---|
| 194 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 195 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 196 | }
|
|---|
| 197 | if(win32wnd && win32wnd->IsWindowCreated())
|
|---|
| 198 | {
|
|---|
| 199 | win32wnd->MsgButton(pWinMsg);
|
|---|
| 200 | RestoreOS2TIB();
|
|---|
| 201 | }
|
|---|
| 202 | return (MRESULT)TRUE;
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 | case WM_BUTTON2MOTIONSTART:
|
|---|
| 206 | case WM_BUTTON2MOTIONEND:
|
|---|
| 207 | case WM_BUTTON2CLICK:
|
|---|
| 208 | case WM_BUTTON1MOTIONSTART:
|
|---|
| 209 | case WM_BUTTON1MOTIONEND:
|
|---|
| 210 | case WM_BUTTON1CLICK:
|
|---|
| 211 | case WM_BUTTON3MOTIONSTART:
|
|---|
| 212 | case WM_BUTTON3MOTIONEND:
|
|---|
| 213 | case WM_BUTTON3CLICK:
|
|---|
| 214 | RestoreOS2TIB();
|
|---|
| 215 | return (MRESULT)TRUE;
|
|---|
| 216 |
|
|---|
| 217 | case WM_MOUSEMOVE:
|
|---|
| 218 | {
|
|---|
| 219 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 220 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 221 | }
|
|---|
| 222 | if(win32wnd && win32wnd->IsWindowCreated())
|
|---|
| 223 | win32wnd->MsgMouseMove(pWinMsg);
|
|---|
| 224 | RestoreOS2TIB();
|
|---|
| 225 | return (MRESULT)TRUE;
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | case WM_PAINT:
|
|---|
| 229 | {
|
|---|
| 230 | dprintf(("PMFRAME: WM_PAINT"));
|
|---|
| 231 | if(win32wnd->getStyle() & WS_MINIMIZE_W)
|
|---|
| 232 | goto RunDefFrameProc;
|
|---|
| 233 | if(win32wnd->IsWindowCreated())
|
|---|
| 234 | win32wnd->MsgNCPaint();
|
|---|
| 235 |
|
|---|
| 236 | goto RunDefWndProc;
|
|---|
| 237 | }
|
|---|
| 238 |
|
|---|
| 239 | case WM_SIZE:
|
|---|
| 240 | dprintf(("PMFRAME: WM_SIZE"));
|
|---|
| 241 | goto RunDefFrameProc;
|
|---|
| 242 |
|
|---|
| 243 | case WM_ADJUSTWINDOWPOS:
|
|---|
| 244 | {
|
|---|
| 245 | PSWP pswp = (PSWP)mp1;
|
|---|
| 246 | SWP swpOld;
|
|---|
| 247 | WINDOWPOS wp,wpOld;
|
|---|
| 248 | HWND hParent = NULLHANDLE, hwndAfter;
|
|---|
| 249 |
|
|---|
| 250 | 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));
|
|---|
| 251 |
|
|---|
| 252 | //CB: show dialog in front of owner
|
|---|
| 253 | if (win32wnd->IsModalDialogOwner())
|
|---|
| 254 | {
|
|---|
| 255 | pswp->fl |= SWP_ZORDER;
|
|---|
| 256 | pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
|
|---|
| 257 | if (pswp->fl & SWP_ACTIVATE)
|
|---|
| 258 | {
|
|---|
| 259 | pswp->fl &= ~SWP_ACTIVATE;
|
|---|
| 260 | WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
|
|---|
| 261 | }
|
|---|
| 262 | }
|
|---|
| 263 |
|
|---|
| 264 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
|---|
| 265 | goto RunDefFrameProc;
|
|---|
| 266 |
|
|---|
| 267 | if(!win32wnd->CanReceiveSizeMsgs())
|
|---|
| 268 | break;
|
|---|
| 269 |
|
|---|
| 270 | WinQueryWindowPos(hwnd, &swpOld);
|
|---|
| 271 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
|---|
| 272 | if (win32wnd->isChild()) {
|
|---|
| 273 | if(win32wnd->getParent()) {
|
|---|
| 274 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 275 | }
|
|---|
| 276 | else goto RunDefFrameProc;
|
|---|
| 277 | }
|
|---|
| 278 | }
|
|---|
| 279 | hwndAfter = pswp->hwndInsertBehind;
|
|---|
| 280 | OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
|
|---|
| 281 |
|
|---|
| 282 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 283 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 284 | {
|
|---|
| 285 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 286 | if(wndAfter) wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 287 | }
|
|---|
| 288 |
|
|---|
| 289 | wpOld = wp;
|
|---|
| 290 | win32wnd->MsgPosChanging((LPARAM)&wp);
|
|---|
| 291 |
|
|---|
| 292 | if ((wp.hwndInsertAfter != wpOld.hwndInsertAfter) ||
|
|---|
| 293 | (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
|
|---|
| 294 | {
|
|---|
| 295 | dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
|
|---|
| 296 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 297 |
|
|---|
| 298 | OSLibMapWINDOWPOStoSWPFrame(&wp, pswp, &swpOld, hParent, hwnd);
|
|---|
| 299 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 300 | pswp->fl |= SWP_NOADJUST;
|
|---|
| 301 | pswp->hwndInsertBehind = hwndAfter;
|
|---|
| 302 | pswp->hwnd = hwnd;
|
|---|
| 303 |
|
|---|
| 304 | RestoreOS2TIB();
|
|---|
| 305 | return (MRESULT)0xf;
|
|---|
| 306 | }
|
|---|
| 307 | RestoreOS2TIB();
|
|---|
| 308 | return (MRESULT)0;
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | case WM_WINDOWPOSCHANGED:
|
|---|
| 312 | {
|
|---|
| 313 | PSWP pswp = (PSWP)mp1,pswpOld = pswp+1;
|
|---|
| 314 | SWP swpOld = *(pswp + 1);
|
|---|
| 315 | WINDOWPOS wp;
|
|---|
| 316 | HWND hParent = NULLHANDLE;
|
|---|
| 317 | RECTL rect;
|
|---|
| 318 | SWP swpClient = {0};
|
|---|
| 319 |
|
|---|
| 320 | dprintf(("PMFRAME: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 321 |
|
|---|
| 322 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
|---|
| 323 | {
|
|---|
| 324 | goto RunDefFrameProc;
|
|---|
| 325 | }
|
|---|
| 326 |
|
|---|
| 327 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
|---|
| 328 | if (win32wnd->isChild()) {
|
|---|
| 329 | if(win32wnd->getParent()) {
|
|---|
| 330 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 331 | }
|
|---|
| 332 | else goto PosChangedEnd; //parent has just been destroyed
|
|---|
| 333 | }
|
|---|
| 334 | }
|
|---|
| 335 |
|
|---|
| 336 | OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
|
|---|
| 337 |
|
|---|
| 338 | if(pswp->fl & SWP_ACTIVATE)
|
|---|
| 339 | {
|
|---|
| 340 | WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
|
|---|
| 341 | }
|
|---|
| 342 |
|
|---|
| 343 | if((pswp->fl & (SWP_MOVE | SWP_SIZE)) && !(win32wnd->getStyle() & WS_MINIMIZE_W))
|
|---|
| 344 | {
|
|---|
| 345 | //Note: Also updates the new window rectangle
|
|---|
| 346 | win32wnd->MsgFormatFrame(&wp);
|
|---|
| 347 |
|
|---|
| 348 | //CB: todo: use result for WM_CALCVALIDRECTS
|
|---|
| 349 | mapWin32ToOS2Rect(win32wnd->getOS2FrameWindowHandle(), win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
|
|---|
| 350 |
|
|---|
| 351 | swpClient.hwnd = win32wnd->getOS2WindowHandle();
|
|---|
| 352 | swpClient.hwndInsertBehind = 0;
|
|---|
| 353 | swpClient.x = rect.xLeft;
|
|---|
| 354 | swpClient.y = rect.yBottom;
|
|---|
| 355 | swpClient.cx = rect.xRight-rect.xLeft;
|
|---|
| 356 | swpClient.cy = rect.yTop-rect.yBottom;
|
|---|
| 357 | //TODO: Get rid of SWP_SHOW; needed for winhlp32 button bar for now
|
|---|
| 358 | swpClient.fl = (pswp->fl & ~SWP_ZORDER) | SWP_MOVE | SWP_SHOW;
|
|---|
| 359 | WinSetMultWindowPos(thdb->hab, &swpClient, 1);
|
|---|
| 360 |
|
|---|
| 361 | //update child positions: rectWindow is in window coordinates
|
|---|
| 362 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
|---|
| 363 | FrameUpdateChildPositions(win32wnd->getOS2WindowHandle());
|
|---|
| 364 | }
|
|---|
| 365 |
|
|---|
| 366 | if(win32wnd->CanReceiveSizeMsgs())
|
|---|
| 367 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 368 |
|
|---|
| 369 | if ((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
|
|---|
| 370 | {
|
|---|
| 371 | //redraw the frame (to prevent unnecessary client updates)
|
|---|
| 372 | BOOL redrawAll = FALSE;
|
|---|
| 373 |
|
|---|
| 374 | if (win32wnd->getWindowClass())
|
|---|
| 375 | {
|
|---|
| 376 | DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
|
|---|
| 377 |
|
|---|
| 378 | if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
|
|---|
| 379 | redrawAll = TRUE;
|
|---|
| 380 | else if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
|
|---|
| 381 | redrawAll = TRUE;
|
|---|
| 382 | } else redrawAll = TRUE;
|
|---|
| 383 |
|
|---|
| 384 | if (redrawAll)
|
|---|
| 385 | {
|
|---|
| 386 | //CB: redraw all children for now
|
|---|
| 387 | // -> problems with update region if we don't do it
|
|---|
| 388 | // todo: rewrite whole handling
|
|---|
| 389 | WinInvalidateRect(hwnd,NULL,TRUE);
|
|---|
| 390 | }
|
|---|
| 391 | else
|
|---|
| 392 | {
|
|---|
| 393 | HPS hps = WinGetPS(hwnd);
|
|---|
| 394 | RECTL frame,client,arcl[4];
|
|---|
| 395 |
|
|---|
| 396 | WinQueryWindowRect(hwnd,&frame);
|
|---|
| 397 | //top
|
|---|
| 398 | arcl[0].xLeft = 0;
|
|---|
| 399 | arcl[0].xRight = frame.xRight;
|
|---|
| 400 | arcl[0].yBottom = rect.yTop;
|
|---|
| 401 | arcl[0].yTop = frame.yTop;
|
|---|
| 402 | //right
|
|---|
| 403 | arcl[1].xLeft = rect.xRight;
|
|---|
| 404 | arcl[1].xRight = frame.xRight;
|
|---|
| 405 | arcl[1].yBottom = 0;
|
|---|
| 406 | arcl[1].yTop = frame.yTop;
|
|---|
| 407 | //left
|
|---|
| 408 | arcl[2].xLeft = 0;
|
|---|
| 409 | arcl[2].xRight = rect.xLeft;
|
|---|
| 410 | arcl[2].yBottom = 0;
|
|---|
| 411 | arcl[2].yTop = frame.yTop;
|
|---|
| 412 | //bottom
|
|---|
| 413 | arcl[3].xLeft = 0;
|
|---|
| 414 | arcl[3].xRight = frame.xRight;
|
|---|
| 415 | arcl[3].yBottom = 0;
|
|---|
| 416 | arcl[3].yTop = rect.yBottom;
|
|---|
| 417 |
|
|---|
| 418 | HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
|
|---|
| 419 |
|
|---|
| 420 | WinInvalidateRegion(hwnd,hrgn,FALSE);
|
|---|
| 421 | GpiDestroyRegion(hps,hrgn);
|
|---|
| 422 | WinReleasePS(hps);
|
|---|
| 423 | }
|
|---|
| 424 | }
|
|---|
| 425 | }
|
|---|
| 426 | else
|
|---|
| 427 | {
|
|---|
| 428 | //update child positions: rectWindow is in window coordinates
|
|---|
| 429 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
|---|
| 430 | FrameUpdateChildPositions(win32wnd->getOS2WindowHandle());
|
|---|
| 431 | }
|
|---|
| 432 |
|
|---|
| 433 | if(win32wnd->CanReceiveSizeMsgs())
|
|---|
| 434 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 435 | }
|
|---|
| 436 |
|
|---|
| 437 | PosChangedEnd:
|
|---|
| 438 | RestoreOS2TIB();
|
|---|
| 439 | return (MRESULT)FALSE;
|
|---|
| 440 | }
|
|---|
| 441 |
|
|---|
| 442 | case WM_SHOW:
|
|---|
| 443 | dprintf(("PMFRAME: WM_SHOW"));
|
|---|
| 444 | break;
|
|---|
| 445 |
|
|---|
| 446 | case WM_ERASEBACKGROUND:
|
|---|
| 447 | {
|
|---|
| 448 | dprintf(("PMFRAME: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
|
|---|
| 449 | RestoreOS2TIB();
|
|---|
| 450 | return (MRESULT)FALSE;
|
|---|
| 451 | }
|
|---|
| 452 |
|
|---|
| 453 | case WM_CALCVALIDRECTS:
|
|---|
| 454 | {
|
|---|
| 455 | //don't redraw here or PM redraw the whole frame (done in WM_WINDOWPOSCHANGED)
|
|---|
| 456 | dprintf(("PMFRAME: WM_CALCVALIDRECTS"));
|
|---|
| 457 | RestoreOS2TIB();
|
|---|
| 458 | return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
|
|---|
| 459 | }
|
|---|
| 460 |
|
|---|
| 461 | case WM_ACTIVATE:
|
|---|
| 462 | {
|
|---|
| 463 | HWND hwndTitle;
|
|---|
| 464 | USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
|
|---|
| 465 |
|
|---|
| 466 | dprintf(("PMFRAME: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
|
|---|
| 467 | if(win32wnd->IsWindowCreated())
|
|---|
| 468 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 469 |
|
|---|
| 470 | if (win32wnd->IsWindowCreated())
|
|---|
| 471 | {
|
|---|
| 472 | WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),WM_ACTIVATE,mp1,mp2);
|
|---|
| 473 | WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
|---|
| 474 |
|
|---|
| 475 | //CB: show owner behind the dialog
|
|---|
| 476 | if (win32wnd->IsModalDialog())
|
|---|
| 477 | {
|
|---|
| 478 | Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
|
|---|
| 479 |
|
|---|
| 480 | if (topOwner) WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
|
|---|
| 481 | }
|
|---|
| 482 | }
|
|---|
| 483 | else
|
|---|
| 484 | {
|
|---|
| 485 | WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
|---|
| 486 | }
|
|---|
| 487 | RestoreOS2TIB();
|
|---|
| 488 | return 0;
|
|---|
| 489 | }
|
|---|
| 490 |
|
|---|
| 491 | case WM_DESTROY:
|
|---|
| 492 | dprintf(("PMFRAME: WM_DESTROY %x",hwnd));
|
|---|
| 493 | WinSetVisibleRegionNotify(hwnd, FALSE);
|
|---|
| 494 | WinSubclassWindow(hwnd,OldFrameProc);
|
|---|
| 495 | win32wnd->setOldFrameProc(NULL);
|
|---|
| 496 | goto RunDefFrameProc;
|
|---|
| 497 |
|
|---|
| 498 | case WM_VRNENABLED:
|
|---|
| 499 | if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
|
|---|
| 500 | {
|
|---|
| 501 | HWND hwndrelated;
|
|---|
| 502 | Win32BaseWindow *topwindow;
|
|---|
| 503 |
|
|---|
| 504 | win32wnd->setComingToTop(TRUE);
|
|---|
| 505 |
|
|---|
| 506 | hwndrelated = WinQueryWindow(hwnd, QW_PREV);
|
|---|
| 507 | dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
|
|---|
| 508 | topwindow = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndrelated);
|
|---|
| 509 | if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
|
|---|
| 510 | //put window at the top of z order
|
|---|
| 511 | WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
|
|---|
| 512 | }
|
|---|
| 513 |
|
|---|
| 514 | win32wnd->setComingToTop(FALSE);
|
|---|
| 515 | break;
|
|---|
| 516 | }
|
|---|
| 517 | goto RunDefFrameProc;
|
|---|
| 518 |
|
|---|
| 519 | default:
|
|---|
| 520 | RestoreOS2TIB();
|
|---|
| 521 | return OldFrameProc(hwnd,msg,mp1,mp2);
|
|---|
| 522 | }
|
|---|
| 523 |
|
|---|
| 524 | RestoreOS2TIB();
|
|---|
| 525 | return (MRESULT)FALSE;
|
|---|
| 526 |
|
|---|
| 527 | RunDefFrameProc:
|
|---|
| 528 | RestoreOS2TIB();
|
|---|
| 529 | return OldFrameProc(hwnd,msg,mp1,mp2);
|
|---|
| 530 |
|
|---|
| 531 | RunDefWndProc:
|
|---|
| 532 | RestoreOS2TIB();
|
|---|
| 533 | return WinDefWindowProc(hwnd,msg,mp1,mp2);
|
|---|
| 534 | }
|
|---|
| 535 | //******************************************************************************
|
|---|
| 536 | //******************************************************************************
|
|---|
| 537 | PVOID FrameSubclassFrameWindow(Win32BaseWindow *win32wnd)
|
|---|
| 538 | {
|
|---|
| 539 | return WinSubclassWindow(win32wnd->getOS2FrameWindowHandle(),PFNWP(Win32FrameProc));
|
|---|
| 540 | }
|
|---|
| 541 | //******************************************************************************
|
|---|
| 542 | //******************************************************************************
|
|---|
| 543 | VOID FrameUpdateClient(Win32BaseWindow *win32wnd)
|
|---|
| 544 | {
|
|---|
| 545 | RECT rectOld, rectNew;
|
|---|
| 546 | RECTL rect;
|
|---|
| 547 | SWP swpClient = {0};
|
|---|
| 548 |
|
|---|
| 549 | rectOld = *win32wnd->getClientRectPtr();
|
|---|
| 550 | win32wnd->MsgFormatFrame(NULL);
|
|---|
| 551 | rectNew = *win32wnd->getClientRectPtr();
|
|---|
| 552 | if(WinEqualRect(0, (PRECTL)&rectOld, (PRECTL)&rectNew) == 1) {
|
|---|
| 553 | WinInvalidateRect(win32wnd->getOS2FrameWindowHandle(), NULL, FALSE);
|
|---|
| 554 | return;
|
|---|
| 555 | }
|
|---|
| 556 | //CB: todo: use result for WM_CALCVALIDRECTS
|
|---|
| 557 | mapWin32ToOS2Rect(win32wnd->getOS2FrameWindowHandle(), win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
|
|---|
| 558 |
|
|---|
| 559 |
|
|---|
| 560 | swpClient.hwnd = win32wnd->getOS2WindowHandle();
|
|---|
| 561 | swpClient.hwndInsertBehind = 0;
|
|---|
| 562 | swpClient.x = rect.xLeft;
|
|---|
| 563 | swpClient.y = rect.yBottom;
|
|---|
| 564 | swpClient.cx = rect.xRight-rect.xLeft;
|
|---|
| 565 | swpClient.cy = rect.yTop-rect.yBottom;
|
|---|
| 566 | swpClient.fl = SWP_MOVE | SWP_SIZE;
|
|---|
| 567 | WinSetMultWindowPos(GetThreadHAB(), &swpClient, 1);
|
|---|
| 568 | }
|
|---|
| 569 | //******************************************************************************
|
|---|
| 570 | //******************************************************************************
|
|---|