| 1 | /* $Id: pmframe.cpp,v 1.11 1999-10-23 23:04:36 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 | return rc; | 
|---|
| 380 | } | 
|---|
| 381 | #if 0 | 
|---|
| 382 | case WM_ENABLE: | 
|---|
| 383 | dprintf(("PMFRAME: WM_ENABLE %x", win32wnd->getWindowHandle())); | 
|---|
| 384 | win32wnd->MsgEnable(SHORT1FROMMP(mp1)); | 
|---|
| 385 | goto RunDefFrameProc; | 
|---|
| 386 |  | 
|---|
| 387 | case WM_SHOW: | 
|---|
| 388 | dprintf(("PMFRAME: WM_SHOW %x %d", win32wnd->getWindowHandle(), mp1)); | 
|---|
| 389 | win32wnd->MsgShow((ULONG)mp1); | 
|---|
| 390 | goto RunDefFrameProc; | 
|---|
| 391 |  | 
|---|
| 392 | case WM_ACTIVATE: | 
|---|
| 393 | { | 
|---|
| 394 | HWND hwndActivate = (HWND)mp2; | 
|---|
| 395 | BOOL fMinimized = FALSE; | 
|---|
| 396 |  | 
|---|
| 397 | dprintf(("PMFRAME: WM_ACTIVATE %x %x", hwnd, hwndActivate)); | 
|---|
| 398 | if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) { | 
|---|
| 399 | //another (non-win32) application's window | 
|---|
| 400 | //set to NULL (allowed according to win32 SDK) to avoid problems | 
|---|
| 401 | hwndActivate = NULL; | 
|---|
| 402 | } | 
|---|
| 403 | if(WinQueryWindowULong(hwnd, QWL_STYLE) & WS_MINIMIZED) | 
|---|
| 404 | { | 
|---|
| 405 | fMinimized = TRUE; | 
|---|
| 406 | } | 
|---|
| 407 |  | 
|---|
| 408 | win32wnd->MsgActivate(SHORT1FROMMP(mp1), fMinimized, Win32BaseWindow::OS2ToWin32Handle(hwndActivate)); | 
|---|
| 409 |  | 
|---|
| 410 | RestoreOS2TIB(); | 
|---|
| 411 | MRESULT rc = OldFrameProc(hwnd,msg,mp1,mp2); | 
|---|
| 412 | DrawActivate(win32wnd, hwnd); | 
|---|
| 413 | return rc; | 
|---|
| 414 | } | 
|---|
| 415 | #else | 
|---|
| 416 | case WM_ACTIVATE: | 
|---|
| 417 | DrawActivate(win32wnd, hwnd); | 
|---|
| 418 | goto RunDefFrameProc; | 
|---|
| 419 | #endif | 
|---|
| 420 | #else | 
|---|
| 421 | case WM_ADJUSTWINDOWPOS: | 
|---|
| 422 | { | 
|---|
| 423 | PSWP     pswp = (PSWP)mp1; | 
|---|
| 424 | Win32BaseWindow *wndchild; | 
|---|
| 425 |  | 
|---|
| 426 | wndchild = Win32BaseWindow::GetWindowFromOS2FrameHandle(pswp->hwnd); | 
|---|
| 427 | if(wndchild && wndchild->isChild()) | 
|---|
| 428 | { | 
|---|
| 429 | #if 0 | 
|---|
| 430 | SWP swp = *pswp; | 
|---|
| 431 |  | 
|---|
| 432 | MRESULT rc = OldFrameProc(hwnd, msg, mp1, mp2); | 
|---|
| 433 | pswp->x = swp.x; | 
|---|
| 434 | pswp->y = swp.y; | 
|---|
| 435 | pswp->fl = swp.fl; | 
|---|
| 436 | #endif | 
|---|
| 437 | dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", hwnd, pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy)); | 
|---|
| 438 | RestoreOS2TIB(); | 
|---|
| 439 | return (MRESULT)0; | 
|---|
| 440 | } | 
|---|
| 441 | goto RunDefFrameProc; | 
|---|
| 442 | } | 
|---|
| 443 |  | 
|---|
| 444 | case WM_ACTIVATE: | 
|---|
| 445 | DrawActivate(win32wnd, hwnd); | 
|---|
| 446 | goto RunDefFrameProc; | 
|---|
| 447 | #endif | 
|---|
| 448 |  | 
|---|
| 449 | case WM_DESTROY: | 
|---|
| 450 | #ifdef PMFRAMELOG | 
|---|
| 451 | dprintf(("PMFRAME: WM_DESTROY")); | 
|---|
| 452 | #endif | 
|---|
| 453 | WinSubclassWindow(hwnd,OldFrameProc); | 
|---|
| 454 | win32wnd->setOldFrameProc(NULL); | 
|---|
| 455 | goto RunDefFrameProc; | 
|---|
| 456 |  | 
|---|
| 457 | case WM_MOUSEMOVE: | 
|---|
| 458 | if (InSizeBox(win32wnd,(POINTS*)&mp1)) | 
|---|
| 459 | { | 
|---|
| 460 | WinSetPointer(HWND_DESKTOP,WinQuerySysPointer(HWND_DESKTOP,SPTR_SIZENWSE,FALSE)); | 
|---|
| 461 | RestoreOS2TIB(); | 
|---|
| 462 | return (MRESULT)TRUE; | 
|---|
| 463 | } | 
|---|
| 464 | else if (win32wnd->isChild()) goto RunDefWndProc; | 
|---|
| 465 | else goto RunDefFrameProc; | 
|---|
| 466 |  | 
|---|
| 467 | case WM_BUTTON1DOWN: | 
|---|
| 468 | #ifdef PMFRAMELOG | 
|---|
| 469 | dprintf(("PMFRAME: WM_BUTTON1DOWN")); | 
|---|
| 470 | #endif | 
|---|
| 471 | if (InSizeBox(win32wnd,(POINTS*)&mp1)) | 
|---|
| 472 | { | 
|---|
| 473 | WinSendMsg(hwnd,WM_TRACKFRAME,(MPARAM)(TF_RIGHT | TF_BOTTOM),(MPARAM)0); | 
|---|
| 474 | RestoreOS2TIB(); | 
|---|
| 475 | return (MRESULT)TRUE; | 
|---|
| 476 | } | 
|---|
| 477 | else if (win32wnd->isChild()) goto RunDefWndProc; | 
|---|
| 478 | else goto RunDefFrameProc; | 
|---|
| 479 |  | 
|---|
| 480 | case WM_BUTTON2DOWN: | 
|---|
| 481 | case WM_BUTTON3DOWN: | 
|---|
| 482 | #ifdef PMFRAMELOG | 
|---|
| 483 | dprintf(("PMFRAME: WM_BUTTON2/3DOWN")); | 
|---|
| 484 | #endif | 
|---|
| 485 | if (win32wnd->isChild()) goto RunDefWndProc; | 
|---|
| 486 | else goto RunDefFrameProc; | 
|---|
| 487 |  | 
|---|
| 488 | case WM_PAINT: | 
|---|
| 489 | #ifdef PMFRAMELOG | 
|---|
| 490 | dprintf(("PMFRAME: WM_PAINT")); | 
|---|
| 491 | #endif | 
|---|
| 492 | if (!win32wnd->isChild()) | 
|---|
| 493 | { | 
|---|
| 494 | if (CanDrawSizeBox(win32wnd)) | 
|---|
| 495 | { | 
|---|
| 496 | MRESULT res; | 
|---|
| 497 | HPS hps; | 
|---|
| 498 | RECTL rect; | 
|---|
| 499 |  | 
|---|
| 500 | RestoreOS2TIB(); | 
|---|
| 501 | res = OldFrameProc(hwnd,msg,mp1,mp2); | 
|---|
| 502 | SetWin32TIB(); | 
|---|
| 503 |  | 
|---|
| 504 | GetSizeBox(win32wnd,&rect); | 
|---|
| 505 | hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS); | 
|---|
| 506 | DrawSizeBox(hps,rect); | 
|---|
| 507 | WinReleasePS(hps); | 
|---|
| 508 |  | 
|---|
| 509 | RestoreOS2TIB(); | 
|---|
| 510 | return res; | 
|---|
| 511 | } | 
|---|
| 512 | else goto RunDefFrameProc; | 
|---|
| 513 | } | 
|---|
| 514 | else | 
|---|
| 515 | { | 
|---|
| 516 | RECTL rect; | 
|---|
| 517 | HPS hps; | 
|---|
| 518 |  | 
|---|
| 519 | RestoreOS2TIB(); | 
|---|
| 520 | OldFrameProc(hwnd,msg,mp1,mp2); | 
|---|
| 521 | SetWin32TIB(); | 
|---|
| 522 |  | 
|---|
| 523 | WinQueryWindowRect(hwnd,&rect); | 
|---|
| 524 | rect.xRight = rect.xRight-rect.xLeft; | 
|---|
| 525 | rect.yTop = rect.yTop-rect.yBottom; | 
|---|
| 526 | rect.xLeft = rect.yBottom = 0; | 
|---|
| 527 | hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS); | 
|---|
| 528 | DrawFrame(hps,&rect,win32wnd); | 
|---|
| 529 | WinReleasePS(hps); | 
|---|
| 530 |  | 
|---|
| 531 | RestoreOS2TIB(); | 
|---|
| 532 | return (MRESULT)0; | 
|---|
| 533 | } | 
|---|
| 534 |  | 
|---|
| 535 | default: | 
|---|
| 536 | RestoreOS2TIB(); | 
|---|
| 537 | return OldFrameProc(hwnd,msg,mp1,mp2); | 
|---|
| 538 | } | 
|---|
| 539 |  | 
|---|
| 540 | RestoreOS2TIB(); | 
|---|
| 541 | return (MRESULT)FALSE; | 
|---|
| 542 |  | 
|---|
| 543 | RunDefFrameProc: | 
|---|
| 544 | RestoreOS2TIB(); | 
|---|
| 545 | return OldFrameProc(hwnd,msg,mp1,mp2); | 
|---|
| 546 |  | 
|---|
| 547 | RunDefWndProc: | 
|---|
| 548 | RestoreOS2TIB(); | 
|---|
| 549 | return WinDefWindowProc(hwnd,msg,mp1,mp2); | 
|---|
| 550 | } | 
|---|
| 551 |  | 
|---|
| 552 | PVOID FrameSubclassFrameWindow(Win32BaseWindow *win32wnd) | 
|---|
| 553 | { | 
|---|
| 554 | return WinSubclassWindow(win32wnd->getOS2FrameWindowHandle(),PFNWP(Win32FrameProc)); | 
|---|
| 555 | } | 
|---|
| 556 |  | 
|---|
| 557 | VOID FrameGetBorderSize(Win32BaseWindow *win32wnd,PWPOINT pSize) | 
|---|
| 558 | { | 
|---|
| 559 | WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_QUERYBORDERSIZE,(MPARAM)pSize,(MPARAM)0); | 
|---|
| 560 | } | 
|---|
| 561 |  | 
|---|
| 562 | VOID FrameSetBorderSize(Win32BaseWindow *win32wnd,BOOL resize) | 
|---|
| 563 | { | 
|---|
| 564 | POINTL point; | 
|---|
| 565 |  | 
|---|
| 566 | if (!resize) | 
|---|
| 567 | { | 
|---|
| 568 | WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight()); | 
|---|
| 569 |  | 
|---|
| 570 | return; | 
|---|
| 571 | } | 
|---|
| 572 |  | 
|---|
| 573 | FrameGetBorderSize(win32wnd,&point); | 
|---|
| 574 | WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight()); | 
|---|
| 575 | if (point.x != win32wnd->getBorderWidth() || point.y != win32wnd->getBorderHeight()) | 
|---|
| 576 | { | 
|---|
| 577 | INT xDiff = win32wnd->getBorderWidth()-point.x; | 
|---|
| 578 | INT yDiff = win32wnd->getBorderHeight()-point.y; | 
|---|
| 579 | SWP swp; | 
|---|
| 580 |  | 
|---|
| 581 | WinQueryWindowPos(win32wnd->getOS2FrameWindowHandle(),&swp); | 
|---|
| 582 | swp.x  += xDiff; | 
|---|
| 583 | swp.y  += yDiff; | 
|---|
| 584 | swp.cx -= 2*xDiff; | 
|---|
| 585 | swp.cy -= 2*yDiff; | 
|---|
| 586 | WinSetWindowPos(win32wnd->getOS2FrameWindowHandle(),0,swp.x,swp.y,swp.cx,swp.cy,SWP_MOVE | SWP_SIZE); | 
|---|
| 587 | } | 
|---|
| 588 | } | 
|---|
| 589 |  | 
|---|
| 590 | UINT FrameGetDefSizeBorderSize(VOID) | 
|---|
| 591 | { | 
|---|
| 592 | return WinQuerySysValue(HWND_DESKTOP,SV_CXSIZEBORDER); | 
|---|
| 593 | } | 
|---|