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