| 1 | /* $Id: pmframe.cpp,v 1.12 1999-10-28 12:00:34 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 <os2.h> /* PM header file */
|
|---|
| 16 | #include <os2wrap.h>
|
|---|
| 17 | #include <stdlib.h>
|
|---|
| 18 | #include "win32type.h"
|
|---|
| 19 | #include <misc.h>
|
|---|
| 20 | #include <win32wbase.h>
|
|---|
| 21 | #include "wprocess.h"
|
|---|
| 22 | #include "pmframe.h"
|
|---|
| 23 | #include "oslibutil.h"
|
|---|
| 24 | #include "oslibwin.h"
|
|---|
| 25 | #include "caret.h"
|
|---|
| 26 |
|
|---|
| 27 | #define PMFRAMELOG
|
|---|
| 28 |
|
|---|
| 29 | //******************************************************************************
|
|---|
| 30 | //******************************************************************************
|
|---|
| 31 | VOID Draw3DRect(HPS hps,RECTL rect,LONG colorBR,LONG colorTL)
|
|---|
| 32 | {
|
|---|
| 33 | POINTL point;
|
|---|
| 34 |
|
|---|
| 35 | GpiSetColor(hps,colorBR);
|
|---|
| 36 | point.x = rect.xLeft;
|
|---|
| 37 | point.y = rect.yBottom;
|
|---|
| 38 | GpiMove(hps,&point);
|
|---|
| 39 | point.x = rect.xRight-1;
|
|---|
| 40 | GpiLine(hps,&point);
|
|---|
| 41 | point.y = rect.yTop-1;
|
|---|
| 42 | GpiLine(hps,&point);
|
|---|
| 43 | GpiSetColor(hps,colorTL);
|
|---|
| 44 | point.x--;
|
|---|
| 45 | GpiMove(hps,&point);
|
|---|
| 46 | point.x = rect.xLeft;
|
|---|
| 47 | GpiLine(hps,&point);
|
|---|
| 48 | point.y = rect.yBottom+1;
|
|---|
| 49 | GpiLine(hps,&point);
|
|---|
| 50 | }
|
|---|
| 51 | //******************************************************************************
|
|---|
| 52 | //******************************************************************************
|
|---|
| 53 | VOID DeflateRect(RECTL *rect)
|
|---|
| 54 | {
|
|---|
| 55 | rect->xLeft++;
|
|---|
| 56 | rect->xRight--;
|
|---|
| 57 | rect->yTop--;
|
|---|
| 58 | rect->yBottom++;
|
|---|
| 59 | }
|
|---|
| 60 | //******************************************************************************
|
|---|
| 61 | //******************************************************************************
|
|---|
| 62 | VOID DrawFrame(HPS hps,RECTL *rect,Win32BaseWindow *win32wnd)
|
|---|
| 63 | {
|
|---|
| 64 | LONG clrWhite,clrBlack,clrDark,clrLight;
|
|---|
| 65 | POINTL point;
|
|---|
| 66 | DWORD dwExStyle = win32wnd->getExStyle();
|
|---|
| 67 | DWORD dwStyle = win32wnd->getStyle();
|
|---|
| 68 |
|
|---|
| 69 | clrWhite = CLR_WHITE;
|
|---|
| 70 | clrBlack = CLR_BLACK;
|
|---|
| 71 | clrLight = CLR_PALEGRAY;
|
|---|
| 72 | clrDark = CLR_DARKGRAY;
|
|---|
| 73 |
|
|---|
| 74 | if (dwExStyle & WS_EX_CLIENTEDGE_W)
|
|---|
| 75 | {
|
|---|
| 76 | Draw3DRect(hps,*rect,clrWhite,clrDark);
|
|---|
| 77 | DeflateRect(rect);
|
|---|
| 78 | Draw3DRect(hps,*rect,clrLight,clrBlack);
|
|---|
| 79 | }
|
|---|
| 80 | else if (dwExStyle & WS_EX_DLGMODALFRAME_W)
|
|---|
| 81 | {
|
|---|
| 82 | Draw3DRect(hps,*rect,clrBlack,clrLight);
|
|---|
| 83 | DeflateRect(rect);
|
|---|
| 84 | Draw3DRect(hps,*rect,clrDark,clrWhite);
|
|---|
| 85 | DeflateRect(rect);
|
|---|
| 86 | Draw3DRect(hps,*rect,clrLight,clrLight);
|
|---|
| 87 | }
|
|---|
| 88 | else if (dwExStyle & WS_EX_STATICEDGE_W)
|
|---|
| 89 | {
|
|---|
| 90 | Draw3DRect(hps,*rect,clrWhite,clrDark);
|
|---|
| 91 | }
|
|---|
| 92 | else if (dwExStyle & WS_EX_WINDOWEDGE_W);
|
|---|
| 93 | else if (dwStyle & WS_BORDER_W)
|
|---|
| 94 | {
|
|---|
| 95 | Draw3DRect(hps,*rect,clrBlack,clrBlack);
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | DeflateRect(rect);
|
|---|
| 99 | }
|
|---|
| 100 | //******************************************************************************
|
|---|
| 101 | //******************************************************************************
|
|---|
| 102 | BOOL CanDrawSizeBox(Win32BaseWindow *win32wnd)
|
|---|
| 103 | {
|
|---|
| 104 | return (win32wnd->getStyle() & WS_SIZEBOX_W && WinQueryWindowULong(win32wnd->getOS2FrameWindowHandle(),QWL_STYLE) & FS_SIZEBORDER
|
|---|
| 105 | && win32wnd->getVertScrollHandle() && WinQueryWindow(win32wnd->getVertScrollHandle(),QW_PARENT) == win32wnd->getOS2FrameWindowHandle()
|
|---|
| 106 | && win32wnd->getHorzScrollHandle() && WinQueryWindow(win32wnd->getHorzScrollHandle(),QW_PARENT) == win32wnd->getOS2FrameWindowHandle());
|
|---|
| 107 | }
|
|---|
| 108 | //******************************************************************************
|
|---|
| 109 | //******************************************************************************
|
|---|
| 110 | VOID GetSizeBox(Win32BaseWindow *win32wnd,RECTL *rect)
|
|---|
| 111 | {
|
|---|
| 112 | SWP swpHorz,swpVert;
|
|---|
| 113 |
|
|---|
| 114 | WinQueryWindowPos(win32wnd->getVertScrollHandle(),&swpVert);
|
|---|
| 115 | WinQueryWindowPos(win32wnd->getHorzScrollHandle(),&swpHorz);
|
|---|
| 116 | rect->xLeft = swpVert.x;
|
|---|
| 117 | rect->xRight = swpVert.x+swpVert.cx;
|
|---|
| 118 | rect->yTop = swpHorz.y+swpHorz.cy;
|
|---|
| 119 | rect->yBottom = swpHorz.y;
|
|---|
| 120 | }
|
|---|
| 121 | //******************************************************************************
|
|---|
| 122 | //******************************************************************************
|
|---|
| 123 | BOOL InSizeBox(Win32BaseWindow *win32wnd,POINTS *points)
|
|---|
| 124 | {
|
|---|
| 125 | if (CanDrawSizeBox(win32wnd))
|
|---|
| 126 | {
|
|---|
| 127 | RECTL rect;
|
|---|
| 128 | POINTL point;
|
|---|
| 129 |
|
|---|
| 130 | point.x = points->x;
|
|---|
| 131 | point.y = points->y;
|
|---|
| 132 | GetSizeBox(win32wnd,&rect);
|
|---|
| 133 | return (WinPtInRect(GetThreadHAB(),&rect,&point));
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | return FALSE;
|
|---|
| 137 | }
|
|---|
| 138 | //******************************************************************************
|
|---|
| 139 | //******************************************************************************
|
|---|
| 140 | VOID DrawSizeBox(HPS hps,RECTL rect)
|
|---|
| 141 | {
|
|---|
| 142 | POINTL p1,p2;
|
|---|
| 143 | LONG clrDark = CLR_DARKGRAY,clrWhite = CLR_WHITE;
|
|---|
| 144 | INT x;
|
|---|
| 145 |
|
|---|
| 146 | WinFillRect(hps,&rect,SYSCLR_DIALOGBACKGROUND);
|
|---|
| 147 | p1.x = rect.xRight-2;
|
|---|
| 148 | p1.y = rect.yBottom;
|
|---|
| 149 | p2.x = rect.xRight-1;
|
|---|
| 150 | p2.y = rect.yBottom+1;
|
|---|
| 151 | for (x = 0;x < 3;x++)
|
|---|
| 152 | {
|
|---|
| 153 | GpiSetColor(hps,clrDark);
|
|---|
| 154 | GpiMove(hps,&p1);
|
|---|
| 155 | GpiLine(hps,&p2);
|
|---|
| 156 | p1.x--;
|
|---|
| 157 | p2.y++;
|
|---|
| 158 | GpiMove(hps,&p1);
|
|---|
| 159 | GpiLine(hps,&p2);
|
|---|
| 160 | GpiSetColor(hps,clrWhite);
|
|---|
| 161 | p1.x--;
|
|---|
| 162 | p2.y++;
|
|---|
| 163 | GpiMove(hps,&p1);
|
|---|
| 164 | GpiLine(hps,&p2);
|
|---|
| 165 | p1.x -= 2;
|
|---|
| 166 | p2.y += 2;
|
|---|
| 167 | }
|
|---|
| 168 | }
|
|---|
| 169 | //******************************************************************************
|
|---|
| 170 | //******************************************************************************
|
|---|
| 171 | void DrawActivate(Win32BaseWindow *win32wnd, HWND hwnd)
|
|---|
| 172 | {
|
|---|
| 173 | if (!win32wnd->isChild())
|
|---|
| 174 | {
|
|---|
| 175 | if (CanDrawSizeBox(win32wnd))
|
|---|
| 176 | {
|
|---|
| 177 | HPS hps;
|
|---|
| 178 | RECTL rect;
|
|---|
| 179 |
|
|---|
| 180 | GetSizeBox(win32wnd,&rect);
|
|---|
| 181 | hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
|
|---|
| 182 | DrawSizeBox(hps,rect);
|
|---|
| 183 | WinReleasePS(hps);
|
|---|
| 184 |
|
|---|
| 185 | }
|
|---|
| 186 | }
|
|---|
| 187 | else
|
|---|
| 188 | {
|
|---|
| 189 | HPS hps;
|
|---|
| 190 | RECTL rect;
|
|---|
| 191 |
|
|---|
| 192 | WinQueryWindowRect(hwnd,&rect);
|
|---|
| 193 | rect.xRight = rect.xRight-rect.xLeft;
|
|---|
| 194 | rect.yTop = rect.yTop-rect.yBottom;
|
|---|
| 195 | rect.xLeft = rect.yBottom = 0;
|
|---|
| 196 | hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
|
|---|
| 197 | DrawFrame(hps,&rect,win32wnd);
|
|---|
| 198 | WinReleasePS(hps);
|
|---|
| 199 | }
|
|---|
| 200 | }
|
|---|
| 201 | //******************************************************************************
|
|---|
| 202 | //Win32 frame message handler
|
|---|
| 203 | //******************************************************************************
|
|---|
| 204 | MRESULT EXPENTRY Win32FrameProc(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
|
|---|
| 205 | {
|
|---|
| 206 | Win32BaseWindow *win32wnd;
|
|---|
| 207 | PFNWP OldFrameProc;
|
|---|
| 208 | MRESULT rc;
|
|---|
| 209 |
|
|---|
| 210 | SetWin32TIB();
|
|---|
| 211 |
|
|---|
| 212 | win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
|
|---|
| 213 |
|
|---|
| 214 | if(win32wnd == NULL || !win32wnd->getOldFrameProc())
|
|---|
| 215 | {
|
|---|
| 216 | dprintf(("Invalid win32wnd pointer for frame %x!!", hwnd));
|
|---|
| 217 | goto RunDefWndProc;
|
|---|
| 218 | }
|
|---|
| 219 |
|
|---|
| 220 | OldFrameProc = (PFNWP)win32wnd->getOldFrameProc();
|
|---|
| 221 |
|
|---|
| 222 | switch(msg)
|
|---|
| 223 | {
|
|---|
| 224 | #if 1
|
|---|
| 225 | case WM_ADJUSTWINDOWPOS:
|
|---|
| 226 | {
|
|---|
| 227 | PSWP pswp = (PSWP)mp1;
|
|---|
| 228 | SWP swpOld;
|
|---|
| 229 | WINDOWPOS wp;
|
|---|
| 230 | HWND hParent = NULLHANDLE, hwndAfter;
|
|---|
| 231 |
|
|---|
| 232 | 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));
|
|---|
| 233 |
|
|---|
| 234 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
|---|
| 235 | goto RunDefFrameProc;
|
|---|
| 236 |
|
|---|
| 237 | if(!win32wnd->CanReceiveSizeMsgs()) {
|
|---|
| 238 | break;
|
|---|
| 239 | }
|
|---|
| 240 |
|
|---|
| 241 | WinQueryWindowPos(hwnd, &swpOld);
|
|---|
| 242 |
|
|---|
| 243 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
|---|
| 244 | if (win32wnd->isChild()) {
|
|---|
| 245 | if(win32wnd->getParent()) {
|
|---|
| 246 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 247 | }
|
|---|
| 248 | else goto RunDefFrameProc;
|
|---|
| 249 | }
|
|---|
| 250 | }
|
|---|
| 251 | hwndAfter = pswp->hwndInsertBehind;
|
|---|
| 252 | OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
|
|---|
| 253 |
|
|---|
| 254 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 255 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 256 | {
|
|---|
| 257 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 258 | if(wndAfter) wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 259 | }
|
|---|
| 260 | if(win32wnd->MsgPosChanging((LPARAM)&wp) == 0)
|
|---|
| 261 | {//app or default window handler changed wp
|
|---|
| 262 | dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
|
|---|
| 263 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 264 | OSLibMapWINDOWPOStoSWPFrame(&wp, pswp, &swpOld, hParent, hwnd);
|
|---|
| 265 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 266 | pswp->fl |= SWP_NOADJUST;
|
|---|
| 267 | pswp->hwndInsertBehind = hwndAfter;
|
|---|
| 268 | pswp->hwnd = hwnd;
|
|---|
| 269 |
|
|---|
| 270 | RestoreOS2TIB();
|
|---|
| 271 | return (MRESULT)0xf;
|
|---|
| 272 | }
|
|---|
| 273 | break;
|
|---|
| 274 | }
|
|---|
| 275 |
|
|---|
| 276 | case WM_WINDOWPOSCHANGED:
|
|---|
| 277 | {
|
|---|
| 278 | PSWP pswp = (PSWP)mp1;
|
|---|
| 279 | SWP swpOld = *(pswp + 1);
|
|---|
| 280 | WINDOWPOS wp;
|
|---|
| 281 | HWND hParent = NULLHANDLE;
|
|---|
| 282 | LONG yDelta = pswp->cy - swpOld.cy;
|
|---|
| 283 | LONG xDelta = pswp->cx - swpOld.cx;
|
|---|
| 284 |
|
|---|
| 285 | dprintf(("PMFRAME: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 286 |
|
|---|
| 287 | RestoreOS2TIB();
|
|---|
| 288 | rc = OldFrameProc(hwnd,msg,mp1,mp2);
|
|---|
| 289 | SetWin32TIB();
|
|---|
| 290 |
|
|---|
| 291 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
|---|
| 292 | goto PosChangedEnd;
|
|---|
| 293 |
|
|---|
| 294 | if(!win32wnd->CanReceiveSizeMsgs())
|
|---|
| 295 | goto PosChangedEnd;
|
|---|
| 296 |
|
|---|
| 297 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
|---|
| 298 | if (win32wnd->isChild()) {
|
|---|
| 299 | if(win32wnd->getParent()) {
|
|---|
| 300 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 301 | }
|
|---|
| 302 | else goto PosChangedEnd; //parent has just been destroyed
|
|---|
| 303 | }
|
|---|
| 304 | }
|
|---|
| 305 | OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
|
|---|
| 306 |
|
|---|
| 307 | //delta is difference between old and new client height
|
|---|
| 308 | yDelta = swpOld.cy - win32wnd->getWindowHeight();
|
|---|
| 309 |
|
|---|
| 310 | win32wnd->setWindowRect(wp.x, wp.y, wp.x+wp.cx, wp.y+wp.cy);
|
|---|
| 311 | win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
|
|---|
| 312 |
|
|---|
| 313 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 314 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 315 | {
|
|---|
| 316 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 317 | if(wndAfter) wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 318 | }
|
|---|
| 319 |
|
|---|
| 320 | if (yDelta != 0 || xDelta != 0)
|
|---|
| 321 | {
|
|---|
| 322 | HENUM henum = WinBeginEnumWindows(WinWindowFromID(pswp->hwnd, FID_CLIENT));
|
|---|
| 323 | SWP swp[10];
|
|---|
| 324 | int i = 0;
|
|---|
| 325 | HWND hwnd;
|
|---|
| 326 |
|
|---|
| 327 | while ((hwnd = WinGetNextWindow(henum)) != NULLHANDLE)
|
|---|
| 328 | {
|
|---|
| 329 | #if 0
|
|---|
| 330 | if (mdiClient )
|
|---|
| 331 | {
|
|---|
| 332 | continue;
|
|---|
| 333 | }
|
|---|
| 334 | #endif
|
|---|
| 335 | WinQueryWindowPos(hwnd, &(swp[i]));
|
|---|
| 336 |
|
|---|
| 337 | #ifdef DEBUG
|
|---|
| 338 | Win32BaseWindow *window = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 339 | dprintf(("ENUMERATE %x delta %d (%d,%d) (%d,%d) %x", (window) ? window->getWindowHandle() : hwnd,
|
|---|
| 340 | yDelta, swp[i].x, swp[i].y, swp[i].cx, swp[i].cy, swp[i].fl));
|
|---|
| 341 | #endif
|
|---|
| 342 |
|
|---|
| 343 | if(swp[i].y != 0) {
|
|---|
| 344 | //child window at offset <> 0 from client area -> offset now changes
|
|---|
| 345 | swp[i].y += yDelta;
|
|---|
| 346 | swp[i].fl &= ~(SWP_NOREDRAW);
|
|---|
| 347 | }
|
|---|
| 348 | //else child window with the same start coorindates as the client area
|
|---|
| 349 | //The app should resize it.
|
|---|
| 350 |
|
|---|
| 351 | if (i == 9)
|
|---|
| 352 | {
|
|---|
| 353 | WinSetMultWindowPos(GetThreadHAB(), swp, 10);
|
|---|
| 354 | i = 0;
|
|---|
| 355 | }
|
|---|
| 356 | else
|
|---|
| 357 | {
|
|---|
| 358 | i++;
|
|---|
| 359 | }
|
|---|
| 360 | }
|
|---|
| 361 |
|
|---|
| 362 | WinEndEnumWindows(henum);
|
|---|
| 363 |
|
|---|
| 364 | if (i)
|
|---|
| 365 | WinSetMultWindowPos(GetThreadHAB(), swp, i);
|
|---|
| 366 | }
|
|---|
| 367 | if (yDelta != 0)
|
|---|
| 368 | {
|
|---|
| 369 | POINT pt;
|
|---|
| 370 | if(GetCaretPos (&pt) == TRUE)
|
|---|
| 371 | {
|
|---|
| 372 | pt.y -= yDelta;
|
|---|
| 373 | SetCaretPos (pt.x, pt.y);
|
|---|
| 374 | }
|
|---|
| 375 | }
|
|---|
| 376 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 377 |
|
|---|
| 378 | PosChangedEnd:
|
|---|
| 379 | RestoreOS2TIB();
|
|---|
| 380 | return rc;
|
|---|
| 381 | }
|
|---|
| 382 | #if 0
|
|---|
| 383 | case WM_ENABLE:
|
|---|
| 384 | dprintf(("PMFRAME: WM_ENABLE %x", win32wnd->getWindowHandle()));
|
|---|
| 385 | win32wnd->MsgEnable(SHORT1FROMMP(mp1));
|
|---|
| 386 | goto RunDefFrameProc;
|
|---|
| 387 |
|
|---|
| 388 | case WM_SHOW:
|
|---|
| 389 | dprintf(("PMFRAME: WM_SHOW %x %d", win32wnd->getWindowHandle(), mp1));
|
|---|
| 390 | win32wnd->MsgShow((ULONG)mp1);
|
|---|
| 391 | goto RunDefFrameProc;
|
|---|
| 392 |
|
|---|
| 393 | case WM_ACTIVATE:
|
|---|
| 394 | {
|
|---|
| 395 | HWND hwndActivate = (HWND)mp2;
|
|---|
| 396 | BOOL fMinimized = FALSE;
|
|---|
| 397 |
|
|---|
| 398 | dprintf(("PMFRAME: WM_ACTIVATE %x %x", hwnd, hwndActivate));
|
|---|
| 399 | if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
|
|---|
| 400 | //another (non-win32) application's window
|
|---|
| 401 | //set to NULL (allowed according to win32 SDK) to avoid problems
|
|---|
| 402 | hwndActivate = NULL;
|
|---|
| 403 | }
|
|---|
| 404 | if(WinQueryWindowULong(hwnd, QWL_STYLE) & WS_MINIMIZED)
|
|---|
| 405 | {
|
|---|
| 406 | fMinimized = TRUE;
|
|---|
| 407 | }
|
|---|
| 408 |
|
|---|
| 409 | win32wnd->MsgActivate(SHORT1FROMMP(mp1), fMinimized, Win32BaseWindow::OS2ToWin32Handle(hwndActivate));
|
|---|
| 410 |
|
|---|
| 411 | RestoreOS2TIB();
|
|---|
| 412 | MRESULT rc = OldFrameProc(hwnd,msg,mp1,mp2);
|
|---|
| 413 | DrawActivate(win32wnd, hwnd);
|
|---|
| 414 | return rc;
|
|---|
| 415 | }
|
|---|
| 416 | #else
|
|---|
| 417 | case WM_ACTIVATE:
|
|---|
| 418 | DrawActivate(win32wnd, hwnd);
|
|---|
| 419 | goto RunDefFrameProc;
|
|---|
| 420 | #endif
|
|---|
| 421 | #else
|
|---|
| 422 | case WM_ADJUSTWINDOWPOS:
|
|---|
| 423 | {
|
|---|
| 424 | PSWP pswp = (PSWP)mp1;
|
|---|
| 425 | Win32BaseWindow *wndchild;
|
|---|
| 426 |
|
|---|
| 427 | wndchild = Win32BaseWindow::GetWindowFromOS2FrameHandle(pswp->hwnd);
|
|---|
| 428 | if(wndchild && wndchild->isChild())
|
|---|
| 429 | {
|
|---|
| 430 | #if 0
|
|---|
| 431 | SWP swp = *pswp;
|
|---|
| 432 |
|
|---|
| 433 | MRESULT rc = OldFrameProc(hwnd, msg, mp1, mp2);
|
|---|
| 434 | pswp->x = swp.x;
|
|---|
| 435 | pswp->y = swp.y;
|
|---|
| 436 | pswp->fl = swp.fl;
|
|---|
| 437 | #endif
|
|---|
| 438 | dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", hwnd, pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 439 | RestoreOS2TIB();
|
|---|
| 440 | return (MRESULT)0;
|
|---|
| 441 | }
|
|---|
| 442 | goto RunDefFrameProc;
|
|---|
| 443 | }
|
|---|
| 444 |
|
|---|
| 445 | case WM_ACTIVATE:
|
|---|
| 446 | DrawActivate(win32wnd, hwnd);
|
|---|
| 447 | goto RunDefFrameProc;
|
|---|
| 448 | #endif
|
|---|
| 449 |
|
|---|
| 450 | case WM_DESTROY:
|
|---|
| 451 | #ifdef PMFRAMELOG
|
|---|
| 452 | dprintf(("PMFRAME: WM_DESTROY"));
|
|---|
| 453 | #endif
|
|---|
| 454 | WinSubclassWindow(hwnd,OldFrameProc);
|
|---|
| 455 | win32wnd->setOldFrameProc(NULL);
|
|---|
| 456 | goto RunDefFrameProc;
|
|---|
| 457 |
|
|---|
| 458 | case WM_MOUSEMOVE:
|
|---|
| 459 | if (InSizeBox(win32wnd,(POINTS*)&mp1))
|
|---|
| 460 | {
|
|---|
| 461 | WinSetPointer(HWND_DESKTOP,WinQuerySysPointer(HWND_DESKTOP,SPTR_SIZENWSE,FALSE));
|
|---|
| 462 | RestoreOS2TIB();
|
|---|
| 463 | return (MRESULT)TRUE;
|
|---|
| 464 | }
|
|---|
| 465 | else if (win32wnd->isChild()) goto RunDefWndProc;
|
|---|
| 466 | else goto RunDefFrameProc;
|
|---|
| 467 |
|
|---|
| 468 | case WM_BUTTON1DOWN:
|
|---|
| 469 | #ifdef PMFRAMELOG
|
|---|
| 470 | dprintf(("PMFRAME: WM_BUTTON1DOWN"));
|
|---|
| 471 | #endif
|
|---|
| 472 | if (InSizeBox(win32wnd,(POINTS*)&mp1))
|
|---|
| 473 | {
|
|---|
| 474 | WinSendMsg(hwnd,WM_TRACKFRAME,(MPARAM)(TF_RIGHT | TF_BOTTOM),(MPARAM)0);
|
|---|
| 475 | RestoreOS2TIB();
|
|---|
| 476 | return (MRESULT)TRUE;
|
|---|
| 477 | }
|
|---|
| 478 | else if (win32wnd->isChild()) goto RunDefWndProc;
|
|---|
| 479 | else goto RunDefFrameProc;
|
|---|
| 480 |
|
|---|
| 481 | case WM_BUTTON2DOWN:
|
|---|
| 482 | case WM_BUTTON3DOWN:
|
|---|
| 483 | #ifdef PMFRAMELOG
|
|---|
| 484 | dprintf(("PMFRAME: WM_BUTTON2/3DOWN"));
|
|---|
| 485 | #endif
|
|---|
| 486 | if (win32wnd->isChild()) goto RunDefWndProc;
|
|---|
| 487 | else goto RunDefFrameProc;
|
|---|
| 488 |
|
|---|
| 489 | case WM_PAINT:
|
|---|
| 490 | #ifdef PMFRAMELOG
|
|---|
| 491 | dprintf(("PMFRAME: WM_PAINT"));
|
|---|
| 492 | #endif
|
|---|
| 493 | if (!win32wnd->isChild())
|
|---|
| 494 | {
|
|---|
| 495 | if (CanDrawSizeBox(win32wnd))
|
|---|
| 496 | {
|
|---|
| 497 | MRESULT res;
|
|---|
| 498 | HPS hps;
|
|---|
| 499 | RECTL rect;
|
|---|
| 500 |
|
|---|
| 501 | RestoreOS2TIB();
|
|---|
| 502 | res = OldFrameProc(hwnd,msg,mp1,mp2);
|
|---|
| 503 | SetWin32TIB();
|
|---|
| 504 |
|
|---|
| 505 | GetSizeBox(win32wnd,&rect);
|
|---|
| 506 | hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
|
|---|
| 507 | DrawSizeBox(hps,rect);
|
|---|
| 508 | WinReleasePS(hps);
|
|---|
| 509 |
|
|---|
| 510 | RestoreOS2TIB();
|
|---|
| 511 | return res;
|
|---|
| 512 | }
|
|---|
| 513 | else goto RunDefFrameProc;
|
|---|
| 514 | }
|
|---|
| 515 | else
|
|---|
| 516 | {
|
|---|
| 517 | RECTL rect;
|
|---|
| 518 | HPS hps;
|
|---|
| 519 |
|
|---|
| 520 | RestoreOS2TIB();
|
|---|
| 521 | OldFrameProc(hwnd,msg,mp1,mp2);
|
|---|
| 522 | SetWin32TIB();
|
|---|
| 523 |
|
|---|
| 524 | WinQueryWindowRect(hwnd,&rect);
|
|---|
| 525 | rect.xRight = rect.xRight-rect.xLeft;
|
|---|
| 526 | rect.yTop = rect.yTop-rect.yBottom;
|
|---|
| 527 | rect.xLeft = rect.yBottom = 0;
|
|---|
| 528 | hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
|
|---|
| 529 | DrawFrame(hps,&rect,win32wnd);
|
|---|
| 530 | WinReleasePS(hps);
|
|---|
| 531 |
|
|---|
| 532 | RestoreOS2TIB();
|
|---|
| 533 | return (MRESULT)0;
|
|---|
| 534 | }
|
|---|
| 535 |
|
|---|
| 536 | default:
|
|---|
| 537 | RestoreOS2TIB();
|
|---|
| 538 | return OldFrameProc(hwnd,msg,mp1,mp2);
|
|---|
| 539 | }
|
|---|
| 540 |
|
|---|
| 541 | RestoreOS2TIB();
|
|---|
| 542 | return (MRESULT)FALSE;
|
|---|
| 543 |
|
|---|
| 544 | RunDefFrameProc:
|
|---|
| 545 | RestoreOS2TIB();
|
|---|
| 546 | return OldFrameProc(hwnd,msg,mp1,mp2);
|
|---|
| 547 |
|
|---|
| 548 | RunDefWndProc:
|
|---|
| 549 | RestoreOS2TIB();
|
|---|
| 550 | return WinDefWindowProc(hwnd,msg,mp1,mp2);
|
|---|
| 551 | }
|
|---|
| 552 |
|
|---|
| 553 | PVOID FrameSubclassFrameWindow(Win32BaseWindow *win32wnd)
|
|---|
| 554 | {
|
|---|
| 555 | return WinSubclassWindow(win32wnd->getOS2FrameWindowHandle(),PFNWP(Win32FrameProc));
|
|---|
| 556 | }
|
|---|
| 557 |
|
|---|
| 558 | VOID FrameGetBorderSize(Win32BaseWindow *win32wnd,PWPOINT pSize)
|
|---|
| 559 | {
|
|---|
| 560 | WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_QUERYBORDERSIZE,(MPARAM)pSize,(MPARAM)0);
|
|---|
| 561 | }
|
|---|
| 562 |
|
|---|
| 563 | VOID FrameSetBorderSize(Win32BaseWindow *win32wnd,BOOL resize)
|
|---|
| 564 | {
|
|---|
| 565 | POINTL point;
|
|---|
| 566 |
|
|---|
| 567 | if (!resize)
|
|---|
| 568 | {
|
|---|
| 569 | WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight());
|
|---|
| 570 |
|
|---|
| 571 | return;
|
|---|
| 572 | }
|
|---|
| 573 |
|
|---|
| 574 | FrameGetBorderSize(win32wnd,&point);
|
|---|
| 575 | WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight());
|
|---|
| 576 | if (point.x != win32wnd->getBorderWidth() || point.y != win32wnd->getBorderHeight())
|
|---|
| 577 | {
|
|---|
| 578 | INT xDiff = win32wnd->getBorderWidth()-point.x;
|
|---|
| 579 | INT yDiff = win32wnd->getBorderHeight()-point.y;
|
|---|
| 580 | SWP swp;
|
|---|
| 581 |
|
|---|
| 582 | WinQueryWindowPos(win32wnd->getOS2FrameWindowHandle(),&swp);
|
|---|
| 583 | swp.x += xDiff;
|
|---|
| 584 | swp.y += yDiff;
|
|---|
| 585 | swp.cx -= 2*xDiff;
|
|---|
| 586 | swp.cy -= 2*yDiff;
|
|---|
| 587 | WinSetWindowPos(win32wnd->getOS2FrameWindowHandle(),0,swp.x,swp.y,swp.cx,swp.cy,SWP_MOVE | SWP_SIZE);
|
|---|
| 588 | }
|
|---|
| 589 | }
|
|---|
| 590 |
|
|---|
| 591 | UINT FrameGetDefSizeBorderSize(VOID)
|
|---|
| 592 | {
|
|---|
| 593 | return WinQuerySysValue(HWND_DESKTOP,SV_CXSIZEBORDER);
|
|---|
| 594 | }
|
|---|