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