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