| 1 | /* $Id: pmframe.cpp,v 1.28 1999-12-19 17:46:24 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 "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 | #define GCL_STYLE_W (-26)
|
|---|
| 30 | #define CS_VREDRAW_W 0x0001
|
|---|
| 31 | #define CS_HREDRAW_W 0x0002
|
|---|
| 32 |
|
|---|
| 33 | //******************************************************************************
|
|---|
| 34 | //******************************************************************************
|
|---|
| 35 | VOID Draw3DRect(HPS hps,RECTL rect,LONG colorBR,LONG colorTL)
|
|---|
| 36 | {
|
|---|
| 37 | POINTL point;
|
|---|
| 38 |
|
|---|
| 39 | GpiSetColor(hps,colorBR);
|
|---|
| 40 | point.x = rect.xLeft;
|
|---|
| 41 | point.y = rect.yBottom;
|
|---|
| 42 | GpiMove(hps,&point);
|
|---|
| 43 | point.x = rect.xRight-1;
|
|---|
| 44 | GpiLine(hps,&point);
|
|---|
| 45 | point.y = rect.yTop-1;
|
|---|
| 46 | GpiLine(hps,&point);
|
|---|
| 47 | GpiSetColor(hps,colorTL);
|
|---|
| 48 | point.x--;
|
|---|
| 49 | GpiMove(hps,&point);
|
|---|
| 50 | point.x = rect.xLeft;
|
|---|
| 51 | GpiLine(hps,&point);
|
|---|
| 52 | point.y = rect.yBottom+1;
|
|---|
| 53 | GpiLine(hps,&point);
|
|---|
| 54 | }
|
|---|
| 55 | //******************************************************************************
|
|---|
| 56 | //******************************************************************************
|
|---|
| 57 | inline VOID DeflateRect(RECTL *rect)
|
|---|
| 58 | {
|
|---|
| 59 | rect->xLeft++;
|
|---|
| 60 | rect->xRight--;
|
|---|
| 61 | rect->yTop--;
|
|---|
| 62 | rect->yBottom++;
|
|---|
| 63 | }
|
|---|
| 64 | //******************************************************************************
|
|---|
| 65 | //******************************************************************************
|
|---|
| 66 | VOID DrawFrame(HPS hps,RECTL *rect,Win32BaseWindow *win32wnd)
|
|---|
| 67 | {
|
|---|
| 68 | LONG clrWhite,clrBlack,clrDark,clrLight;
|
|---|
| 69 | POINTL point;
|
|---|
| 70 | DWORD dwExStyle = win32wnd->getExStyle();
|
|---|
| 71 | DWORD dwStyle = win32wnd->getStyle();
|
|---|
| 72 |
|
|---|
| 73 | //CB: todo: switch to RGB mode and use win colors
|
|---|
| 74 | clrWhite = CLR_WHITE;
|
|---|
| 75 | clrBlack = CLR_BLACK;
|
|---|
| 76 | clrLight = CLR_PALEGRAY;
|
|---|
| 77 | clrDark = CLR_DARKGRAY;
|
|---|
| 78 |
|
|---|
| 79 | if (dwExStyle & WS_EX_CLIENTEDGE_W)
|
|---|
| 80 | {
|
|---|
| 81 | Draw3DRect(hps,*rect,clrWhite,clrDark);
|
|---|
| 82 | DeflateRect(rect);
|
|---|
| 83 | Draw3DRect(hps,*rect,clrLight,clrBlack);
|
|---|
| 84 | }
|
|---|
| 85 | else if (dwExStyle & WS_EX_DLGMODALFRAME_W)
|
|---|
| 86 | {
|
|---|
| 87 | Draw3DRect(hps,*rect,clrBlack,clrLight);
|
|---|
| 88 | DeflateRect(rect);
|
|---|
| 89 | Draw3DRect(hps,*rect,clrDark,clrWhite);
|
|---|
| 90 | DeflateRect(rect);
|
|---|
| 91 | Draw3DRect(hps,*rect,clrLight,clrLight);
|
|---|
| 92 | }
|
|---|
| 93 | else if (dwExStyle & WS_EX_STATICEDGE_W)
|
|---|
| 94 | {
|
|---|
| 95 | Draw3DRect(hps,*rect,clrWhite,clrDark);
|
|---|
| 96 | }
|
|---|
| 97 | else if (dwExStyle & WS_EX_WINDOWEDGE_W);
|
|---|
| 98 | else if (dwStyle & WS_BORDER_W)
|
|---|
| 99 | {
|
|---|
| 100 | Draw3DRect(hps,*rect,clrBlack,clrBlack);
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | DeflateRect(rect);
|
|---|
| 104 | }
|
|---|
| 105 | //******************************************************************************
|
|---|
| 106 | //******************************************************************************
|
|---|
| 107 | BOOL CanDrawSizeBox(Win32BaseWindow *win32wnd)
|
|---|
| 108 | {
|
|---|
| 109 | return (win32wnd->getStyle() & WS_SIZEBOX_W && WinQueryWindowULong(win32wnd->getOS2FrameWindowHandle(),QWL_STYLE) & FS_SIZEBORDER
|
|---|
| 110 | && win32wnd->getVertScrollHandle() && WinQueryWindow(win32wnd->getVertScrollHandle(),QW_PARENT) == win32wnd->getOS2FrameWindowHandle()
|
|---|
| 111 | && win32wnd->getHorzScrollHandle() && WinQueryWindow(win32wnd->getHorzScrollHandle(),QW_PARENT) == win32wnd->getOS2FrameWindowHandle());
|
|---|
| 112 | }
|
|---|
| 113 | //******************************************************************************
|
|---|
| 114 | //******************************************************************************
|
|---|
| 115 | VOID GetSizeBox(Win32BaseWindow *win32wnd,RECTL *rect)
|
|---|
| 116 | {
|
|---|
| 117 | SWP swpHorz,swpVert;
|
|---|
| 118 |
|
|---|
| 119 | WinQueryWindowPos(win32wnd->getVertScrollHandle(),&swpVert);
|
|---|
| 120 | WinQueryWindowPos(win32wnd->getHorzScrollHandle(),&swpHorz);
|
|---|
| 121 | rect->xLeft = swpVert.x;
|
|---|
| 122 | rect->xRight = swpVert.x+swpVert.cx;
|
|---|
| 123 | rect->yTop = swpHorz.y+swpHorz.cy;
|
|---|
| 124 | rect->yBottom = swpHorz.y;
|
|---|
| 125 | }
|
|---|
| 126 | //******************************************************************************
|
|---|
| 127 | //******************************************************************************
|
|---|
| 128 | BOOL InSizeBox(Win32BaseWindow *win32wnd,POINTS *points)
|
|---|
| 129 | {
|
|---|
| 130 | if (CanDrawSizeBox(win32wnd))
|
|---|
| 131 | {
|
|---|
| 132 | RECTL rect;
|
|---|
| 133 | POINTL point;
|
|---|
| 134 |
|
|---|
| 135 | point.x = points->x;
|
|---|
| 136 | point.y = points->y;
|
|---|
| 137 | GetSizeBox(win32wnd,&rect);
|
|---|
| 138 | return (WinPtInRect(GetThreadHAB(),&rect,&point));
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | return FALSE;
|
|---|
| 142 | }
|
|---|
| 143 | //******************************************************************************
|
|---|
| 144 | //******************************************************************************
|
|---|
| 145 | VOID DrawSizeBox(HPS hps,RECTL rect)
|
|---|
| 146 | {
|
|---|
| 147 | POINTL p1,p2;
|
|---|
| 148 | LONG clrDark = CLR_DARKGRAY,clrWhite = CLR_WHITE;
|
|---|
| 149 | INT x;
|
|---|
| 150 |
|
|---|
| 151 | //CB: todo: switch to RGB mode and use win colors
|
|---|
| 152 | WinFillRect(hps,&rect,SYSCLR_DIALOGBACKGROUND);
|
|---|
| 153 | p1.x = rect.xRight-2;
|
|---|
| 154 | p1.y = rect.yBottom;
|
|---|
| 155 | p2.x = rect.xRight-1;
|
|---|
| 156 | p2.y = rect.yBottom+1;
|
|---|
| 157 | for (x = 0;x < 3;x++)
|
|---|
| 158 | {
|
|---|
| 159 | GpiSetColor(hps,clrDark);
|
|---|
| 160 | GpiMove(hps,&p1);
|
|---|
| 161 | GpiLine(hps,&p2);
|
|---|
| 162 | p1.x--;
|
|---|
| 163 | p2.y++;
|
|---|
| 164 | GpiMove(hps,&p1);
|
|---|
| 165 | GpiLine(hps,&p2);
|
|---|
| 166 | GpiSetColor(hps,clrWhite);
|
|---|
| 167 | p1.x--;
|
|---|
| 168 | p2.y++;
|
|---|
| 169 | GpiMove(hps,&p1);
|
|---|
| 170 | GpiLine(hps,&p2);
|
|---|
| 171 | p1.x -= 2;
|
|---|
| 172 | p2.y += 2;
|
|---|
| 173 | }
|
|---|
| 174 | }
|
|---|
| 175 | //******************************************************************************
|
|---|
| 176 | //******************************************************************************
|
|---|
| 177 | void DrawActivate(Win32BaseWindow *win32wnd, HWND hwnd)
|
|---|
| 178 | {
|
|---|
| 179 | if (!win32wnd->isChild())
|
|---|
| 180 | {
|
|---|
| 181 | if (CanDrawSizeBox(win32wnd))
|
|---|
| 182 | {
|
|---|
| 183 | HPS hps;
|
|---|
| 184 | RECTL rect;
|
|---|
| 185 |
|
|---|
| 186 | GetSizeBox(win32wnd,&rect);
|
|---|
| 187 | hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
|
|---|
| 188 | DrawSizeBox(hps,rect);
|
|---|
| 189 | WinReleasePS(hps);
|
|---|
| 190 |
|
|---|
| 191 | }
|
|---|
| 192 | }
|
|---|
| 193 | else
|
|---|
| 194 | {
|
|---|
| 195 | HPS hps;
|
|---|
| 196 | RECTL rect;
|
|---|
| 197 |
|
|---|
| 198 | WinQueryWindowRect(hwnd,&rect);
|
|---|
| 199 | rect.xRight = rect.xRight-rect.xLeft;
|
|---|
| 200 | rect.yTop = rect.yTop-rect.yBottom;
|
|---|
| 201 | rect.xLeft = rect.yBottom = 0;
|
|---|
| 202 | hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
|
|---|
| 203 | DrawFrame(hps,&rect,win32wnd);
|
|---|
| 204 | WinReleasePS(hps);
|
|---|
| 205 | }
|
|---|
| 206 | }
|
|---|
| 207 | //******************************************************************************
|
|---|
| 208 | //******************************************************************************
|
|---|
| 209 | void FrameTrackFrame(Win32BaseWindow *win32wnd,BOOL lefttop)
|
|---|
| 210 | {
|
|---|
| 211 | INT flags = lefttop ? (TF_LEFT | TF_TOP):(TF_RIGHT | TF_BOTTOM);
|
|---|
| 212 |
|
|---|
| 213 | WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_TRACKFRAME,(MPARAM)flags,(MPARAM)0);
|
|---|
| 214 | }
|
|---|
| 215 | //******************************************************************************
|
|---|
| 216 | // used by statusbar control
|
|---|
| 217 | //******************************************************************************
|
|---|
| 218 | VOID WINAPI TrackWin32Window(HWND hwnd,BOOL lefttop)
|
|---|
| 219 | {
|
|---|
| 220 | Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 221 | INT flags = lefttop ? (TF_LEFT | TF_TOP):(TF_RIGHT | TF_BOTTOM);
|
|---|
| 222 |
|
|---|
| 223 | if (!win32wnd) return;
|
|---|
| 224 |
|
|---|
| 225 | WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_TRACKFRAME,(MPARAM)flags,(MPARAM)0);
|
|---|
| 226 | }
|
|---|
| 227 | //******************************************************************************
|
|---|
| 228 | //Win32 frame message handler
|
|---|
| 229 | //******************************************************************************
|
|---|
| 230 | MRESULT EXPENTRY Win32FrameProc(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
|
|---|
| 231 | {
|
|---|
| 232 | Win32BaseWindow *win32wnd;
|
|---|
| 233 | PFNWP OldFrameProc;
|
|---|
| 234 | MRESULT rc;
|
|---|
| 235 |
|
|---|
| 236 | SetWin32TIB();
|
|---|
| 237 |
|
|---|
| 238 | win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
|
|---|
| 239 |
|
|---|
| 240 | if(win32wnd == NULL || !win32wnd->getOldFrameProc())
|
|---|
| 241 | {
|
|---|
| 242 | dprintf(("Invalid win32wnd pointer for frame %x!!", hwnd));
|
|---|
| 243 | goto RunDefWndProc;
|
|---|
| 244 | }
|
|---|
| 245 |
|
|---|
| 246 | OldFrameProc = (PFNWP)win32wnd->getOldFrameProc();
|
|---|
| 247 |
|
|---|
| 248 | switch(msg)
|
|---|
| 249 | {
|
|---|
| 250 | case WM_ADJUSTWINDOWPOS:
|
|---|
| 251 | {
|
|---|
| 252 | PSWP pswp = (PSWP)mp1;
|
|---|
| 253 | SWP swpOld;
|
|---|
| 254 | WINDOWPOS wp;
|
|---|
| 255 | HWND hParent = NULLHANDLE, hwndAfter;
|
|---|
| 256 |
|
|---|
| 257 | 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));
|
|---|
| 258 |
|
|---|
| 259 | //CB: show dialog in front of owner
|
|---|
| 260 | if (win32wnd->IsModalDialogOwner())
|
|---|
| 261 | {
|
|---|
| 262 | pswp->fl |= SWP_ZORDER;
|
|---|
| 263 | pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
|
|---|
| 264 | if (pswp->fl & SWP_ACTIVATE)
|
|---|
| 265 | {
|
|---|
| 266 | pswp->fl &= ~SWP_ACTIVATE;
|
|---|
| 267 | WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
|
|---|
| 268 | }
|
|---|
| 269 | }
|
|---|
| 270 |
|
|---|
| 271 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
|---|
| 272 | goto RunDefFrameProc;
|
|---|
| 273 |
|
|---|
| 274 | if(!win32wnd->CanReceiveSizeMsgs()) {
|
|---|
| 275 | //SvL: Doing this breaks button.exe, header4(a).exe & style.exe
|
|---|
| 276 | // goto RunDefFrameProc; //CB: must call def frame proc or frame control activation is broken
|
|---|
| 277 | break;
|
|---|
| 278 | }
|
|---|
| 279 |
|
|---|
| 280 | WinQueryWindowPos(hwnd, &swpOld);
|
|---|
| 281 |
|
|---|
| 282 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
|---|
| 283 | if (win32wnd->isChild()) {
|
|---|
| 284 | if(win32wnd->getParent()) {
|
|---|
| 285 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 286 | }
|
|---|
| 287 | else goto RunDefFrameProc;
|
|---|
| 288 | }
|
|---|
| 289 | }
|
|---|
| 290 | hwndAfter = pswp->hwndInsertBehind;
|
|---|
| 291 | OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
|
|---|
| 292 |
|
|---|
| 293 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 294 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 295 | {
|
|---|
| 296 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 297 | if(wndAfter) wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 298 | }
|
|---|
| 299 |
|
|---|
| 300 | //CB: problems with profmine titlebar tracking
|
|---|
| 301 | if(win32wnd->MsgPosChanging((LPARAM)&wp) == 0)
|
|---|
| 302 | {//app or default window handler changed wp
|
|---|
| 303 | dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
|
|---|
| 304 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 305 |
|
|---|
| 306 | OSLibMapWINDOWPOStoSWPFrame(&wp, pswp, &swpOld, hParent, hwnd);
|
|---|
| 307 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 308 | pswp->fl |= SWP_NOADJUST;
|
|---|
| 309 | pswp->hwndInsertBehind = hwndAfter;
|
|---|
| 310 | pswp->hwnd = hwnd;
|
|---|
| 311 |
|
|---|
| 312 | // goto RunDefFrameProc; //CB: must call def frame proc or frame control activation is broken
|
|---|
| 313 | RestoreOS2TIB();
|
|---|
| 314 | return (MRESULT)0xf;
|
|---|
| 315 | }
|
|---|
| 316 | goto RunDefFrameProc; //CB: must call def frame proc or frame control activation is broken
|
|---|
| 317 | }
|
|---|
| 318 |
|
|---|
| 319 | case WM_WINDOWPOSCHANGED:
|
|---|
| 320 | {
|
|---|
| 321 | PSWP pswp = (PSWP)mp1;
|
|---|
| 322 | SWP swpOld = *(pswp + 1);
|
|---|
| 323 | WINDOWPOS wp;
|
|---|
| 324 | HWND hParent = NULLHANDLE;
|
|---|
| 325 | LONG yDelta = pswp->cy - swpOld.cy;
|
|---|
| 326 | LONG xDelta = pswp->cx - swpOld.cx;
|
|---|
| 327 | LONG clientHeight;
|
|---|
| 328 |
|
|---|
| 329 | dprintf(("PMFRAME: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 330 |
|
|---|
| 331 | //Save height so WM_WINDOWPOSCHANGED handler in pmwindow.cpp
|
|---|
| 332 | //(for client) doesn't overwrite the client rectangle (breaks ydelta calculation)
|
|---|
| 333 | clientHeight = win32wnd->getWindowHeight();
|
|---|
| 334 |
|
|---|
| 335 | RestoreOS2TIB();
|
|---|
| 336 | rc = OldFrameProc(hwnd,msg,mp1,mp2);
|
|---|
| 337 | SetWin32TIB();
|
|---|
| 338 |
|
|---|
| 339 | if (win32wnd->getParent() && win32wnd->getParent()->InMovingChildren())
|
|---|
| 340 | goto PosChangedEnd; //same Win32 pos, only OS/2 pos changed
|
|---|
| 341 |
|
|---|
| 342 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
|---|
| 343 | goto PosChangedEnd;
|
|---|
| 344 |
|
|---|
| 345 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
|---|
| 346 | if (win32wnd->isChild()) {
|
|---|
| 347 | if(win32wnd->getParent()) {
|
|---|
| 348 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 349 | }
|
|---|
| 350 | else goto PosChangedEnd; //parent has just been destroyed
|
|---|
| 351 | }
|
|---|
| 352 | }
|
|---|
| 353 | OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
|
|---|
| 354 |
|
|---|
| 355 | //delta is difference between old and new client height
|
|---|
| 356 | yDelta = swpOld.cy - clientHeight;
|
|---|
| 357 |
|
|---|
| 358 | win32wnd->setWindowRect(wp.x, wp.y, wp.x+wp.cx, wp.y+wp.cy);
|
|---|
| 359 | win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
|
|---|
| 360 |
|
|---|
| 361 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 362 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 363 | {
|
|---|
| 364 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 365 | if(wndAfter) wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 | #if 0 //CB: PM does it now for us (-> WM_CALVALIDRECTS)
|
|---|
| 369 | // if you remove this code, delete *MovingChildren in Win32BaseWindow class
|
|---|
| 370 | if (yDelta != 0 || xDelta != 0)
|
|---|
| 371 | {
|
|---|
| 372 | HENUM henum = WinBeginEnumWindows(WinWindowFromID(hwnd,FID_CLIENT));
|
|---|
| 373 | SWP swp[10];
|
|---|
| 374 | int i = 0;
|
|---|
| 375 | HWND hwnd;
|
|---|
| 376 |
|
|---|
| 377 | win32wnd->setMovingChildren(TRUE);
|
|---|
| 378 | while ((hwnd = WinGetNextWindow(henum)) != NULLHANDLE)
|
|---|
| 379 | {
|
|---|
| 380 | WinQueryWindowPos(hwnd, &(swp[i]));
|
|---|
| 381 |
|
|---|
| 382 | #ifdef DEBUG
|
|---|
| 383 | Win32BaseWindow *window = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 384 | dprintf(("ENUMERATE %x delta %d (%d,%d) (%d,%d) %x", (window) ? window->getWindowHandle() : hwnd,
|
|---|
| 385 | yDelta, swp[i].x, swp[i].y, swp[i].cx, swp[i].cy, swp[i].fl));
|
|---|
| 386 | #endif
|
|---|
| 387 |
|
|---|
| 388 | //if(swp[i].y != 0) //CB: y value of 0 is valid!
|
|---|
| 389 | {
|
|---|
| 390 | //child window at offset <> 0 from client area -> offset now changes
|
|---|
| 391 | swp[i].y += yDelta;
|
|---|
| 392 | swp[i].fl = SWP_MOVE | SWP_NOADJUST;
|
|---|
| 393 | }
|
|---|
| 394 | //else child window with the same start coordinates as the client area
|
|---|
| 395 | //The app should resize it.
|
|---|
| 396 |
|
|---|
| 397 | if (i == 9)
|
|---|
| 398 | {
|
|---|
| 399 | WinSetMultWindowPos(GetThreadHAB(), swp, 10);
|
|---|
| 400 | i = 0;
|
|---|
| 401 | }
|
|---|
| 402 | else
|
|---|
| 403 | {
|
|---|
| 404 | i++;
|
|---|
| 405 | }
|
|---|
| 406 | }
|
|---|
| 407 |
|
|---|
| 408 | WinEndEnumWindows(henum);
|
|---|
| 409 |
|
|---|
| 410 | if (i)
|
|---|
| 411 | WinSetMultWindowPos(GetThreadHAB(), swp, i);
|
|---|
| 412 | win32wnd->setMovingChildren(FALSE);
|
|---|
| 413 | }
|
|---|
| 414 | if (yDelta != 0)
|
|---|
| 415 | {
|
|---|
| 416 | POINT pt;
|
|---|
| 417 | if(GetCaretPos (&pt) == TRUE)
|
|---|
| 418 | {
|
|---|
| 419 | pt.y -= yDelta;
|
|---|
| 420 | SetCaretPos (pt.x, pt.y);
|
|---|
| 421 | }
|
|---|
| 422 | }
|
|---|
| 423 | #endif
|
|---|
| 424 | if(!win32wnd->CanReceiveSizeMsgs())
|
|---|
| 425 | goto PosChangedEnd;
|
|---|
| 426 |
|
|---|
| 427 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 428 |
|
|---|
| 429 | PosChangedEnd:
|
|---|
| 430 | RestoreOS2TIB();
|
|---|
| 431 | return rc;
|
|---|
| 432 | }
|
|---|
| 433 |
|
|---|
| 434 | case WM_CALCVALIDRECTS:
|
|---|
| 435 | {
|
|---|
| 436 | PRECTL oldRect = (PRECTL)mp1,newRect = oldRect+1;
|
|---|
| 437 | UINT res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
|
|---|
| 438 |
|
|---|
| 439 | //CB: only used if CS_SIZEDRAW isn't set
|
|---|
| 440 | // PM moves children -> fast, no flickering (if redraw flags not set)
|
|---|
| 441 | if (win32wnd->getWindowClass())
|
|---|
| 442 | {
|
|---|
| 443 | DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
|
|---|
| 444 |
|
|---|
| 445 | if (dwStyle & CS_HREDRAW_W && newRect->xRight-newRect->xLeft != oldRect->xRight-oldRect->xLeft)
|
|---|
| 446 | res |= CVR_REDRAW;
|
|---|
| 447 | else if (dwStyle & CS_VREDRAW_W && newRect->yTop-newRect->yBottom != oldRect->yTop-oldRect->yBottom)
|
|---|
| 448 | res |= CVR_REDRAW;
|
|---|
| 449 | } else res |= CVR_REDRAW;
|
|---|
| 450 |
|
|---|
| 451 | //CB: PM updates window frame (and unfortunately all other frame controls)
|
|---|
| 452 | RestoreOS2TIB();
|
|---|
| 453 | OldFrameProc(hwnd,msg,mp1,mp2);
|
|---|
| 454 | SetWin32TIB();
|
|---|
| 455 |
|
|---|
| 456 | RestoreOS2TIB();
|
|---|
| 457 | return (MRESULT)res;
|
|---|
| 458 | }
|
|---|
| 459 |
|
|---|
| 460 | case WM_ACTIVATE:
|
|---|
| 461 | {
|
|---|
| 462 | HWND hwndTitle;
|
|---|
| 463 | USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
|
|---|
| 464 |
|
|---|
| 465 | //CB: emulate WM_ACTIVATE -> no flickering
|
|---|
| 466 | hwndTitle = WinWindowFromID(hwnd,FID_TITLEBAR);
|
|---|
| 467 | if (hwndTitle) WinSendMsg(hwndTitle,TBM_SETHILITE,mp1,MPVOID);
|
|---|
| 468 |
|
|---|
| 469 | WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),WM_ACTIVATE,mp1,mp2);
|
|---|
| 470 | WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
|---|
| 471 |
|
|---|
| 472 | //CB: show owner behind the dialog
|
|---|
| 473 | if (win32wnd->IsModalDialog())
|
|---|
| 474 | {
|
|---|
| 475 | Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
|
|---|
| 476 |
|
|---|
| 477 | if (topOwner) WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
|
|---|
| 478 | }
|
|---|
| 479 |
|
|---|
| 480 | RestoreOS2TIB();
|
|---|
| 481 | return 0;
|
|---|
| 482 | }
|
|---|
| 483 |
|
|---|
| 484 | case WM_DESTROY:
|
|---|
| 485 | #ifdef PMFRAMELOG
|
|---|
| 486 | dprintf(("PMFRAME: WM_DESTROY"));
|
|---|
| 487 | #endif
|
|---|
| 488 | WinSubclassWindow(hwnd,OldFrameProc);
|
|---|
| 489 | win32wnd->setOldFrameProc(NULL);
|
|---|
| 490 | goto RunDefFrameProc;
|
|---|
| 491 |
|
|---|
| 492 | case WM_MOUSEMOVE:
|
|---|
| 493 | if (InSizeBox(win32wnd,(POINTS*)&mp1))
|
|---|
| 494 | {
|
|---|
| 495 | WinSetPointer(HWND_DESKTOP,WinQuerySysPointer(HWND_DESKTOP,SPTR_SIZENWSE,FALSE));
|
|---|
| 496 | RestoreOS2TIB();
|
|---|
| 497 | return (MRESULT)TRUE;
|
|---|
| 498 | }
|
|---|
| 499 | else if (win32wnd->isChild()) goto RunDefWndProc;
|
|---|
| 500 | else goto RunDefFrameProc;
|
|---|
| 501 |
|
|---|
| 502 | case WM_BUTTON1DOWN:
|
|---|
| 503 | #ifdef PMFRAMELOG
|
|---|
| 504 | dprintf(("PMFRAME: WM_BUTTON1DOWN"));
|
|---|
| 505 | #endif
|
|---|
| 506 |
|
|---|
| 507 | if (InSizeBox(win32wnd,(POINTS*)&mp1))
|
|---|
| 508 | {
|
|---|
| 509 | WinSetActiveWindow(HWND_DESKTOP,hwnd);
|
|---|
| 510 | WinSendMsg(hwnd,WM_TRACKFRAME,(MPARAM)(TF_RIGHT | TF_BOTTOM),(MPARAM)0);
|
|---|
| 511 | RestoreOS2TIB();
|
|---|
| 512 | return (MRESULT)TRUE;
|
|---|
| 513 | }
|
|---|
| 514 | else if (win32wnd->isChild()) goto RunDefWndProc;
|
|---|
| 515 | else goto RunDefFrameProc;
|
|---|
| 516 |
|
|---|
| 517 | case WM_BUTTON2DOWN:
|
|---|
| 518 | case WM_BUTTON3DOWN:
|
|---|
| 519 | #ifdef PMFRAMELOG
|
|---|
| 520 | dprintf(("PMFRAME: WM_BUTTON2/3DOWN"));
|
|---|
| 521 | #endif
|
|---|
| 522 | if (win32wnd->isChild()) goto RunDefWndProc;
|
|---|
| 523 | else goto RunDefFrameProc;
|
|---|
| 524 |
|
|---|
| 525 | case WM_PAINT:
|
|---|
| 526 | #ifdef PMFRAMELOG
|
|---|
| 527 | dprintf(("PMFRAME: WM_PAINT"));
|
|---|
| 528 | #endif
|
|---|
| 529 | if (!win32wnd->isChild())
|
|---|
| 530 | {
|
|---|
| 531 | if (CanDrawSizeBox(win32wnd))
|
|---|
| 532 | {
|
|---|
| 533 | MRESULT res;
|
|---|
| 534 | HPS hps;
|
|---|
| 535 | RECTL rect;
|
|---|
| 536 |
|
|---|
| 537 | RestoreOS2TIB();
|
|---|
| 538 | res = OldFrameProc(hwnd,msg,mp1,mp2);
|
|---|
| 539 | SetWin32TIB();
|
|---|
| 540 |
|
|---|
| 541 | GetSizeBox(win32wnd,&rect);
|
|---|
| 542 | hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
|
|---|
| 543 | DrawSizeBox(hps,rect);
|
|---|
| 544 | WinReleasePS(hps);
|
|---|
| 545 |
|
|---|
| 546 | RestoreOS2TIB();
|
|---|
| 547 | return res;
|
|---|
| 548 | }
|
|---|
| 549 | else goto RunDefFrameProc;
|
|---|
| 550 | }
|
|---|
| 551 | else
|
|---|
| 552 | {
|
|---|
| 553 | RECTL rect;
|
|---|
| 554 | HPS hps;
|
|---|
| 555 |
|
|---|
| 556 | RestoreOS2TIB();
|
|---|
| 557 | OldFrameProc(hwnd,msg,mp1,mp2);
|
|---|
| 558 | SetWin32TIB();
|
|---|
| 559 |
|
|---|
| 560 | WinQueryWindowRect(hwnd,&rect);
|
|---|
| 561 | rect.xRight = rect.xRight-rect.xLeft;
|
|---|
| 562 | rect.yTop = rect.yTop-rect.yBottom;
|
|---|
| 563 | rect.xLeft = rect.yBottom = 0;
|
|---|
| 564 | hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
|
|---|
| 565 | DrawFrame(hps,&rect,win32wnd);
|
|---|
| 566 | WinReleasePS(hps);
|
|---|
| 567 |
|
|---|
| 568 | RestoreOS2TIB();
|
|---|
| 569 | return (MRESULT)0;
|
|---|
| 570 | }
|
|---|
| 571 |
|
|---|
| 572 | default:
|
|---|
| 573 | RestoreOS2TIB();
|
|---|
| 574 | return OldFrameProc(hwnd,msg,mp1,mp2);
|
|---|
| 575 | }
|
|---|
| 576 |
|
|---|
| 577 | RestoreOS2TIB();
|
|---|
| 578 | return (MRESULT)FALSE;
|
|---|
| 579 |
|
|---|
| 580 | RunDefFrameProc:
|
|---|
| 581 | RestoreOS2TIB();
|
|---|
| 582 | return OldFrameProc(hwnd,msg,mp1,mp2);
|
|---|
| 583 |
|
|---|
| 584 | RunDefWndProc:
|
|---|
| 585 | RestoreOS2TIB();
|
|---|
| 586 | return WinDefWindowProc(hwnd,msg,mp1,mp2);
|
|---|
| 587 | }
|
|---|
| 588 |
|
|---|
| 589 | PVOID FrameSubclassFrameWindow(Win32BaseWindow *win32wnd)
|
|---|
| 590 | {
|
|---|
| 591 | return WinSubclassWindow(win32wnd->getOS2FrameWindowHandle(),PFNWP(Win32FrameProc));
|
|---|
| 592 | }
|
|---|
| 593 |
|
|---|
| 594 | VOID FrameGetBorderSize(Win32BaseWindow *win32wnd,PWPOINT pSize)
|
|---|
| 595 | {
|
|---|
| 596 | WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_QUERYBORDERSIZE,(MPARAM)pSize,(MPARAM)0);
|
|---|
| 597 | }
|
|---|
| 598 |
|
|---|
| 599 | VOID FrameSetBorderSize(Win32BaseWindow *win32wnd,BOOL resize)
|
|---|
| 600 | {
|
|---|
| 601 | POINTL point;
|
|---|
| 602 |
|
|---|
| 603 | if (!resize)
|
|---|
| 604 | {
|
|---|
| 605 | WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight());
|
|---|
| 606 |
|
|---|
| 607 | return;
|
|---|
| 608 | }
|
|---|
| 609 |
|
|---|
| 610 | FrameGetBorderSize(win32wnd,&point);
|
|---|
| 611 | WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight());
|
|---|
| 612 | if (point.x != win32wnd->getBorderWidth() || point.y != win32wnd->getBorderHeight())
|
|---|
| 613 | {
|
|---|
| 614 | INT xDiff = win32wnd->getBorderWidth()-point.x;
|
|---|
| 615 | INT yDiff = win32wnd->getBorderHeight()-point.y;
|
|---|
| 616 | SWP swp;
|
|---|
| 617 |
|
|---|
| 618 | WinQueryWindowPos(win32wnd->getOS2FrameWindowHandle(),&swp);
|
|---|
| 619 | swp.x += xDiff;
|
|---|
| 620 | swp.y += yDiff;
|
|---|
| 621 | swp.cx -= 2*xDiff;
|
|---|
| 622 | swp.cy -= 2*yDiff;
|
|---|
| 623 | WinSetWindowPos(win32wnd->getOS2FrameWindowHandle(),0,swp.x,swp.y,swp.cx,swp.cy,SWP_MOVE | SWP_SIZE);
|
|---|
| 624 | }
|
|---|
| 625 | }
|
|---|
| 626 |
|
|---|
| 627 | UINT FrameGetDefSizeBorderSize(VOID)
|
|---|
| 628 | {
|
|---|
| 629 | return WinQuerySysValue(HWND_DESKTOP,SV_CXSIZEBORDER);
|
|---|
| 630 | }
|
|---|
| 631 |
|
|---|
| 632 | BOOL FrameCreateScrollBars(Win32BaseWindow *win32wnd,BOOL createHorz,BOOL createVert,BOOL updateFrame,DWORD *flags)
|
|---|
| 633 | {
|
|---|
| 634 | HWND hwndHScroll = 0,hwndVScroll = 0;
|
|---|
| 635 | ULONG updateFlags = 0;
|
|---|
| 636 |
|
|---|
| 637 | if (createHorz)
|
|---|
| 638 | {
|
|---|
| 639 | 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);
|
|---|
| 640 | if (hwndHScroll) win32wnd->setHorzScrollHandle(hwndHScroll);
|
|---|
| 641 | else return FALSE;
|
|---|
| 642 | updateFlags = FCF_HORZSCROLL;
|
|---|
| 643 | }
|
|---|
| 644 |
|
|---|
| 645 | if (createVert)
|
|---|
| 646 | {
|
|---|
| 647 | 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);
|
|---|
| 648 | if (hwndVScroll) win32wnd->setVertScrollHandle(hwndVScroll); else
|
|---|
| 649 | {
|
|---|
| 650 | if (hwndHScroll) WinDestroyWindow(hwndHScroll);
|
|---|
| 651 |
|
|---|
| 652 | return FALSE;
|
|---|
| 653 | }
|
|---|
| 654 | updateFlags |= FCF_VERTSCROLL;
|
|---|
| 655 | }
|
|---|
| 656 |
|
|---|
| 657 | win32wnd->subclassScrollBars(hwndHScroll,hwndVScroll);
|
|---|
| 658 |
|
|---|
| 659 | if (updateFrame && updateFlags) WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)0,(MPARAM)0);
|
|---|
| 660 | if (flags) *flags = updateFlags;
|
|---|
| 661 |
|
|---|
| 662 | return TRUE;
|
|---|
| 663 | }
|
|---|
| 664 |
|
|---|
| 665 | VOID FrameGetScrollBarHandles(Win32BaseWindow *win32wnd,BOOL getHorz,BOOL getVert)
|
|---|
| 666 | {
|
|---|
| 667 | if (getHorz) win32wnd->setHorzScrollHandle(WinWindowFromID(win32wnd->getOS2FrameWindowHandle(),FID_HORZSCROLL));
|
|---|
| 668 | if (getVert) win32wnd->setVertScrollHandle(WinWindowFromID(win32wnd->getOS2FrameWindowHandle(),FID_VERTSCROLL));
|
|---|
| 669 | }
|
|---|
| 670 |
|
|---|
| 671 | BOOL FrameShowScrollBars(Win32BaseWindow *win32wnd,BOOL changeHorz,BOOL changeVert,BOOL fShow,BOOL updateFrame,DWORD *flags)
|
|---|
| 672 | {
|
|---|
| 673 | HWND hwndObj = WinQueryObjectWindow(HWND_DESKTOP);
|
|---|
| 674 | ULONG updateFlags = 0;
|
|---|
| 675 |
|
|---|
| 676 | if (changeHorz)
|
|---|
| 677 | {
|
|---|
| 678 | HWND hwndCurPar = WinQueryWindow(win32wnd->getHorzScrollHandle(),QW_PARENT);
|
|---|
| 679 |
|
|---|
| 680 | if ((fShow && hwndCurPar == hwndObj) || (!fShow && hwndCurPar != hwndObj))
|
|---|
| 681 | {
|
|---|
| 682 | WinSetParent(win32wnd->getHorzScrollHandle(),fShow ? win32wnd->getOS2FrameWindowHandle():HWND_OBJECT,FALSE);
|
|---|
| 683 | updateFlags |= FCF_HORZSCROLL;
|
|---|
| 684 | }
|
|---|
| 685 | }
|
|---|
| 686 |
|
|---|
| 687 | if (changeVert)
|
|---|
| 688 | {
|
|---|
| 689 | HWND hwndCurPar = WinQueryWindow(win32wnd->getVertScrollHandle(),QW_PARENT);
|
|---|
| 690 |
|
|---|
| 691 | if ((fShow && hwndCurPar == hwndObj) || (!fShow && hwndCurPar != hwndObj))
|
|---|
| 692 | {
|
|---|
| 693 | WinSetParent(win32wnd->getVertScrollHandle(),fShow ? win32wnd->getOS2FrameWindowHandle():HWND_OBJECT,FALSE);
|
|---|
| 694 | updateFlags |= FCF_VERTSCROLL;
|
|---|
| 695 | }
|
|---|
| 696 | }
|
|---|
| 697 |
|
|---|
| 698 | if (updateFrame && updateFlags) WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)updateFlags,(MPARAM)0);
|
|---|
| 699 | if (flags) *flags = updateFlags;
|
|---|
| 700 |
|
|---|
| 701 | return TRUE;
|
|---|
| 702 | }
|
|---|
| 703 |
|
|---|
| 704 | VOID FrameUpdateFrame(Win32BaseWindow *win32wnd,DWORD flags)
|
|---|
| 705 | {
|
|---|
| 706 | WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)flags,(MPARAM)0);
|
|---|
| 707 | }
|
|---|
| 708 |
|
|---|