| 1 | /* $Id: dc.cpp,v 1.54 2000-04-07 12:55:15 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * DC functions for USER32
|
|---|
| 5 | *
|
|---|
| 6 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 7 | *
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | /*****************************************************************************
|
|---|
| 11 | * Includes *
|
|---|
| 12 | *****************************************************************************/
|
|---|
| 13 |
|
|---|
| 14 | #include <odin.h>
|
|---|
| 15 |
|
|---|
| 16 | #define INCL_WIN
|
|---|
| 17 | #define INCL_GPI
|
|---|
| 18 | #define INCL_GREALL
|
|---|
| 19 | #define INCL_DEV
|
|---|
| 20 | #include <os2wrap.h>
|
|---|
| 21 | //#include <pmddi.h>
|
|---|
| 22 | #include <stdlib.h>
|
|---|
| 23 |
|
|---|
| 24 | #include <win32type.h>
|
|---|
| 25 | #include <win32api.h>
|
|---|
| 26 | #include <winconst.h>
|
|---|
| 27 | #include <misc.h>
|
|---|
| 28 | #include <win32wbase.h>
|
|---|
| 29 | #include <math.h>
|
|---|
| 30 | #include <limits.h>
|
|---|
| 31 | #include "oslibwin.h"
|
|---|
| 32 | #include "oslibmsg.h"
|
|---|
| 33 | #include <dcdata.h>
|
|---|
| 34 |
|
|---|
| 35 | #define INCLUDED_BY_DC
|
|---|
| 36 | #include "dc.h"
|
|---|
| 37 |
|
|---|
| 38 | #define DBG_LOCALLOG DBG_dc
|
|---|
| 39 | #include "dbglocal.h"
|
|---|
| 40 |
|
|---|
| 41 | #ifndef DEVESC_SETPS
|
|---|
| 42 | #define DEVESC_SETPS 49149L
|
|---|
| 43 | #endif
|
|---|
| 44 |
|
|---|
| 45 | #define FLOAT_TO_FIXED(x) ((FIXED) ((x) * 65536.0))
|
|---|
| 46 | #define MICRO_HPS_TO_HDC(x) ((x) & 0xFFFFFFFE)
|
|---|
| 47 |
|
|---|
| 48 | #define PMRECT_FROM_WINRECT( pmRect, winRect ) \
|
|---|
| 49 | { \
|
|---|
| 50 | (pmRect).xLeft = (winRect).left; \
|
|---|
| 51 | (pmRect).yBottom = (winRect).bottom; \
|
|---|
| 52 | (pmRect).xRight = (winRect).right; \
|
|---|
| 53 | (pmRect).yTop = (winRect).top; \
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | #define WINRECT_FROM_PMRECT( winRect, pmRect ) \
|
|---|
| 57 | { \
|
|---|
| 58 | (winRect).left = (pmRect).xLeft; \
|
|---|
| 59 | (winRect).top = (pmRect).yTop; \
|
|---|
| 60 | (winRect).right = (pmRect).xRight; \
|
|---|
| 61 | (winRect).bottom = (pmRect).yBottom; \
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | #define MEM_HPS_MAX 768
|
|---|
| 65 |
|
|---|
| 66 | const XFORM_W XFORMIdentity = { 1.0, 0.0, 0.0, 1.0, 0, 0 };
|
|---|
| 67 | const MATRIXLF matrixlfIdentity = { 0x10000, 0, 0, 0, 0x10000, 0, 0, 0, 0};
|
|---|
| 68 |
|
|---|
| 69 | BOOL setPageXForm(Win32BaseWindow *wnd, pDCData pHps);
|
|---|
| 70 | BOOL changePageXForm(Win32BaseWindow *wnd, pDCData pHps, PPOINTL pValue, int x, int y, PPOINTL pPrev);
|
|---|
| 71 | LONG clientHeight(Win32BaseWindow *wnd, HWND hwnd, pDCData pHps);
|
|---|
| 72 |
|
|---|
| 73 | //******************************************************************************
|
|---|
| 74 | //******************************************************************************
|
|---|
| 75 | void TestWideLine (pDCData pHps)
|
|---|
| 76 | {
|
|---|
| 77 | const LOGPEN_W *pLogPen;
|
|---|
| 78 |
|
|---|
| 79 | pHps->isWideLine = FALSE;
|
|---|
| 80 | pLogPen = pHps->penIsExtPen ?
|
|---|
| 81 | &(pHps->lastPenObject->ExtPen.logpen) :
|
|---|
| 82 | &(pHps->lastPenObject->Pen.logpen);
|
|---|
| 83 |
|
|---|
| 84 | if (((pLogPen->lopnStyle & PS_STYLE_MASK_W) != PS_NULL_W) &&
|
|---|
| 85 | (pLogPen->lopnWidth.x > 0))
|
|---|
| 86 | {
|
|---|
| 87 | POINTL aptl[2] = { 0, 0, pLogPen->lopnWidth.x, pLogPen->lopnWidth.x };
|
|---|
| 88 |
|
|---|
| 89 | GpiConvert(pHps->hps, CVTC_WORLD, CVTC_DEVICE, 2, aptl);
|
|---|
| 90 |
|
|---|
| 91 | ULONG dx = abs(aptl[0].x - aptl[1].x);
|
|---|
| 92 | ULONG dy = abs(aptl[0].y - aptl[1].y);
|
|---|
| 93 |
|
|---|
| 94 | pHps->isWideLine = (dx > 1) || (dy > 1);
|
|---|
| 95 | }
|
|---|
| 96 | }
|
|---|
| 97 | //******************************************************************************
|
|---|
| 98 | //******************************************************************************
|
|---|
| 99 | void Calculate1PixelDelta(pDCData pHps)
|
|---|
| 100 | {
|
|---|
| 101 | POINTL aptl[2] = {0, 0, 1, 1};
|
|---|
| 102 |
|
|---|
| 103 | GpiConvert(pHps->hps, CVTC_DEVICE, CVTC_WORLD, 2, aptl);
|
|---|
| 104 | pHps->worldYDeltaFor1Pixel = (int)(aptl[1].y - aptl[0].y);
|
|---|
| 105 | pHps->worldXDeltaFor1Pixel = (int)(aptl[1].x - aptl[0].x); // 171182
|
|---|
| 106 | }
|
|---|
| 107 | //******************************************************************************
|
|---|
| 108 | //******************************************************************************
|
|---|
| 109 | int setMapMode(Win32BaseWindow *wnd, pDCData pHps, int mode)
|
|---|
| 110 | {
|
|---|
| 111 | int prevMode = 0;
|
|---|
| 112 | ULONG flOptions;
|
|---|
| 113 |
|
|---|
| 114 | switch (mode)
|
|---|
| 115 | {
|
|---|
| 116 | case MM_HIENGLISH_W : flOptions = PU_HIENGLISH; break;
|
|---|
| 117 | case MM_LOENGLISH_W : flOptions = PU_LOENGLISH; break;
|
|---|
| 118 | case MM_HIMETRIC_W : flOptions = PU_HIMETRIC ; break;
|
|---|
| 119 | case MM_LOMETRIC_W : flOptions = PU_LOMETRIC ; break;
|
|---|
| 120 | case MM_TEXT_W : flOptions = PU_PELS ; break;
|
|---|
| 121 | case MM_TWIPS_W : flOptions = PU_TWIPS ; break;
|
|---|
| 122 | case MM_ANISOTROPIC_W: flOptions = PU_PELS ; break;
|
|---|
| 123 | case MM_ISOTROPIC_W : flOptions = PU_LOMETRIC ; break;
|
|---|
| 124 | default:
|
|---|
| 125 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 126 | return FALSE;
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | prevMode = pHps->MapMode; /* store previous mode */
|
|---|
| 130 | pHps->MapMode = mode;
|
|---|
| 131 |
|
|---|
| 132 | if (mode == MM_TEXT_W)
|
|---|
| 133 | {
|
|---|
| 134 | pHps->viewportXExt =
|
|---|
| 135 | pHps->viewportYExt = 1.0;
|
|---|
| 136 | pHps->windowExt.cx =
|
|---|
| 137 | pHps->windowExt.cy = 1;
|
|---|
| 138 | }
|
|---|
| 139 | else if (mode != MM_ANISOTROPIC_W)
|
|---|
| 140 | {
|
|---|
| 141 | RECTL rectl;
|
|---|
| 142 | SIZEL sizel;
|
|---|
| 143 | ULONG data[3];
|
|---|
| 144 |
|
|---|
| 145 | data[0] = flOptions;
|
|---|
| 146 | data[1] = data[2] = 0;
|
|---|
| 147 |
|
|---|
| 148 | if (DevEscape(pHps->hdc ? pHps->hdc : pHps->hps, DEVESC_SETPS, 12, (PBYTE)data, 0, 0) == DEVESC_ERROR)
|
|---|
| 149 | {
|
|---|
| 150 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 151 | return 0;
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | GpiQueryPageViewport(pHps->hps, &rectl);
|
|---|
| 155 | pHps->viewportXExt = (double)rectl.xRight;
|
|---|
| 156 | pHps->viewportYExt = -(double)rectl.yTop;
|
|---|
| 157 |
|
|---|
| 158 | GreGetPageUnits(pHps->hdc? pHps->hdc : pHps->hps, &sizel);
|
|---|
| 159 | pHps->windowExt.cx = sizel.cx;
|
|---|
| 160 | pHps->windowExt.cy = sizel.cy;
|
|---|
| 161 |
|
|---|
| 162 | data[0] = PU_PELS;
|
|---|
| 163 | DevEscape(pHps->hdc ? pHps->hdc : pHps->hps, DEVESC_SETPS, 12, (PBYTE)data, 0, 0);
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | if (((prevMode != MM_ISOTROPIC_W) && (prevMode != MM_ANISOTROPIC_W)) &&
|
|---|
| 167 | ((mode == MM_ISOTROPIC_W) || (mode == MM_ANISOTROPIC_W)))
|
|---|
| 168 | {
|
|---|
| 169 | if (pHps->lWndXExtSave && pHps->lWndYExtSave)
|
|---|
| 170 | {
|
|---|
| 171 | changePageXForm (wnd, pHps, (PPOINTL)&pHps->windowExt,
|
|---|
| 172 | pHps->lWndXExtSave, pHps->lWndYExtSave, NULL );
|
|---|
| 173 | pHps->lWndXExtSave = pHps->lWndYExtSave = 0;
|
|---|
| 174 | }
|
|---|
| 175 | if (pHps->lVwpXExtSave && pHps->lVwpYExtSave)
|
|---|
| 176 | {
|
|---|
| 177 | changePageXForm (wnd, pHps, NULL,
|
|---|
| 178 | pHps->lVwpXExtSave, pHps->lVwpYExtSave, NULL );
|
|---|
| 179 | pHps->lVwpXExtSave = pHps->lVwpYExtSave = 0;
|
|---|
| 180 | }
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | setPageXForm(wnd, pHps);
|
|---|
| 184 |
|
|---|
| 185 | return prevMode;
|
|---|
| 186 | }
|
|---|
| 187 | //******************************************************************************
|
|---|
| 188 | //******************************************************************************
|
|---|
| 189 | BOOL setPageXForm(Win32BaseWindow *wnd, pDCData pHps)
|
|---|
| 190 | {
|
|---|
| 191 | MATRIXLF mlf;
|
|---|
| 192 | BOOL rc = TRUE;
|
|---|
| 193 |
|
|---|
| 194 | pHps->height = clientHeight(wnd, 0, pHps) - 1;
|
|---|
| 195 |
|
|---|
| 196 | double xScale = pHps->viewportXExt / (double)pHps->windowExt.cx;
|
|---|
| 197 | double yScale = pHps->viewportYExt / (double)pHps->windowExt.cy;
|
|---|
| 198 |
|
|---|
| 199 | mlf.fxM11 = FLOAT_TO_FIXED(xScale);
|
|---|
| 200 | mlf.fxM12 = 0;
|
|---|
| 201 | mlf.lM13 = 0;
|
|---|
| 202 | mlf.fxM21 = 0;
|
|---|
| 203 | mlf.fxM22 = FLOAT_TO_FIXED(yScale);
|
|---|
| 204 | mlf.lM23 = 0;
|
|---|
| 205 | mlf.lM31 = pHps->viewportOrg.x - (LONG)(pHps->windowOrg.x * xScale);
|
|---|
| 206 | mlf.lM32 = pHps->viewportOrg.y - (LONG)(pHps->windowOrg.y * yScale);
|
|---|
| 207 |
|
|---|
| 208 | pHps->isLeftLeft = mlf.fxM11 >= 0;
|
|---|
| 209 | pHps->isTopTop = mlf.fxM22 >= 0;
|
|---|
| 210 |
|
|---|
| 211 | BOOL bEnableYInversion = FALSE;
|
|---|
| 212 | if ((mlf.fxM22 > 0) ||
|
|---|
| 213 | ((pHps->graphicsMode == GM_ADVANCED_W) &&
|
|---|
| 214 | ((pHps->MapMode == MM_ANISOTROPIC_W) ||
|
|---|
| 215 | (pHps->MapMode == MM_ISOTROPIC_W))))
|
|---|
| 216 | {
|
|---|
| 217 | bEnableYInversion = TRUE;
|
|---|
| 218 | }
|
|---|
| 219 | else
|
|---|
| 220 | {
|
|---|
| 221 | bEnableYInversion = FALSE;
|
|---|
| 222 | mlf.lM32 = pHps->HPStoHDCInversionHeight + pHps->height - mlf.lM32;
|
|---|
| 223 | mlf.fxM22 = -mlf.fxM22;
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | if (!pHps->isMetaPS)
|
|---|
| 227 | // if ((!pHps->isMetaPS) ||
|
|---|
| 228 | // (pHps->pMetaFileObject && pHps->pMetaFileObject->isEnhanced()))
|
|---|
| 229 | rc = GpiSetDefaultViewMatrix(pHps->hps, 8, &mlf, TRANSFORM_REPLACE);
|
|---|
| 230 |
|
|---|
| 231 | if (bEnableYInversion)
|
|---|
| 232 | GpiEnableYInversion(pHps->hps, pHps->height + pHps->HPStoHDCInversionHeight);
|
|---|
| 233 | else
|
|---|
| 234 | GpiEnableYInversion(pHps->hps, 0);
|
|---|
| 235 |
|
|---|
| 236 | TestWideLine(pHps);
|
|---|
| 237 | Calculate1PixelDelta(pHps);
|
|---|
| 238 | return rc;
|
|---|
| 239 | }
|
|---|
| 240 | //******************************************************************************
|
|---|
| 241 | //******************************************************************************
|
|---|
| 242 | BOOL changePageXForm(Win32BaseWindow *wnd, pDCData pHps, PPOINTL pValue, int x, int y, PPOINTL pPrev)
|
|---|
| 243 | {
|
|---|
| 244 | BOOL result = FALSE;
|
|---|
| 245 |
|
|---|
| 246 | if (pValue)
|
|---|
| 247 | {
|
|---|
| 248 | if (pPrev)
|
|---|
| 249 | *pPrev = *pValue;
|
|---|
| 250 |
|
|---|
| 251 | if ((pValue->x == x) && (pValue->y == y)) {
|
|---|
| 252 | return TRUE;
|
|---|
| 253 | }
|
|---|
| 254 | pValue->x = x;
|
|---|
| 255 | pValue->y = y;
|
|---|
| 256 | }
|
|---|
| 257 | else
|
|---|
| 258 | {
|
|---|
| 259 | if (pPrev)
|
|---|
| 260 | {
|
|---|
| 261 | pPrev->x = (int)pHps->viewportXExt;
|
|---|
| 262 | pPrev->y = (int)pHps->viewportYExt;
|
|---|
| 263 | }
|
|---|
| 264 | pHps->viewportXExt = (double)x;
|
|---|
| 265 | pHps->viewportYExt = (double)y;
|
|---|
| 266 | }
|
|---|
| 267 |
|
|---|
| 268 | if (pHps->MapMode == MM_ISOTROPIC_W)
|
|---|
| 269 | {
|
|---|
| 270 | double xExt = fabs(pHps->viewportXExt);
|
|---|
| 271 | double yExt = fabs(pHps->viewportYExt);
|
|---|
| 272 | double sf = fabs((double)pHps->windowExt.cx / pHps->windowExt.cy);
|
|---|
| 273 |
|
|---|
| 274 | if (xExt > (yExt * sf))
|
|---|
| 275 | {
|
|---|
| 276 | xExt = yExt * sf;
|
|---|
| 277 |
|
|---|
| 278 | if ((double)LONG_MAX <= xExt) return (result);
|
|---|
| 279 |
|
|---|
| 280 | if (pHps->viewportXExt < 0.0)
|
|---|
| 281 | pHps->viewportXExt = -xExt;
|
|---|
| 282 | else
|
|---|
| 283 | pHps->viewportXExt = xExt;
|
|---|
| 284 | }
|
|---|
| 285 | else
|
|---|
| 286 | {
|
|---|
| 287 | yExt = xExt / sf;
|
|---|
| 288 |
|
|---|
| 289 | if ((double)LONG_MAX <= yExt) return (result);
|
|---|
| 290 |
|
|---|
| 291 | if (pHps->viewportYExt < 0.0)
|
|---|
| 292 | pHps->viewportYExt = -yExt;
|
|---|
| 293 | else
|
|---|
| 294 | pHps->viewportYExt = yExt;
|
|---|
| 295 | }
|
|---|
| 296 | }
|
|---|
| 297 | result = setPageXForm(wnd, pHps);
|
|---|
| 298 |
|
|---|
| 299 | return (result);
|
|---|
| 300 | }
|
|---|
| 301 | //******************************************************************************
|
|---|
| 302 | //******************************************************************************
|
|---|
| 303 | LONG clientHeight(Win32BaseWindow *wnd, HWND hwnd, pDCData pHps)
|
|---|
| 304 | {
|
|---|
| 305 | if ((hwnd == 0) && (pHps != 0))
|
|---|
| 306 | hwnd = pHps->hwnd;
|
|---|
| 307 |
|
|---|
| 308 | if ((hwnd != 0) || (pHps == 0))
|
|---|
| 309 | {
|
|---|
| 310 | if (wnd)
|
|---|
| 311 | return (wnd->getClientHeight());
|
|---|
| 312 | else
|
|---|
| 313 | return OSLibQueryScreenHeight();
|
|---|
| 314 | }
|
|---|
| 315 | else if (pHps->bitmapHandle)
|
|---|
| 316 | {
|
|---|
| 317 | return pHps->bitmapHeight;
|
|---|
| 318 | }
|
|---|
| 319 | else if (pHps->isMetaPS)
|
|---|
| 320 | {
|
|---|
| 321 | return 0;
|
|---|
| 322 | }
|
|---|
| 323 | else if (pHps->isPrinter)
|
|---|
| 324 | {
|
|---|
| 325 | return pHps->printPageHeight;
|
|---|
| 326 | }
|
|---|
| 327 | else
|
|---|
| 328 | {
|
|---|
| 329 | return MEM_HPS_MAX;
|
|---|
| 330 | }
|
|---|
| 331 | }
|
|---|
| 332 | //******************************************************************************
|
|---|
| 333 | //******************************************************************************
|
|---|
| 334 | BOOL isYup (pDCData pHps)
|
|---|
| 335 | {
|
|---|
| 336 | if (((pHps->windowExt.cy < 0) && (pHps->viewportYExt > 0.0)) ||
|
|---|
| 337 | ((pHps->windowExt.cy > 0) && (pHps->viewportYExt < 0.0)))
|
|---|
| 338 | {
|
|---|
| 339 | if ((pHps->graphicsMode == GM_COMPATIBLE_W) ||
|
|---|
| 340 | ((pHps->graphicsMode == GM_ADVANCED_W) && (pHps->xform.eM22 >= 0.0)))
|
|---|
| 341 | return TRUE;
|
|---|
| 342 | }
|
|---|
| 343 | else
|
|---|
| 344 | {
|
|---|
| 345 | if ((pHps->graphicsMode == GM_ADVANCED_W) && (pHps->xform.eM22 < 0.0))
|
|---|
| 346 | return TRUE;
|
|---|
| 347 | }
|
|---|
| 348 | return FALSE;
|
|---|
| 349 | }
|
|---|
| 350 | //******************************************************************************
|
|---|
| 351 | //******************************************************************************
|
|---|
| 352 | INT revertDy (Win32BaseWindow *wnd, INT dy)
|
|---|
| 353 | {
|
|---|
| 354 | //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
|
|---|
| 355 | // if (wnd->isOwnDC() && wnd->getOwnDC())
|
|---|
| 356 | if (wnd->isOwnDC())
|
|---|
| 357 | {
|
|---|
| 358 | pDCData pHps = (pDCData)GpiQueryDCData (wnd->getOwnDC());
|
|---|
| 359 |
|
|---|
| 360 | if (pHps != NULLHANDLE)
|
|---|
| 361 | if (!isYup (pHps))
|
|---|
| 362 | dy = -dy;
|
|---|
| 363 | }
|
|---|
| 364 | else
|
|---|
| 365 | {
|
|---|
| 366 | dy = -dy;
|
|---|
| 367 | }
|
|---|
| 368 | return (dy);
|
|---|
| 369 | }
|
|---|
| 370 | //******************************************************************************
|
|---|
| 371 | //******************************************************************************
|
|---|
| 372 | HDC sendEraseBkgnd (Win32BaseWindow *wnd)
|
|---|
| 373 | {
|
|---|
| 374 | BOOL erased;
|
|---|
| 375 | HWND hwnd;
|
|---|
| 376 | HDC hdc;
|
|---|
| 377 | HPS hps;
|
|---|
| 378 | HRGN hrgnUpdate, hrgnOld, hrgnClip, hrgnCombined;
|
|---|
| 379 | RECTL rectl = { 1, 1, 2, 2 };
|
|---|
| 380 |
|
|---|
| 381 | hwnd = wnd->getOS2WindowHandle();
|
|---|
| 382 | hps = WinGetPS(hwnd);
|
|---|
| 383 |
|
|---|
| 384 | hrgnUpdate = GpiCreateRegion (hps, 1, &rectl);
|
|---|
| 385 | WinQueryUpdateRegion (hwnd, hrgnUpdate);
|
|---|
| 386 | hrgnClip = GpiQueryClipRegion (hps);
|
|---|
| 387 |
|
|---|
| 388 | if (hrgnClip == NULLHANDLE)
|
|---|
| 389 | {
|
|---|
| 390 | GpiSetClipRegion (hps, hrgnUpdate, &hrgnOld);
|
|---|
| 391 | }
|
|---|
| 392 | else
|
|---|
| 393 | {
|
|---|
| 394 | hrgnCombined = GpiCreateRegion (hps, 1, &rectl);
|
|---|
| 395 | GpiCombineRegion (hps, hrgnCombined, hrgnClip, hrgnUpdate, CRGN_AND);
|
|---|
| 396 | GpiSetClipRegion (hps, hrgnCombined, &hrgnOld);
|
|---|
| 397 | GpiDestroyRegion (hps, hrgnUpdate);
|
|---|
| 398 | GpiDestroyRegion (hps, hrgnClip);
|
|---|
| 399 | }
|
|---|
| 400 | if (hrgnOld != NULLHANDLE)
|
|---|
| 401 | GpiDestroyRegion (hps, hrgnOld);
|
|---|
| 402 |
|
|---|
| 403 | hdc = HPSToHDC (hwnd, hps, NULL, NULL);
|
|---|
| 404 |
|
|---|
| 405 | erased = wnd->MsgEraseBackGround (hdc);
|
|---|
| 406 |
|
|---|
| 407 | DeleteHDC (hdc);
|
|---|
| 408 | WinReleasePS (hps);
|
|---|
| 409 |
|
|---|
| 410 | return erased;
|
|---|
| 411 | }
|
|---|
| 412 | //******************************************************************************
|
|---|
| 413 | //******************************************************************************
|
|---|
| 414 | void releaseOwnDC (HDC hps)
|
|---|
| 415 | {
|
|---|
| 416 | pDCData pHps = (pDCData)GpiQueryDCData ((HPS)hps);
|
|---|
| 417 |
|
|---|
| 418 | if (pHps) {
|
|---|
| 419 | if (pHps->hrgnHDC)
|
|---|
| 420 | GpiDestroyRegion (pHps->hps, pHps->hrgnHDC);
|
|---|
| 421 |
|
|---|
| 422 | GpiSetBitmap (pHps->hps, NULL);
|
|---|
| 423 | O32_DeleteObject (pHps->nullBitmapHandle);
|
|---|
| 424 | GpiDestroyPS(pHps->hps);
|
|---|
| 425 |
|
|---|
| 426 | if (pHps->hdc)
|
|---|
| 427 | DevCloseDC(pHps->hdc);
|
|---|
| 428 | }
|
|---|
| 429 | }
|
|---|
| 430 | //******************************************************************************
|
|---|
| 431 | //******************************************************************************
|
|---|
| 432 | #if 0
|
|---|
| 433 | HDC WIN32API BeginPaint (HWND hWnd, PPAINTSTRUCT_W lpps)
|
|---|
| 434 | {
|
|---|
| 435 | HWND hwnd = hWnd ? hWnd : HWND_DESKTOP;
|
|---|
| 436 | pDCData pHps = NULLHANDLE;
|
|---|
| 437 | RECTL rect;
|
|---|
| 438 | HPS hPS_ownDC = NULLHANDLE;
|
|---|
| 439 |
|
|---|
| 440 | if ( !lpps )
|
|---|
| 441 | {
|
|---|
| 442 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 443 | return (HDC)NULLHANDLE;
|
|---|
| 444 | }
|
|---|
| 445 |
|
|---|
| 446 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 447 |
|
|---|
| 448 | #if 0
|
|---|
| 449 | if ((hwnd != HWND_DESKTOP) && wnd->isOwnDC())
|
|---|
| 450 | {
|
|---|
| 451 | hPS_ownDC = wnd->getOwnDC();
|
|---|
| 452 | //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
|
|---|
| 453 | if(hPS_ownDC) {
|
|---|
| 454 | pHps = (pDCData)GpiQueryDCData(hPS_ownDC);
|
|---|
| 455 | if (!pHps)
|
|---|
| 456 | {
|
|---|
| 457 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 458 | return (HDC)NULLHANDLE;
|
|---|
| 459 | }
|
|---|
| 460 | }
|
|---|
| 461 | }
|
|---|
| 462 | #endif
|
|---|
| 463 |
|
|---|
| 464 | HWND hwndClient = wnd->getOS2WindowHandle();
|
|---|
| 465 | HPS hps = WinBeginPaint(hwndClient, hPS_ownDC, &rect);
|
|---|
| 466 |
|
|---|
| 467 | if (!pHps)
|
|---|
| 468 | {
|
|---|
| 469 | HDC hdc = HPSToHDC (hwndClient, hps, NULL, NULL);
|
|---|
| 470 | pHps = (pDCData)GpiQueryDCData(hps);
|
|---|
| 471 | }
|
|---|
| 472 |
|
|---|
| 473 | if (hPS_ownDC == 0)
|
|---|
| 474 | setMapMode (wnd, pHps, MM_TEXT_W);
|
|---|
| 475 | else
|
|---|
| 476 | setPageXForm (wnd, pHps);
|
|---|
| 477 |
|
|---|
| 478 | pHps->hdcType = TYPE_3;
|
|---|
| 479 |
|
|---|
| 480 | HideCaret(hwnd);
|
|---|
| 481 |
|
|---|
| 482 | if(wnd->needsEraseBkgnd()) {
|
|---|
| 483 | wnd->setEraseBkgnd(FALSE);
|
|---|
| 484 | lpps->fErase = (wnd->MsgEraseBackGround(pHps->hps) != 0);
|
|---|
| 485 | }
|
|---|
| 486 | else lpps->fErase = TRUE;
|
|---|
| 487 | lpps->hdc = (HDC)hps;
|
|---|
| 488 |
|
|---|
| 489 | if (!hPS_ownDC)
|
|---|
| 490 | {
|
|---|
| 491 | long height = wnd->getClientHeight();
|
|---|
| 492 |
|
|---|
| 493 | rect.yTop = height - rect.yTop;
|
|---|
| 494 | rect.yBottom = height - rect.yBottom;
|
|---|
| 495 | }
|
|---|
| 496 | else
|
|---|
| 497 | {
|
|---|
| 498 | rect.yTop--;
|
|---|
| 499 | rect.yBottom--;
|
|---|
| 500 | GpiConvert(pHps->hps, CVTC_DEVICE, CVTC_WORLD, 2, (PPOINTL)&rect);
|
|---|
| 501 | }
|
|---|
| 502 |
|
|---|
| 503 | WINRECT_FROM_PMRECT(lpps->rcPaint, rect);
|
|---|
| 504 | dprintf(("USER32: BeginPaint %x -> hdc %x (%d,%d)(%d,%d)", hWnd, pHps->hps, lpps->rcPaint.left, lpps->rcPaint.top, lpps->rcPaint.right, lpps->rcPaint.bottom));
|
|---|
| 505 |
|
|---|
| 506 | SetLastError(0);
|
|---|
| 507 | return (HDC)pHps->hps;
|
|---|
| 508 | }
|
|---|
| 509 |
|
|---|
| 510 | BOOL WIN32API EndPaint (HWND hwnd, const PAINTSTRUCT_W *pPaint)
|
|---|
| 511 | {
|
|---|
| 512 | pDCData pHps;
|
|---|
| 513 |
|
|---|
| 514 | dprintf (("USER32: EndPaint(%x)", hwnd));
|
|---|
| 515 |
|
|---|
| 516 | ShowCaret(hwnd);
|
|---|
| 517 | if (!pPaint || !pPaint->hdc )
|
|---|
| 518 | return TRUE;
|
|---|
| 519 |
|
|---|
| 520 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 521 |
|
|---|
| 522 | if (!wnd) goto exit;
|
|---|
| 523 |
|
|---|
| 524 | //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
|
|---|
| 525 | pHps = (pDCData)GpiQueryDCData((HPS)pPaint->hdc);
|
|---|
| 526 | if (pHps && (pHps->hdcType == TYPE_3)) {
|
|---|
| 527 | WinEndPaint (pHps->hps);
|
|---|
| 528 | }
|
|---|
| 529 | wnd->setEraseBkgnd(TRUE);
|
|---|
| 530 |
|
|---|
| 531 | exit:
|
|---|
| 532 | SetLastError(0);
|
|---|
| 533 | return TRUE;
|
|---|
| 534 | }
|
|---|
| 535 | #else
|
|---|
| 536 | HDC WIN32API BeginPaint (HWND hWnd, PPAINTSTRUCT_W lpps)
|
|---|
| 537 | {
|
|---|
| 538 | HWND hwnd = hWnd ? hWnd : HWND_DESKTOP;
|
|---|
| 539 | pDCData pHps = NULLHANDLE;
|
|---|
| 540 | HPS hPS_ownDC = NULLHANDLE, hpsPaint = 0;
|
|---|
| 541 | RECTL rectl = {0, 0, 1, 1};
|
|---|
| 542 | HRGN hrgnUpdate, hrgnOld;
|
|---|
| 543 | LONG lComplexity;
|
|---|
| 544 |
|
|---|
| 545 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 546 | if(!lpps || !wnd) {
|
|---|
| 547 | dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
|
|---|
| 548 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 549 | return (HDC)0;
|
|---|
| 550 | }
|
|---|
| 551 | HWND hwndClient = wnd->getOS2WindowHandle();
|
|---|
| 552 |
|
|---|
| 553 | if(hwnd != HWND_DESKTOP && wnd->isOwnDC())
|
|---|
| 554 | {
|
|---|
| 555 | hPS_ownDC = wnd->getOwnDC();
|
|---|
| 556 | //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
|
|---|
| 557 | if(hPS_ownDC) {
|
|---|
| 558 | pHps = (pDCData)GpiQueryDCData(hPS_ownDC);
|
|---|
| 559 | if (!pHps)
|
|---|
| 560 | {
|
|---|
| 561 | dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
|
|---|
| 562 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 563 | return (HDC)NULLHANDLE;
|
|---|
| 564 | }
|
|---|
| 565 | hpsPaint = hPS_ownDC;
|
|---|
| 566 | }
|
|---|
| 567 | }
|
|---|
| 568 | if(!hpsPaint) {
|
|---|
| 569 | hpsPaint = GetDCEx(hwnd, 0, DCX_CACHE_W);
|
|---|
| 570 | pHps = (pDCData)GpiQueryDCData(hpsPaint);
|
|---|
| 571 | if (!pHps)
|
|---|
| 572 | {
|
|---|
| 573 | dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
|
|---|
| 574 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 575 | return (HDC)NULLHANDLE;
|
|---|
| 576 | }
|
|---|
| 577 | }
|
|---|
| 578 |
|
|---|
| 579 | #if 0
|
|---|
| 580 | HPS hps = WinBeginPaint(hwndClient, hPS_ownDC, &rect);
|
|---|
| 581 |
|
|---|
| 582 | if (!pHps)
|
|---|
| 583 | {
|
|---|
| 584 | HDC hdc = HPSToHDC (hwndClient, hps, NULL, NULL);
|
|---|
| 585 | pHps = (pDCData)GpiQueryDCData(hps);
|
|---|
| 586 | }
|
|---|
| 587 | #endif
|
|---|
| 588 |
|
|---|
| 589 | if (hPS_ownDC == 0)
|
|---|
| 590 | setMapMode (wnd, pHps, MM_TEXT_W);
|
|---|
| 591 | else
|
|---|
| 592 | setPageXForm (wnd, pHps);
|
|---|
| 593 |
|
|---|
| 594 | pHps->hdcType = TYPE_3;
|
|---|
| 595 |
|
|---|
| 596 | hrgnUpdate = GpiCreateRegion(pHps->hps, 1, &rectl);
|
|---|
| 597 | lComplexity = WinQueryUpdateRegion(hwndClient, hrgnUpdate);
|
|---|
| 598 | if(lComplexity == RGN_ERROR) {
|
|---|
| 599 | dprintf (("USER32: BeginPaint update region error!!"));
|
|---|
| 600 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 601 | return 0;
|
|---|
| 602 | }
|
|---|
| 603 | WinQueryUpdateRect(hwndClient, &rectl);
|
|---|
| 604 |
|
|---|
| 605 | if(lComplexity != RGN_NULL) {
|
|---|
| 606 | WinValidateRegion(hwndClient, hrgnUpdate, FALSE);
|
|---|
| 607 |
|
|---|
| 608 | GpiSetClipRegion(pHps->hps, hrgnUpdate, &hrgnOld);
|
|---|
| 609 | //save old clip region (restored for CS_OWNDC windows in EndPaint)
|
|---|
| 610 | wnd->SetClipRegion(hrgnOld);
|
|---|
| 611 | }
|
|---|
| 612 |
|
|---|
| 613 | if(wnd->needsEraseBkgnd() && lComplexity != RGN_NULL) {
|
|---|
| 614 | wnd->setEraseBkgnd(FALSE);
|
|---|
| 615 | lpps->fErase = (wnd->MsgEraseBackGround(pHps->hps) != 0);
|
|---|
| 616 | }
|
|---|
| 617 | else lpps->fErase = TRUE;
|
|---|
| 618 |
|
|---|
| 619 | lpps->hdc = (HDC)pHps->hps;
|
|---|
| 620 |
|
|---|
| 621 | if(lComplexity != RGN_NULL) {
|
|---|
| 622 | long height = wnd->getClientHeight();
|
|---|
| 623 | lpps->rcPaint.top = height - rectl.yTop;
|
|---|
| 624 | lpps->rcPaint.left = rectl.xLeft;
|
|---|
| 625 | lpps->rcPaint.bottom = height - rectl.yBottom;
|
|---|
| 626 | lpps->rcPaint.right = rectl.xRight;
|
|---|
| 627 | }
|
|---|
| 628 | else {
|
|---|
| 629 | lpps->rcPaint.bottom = lpps->rcPaint.top = 0;
|
|---|
| 630 | lpps->rcPaint.right = lpps->rcPaint.left = 0;
|
|---|
| 631 | }
|
|---|
| 632 |
|
|---|
| 633 | HideCaret(hwnd);
|
|---|
| 634 |
|
|---|
| 635 | SetLastError(0);
|
|---|
| 636 | dprintf(("USER32: BeginPaint %x -> hdc %x (%d,%d)(%d,%d)", hWnd, pHps->hps, lpps->rcPaint.left, lpps->rcPaint.top, lpps->rcPaint.right, lpps->rcPaint.bottom));
|
|---|
| 637 | return (HDC)pHps->hps;
|
|---|
| 638 | }
|
|---|
| 639 | //******************************************************************************
|
|---|
| 640 | //******************************************************************************
|
|---|
| 641 | BOOL WIN32API EndPaint (HWND hWnd, const PAINTSTRUCT_W *pPaint)
|
|---|
| 642 | {
|
|---|
| 643 | HWND hwnd = hWnd ? hWnd : HWND_DESKTOP;
|
|---|
| 644 | HRGN hrgnOld;
|
|---|
| 645 | pDCData pHps;
|
|---|
| 646 |
|
|---|
| 647 | dprintf (("USER32: EndPaint(%x)", hwnd));
|
|---|
| 648 |
|
|---|
| 649 | if (!pPaint || !pPaint->hdc )
|
|---|
| 650 | return TRUE;
|
|---|
| 651 |
|
|---|
| 652 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 653 |
|
|---|
| 654 | if (!wnd) goto exit;
|
|---|
| 655 |
|
|---|
| 656 | pHps = (pDCData)GpiQueryDCData((HPS)pPaint->hdc);
|
|---|
| 657 | if (pHps && (pHps->hdcType == TYPE_3))
|
|---|
| 658 | {
|
|---|
| 659 | GpiSetClipRegion(pHps->hps, NULLHANDLE, &hrgnOld);
|
|---|
| 660 | if(hrgnOld) {
|
|---|
| 661 | GpiDestroyRegion(pHps->hps, hrgnOld);
|
|---|
| 662 | }
|
|---|
| 663 | if(hwnd == HWND_DESKTOP || !wnd->isOwnDC()) {
|
|---|
| 664 | ReleaseDC(hwnd, pPaint->hdc);
|
|---|
| 665 | }
|
|---|
| 666 | else
|
|---|
| 667 | if(wnd->GetClipRegion()) {
|
|---|
| 668 | //TODO: What else do we need to restore here???
|
|---|
| 669 | GpiSetClipRegion(pHps->hps, wnd->GetClipRegion(), &hrgnOld);
|
|---|
| 670 | wnd->SetClipRegion(0);
|
|---|
| 671 | pHps->hdcType = TYPE_1;
|
|---|
| 672 | }
|
|---|
| 673 |
|
|---|
| 674 | //// WinEndPaint (pHps->hps);
|
|---|
| 675 | }
|
|---|
| 676 | else {
|
|---|
| 677 | dprintf(("EndPaint: wrong hdc %x!!", pPaint->hdc));
|
|---|
| 678 | }
|
|---|
| 679 | wnd->setEraseBkgnd(TRUE);
|
|---|
| 680 | ShowCaret(hwnd);
|
|---|
| 681 |
|
|---|
| 682 | exit:
|
|---|
| 683 | SetLastError(0);
|
|---|
| 684 | return TRUE;
|
|---|
| 685 | }
|
|---|
| 686 | #endif
|
|---|
| 687 | //******************************************************************************
|
|---|
| 688 | //******************************************************************************
|
|---|
| 689 | BOOL WIN32API GetUpdateRect (HWND hwnd, LPRECT pRect, BOOL erase)
|
|---|
| 690 | {
|
|---|
| 691 | if (!hwnd)
|
|---|
| 692 | {
|
|---|
| 693 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
|---|
| 694 | return FALSE;
|
|---|
| 695 | }
|
|---|
| 696 |
|
|---|
| 697 | RECTL rectl;
|
|---|
| 698 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 699 |
|
|---|
| 700 | if (!wnd)
|
|---|
| 701 | {
|
|---|
| 702 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
|---|
| 703 | return FALSE;
|
|---|
| 704 | }
|
|---|
| 705 |
|
|---|
| 706 | BOOL updateRegionExists = WinQueryUpdateRect (wnd->getOS2WindowHandle(), pRect ? &rectl : NULL);
|
|---|
| 707 | if (!pRect) {
|
|---|
| 708 | return (updateRegionExists);
|
|---|
| 709 | }
|
|---|
| 710 |
|
|---|
| 711 | if (updateRegionExists)
|
|---|
| 712 | {
|
|---|
| 713 | //CB: for PM empty rect is valid
|
|---|
| 714 | if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) {
|
|---|
| 715 | if(pRect) {
|
|---|
| 716 | pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
|
|---|
| 717 | }
|
|---|
| 718 | return FALSE;
|
|---|
| 719 | }
|
|---|
| 720 | #if 0
|
|---|
| 721 | //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
|
|---|
| 722 | // if (wnd->isOwnDC() && wnd->getOwnDC())
|
|---|
| 723 | if (wnd->isOwnDC())
|
|---|
| 724 | {
|
|---|
| 725 | pDCData pHps = NULL;
|
|---|
| 726 | pHps = (pDCData)GpiQueryDCData(wnd->getOwnDC());
|
|---|
| 727 | if (!pHps)
|
|---|
| 728 | {
|
|---|
| 729 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 730 | return FALSE;
|
|---|
| 731 | }
|
|---|
| 732 | GpiConvert (pHps->hps, CVTC_DEVICE, CVTC_WORLD, 2, (PPOINTL)&rectl);
|
|---|
| 733 | }
|
|---|
| 734 | else
|
|---|
| 735 | {
|
|---|
| 736 | #endif
|
|---|
| 737 | long height = wnd->getClientHeight();
|
|---|
| 738 | rectl.yTop = height - rectl.yTop;
|
|---|
| 739 | rectl.yBottom = height - rectl.yBottom;
|
|---|
| 740 | ////////// }
|
|---|
| 741 |
|
|---|
| 742 | if (pRect)
|
|---|
| 743 | WINRECT_FROM_PMRECT (*pRect, rectl);
|
|---|
| 744 |
|
|---|
| 745 | if (erase)
|
|---|
| 746 | sendEraseBkgnd (wnd);
|
|---|
| 747 | }
|
|---|
| 748 | else
|
|---|
| 749 | {
|
|---|
| 750 | if(pRect) {
|
|---|
| 751 | pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
|
|---|
| 752 | }
|
|---|
| 753 | }
|
|---|
| 754 |
|
|---|
| 755 | return updateRegionExists;
|
|---|
| 756 | }
|
|---|
| 757 | //******************************************************************************
|
|---|
| 758 | //functions for WM_NCPAINT
|
|---|
| 759 | //******************************************************************************
|
|---|
| 760 | INT SYSTEM GetOS2UpdateRgn(HWND hwnd,HRGN hrgn)
|
|---|
| 761 | {
|
|---|
| 762 | return O32_GetUpdateRgn(hwnd,hrgn,FALSE);
|
|---|
| 763 | }
|
|---|
| 764 | //******************************************************************************
|
|---|
| 765 | //******************************************************************************
|
|---|
| 766 | BOOL SYSTEM GetOS2UpdateRect(HWND hwnd,LPRECT pRect)
|
|---|
| 767 | {
|
|---|
| 768 | RECTL rectl;
|
|---|
| 769 | BOOL updateRegionExists = WinQueryUpdateRect(hwnd,pRect ? &rectl:NULL);
|
|---|
| 770 |
|
|---|
| 771 | if (!pRect)
|
|---|
| 772 | return (updateRegionExists);
|
|---|
| 773 |
|
|---|
| 774 | if (updateRegionExists)
|
|---|
| 775 | {
|
|---|
| 776 | //CB: for PM empty rect is valid
|
|---|
| 777 | if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) return FALSE;
|
|---|
| 778 | mapOS2ToWin32Rect(hwnd,(PRECTLOS2)&rectl,pRect);
|
|---|
| 779 | }
|
|---|
| 780 | else
|
|---|
| 781 | pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
|
|---|
| 782 |
|
|---|
| 783 | return updateRegionExists;
|
|---|
| 784 | }
|
|---|
| 785 | //******************************************************************************
|
|---|
| 786 | //******************************************************************************
|
|---|
| 787 | int WIN32API GetUpdateRgn (HWND hwnd, HRGN hrgn, BOOL erase)
|
|---|
| 788 | {
|
|---|
| 789 | LONG Complexity;
|
|---|
| 790 |
|
|---|
| 791 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 792 |
|
|---|
| 793 | if (!wnd)
|
|---|
| 794 | {
|
|---|
| 795 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
|---|
| 796 | return ERROR_W;
|
|---|
| 797 | }
|
|---|
| 798 |
|
|---|
| 799 | Complexity = O32_GetUpdateRgn (wnd->getOS2WindowHandle(), hrgn, FALSE);
|
|---|
| 800 | if (erase && (Complexity > NULLREGION_W)) sendEraseBkgnd(wnd);
|
|---|
| 801 |
|
|---|
| 802 | return Complexity;
|
|---|
| 803 | }
|
|---|
| 804 | //******************************************************************************
|
|---|
| 805 | // This implementation of GetDCEx supports
|
|---|
| 806 | // DCX_WINDOW
|
|---|
| 807 | // DCX_CACHE
|
|---|
| 808 | // DCX_EXCLUDERGN (complex regions allowed)
|
|---|
| 809 | // DCX_INTERSECTRGN (complex regions allowed)
|
|---|
| 810 | //
|
|---|
| 811 | //TODO: WM_SETREDRAW affects drawingAllowed flag!!
|
|---|
| 812 | //******************************************************************************
|
|---|
| 813 | HDC WIN32API GetDCEx (HWND hwnd, HRGN hrgn, ULONG flags)
|
|---|
| 814 | {
|
|---|
| 815 | Win32BaseWindow *wnd = NULL;
|
|---|
| 816 | HWND hWindow;
|
|---|
| 817 | BOOL success;
|
|---|
| 818 | pDCData pHps = NULL;
|
|---|
| 819 | HPS hps = NULLHANDLE;
|
|---|
| 820 | BOOL drawingAllowed = TRUE;
|
|---|
| 821 | BOOL isWindowOwnDC;
|
|---|
| 822 | BOOL creatingOwnDC = FALSE;
|
|---|
| 823 | PS_Type psType;
|
|---|
| 824 |
|
|---|
| 825 | if(hwnd == 0) {
|
|---|
| 826 | dprintf(("error: GetDCEx window %x not found", hwnd));
|
|---|
| 827 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
|---|
| 828 | return 0;
|
|---|
| 829 | }
|
|---|
| 830 |
|
|---|
| 831 | if (hwnd)
|
|---|
| 832 | {
|
|---|
| 833 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 834 | if(wnd == NULL) {
|
|---|
| 835 | dprintf (("ERROR: User32: GetDCEx bad window handle %X!!!!!", hwnd));
|
|---|
| 836 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
|---|
| 837 | return 0;
|
|---|
| 838 | }
|
|---|
| 839 | //SvL: Experimental change (doesn't work right)
|
|---|
| 840 | #if 0
|
|---|
| 841 | if(wnd->fHasParentDC() && wnd->getParent()) {
|
|---|
| 842 | wnd = wnd->getParent();
|
|---|
| 843 | }
|
|---|
| 844 | #endif
|
|---|
| 845 | if (flags & DCX_WINDOW_W)
|
|---|
| 846 | hWindow = wnd->getOS2FrameWindowHandle();
|
|---|
| 847 | else
|
|---|
| 848 | hWindow = wnd->getOS2WindowHandle();
|
|---|
| 849 | }
|
|---|
| 850 |
|
|---|
| 851 | isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : (wnd->isOwnDC()))
|
|---|
| 852 | && !(flags & DCX_CACHE_W|DCX_WINDOW_W));
|
|---|
| 853 |
|
|---|
| 854 | if (isWindowOwnDC)
|
|---|
| 855 | {
|
|---|
| 856 | hps = wnd->getOwnDC();
|
|---|
| 857 | if (hps)
|
|---|
| 858 | {
|
|---|
| 859 | pDCData pHps = (pDCData)GpiQueryDCData (hps);
|
|---|
| 860 | if (!pHps)
|
|---|
| 861 | goto error;
|
|---|
| 862 |
|
|---|
| 863 | setPageXForm (wnd, pHps);
|
|---|
| 864 |
|
|---|
| 865 | pHps->hdcType = TYPE_1;
|
|---|
| 866 | dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x hdc %x", hwnd, hrgn, flags, wnd, hps));
|
|---|
| 867 | return (HDC)hps;
|
|---|
| 868 | }
|
|---|
| 869 | else
|
|---|
| 870 | creatingOwnDC = TRUE;
|
|---|
| 871 | }
|
|---|
| 872 |
|
|---|
| 873 | if (isWindowOwnDC)
|
|---|
| 874 | {
|
|---|
| 875 | SIZEL sizel = {0,0};
|
|---|
| 876 | hps = GpiCreatePS (WinQueryAnchorBlock (hWindow),
|
|---|
| 877 | WinOpenWindowDC (hWindow),
|
|---|
| 878 | &sizel, PU_PELS | GPIT_MICRO | GPIA_ASSOC );
|
|---|
| 879 | psType = MICRO;
|
|---|
| 880 | }
|
|---|
| 881 | else
|
|---|
| 882 | {
|
|---|
| 883 | if (hWindow == HWND_DESKTOP)
|
|---|
| 884 | hps = WinGetScreenPS (hWindow);
|
|---|
| 885 | else
|
|---|
| 886 | hps = WinGetPS (hWindow);
|
|---|
| 887 |
|
|---|
| 888 | psType = MICRO_CACHED;
|
|---|
| 889 | }
|
|---|
| 890 |
|
|---|
| 891 | if (!hps)
|
|---|
| 892 | goto error;
|
|---|
| 893 |
|
|---|
| 894 | HPSToHDC (hWindow, hps, NULL, NULL);
|
|---|
| 895 | pHps = (pDCData)GpiQueryDCData (hps);
|
|---|
| 896 |
|
|---|
| 897 | if ((flags & DCX_EXCLUDERGN_W) || (flags & DCX_INTERSECTRGN_W))
|
|---|
| 898 | {
|
|---|
| 899 | ULONG BytesNeeded;
|
|---|
| 900 | PRGNDATA_W RgnData;
|
|---|
| 901 | PRECT pr;
|
|---|
| 902 | int i;
|
|---|
| 903 | RECTL rectl;
|
|---|
| 904 |
|
|---|
| 905 | if (!hrgn)
|
|---|
| 906 | goto error;
|
|---|
| 907 |
|
|---|
| 908 | success = TRUE;
|
|---|
| 909 | if (flags & DCX_EXCLUDERGN_W)
|
|---|
| 910 | {
|
|---|
| 911 | #if 0 //CB: todo
|
|---|
| 912 | long height;
|
|---|
| 913 |
|
|---|
| 914 | BytesNeeded = GetRegionData (hrgn, 0, NULL);
|
|---|
| 915 | RgnData = (PRGNDATA_W)_alloca (BytesNeeded);
|
|---|
| 916 | if (RgnData == NULL)
|
|---|
| 917 | goto error;
|
|---|
| 918 | GetRegionData (hrgn, BytesNeeded, RgnData);
|
|---|
| 919 |
|
|---|
| 920 | i = RgnData->rdh.nCount;
|
|---|
| 921 | pr = (PRECT)(RgnData->Buffer);
|
|---|
| 922 |
|
|---|
| 923 | if (flags & DCX_WINDOW_W)
|
|---|
| 924 | height = wnd->getWindowHeight();
|
|---|
| 925 | else height = wnd->getClientHeight();
|
|---|
| 926 |
|
|---|
| 927 | for (; (i > 0) && success; i--, pr++) {
|
|---|
| 928 | LONG y = pr->yBottom;
|
|---|
| 929 |
|
|---|
| 930 | pr->yBottom = height - pr->yTop;
|
|---|
| 931 | pr->yTop = height - y;
|
|---|
| 932 | success &= GpiExcludeClipRectangle (pHps->hps, pr);
|
|---|
| 933 | }
|
|---|
| 934 | #endif
|
|---|
| 935 | }
|
|---|
| 936 | else //DCX_INTERSECTRGN_W
|
|---|
| 937 | {
|
|---|
| 938 | //SvL: I'm getting paint problems when clipping a dc created in GetDCEx
|
|---|
| 939 | // with a region that covers the entire window (RealPlayer 7 Update 1)
|
|---|
| 940 | // Using SelectClipRgn here doesn't make any difference.
|
|---|
| 941 | if(ExtSelectClipRgn(pHps->hps, hrgn, RGN_AND_W) == ERROR_W) {
|
|---|
| 942 | dprintf(("ExtSelectClipRgn failed!!"));
|
|---|
| 943 | }
|
|---|
| 944 | }
|
|---|
| 945 | if (!success)
|
|---|
| 946 | goto error;
|
|---|
| 947 | }
|
|---|
| 948 |
|
|---|
| 949 | if (creatingOwnDC)
|
|---|
| 950 | wnd->setOwnDC ((HDC)hps);
|
|---|
| 951 |
|
|---|
| 952 | pHps->psType = psType;
|
|---|
| 953 | pHps->hdcType = TYPE_1;
|
|---|
| 954 | //TODO: WM_SETREDRAW affects drawingAllowed flag!!
|
|---|
| 955 | GpiSetDrawControl (hps, DCTL_DISPLAY, drawingAllowed ? DCTL_ON : DCTL_OFF);
|
|---|
| 956 |
|
|---|
| 957 | dprintf (("User32: GetDCEx hwnd %x (%x %x) -> hdc %x", hwnd, hrgn, flags, pHps->hps));
|
|---|
| 958 | return (HDC)pHps->hps;
|
|---|
| 959 |
|
|---|
| 960 | error:
|
|---|
| 961 | /* Something went wrong; clean up
|
|---|
| 962 | */
|
|---|
| 963 | if (pHps)
|
|---|
| 964 | {
|
|---|
| 965 | if (pHps->hps)
|
|---|
| 966 | {
|
|---|
| 967 | if(pHps->psType == MICRO_CACHED)
|
|---|
| 968 | WinReleasePS(pHps->hps);
|
|---|
| 969 | else
|
|---|
| 970 | GpiDestroyPS(pHps->hps);
|
|---|
| 971 | }
|
|---|
| 972 |
|
|---|
| 973 | if (pHps->hdc) DevCloseDC(pHps->hdc);
|
|---|
| 974 | if (pHps->hrgnHDC) GpiDestroyRegion(pHps->hps, pHps->hrgnHDC);
|
|---|
| 975 |
|
|---|
| 976 | O32_DeleteObject (pHps->nullBitmapHandle);
|
|---|
| 977 | }
|
|---|
| 978 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 979 | return NULL;
|
|---|
| 980 | }
|
|---|
| 981 | //******************************************************************************
|
|---|
| 982 | //******************************************************************************
|
|---|
| 983 | HDC WIN32API GetDC (HWND hwnd)
|
|---|
| 984 | {
|
|---|
| 985 | if(!hwnd)
|
|---|
| 986 | return GetDCEx( GetDesktopWindow(), 0, DCX_CACHE_W | DCX_WINDOW_W );
|
|---|
| 987 | return GetDCEx (hwnd, NULL, 0);
|
|---|
| 988 | }
|
|---|
| 989 | //******************************************************************************
|
|---|
| 990 | //******************************************************************************
|
|---|
| 991 | HDC WIN32API GetWindowDC (HWND hwnd)
|
|---|
| 992 | {
|
|---|
| 993 | if (!hwnd) hwnd = GetDesktopWindow();
|
|---|
| 994 | return GetDCEx (hwnd, NULL, DCX_USESTYLE_W | DCX_WINDOW_W);
|
|---|
| 995 | }
|
|---|
| 996 | //******************************************************************************
|
|---|
| 997 | //******************************************************************************
|
|---|
| 998 | int WIN32API ReleaseDC (HWND hwnd, HDC hdc)
|
|---|
| 999 | {
|
|---|
| 1000 | BOOL isOwnDC = FALSE;
|
|---|
| 1001 | int rc;
|
|---|
| 1002 |
|
|---|
| 1003 | if (hwnd)
|
|---|
| 1004 | {
|
|---|
| 1005 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
|---|
| 1006 | if(wnd == NULL) {
|
|---|
| 1007 | dprintf(("ERROR: ReleaseDC %x %x failed", hwnd, hdc));
|
|---|
| 1008 | return 0;
|
|---|
| 1009 | }
|
|---|
| 1010 | //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
|
|---|
| 1011 | // isOwnDC = wnd->isOwnDC() && wnd->getOwnDC();
|
|---|
| 1012 | isOwnDC = wnd->isOwnDC() && (wnd->getOwnDC() == hdc);
|
|---|
| 1013 | }
|
|---|
| 1014 | if (isOwnDC)
|
|---|
| 1015 | rc = TRUE;
|
|---|
| 1016 | else
|
|---|
| 1017 | rc = O32_ReleaseDC (0, hdc);
|
|---|
| 1018 |
|
|---|
| 1019 | dprintf(("ReleaseDC %x %x", hwnd, hdc));
|
|---|
| 1020 | return (rc);
|
|---|
| 1021 | }
|
|---|
| 1022 | //******************************************************************************
|
|---|
| 1023 | // This implementation of RedrawWindow supports
|
|---|
| 1024 | // RDW_ERASE
|
|---|
| 1025 | // RDW_NOERASE
|
|---|
| 1026 | // RDW_INTERNALPAINT
|
|---|
| 1027 | // RDW_NOINTERNALPAINT
|
|---|
| 1028 | // RDW_INVALIDATE
|
|---|
| 1029 | // RDW_VALIDATE
|
|---|
| 1030 | // RDW_ERASENOW
|
|---|
| 1031 | // RDW_UPDATENOW
|
|---|
| 1032 | //******************************************************************************
|
|---|
| 1033 | BOOL WIN32API RedrawWindow(HWND hwnd, const RECT* pRect, HRGN hrgn, DWORD redraw)
|
|---|
| 1034 | {
|
|---|
| 1035 | Win32BaseWindow *wnd;
|
|---|
| 1036 |
|
|---|
| 1037 | if(pRect) {
|
|---|
| 1038 | dprintf(("RedrawWindow %x (%d,%d)(%d,%d) %x %x", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom, hrgn, redraw));
|
|---|
| 1039 | }
|
|---|
| 1040 | else dprintf(("RedrawWindow %x %x %x %x", hwnd, pRect, hrgn, redraw));
|
|---|
| 1041 |
|
|---|
| 1042 | if (redraw & (RDW_FRAME_W | RDW_NOFRAME_W))
|
|---|
| 1043 | {
|
|---|
| 1044 | SetLastError(ERROR_NOT_SUPPORTED_W);
|
|---|
| 1045 | return FALSE;
|
|---|
| 1046 | }
|
|---|
| 1047 |
|
|---|
| 1048 | if (hwnd == NULLHANDLE)
|
|---|
| 1049 | {
|
|---|
| 1050 | #if 1
|
|---|
| 1051 | // Don't do this for now (causes lots of desktop repaints in WordPad)
|
|---|
| 1052 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 1053 | return FALSE;
|
|---|
| 1054 | #else
|
|---|
| 1055 | hwnd = HWND_DESKTOP;
|
|---|
| 1056 | wnd = Win32BaseWindow::GetWindowFromOS2Handle(OSLIB_HWND_DESKTOP);
|
|---|
| 1057 |
|
|---|
| 1058 | if (!wnd)
|
|---|
| 1059 | {
|
|---|
| 1060 | dprintf(("USER32:dc: RedrawWindow can't find desktop window %08xh\n",
|
|---|
| 1061 | hwnd));
|
|---|
| 1062 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 1063 | return FALSE;
|
|---|
| 1064 | }
|
|---|
| 1065 | #endif
|
|---|
| 1066 | }
|
|---|
| 1067 | else
|
|---|
| 1068 | {
|
|---|
| 1069 | wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
|---|
| 1070 |
|
|---|
| 1071 | if (!wnd)
|
|---|
| 1072 | {
|
|---|
| 1073 | dprintf(("USER32:dc: RedrawWindow can't find window %08xh\n",
|
|---|
| 1074 | hwnd));
|
|---|
| 1075 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 1076 | return FALSE;
|
|---|
| 1077 | }
|
|---|
| 1078 | hwnd = wnd->getOS2WindowHandle();
|
|---|
| 1079 | }
|
|---|
| 1080 |
|
|---|
| 1081 | BOOL IncludeChildren = redraw & RDW_ALLCHILDREN_W ? TRUE : FALSE;
|
|---|
| 1082 | BOOL success = TRUE;
|
|---|
| 1083 | HPS hpsTemp = NULLHANDLE;
|
|---|
| 1084 | HRGN hrgnTemp = NULLHANDLE;
|
|---|
| 1085 | RECTL rectl;
|
|---|
| 1086 |
|
|---|
| 1087 | if (hrgn)
|
|---|
| 1088 | {
|
|---|
| 1089 | ULONG BytesNeeded;
|
|---|
| 1090 | PRGNDATA_W RgnData;
|
|---|
| 1091 | PRECTL pr;
|
|---|
| 1092 | int i;
|
|---|
| 1093 | LONG height = wnd ? wnd->getClientHeight() : OSLibQueryScreenHeight();
|
|---|
| 1094 |
|
|---|
| 1095 | if (!hrgn)
|
|---|
| 1096 | goto error;
|
|---|
| 1097 |
|
|---|
| 1098 | BytesNeeded = O32_GetRegionData (hrgn, 0, NULL);
|
|---|
| 1099 | RgnData = (PRGNDATA_W)_alloca (BytesNeeded);
|
|---|
| 1100 | if (RgnData == NULL)
|
|---|
| 1101 | goto error;
|
|---|
| 1102 | O32_GetRegionData (hrgn, BytesNeeded, RgnData);
|
|---|
| 1103 |
|
|---|
| 1104 | pr = (PRECTL)(RgnData->Buffer);
|
|---|
| 1105 | for (i = RgnData->rdh.nCount; i > 0; i--, pr++) {
|
|---|
| 1106 | LONG temp = pr->yTop;
|
|---|
| 1107 | pr->yTop = height - pr->yBottom;
|
|---|
| 1108 | pr->yBottom = height - temp;
|
|---|
| 1109 | }
|
|---|
| 1110 |
|
|---|
| 1111 | hpsTemp = WinGetScreenPS (HWND_DESKTOP);
|
|---|
| 1112 | hrgnTemp = GpiCreateRegion (hpsTemp, RgnData->rdh.nCount, (PRECTL)(RgnData->Buffer));
|
|---|
| 1113 | if (!hrgnTemp) goto error;
|
|---|
| 1114 | }
|
|---|
| 1115 | else if (pRect)
|
|---|
| 1116 | {
|
|---|
| 1117 | LONG height = wnd ? wnd->getClientHeight() : OSLibQueryScreenHeight();
|
|---|
| 1118 |
|
|---|
| 1119 | PMRECT_FROM_WINRECT (rectl, *pRect);
|
|---|
| 1120 | rectl.yTop = height - rectl.yTop;
|
|---|
| 1121 | rectl.yBottom = height - rectl.yBottom;
|
|---|
| 1122 | }
|
|---|
| 1123 |
|
|---|
| 1124 | if (redraw & RDW_INVALIDATE_W)
|
|---|
| 1125 | {
|
|---|
| 1126 | //TODO: SvL: pingpong.exe doesn't have RDW_NOERASE, but doesn't want WM_ERASEBKGND msgs
|
|---|
| 1127 | if (redraw & RDW_ERASE_W)
|
|---|
| 1128 | wnd->setEraseBkgnd (TRUE);
|
|---|
| 1129 |
|
|---|
| 1130 | if (!pRect && !hrgn)
|
|---|
| 1131 | success = WinInvalidateRect (hwnd, NULL, IncludeChildren);
|
|---|
| 1132 | else
|
|---|
| 1133 | if (hrgn)
|
|---|
| 1134 | success = WinInvalidateRegion (hwnd, hrgnTemp, IncludeChildren);
|
|---|
| 1135 | else
|
|---|
| 1136 | success = WinInvalidateRect (hwnd, &rectl, IncludeChildren);
|
|---|
| 1137 |
|
|---|
| 1138 | if (!success) goto error;
|
|---|
| 1139 | }
|
|---|
| 1140 | else if (redraw & RDW_VALIDATE_W)
|
|---|
| 1141 | {
|
|---|
| 1142 | if (redraw & RDW_NOERASE_W)
|
|---|
| 1143 | wnd->setEraseBkgnd(FALSE);
|
|---|
| 1144 |
|
|---|
| 1145 | if (WinQueryUpdateRect (hwnd, NULL))
|
|---|
| 1146 | {
|
|---|
| 1147 | if (!pRect && !hrgn)
|
|---|
| 1148 | success = WinValidateRect (hwnd, NULL, IncludeChildren);
|
|---|
| 1149 | else
|
|---|
| 1150 | if (hrgn)
|
|---|
| 1151 | success = WinValidateRegion (hwnd, hrgnTemp, IncludeChildren);
|
|---|
| 1152 | else
|
|---|
| 1153 | success = WinValidateRect (hwnd, &rectl, IncludeChildren);
|
|---|
| 1154 | if (!success) goto error;
|
|---|
| 1155 | }
|
|---|
| 1156 | }
|
|---|
| 1157 |
|
|---|
| 1158 | if(WinQueryUpdateRect(hwnd, NULL))
|
|---|
| 1159 | {
|
|---|
| 1160 | //TODO: Does this work if RDW_ALLCHILDREN is set??
|
|---|
| 1161 | if(redraw & RDW_UPDATENOW_W) {
|
|---|
| 1162 | wnd->MsgPaint (0, FALSE);
|
|---|
| 1163 | }
|
|---|
| 1164 | else
|
|---|
| 1165 | // if((redraw & RDW_ERASE_W) && (redraw & RDW_ERASENOW_W))
|
|---|
| 1166 | if(redraw & RDW_ERASENOW_W && wnd->needsEraseBkgnd())
|
|---|
| 1167 | wnd->setEraseBkgnd(sendEraseBkgnd(wnd) == 0);
|
|---|
| 1168 | }
|
|---|
| 1169 | else if((redraw & RDW_INTERNALPAINT_W) && !(redraw & RDW_INVALIDATE_W))
|
|---|
| 1170 | {
|
|---|
| 1171 | if(redraw & RDW_UPDATENOW_W)
|
|---|
| 1172 | wnd->MsgPaint (0, FALSE);
|
|---|
| 1173 | else PostMessageA(hwnd, WINWM_PAINT, 0, 0);
|
|---|
| 1174 | }
|
|---|
| 1175 |
|
|---|
| 1176 | error:
|
|---|
| 1177 | /* clean up */
|
|---|
| 1178 | if (hrgnTemp)
|
|---|
| 1179 | GpiDestroyRegion (hpsTemp, hrgnTemp);
|
|---|
| 1180 |
|
|---|
| 1181 | if (hpsTemp)
|
|---|
| 1182 | WinReleasePS (hpsTemp);
|
|---|
| 1183 |
|
|---|
| 1184 | if (!success)
|
|---|
| 1185 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 1186 |
|
|---|
| 1187 | return (success);
|
|---|
| 1188 | }
|
|---|
| 1189 | //******************************************************************************
|
|---|
| 1190 | //******************************************************************************
|
|---|
| 1191 | BOOL WIN32API UpdateWindow (HWND hwnd)
|
|---|
| 1192 | {
|
|---|
| 1193 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
|---|
| 1194 |
|
|---|
| 1195 | if(!wnd) {
|
|---|
| 1196 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
|---|
| 1197 | return FALSE;
|
|---|
| 1198 | }
|
|---|
| 1199 |
|
|---|
| 1200 | dprintf (("User32: UpdateWindow hwnd %x", hwnd));
|
|---|
| 1201 | ////SvL: This doesn't work right (Wine uses RDW_NOCHILDREN_W -> doesn't work here)
|
|---|
| 1202 | //// Breaks vpbuddy
|
|---|
| 1203 | //// return RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW_W | RDW_ALLCHILDREN_W);
|
|---|
| 1204 | WinUpdateWindow(wnd->getOS2WindowHandle());
|
|---|
| 1205 | return TRUE;
|
|---|
| 1206 | }
|
|---|
| 1207 | //******************************************************************************
|
|---|
| 1208 | //******************************************************************************
|
|---|
| 1209 | BOOL WIN32API InvalidateRect (HWND hwnd, const RECT *pRect, BOOL erase)
|
|---|
| 1210 | {
|
|---|
| 1211 | BOOL result;
|
|---|
| 1212 |
|
|---|
| 1213 | result = RedrawWindow (hwnd, pRect, NULLHANDLE,
|
|---|
| 1214 | RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
|
|---|
| 1215 | (erase ? RDW_ERASE_W : 0) |
|
|---|
| 1216 | (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
|
|---|
| 1217 | return (result);
|
|---|
| 1218 | }
|
|---|
| 1219 | //******************************************************************************
|
|---|
| 1220 | //******************************************************************************
|
|---|
| 1221 | BOOL WIN32API InvalidateRgn (HWND hwnd, HRGN hrgn, BOOL erase)
|
|---|
| 1222 | {
|
|---|
| 1223 | BOOL result;
|
|---|
| 1224 |
|
|---|
| 1225 | result = RedrawWindow (hwnd, NULL, hrgn,
|
|---|
| 1226 | RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
|
|---|
| 1227 | (erase ? RDW_ERASE_W : 0) |
|
|---|
| 1228 | (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
|
|---|
| 1229 | return (result);
|
|---|
| 1230 | }
|
|---|
| 1231 | //******************************************************************************
|
|---|
| 1232 | //******************************************************************************
|
|---|
| 1233 | BOOL setPMRgnIntoWinRgn (HRGN hrgnPM, HRGN hrgnWin, LONG height)
|
|---|
| 1234 | {
|
|---|
| 1235 | BOOL rc;
|
|---|
| 1236 | HPS hps = WinGetScreenPS (HWND_DESKTOP);
|
|---|
| 1237 | RGNRECT rgnRect;
|
|---|
| 1238 | rgnRect.ircStart = 1;
|
|---|
| 1239 | rgnRect.crc = 0;
|
|---|
| 1240 | rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT; // doesn't make a difference because we're getting them all
|
|---|
| 1241 |
|
|---|
| 1242 | rc = GpiQueryRegionRects (hps, hrgnPM, NULL, &rgnRect, NULL);
|
|---|
| 1243 |
|
|---|
| 1244 | if (rc && (rgnRect.crcReturned > 0))
|
|---|
| 1245 | {
|
|---|
| 1246 | PRECTL Rcls = new RECTL[rgnRect.crcReturned];
|
|---|
| 1247 | PRECTL pRcl = Rcls;
|
|---|
| 1248 |
|
|---|
| 1249 | if (Rcls != NULL)
|
|---|
| 1250 | {
|
|---|
| 1251 | rgnRect.crc = rgnRect.crcReturned;
|
|---|
| 1252 | rc = GpiQueryRegionRects (hps, hrgnPM, NULL, &rgnRect, Rcls);
|
|---|
| 1253 |
|
|---|
| 1254 | rc = O32_SetRectRgn (hrgnWin, pRcl->xLeft,
|
|---|
| 1255 | pRcl->xRight,
|
|---|
| 1256 | height - pRcl->yTop,
|
|---|
| 1257 | height - pRcl->yBottom);
|
|---|
| 1258 |
|
|---|
| 1259 | if (rgnRect.crcReturned > 1)
|
|---|
| 1260 | {
|
|---|
| 1261 | int i;
|
|---|
| 1262 | HRGN temp;
|
|---|
| 1263 | temp = O32_CreateRectRgn (0, 0, 1, 1);
|
|---|
| 1264 |
|
|---|
| 1265 | for (i = 1, pRcl++; rc && (i < rgnRect.crcReturned); i++, pRcl++)
|
|---|
| 1266 | {
|
|---|
| 1267 | rc = O32_SetRectRgn (temp, pRcl->xLeft,
|
|---|
| 1268 | pRcl->xRight,
|
|---|
| 1269 | height - pRcl->yTop,
|
|---|
| 1270 | height - pRcl->yBottom);
|
|---|
| 1271 | rc &= O32_CombineRgn (hrgnWin, hrgnWin, temp, RGN_OR_W);
|
|---|
| 1272 | }
|
|---|
| 1273 | O32_DeleteObject (temp);
|
|---|
| 1274 | }
|
|---|
| 1275 | delete[] Rcls;
|
|---|
| 1276 | }
|
|---|
| 1277 | else
|
|---|
| 1278 | {
|
|---|
| 1279 | rc = FALSE;
|
|---|
| 1280 | }
|
|---|
| 1281 | }
|
|---|
| 1282 | else
|
|---|
| 1283 | {
|
|---|
| 1284 | rc = O32_SetRectRgn (hrgnWin, 0, 0, 0, 0);
|
|---|
| 1285 | }
|
|---|
| 1286 |
|
|---|
| 1287 | WinReleasePS (hps);
|
|---|
| 1288 | return (rc);
|
|---|
| 1289 | }
|
|---|
| 1290 | //******************************************************************************
|
|---|
| 1291 | //******************************************************************************
|
|---|
| 1292 | BOOL WIN32API ScrollDC (HDC hDC, int dx, int dy, const RECT *pScroll,
|
|---|
| 1293 | const RECT *pClip, HRGN hrgnUpdate, LPRECT pRectUpdate)
|
|---|
| 1294 | {
|
|---|
| 1295 | BOOL rc = TRUE;
|
|---|
| 1296 |
|
|---|
| 1297 | dprintf (("USER32: ScrollDC"));
|
|---|
| 1298 |
|
|---|
| 1299 | if (!hDC)
|
|---|
| 1300 | {
|
|---|
| 1301 | return (FALSE);
|
|---|
| 1302 | }
|
|---|
| 1303 |
|
|---|
| 1304 | pDCData pHps = (pDCData)GpiQueryDCData ((HPS)hDC);
|
|---|
| 1305 | HWND hwnd = pHps->hwnd;
|
|---|
| 1306 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
|---|
| 1307 |
|
|---|
| 1308 | if ((hwnd == NULLHANDLE) || !wnd)
|
|---|
| 1309 | {
|
|---|
| 1310 | return (FALSE);
|
|---|
| 1311 | }
|
|---|
| 1312 |
|
|---|
| 1313 | POINTL ptl[2] = { 0, 0, dx, dy };
|
|---|
| 1314 |
|
|---|
| 1315 | GpiConvert (pHps->hps, CVTC_WORLD, CVTC_DEVICE, 2, ptl);
|
|---|
| 1316 | dx = (int)(ptl[1].x - ptl[0].x);
|
|---|
| 1317 | dy = (int)(ptl[1].y - ptl[0].y);
|
|---|
| 1318 |
|
|---|
| 1319 | RECTL scrollRect;
|
|---|
| 1320 | RECTL clipRect;
|
|---|
| 1321 |
|
|---|
| 1322 | if (pClip)
|
|---|
| 1323 | {
|
|---|
| 1324 | clipRect.xLeft = min (pClip->left, pClip->right);
|
|---|
| 1325 | clipRect.xRight = max (pClip->left, pClip->right);
|
|---|
| 1326 | clipRect.yTop = max (pClip->top, pClip->bottom);
|
|---|
| 1327 | clipRect.yBottom = min (pClip->top, pClip->bottom);
|
|---|
| 1328 |
|
|---|
| 1329 | if ((pHps->graphicsMode == GM_COMPATIBLE_W) &&
|
|---|
| 1330 | (clipRect.xLeft != clipRect.xRight) &&
|
|---|
| 1331 | (clipRect.yBottom != clipRect.yTop))
|
|---|
| 1332 | {
|
|---|
| 1333 | if (abs((int)pHps->viewportXExt) <= abs((int)pHps->windowExt.cx))
|
|---|
| 1334 | clipRect.xRight -= abs(pHps->worldXDeltaFor1Pixel);
|
|---|
| 1335 | else
|
|---|
| 1336 | clipRect.xLeft += abs(pHps->worldXDeltaFor1Pixel);
|
|---|
| 1337 |
|
|---|
| 1338 | if (abs((int)pHps->viewportYExt) <= abs((int)pHps->windowExt.cy))
|
|---|
| 1339 | clipRect.yTop -= abs(pHps->worldYDeltaFor1Pixel);
|
|---|
| 1340 | else
|
|---|
| 1341 | clipRect.yBottom += abs(pHps->worldYDeltaFor1Pixel);
|
|---|
| 1342 | }
|
|---|
| 1343 | GpiConvert (pHps->hps, CVTC_WORLD, CVTC_DEVICE, 2, (PPOINTL)&clipRect);
|
|---|
| 1344 | if (clipRect.xRight < clipRect.xLeft) {
|
|---|
| 1345 | ULONG temp = clipRect.xLeft;
|
|---|
| 1346 | clipRect.xLeft = clipRect.xRight;
|
|---|
| 1347 | clipRect.xRight = temp;
|
|---|
| 1348 | }
|
|---|
| 1349 | if (clipRect.yTop < clipRect.yBottom) {
|
|---|
| 1350 | ULONG temp = clipRect.yBottom;
|
|---|
| 1351 | clipRect.yBottom = clipRect.yTop;
|
|---|
| 1352 | clipRect.yTop = temp;
|
|---|
| 1353 | }
|
|---|
| 1354 | }
|
|---|
| 1355 |
|
|---|
| 1356 | if (pScroll)
|
|---|
| 1357 | {
|
|---|
| 1358 | scrollRect.xLeft = min (pScroll->left, pScroll->right);
|
|---|
| 1359 | scrollRect.xRight = max (pScroll->left, pScroll->right);
|
|---|
| 1360 | scrollRect.yTop = max (pScroll->top, pScroll->bottom);
|
|---|
| 1361 | scrollRect.yBottom = min (pScroll->top, pScroll->bottom);
|
|---|
| 1362 |
|
|---|
| 1363 | if ((pHps->graphicsMode == GM_COMPATIBLE_W) &&
|
|---|
| 1364 | (scrollRect.xLeft != scrollRect.xRight) &&
|
|---|
| 1365 | (scrollRect.yBottom != scrollRect.yTop))
|
|---|
| 1366 | {
|
|---|
| 1367 | if (abs((int)pHps->viewportXExt) <= abs((int)pHps->windowExt.cx))
|
|---|
| 1368 | scrollRect.xRight -= abs(pHps->worldXDeltaFor1Pixel);
|
|---|
| 1369 | else
|
|---|
| 1370 | scrollRect.xLeft += abs(pHps->worldXDeltaFor1Pixel);
|
|---|
| 1371 |
|
|---|
| 1372 | if (abs((int)pHps->viewportYExt) <= abs((int)pHps->windowExt.cy))
|
|---|
| 1373 | scrollRect.yTop -= abs(pHps->worldYDeltaFor1Pixel);
|
|---|
| 1374 | else
|
|---|
| 1375 | scrollRect.yBottom += abs(pHps->worldYDeltaFor1Pixel);
|
|---|
| 1376 | }
|
|---|
| 1377 | GpiConvert (pHps->hps, CVTC_WORLD, CVTC_DEVICE, 2, (PPOINTL)&scrollRect);
|
|---|
| 1378 | if (scrollRect.xRight < scrollRect.xLeft) {
|
|---|
| 1379 | ULONG temp = scrollRect.xLeft;
|
|---|
| 1380 | scrollRect.xLeft = scrollRect.xRight;
|
|---|
| 1381 | scrollRect.xRight = temp;
|
|---|
| 1382 | }
|
|---|
| 1383 | if (scrollRect.yTop < scrollRect.yBottom) {
|
|---|
| 1384 | ULONG temp = scrollRect.yBottom;
|
|---|
| 1385 | scrollRect.yBottom = scrollRect.yTop;
|
|---|
| 1386 | scrollRect.yTop = temp;
|
|---|
| 1387 | }
|
|---|
| 1388 | }
|
|---|
| 1389 | RECTL rectlUpdate;
|
|---|
| 1390 | HRGN hrgn;
|
|---|
| 1391 |
|
|---|
| 1392 | LONG lComplexity = WinScrollWindow (hwnd, dx, dy, (pScroll) ? &scrollRect : NULL, (pClip) ? &clipRect : NULL, hrgn, &rectlUpdate, 0);
|
|---|
| 1393 | if (lComplexity == RGN_ERROR)
|
|---|
| 1394 | {
|
|---|
| 1395 | return (FALSE);
|
|---|
| 1396 | }
|
|---|
| 1397 |
|
|---|
| 1398 | RECT winRectUpdate;
|
|---|
| 1399 | LONG height = wnd->getClientHeight();
|
|---|
| 1400 |
|
|---|
| 1401 | winRectUpdate.left = rectlUpdate.xLeft;
|
|---|
| 1402 | winRectUpdate.right = rectlUpdate.xRight;
|
|---|
| 1403 | winRectUpdate.top = height - rectlUpdate.yTop;
|
|---|
| 1404 | winRectUpdate.bottom = height - rectlUpdate.yBottom;
|
|---|
| 1405 |
|
|---|
| 1406 | if (pRectUpdate)
|
|---|
| 1407 | *pRectUpdate = winRectUpdate;
|
|---|
| 1408 |
|
|---|
| 1409 | if (hrgnUpdate)
|
|---|
| 1410 | rc = setPMRgnIntoWinRgn (hrgn, hrgnUpdate, height);
|
|---|
| 1411 |
|
|---|
| 1412 | return (rc);
|
|---|
| 1413 | }
|
|---|
| 1414 | //******************************************************************************
|
|---|
| 1415 | //******************************************************************************
|
|---|
| 1416 | #if 1
|
|---|
| 1417 | BOOL WIN32API ScrollWindow(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip)
|
|---|
| 1418 | {
|
|---|
| 1419 | Win32BaseWindow *window;
|
|---|
| 1420 | APIRET rc;
|
|---|
| 1421 | RECTL clientRect;
|
|---|
| 1422 | PRECT pClientRect;
|
|---|
| 1423 | RECTL scrollRect;
|
|---|
| 1424 | RECTL clipRect;
|
|---|
| 1425 | PRECTL pScrollRect = NULL;
|
|---|
| 1426 | PRECTL pClipRect = NULL;
|
|---|
| 1427 | ULONG scrollFlags = SW_INVALIDATERGN;
|
|---|
| 1428 |
|
|---|
| 1429 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 1430 | if(!window) {
|
|---|
| 1431 | dprintf(("ScrollWindow, window %x not found", hwnd));
|
|---|
| 1432 | return 0;
|
|---|
| 1433 | }
|
|---|
| 1434 | dprintf(("ScrollWindow %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip));
|
|---|
| 1435 |
|
|---|
| 1436 | pClientRect = window->getClientRectPtr();
|
|---|
| 1437 | clientRect.xLeft = 0;
|
|---|
| 1438 | clientRect.yBottom = 0;
|
|---|
| 1439 | clientRect.xRight = pClientRect->right - pClientRect->left;
|
|---|
| 1440 | clientRect.yTop = pClientRect->bottom - pClientRect->top;
|
|---|
| 1441 |
|
|---|
| 1442 | if(pScroll) {
|
|---|
| 1443 | mapWin32ToOS2Rect(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect);
|
|---|
| 1444 | pScrollRect = &scrollRect;
|
|---|
| 1445 |
|
|---|
| 1446 | //Scroll rectangle relative to client area
|
|---|
| 1447 | WinIntersectRect ((HAB) 0, pScrollRect, pScrollRect, &clientRect);
|
|---|
| 1448 | }
|
|---|
| 1449 | else scrollFlags |= SW_SCROLLCHILDREN;
|
|---|
| 1450 |
|
|---|
| 1451 | if(pClip) {
|
|---|
| 1452 | mapWin32ToOS2Rect(window,(RECT *)pClip, (PRECTLOS2)&clipRect);
|
|---|
| 1453 | pClipRect = &clipRect;
|
|---|
| 1454 |
|
|---|
| 1455 | //Clip rectangle relative to client area
|
|---|
| 1456 | WinIntersectRect ((HAB) 0, pClipRect, pClipRect, &clientRect);
|
|---|
| 1457 | }
|
|---|
| 1458 |
|
|---|
| 1459 | dy = revertDy (window, dy);
|
|---|
| 1460 |
|
|---|
| 1461 | rc = WinScrollWindow(window->getOS2WindowHandle(), dx, dy,
|
|---|
| 1462 | pScrollRect, pClipRect, NULLHANDLE,
|
|---|
| 1463 | NULL, scrollFlags);
|
|---|
| 1464 |
|
|---|
| 1465 | return (rc != RGN_ERROR);
|
|---|
| 1466 | }
|
|---|
| 1467 | #else
|
|---|
| 1468 | BOOL WIN32API ScrollWindow(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip)
|
|---|
| 1469 | {
|
|---|
| 1470 | Win32BaseWindow *window;
|
|---|
| 1471 | APIRET rc;
|
|---|
| 1472 | RECTL clientRect;
|
|---|
| 1473 | RECTL scrollRect;
|
|---|
| 1474 | RECTL clipRect;
|
|---|
| 1475 | PRECTL pScrollRect = NULL;
|
|---|
| 1476 | PRECTL pClipRect = NULL;
|
|---|
| 1477 | ULONG scrollFlags = SW_INVALIDATERGN;
|
|---|
| 1478 |
|
|---|
| 1479 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 1480 | if(!window) {
|
|---|
| 1481 | dprintf(("ScrollWindow, window %x not found", hwnd));
|
|---|
| 1482 | return 0;
|
|---|
| 1483 | }
|
|---|
| 1484 | dprintf(("ScrollWindow %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip));
|
|---|
| 1485 | mapWin32ToOS2Rect(window,window->getClientRectPtr(),(PRECTLOS2)&clientRect);
|
|---|
| 1486 | #if 0
|
|---|
| 1487 | //Rectangle could be relative to parent window, so fix this
|
|---|
| 1488 | if(clientRect.yBottom != 0) {
|
|---|
| 1489 | clientRect.yTop -= clientRect.yBottom;
|
|---|
| 1490 | clientRect.yBottom = 0;
|
|---|
| 1491 | }
|
|---|
| 1492 | if(clientRect.xLeft != 0) {
|
|---|
| 1493 | clientRect.xRight -= clientRect.xLeft;
|
|---|
| 1494 | clientRect.xLeft = 0;
|
|---|
| 1495 | }
|
|---|
| 1496 | #endif
|
|---|
| 1497 | if(pScroll) {
|
|---|
| 1498 | mapWin32ToOS2Rect(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect);
|
|---|
| 1499 | pScrollRect = &scrollRect;
|
|---|
| 1500 |
|
|---|
| 1501 | //Scroll rectangle relative to client area
|
|---|
| 1502 | pScrollRect->xLeft += clientRect.xLeft;
|
|---|
| 1503 | pScrollRect->xRight += clientRect.xLeft;
|
|---|
| 1504 | pScrollRect->yTop += clientRect.yBottom;
|
|---|
| 1505 | pScrollRect->yBottom += clientRect.yBottom;
|
|---|
| 1506 | WinIntersectRect ((HAB) 0, pScrollRect, pScrollRect, &clientRect);
|
|---|
| 1507 | }
|
|---|
| 1508 | else scrollFlags |= SW_SCROLLCHILDREN;
|
|---|
| 1509 |
|
|---|
| 1510 | if(pClip) {
|
|---|
| 1511 | mapWin32ToOS2Rect(window,(RECT *)pClip, (PRECTLOS2)&clipRect);
|
|---|
| 1512 | pClipRect = &clipRect;
|
|---|
| 1513 |
|
|---|
| 1514 | //Clip rectangle relative to client area
|
|---|
| 1515 | pClipRect->xLeft += clientRect.xLeft;
|
|---|
| 1516 | pClipRect->xRight += clientRect.xLeft;
|
|---|
| 1517 | pClipRect->yTop += clientRect.yBottom;
|
|---|
| 1518 | pClipRect->yBottom += clientRect.yBottom;
|
|---|
| 1519 | WinIntersectRect ((HAB) 0, pClipRect, pClipRect, &clientRect);
|
|---|
| 1520 | }
|
|---|
| 1521 |
|
|---|
| 1522 | dy = revertDy (window, dy);
|
|---|
| 1523 |
|
|---|
| 1524 | rc = WinScrollWindow(window->getOS2WindowHandle(), dx, dy,
|
|---|
| 1525 | pScrollRect, pClipRect, NULLHANDLE,
|
|---|
| 1526 | NULL, scrollFlags);
|
|---|
| 1527 |
|
|---|
| 1528 | return (rc != RGN_ERROR);
|
|---|
| 1529 | }
|
|---|
| 1530 | #endif
|
|---|
| 1531 | //******************************************************************************
|
|---|
| 1532 | //******************************************************************************
|
|---|
| 1533 | INT WIN32API ScrollWindowEx(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip,
|
|---|
| 1534 | HRGN hrgnUpdate, PRECT pRectUpdate, UINT scrollFlag)
|
|---|
| 1535 | {
|
|---|
| 1536 | Win32BaseWindow *window;
|
|---|
| 1537 | APIRET rc;
|
|---|
| 1538 | RECTL scrollRect;
|
|---|
| 1539 | RECTL clipRect;
|
|---|
| 1540 | ULONG scrollFlags = 0;
|
|---|
| 1541 | int regionType = ERROR_W;
|
|---|
| 1542 |
|
|---|
| 1543 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 1544 | if(!window) {
|
|---|
| 1545 | dprintf(("ScrollWindowEx, window %x not found", hwnd));
|
|---|
| 1546 | return 0;
|
|---|
| 1547 | }
|
|---|
| 1548 |
|
|---|
| 1549 | dprintf(("ScrollWindowEx %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip));
|
|---|
| 1550 |
|
|---|
| 1551 | dy = revertDy (window, dy);
|
|---|
| 1552 |
|
|---|
| 1553 | if (scrollFlag & SW_INVALIDATE_W) scrollFlags |= SW_INVALIDATERGN;
|
|---|
| 1554 | if (scrollFlag & SW_SCROLLCHILDREN_W) scrollFlags |= SW_SCROLLCHILDREN;
|
|---|
| 1555 |
|
|---|
| 1556 | if(pScroll) mapWin32ToOS2Rect(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect);
|
|---|
| 1557 | if(pClip) mapWin32ToOS2Rect(window,(RECT *)pClip, (PRECTLOS2)&clipRect);
|
|---|
| 1558 |
|
|---|
| 1559 | RECTL rectlUpdate;
|
|---|
| 1560 | HRGN hrgn;
|
|---|
| 1561 |
|
|---|
| 1562 | if (scrollFlag & SW_SMOOTHSCROLL_W)
|
|---|
| 1563 | {
|
|---|
| 1564 | INT time = (scrollFlag >> 16) & 0xFFFF;
|
|---|
| 1565 |
|
|---|
| 1566 | //CB: todo, scroll in several steps
|
|---|
| 1567 | // is time in ms? time <-> iteration count?
|
|---|
| 1568 | }
|
|---|
| 1569 |
|
|---|
| 1570 | LONG lComplexity = WinScrollWindow (window->getOS2WindowHandle(), dx, dy,
|
|---|
| 1571 | (pScroll) ? &scrollRect : NULL,
|
|---|
| 1572 | (pClip) ? &clipRect : NULL,
|
|---|
| 1573 | hrgn, &rectlUpdate, scrollFlags);
|
|---|
| 1574 | if (lComplexity == RGN_ERROR)
|
|---|
| 1575 | {
|
|---|
| 1576 | return ERROR_W;
|
|---|
| 1577 | }
|
|---|
| 1578 |
|
|---|
| 1579 | RECT winRectUpdate;
|
|---|
| 1580 | LONG height = window->getClientHeight();
|
|---|
| 1581 |
|
|---|
| 1582 | winRectUpdate.left = rectlUpdate.xLeft;
|
|---|
| 1583 | winRectUpdate.right = rectlUpdate.xRight;
|
|---|
| 1584 | winRectUpdate.top = height - rectlUpdate.yTop;
|
|---|
| 1585 | winRectUpdate.bottom = height - rectlUpdate.yBottom;
|
|---|
| 1586 |
|
|---|
| 1587 | if (pRectUpdate)
|
|---|
| 1588 | *pRectUpdate = winRectUpdate;
|
|---|
| 1589 |
|
|---|
| 1590 | if (hrgnUpdate)
|
|---|
| 1591 | rc = setPMRgnIntoWinRgn (hrgn, hrgnUpdate, height);
|
|---|
| 1592 |
|
|---|
| 1593 | //SvL: WinScrollWindow already invalidates the area; no need to do it again
|
|---|
| 1594 | //(call to invalidateRect was wrong; has to include erase flag)
|
|---|
| 1595 | #if 0
|
|---|
| 1596 | if ((scrollFlag & SW_INVALIDATE_W) &&
|
|---|
| 1597 | ((lComplexity == RGN_RECT) || (lComplexity == RGN_COMPLEX)))
|
|---|
| 1598 | {
|
|---|
| 1599 | rc = InvalidateRect (hwnd, &winRectUpdate, (scrollFlag & SW_ERASE_W) ? 1 : 0);
|
|---|
| 1600 | if (rc == FALSE)
|
|---|
| 1601 | {
|
|---|
| 1602 | return (0);
|
|---|
| 1603 | }
|
|---|
| 1604 | }
|
|---|
| 1605 | #endif
|
|---|
| 1606 |
|
|---|
| 1607 | switch (lComplexity)
|
|---|
| 1608 | {
|
|---|
| 1609 | case RGN_NULL:
|
|---|
| 1610 | regionType = NULLREGION_W;
|
|---|
| 1611 | break;
|
|---|
| 1612 | case RGN_RECT:
|
|---|
| 1613 | regionType = SIMPLEREGION_W;
|
|---|
| 1614 | break;
|
|---|
| 1615 | case RGN_COMPLEX:
|
|---|
| 1616 | regionType = COMPLEXREGION_W;
|
|---|
| 1617 | break;
|
|---|
| 1618 | default:
|
|---|
| 1619 | regionType = ERROR_W;
|
|---|
| 1620 | break;
|
|---|
| 1621 | }
|
|---|
| 1622 |
|
|---|
| 1623 | return (regionType);
|
|---|
| 1624 | }
|
|---|
| 1625 | //******************************************************************************
|
|---|
| 1626 | //******************************************************************************
|
|---|
| 1627 | HWND WIN32API WindowFromDC(HDC hdc)
|
|---|
| 1628 | {
|
|---|
| 1629 | pDCData pHps = (pDCData)GpiQueryDCData( (HPS)hdc );
|
|---|
| 1630 |
|
|---|
| 1631 | dprintf2(("USER32: WindowFromDC %x", hdc));
|
|---|
| 1632 | if ( pHps )
|
|---|
| 1633 | return Win32BaseWindow::OS2ToWin32Handle(pHps->hwnd);
|
|---|
| 1634 | else
|
|---|
| 1635 | return 0;
|
|---|
| 1636 | }
|
|---|
| 1637 | //******************************************************************************
|
|---|
| 1638 | //******************************************************************************
|
|---|
| 1639 | INT WIN32API ExcludeUpdateRgn( HDC hDC, HWND hWnd)
|
|---|
| 1640 | {
|
|---|
| 1641 | dprintf(("USER32: ExcludeUpdateRgn\n"));
|
|---|
| 1642 | hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
|
|---|
| 1643 |
|
|---|
| 1644 | return O32_ExcludeUpdateRgn(hDC,hWnd);
|
|---|
| 1645 | }
|
|---|
| 1646 | //******************************************************************************
|
|---|
| 1647 | //******************************************************************************
|
|---|
| 1648 | BOOL WIN32API ValidateRect( HWND hwnd, const RECT * lprc)
|
|---|
| 1649 | {
|
|---|
| 1650 | if(lprc) {
|
|---|
| 1651 | dprintf(("USER32: ValidateRect %x (%d,%d)(%d,%d)", hwnd, lprc->left, lprc->top, lprc->right, lprc->bottom));
|
|---|
| 1652 | }
|
|---|
| 1653 | else dprintf(("USER32: ValidateRect %x", hwnd));
|
|---|
| 1654 |
|
|---|
| 1655 | return RedrawWindow( hwnd, lprc, 0, RDW_VALIDATE_W | RDW_NOCHILDREN_W | (hwnd==0 ? RDW_UPDATENOW_W : 0));
|
|---|
| 1656 | }
|
|---|
| 1657 | //******************************************************************************
|
|---|
| 1658 | //******************************************************************************
|
|---|
| 1659 | BOOL WIN32API ValidateRgn( HWND hwnd, HRGN hrgn)
|
|---|
| 1660 | {
|
|---|
| 1661 | dprintf(("USER32: ValidateRgn %x %x", hwnd, hrgn));
|
|---|
| 1662 | return RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE_W | RDW_NOCHILDREN_W | (hwnd==0 ? RDW_UPDATENOW_W : 0));
|
|---|
| 1663 | }
|
|---|
| 1664 | /*****************************************************************************
|
|---|
| 1665 | * Name : int WIN32API GetWindowRgn
|
|---|
| 1666 | * Purpose : The GetWindowRgn function obtains a copy of the window region of a window.
|
|---|
| 1667 | * Parameters: HWND hWnd handle to window whose window region is to be obtained
|
|---|
| 1668 | * HRGN hRgn handle to region that receives a copy of the window region
|
|---|
| 1669 | * Variables :
|
|---|
| 1670 | * Result : NULLREGION, SIMPLEREGION, COMPLEXREGION, ERROR
|
|---|
| 1671 | * Remark :
|
|---|
| 1672 | * Status : UNTESTED STUB
|
|---|
| 1673 | *
|
|---|
| 1674 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 1675 | *****************************************************************************/
|
|---|
| 1676 |
|
|---|
| 1677 | int WIN32API GetWindowRgn(HWND hwnd, HRGN hRgn)
|
|---|
| 1678 | {
|
|---|
| 1679 | Win32BaseWindow *window;
|
|---|
| 1680 | HRGN hWindowRegion;
|
|---|
| 1681 |
|
|---|
| 1682 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 1683 | if(!window) {
|
|---|
| 1684 | dprintf(("SetWindowContextHelpId, window %x not found", hwnd));
|
|---|
| 1685 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
|---|
| 1686 | return 0;
|
|---|
| 1687 | }
|
|---|
| 1688 | dprintf(("USER32:GetWindowRgn (%x,%x)", hwnd, hRgn));
|
|---|
| 1689 | hWindowRegion = window->GetWindowRegion();
|
|---|
| 1690 |
|
|---|
| 1691 | return O32_CombineRgn(hRgn, hWindowRegion, 0, RGN_COPY_W);
|
|---|
| 1692 | }
|
|---|
| 1693 | /*****************************************************************************
|
|---|
| 1694 | * Name : int WIN32API SetWindowRgn
|
|---|
| 1695 | * Purpose : The SetWindowRgn function sets the window region of a window. The
|
|---|
| 1696 | * window region determines the area within the window where the
|
|---|
| 1697 | * operating system permits drawing. The operating system does not
|
|---|
| 1698 | * display any portion of a window that lies outside of the window region
|
|---|
| 1699 | * When this function is called, the system sends the WM_WINDOWPOSCHANGING and
|
|---|
| 1700 | * WM_WINDOWPOSCHANGED messages to the window.
|
|---|
| 1701 | *
|
|---|
| 1702 | * Parameters: HWND hWnd handle to window whose window region is to be set
|
|---|
| 1703 | * HRGN hRgn handle to region
|
|---|
| 1704 | * BOOL bRedraw window redraw flag
|
|---|
| 1705 | * Variables :
|
|---|
| 1706 | * Result : If the function succeeds, the return value is non-zero.
|
|---|
| 1707 | * If the function fails, the return value is zero.
|
|---|
| 1708 | * Remark :
|
|---|
| 1709 | * Status : UNTESTED STUB
|
|---|
| 1710 | *
|
|---|
| 1711 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 1712 | *****************************************************************************/
|
|---|
| 1713 |
|
|---|
| 1714 | int WIN32API SetWindowRgn(HWND hwnd,
|
|---|
| 1715 | HRGN hRgn,
|
|---|
| 1716 | BOOL bRedraw)
|
|---|
| 1717 | {
|
|---|
| 1718 | Win32BaseWindow *window;
|
|---|
| 1719 | HRGN hWindowRegion;
|
|---|
| 1720 |
|
|---|
| 1721 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 1722 | if(!window) {
|
|---|
| 1723 | dprintf(("SetWindowContextHelpId, window %x not found", hwnd));
|
|---|
| 1724 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
|---|
| 1725 | return 0;
|
|---|
| 1726 | }
|
|---|
| 1727 | dprintf(("USER32:SetWindowRgn (%x,%x,%d)", hwnd, hRgn, bRedraw));
|
|---|
| 1728 | if(window->GetWindowRegion()) {
|
|---|
| 1729 | O32_DeleteObject(window->GetWindowRegion());
|
|---|
| 1730 | }
|
|---|
| 1731 | window->SetWindowRegion(hRgn);
|
|---|
| 1732 | if(bRedraw) {
|
|---|
| 1733 | RedrawWindow(hwnd, 0, 0, RDW_UPDATENOW_W);
|
|---|
| 1734 | }
|
|---|
| 1735 | //TODO:
|
|---|
| 1736 | // When this function is called, the system sends the WM_WINDOWPOSCHANGING and
|
|---|
| 1737 | // WM_WINDOWPOSCHANGED messages to the window.
|
|---|
| 1738 | return 1;
|
|---|
| 1739 | }
|
|---|
| 1740 | //******************************************************************************
|
|---|
| 1741 | //******************************************************************************
|
|---|