1 | /* $Id: dc.cpp,v 1.59 2000-06-07 14:51:25 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 |
|
---|
351 | pHps->isClient = TRUE;
|
---|
352 |
|
---|
353 | hwnd = window->getOS2WindowHandle();
|
---|
354 |
|
---|
355 | mapWin32ToOS2Rect(window->getWindowHeight(), window->getClientRectPtr(), (PRECTLOS2)&rcl);
|
---|
356 |
|
---|
357 | //convert to screen coordinates
|
---|
358 | GreGetDCOrigin(pHps->hps, (PPOINTL)&rcltemp);
|
---|
359 | rcl.xLeft += rcltemp.xLeft;
|
---|
360 | rcl.xRight += rcltemp.xLeft;
|
---|
361 | rcl.yTop += rcltemp.yBottom;
|
---|
362 | rcl.yBottom += rcltemp.yBottom;
|
---|
363 |
|
---|
364 | pHps->ptlOrigin.x = rcltemp.xLeft;
|
---|
365 | pHps->ptlOrigin.y = rcltemp.yBottom;
|
---|
366 |
|
---|
367 | dprintf2(("selectClientArea: (%d,%d) -> (%d,%d)", rcltemp.xLeft, rcltemp.yBottom, rcl.xLeft, rcl.yBottom));
|
---|
368 |
|
---|
369 | if(pHps->hrgnVis == 0)
|
---|
370 | pHps->hrgnVis = GreCreateRectRegion(pHps->hps, &rcl, 1);
|
---|
371 |
|
---|
372 | hrgnRect = GreCreateRectRegion(pHps->hps, &rcl, 1);
|
---|
373 |
|
---|
374 | // Query the visible region
|
---|
375 | GreCopyClipRegion(pHps->hps, pHps->hrgnVis, 0, COPYCRGN_VISRGN);
|
---|
376 | GpiQueryRegionBox(pHps->hps, pHps->hrgnVis, &rcltemp);
|
---|
377 | // And the visible region of the frame with the client rectangle
|
---|
378 | // to get the new visible region
|
---|
379 | GreCombineRegion(pHps->hps, hrgnRect, pHps->hrgnVis, hrgnRect, CRGN_AND);
|
---|
380 |
|
---|
381 | // Set the new origin plus visible region in the DC
|
---|
382 | GreSetupDC(pHps->hps,
|
---|
383 | hrgnRect,
|
---|
384 | rcl.xLeft,
|
---|
385 | rcl.yBottom,
|
---|
386 | NULL,
|
---|
387 | SETUPDC_ORIGIN | SETUPDC_VISRGN | SETUPDC_RECALCCLIP);
|
---|
388 |
|
---|
389 | /*
|
---|
390 | GpiQueryRegionBox(pHps->hps, hrgnClip, &rcltemp);
|
---|
391 | GpiQueryRegionBox(pHps->hps, hrgnOldClip, &rcltemp);
|
---|
392 |
|
---|
393 | GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp);
|
---|
394 |
|
---|
395 | GreGetDCOrigin(pHps->hps, (PPOINTL)&rcltemp);
|
---|
396 |
|
---|
397 | GreCopyClipRegion(pHps->hps, hrgnRect, 0, COPYCRGN_VISRGN);
|
---|
398 | GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp);
|
---|
399 |
|
---|
400 | GreCopyClipRegion(pHps->hps, hrgnRect, 0, COPYCRGN_ALLINTERSECT);
|
---|
401 | GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp);
|
---|
402 |
|
---|
403 | GreCopyClipRegion(pHps->hps, hrgnRect, 0, COPYCRGN_CLIPRGN);
|
---|
404 | GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp);
|
---|
405 | */
|
---|
406 | pHps->isClientArea = TRUE;
|
---|
407 |
|
---|
408 | // Destroy the region now we have finished with it.
|
---|
409 | GreDestroyRegion(pHps->hps, hrgnRect);
|
---|
410 |
|
---|
411 | setupclipregion:
|
---|
412 | if(prclPaint) {
|
---|
413 | hrgnClip = GpiQueryClipRegion(pHps->hps);
|
---|
414 | if(hrgnClip) {
|
---|
415 | rc = GreIntersectClipRectangle(pHps->hps, prclPaint);
|
---|
416 | if(rc == RGN_ERROR) {
|
---|
417 | dprintf(("selectClientArea: GreIntersectClipRectangle returned RGN_ERROR!"));
|
---|
418 | }
|
---|
419 | }
|
---|
420 | else {
|
---|
421 | hrgnClip = GreCreateRectRegion(pHps->hps, prclPaint, 1);
|
---|
422 | GreSelectClipRegion(pHps->hps, hrgnClip, &hrgnOldClip);
|
---|
423 | }
|
---|
424 | }
|
---|
425 |
|
---|
426 | return hrgnOldClip;
|
---|
427 | }
|
---|
428 | //******************************************************************************
|
---|
429 | //******************************************************************************
|
---|
430 | LONG clientHeight(Win32BaseWindow *wnd, HWND hwnd, pDCData pHps)
|
---|
431 | {
|
---|
432 | if ((hwnd == 0) && (pHps != 0))
|
---|
433 | hwnd = pHps->hwnd;
|
---|
434 |
|
---|
435 | if ((hwnd != 0) || (pHps == 0))
|
---|
436 | {
|
---|
437 | if(wnd) {
|
---|
438 | if(pHps && !pHps->isClientArea) {
|
---|
439 | return (wnd->getWindowHeight());
|
---|
440 | }
|
---|
441 | else return (wnd->getClientHeight());
|
---|
442 | }
|
---|
443 | else return OSLibQueryScreenHeight();
|
---|
444 | }
|
---|
445 | else if (pHps->bitmapHandle)
|
---|
446 | {
|
---|
447 | return pHps->bitmapHeight;
|
---|
448 | }
|
---|
449 | else if (pHps->isMetaPS)
|
---|
450 | {
|
---|
451 | return 0;
|
---|
452 | }
|
---|
453 | else if (pHps->isPrinter)
|
---|
454 | {
|
---|
455 | return pHps->printPageHeight;
|
---|
456 | }
|
---|
457 | else
|
---|
458 | {
|
---|
459 | return MEM_HPS_MAX;
|
---|
460 | }
|
---|
461 | }
|
---|
462 | //******************************************************************************
|
---|
463 | //******************************************************************************
|
---|
464 | BOOL isYup (pDCData pHps)
|
---|
465 | {
|
---|
466 | if (((pHps->windowExt.cy < 0) && (pHps->viewportYExt > 0.0)) ||
|
---|
467 | ((pHps->windowExt.cy > 0) && (pHps->viewportYExt < 0.0)))
|
---|
468 | {
|
---|
469 | if ((pHps->graphicsMode == GM_COMPATIBLE_W) ||
|
---|
470 | ((pHps->graphicsMode == GM_ADVANCED_W) && (pHps->xform.eM22 >= 0.0)))
|
---|
471 | return TRUE;
|
---|
472 | }
|
---|
473 | else
|
---|
474 | {
|
---|
475 | if ((pHps->graphicsMode == GM_ADVANCED_W) && (pHps->xform.eM22 < 0.0))
|
---|
476 | return TRUE;
|
---|
477 | }
|
---|
478 | return FALSE;
|
---|
479 | }
|
---|
480 | //******************************************************************************
|
---|
481 | //******************************************************************************
|
---|
482 | INT revertDy (Win32BaseWindow *wnd, INT dy)
|
---|
483 | {
|
---|
484 | //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
|
---|
485 | // if (wnd->isOwnDC() && wnd->getOwnDC())
|
---|
486 | if (wnd->isOwnDC())
|
---|
487 | {
|
---|
488 | pDCData pHps = (pDCData)GpiQueryDCData (wnd->getOwnDC());
|
---|
489 |
|
---|
490 | if (pHps != NULLHANDLE)
|
---|
491 | if (!isYup (pHps))
|
---|
492 | dy = -dy;
|
---|
493 | }
|
---|
494 | else
|
---|
495 | {
|
---|
496 | dy = -dy;
|
---|
497 | }
|
---|
498 | return (dy);
|
---|
499 | }
|
---|
500 | //******************************************************************************
|
---|
501 | //******************************************************************************
|
---|
502 | HDC sendEraseBkgnd (Win32BaseWindow *wnd)
|
---|
503 | {
|
---|
504 | BOOL erased;
|
---|
505 | HWND hwnd;
|
---|
506 | HDC hdc;
|
---|
507 | HPS hps;
|
---|
508 | HRGN hrgnUpdate, hrgnOld, hrgnClip, hrgnCombined;
|
---|
509 | RECTL rectl = { 1, 1, 2, 2 };
|
---|
510 |
|
---|
511 | hwnd = wnd->getOS2WindowHandle();
|
---|
512 | hps = WinGetPS(hwnd);
|
---|
513 |
|
---|
514 | hrgnUpdate = GpiCreateRegion (hps, 1, &rectl);
|
---|
515 | WinQueryUpdateRegion (hwnd, hrgnUpdate);
|
---|
516 | hrgnClip = GpiQueryClipRegion (hps);
|
---|
517 |
|
---|
518 | if (hrgnClip == NULLHANDLE)
|
---|
519 | {
|
---|
520 | GpiSetClipRegion (hps, hrgnUpdate, &hrgnOld);
|
---|
521 | }
|
---|
522 | else
|
---|
523 | {
|
---|
524 | hrgnCombined = GpiCreateRegion (hps, 1, &rectl);
|
---|
525 | GpiCombineRegion (hps, hrgnCombined, hrgnClip, hrgnUpdate, CRGN_AND);
|
---|
526 | GpiSetClipRegion (hps, hrgnCombined, &hrgnOld);
|
---|
527 | GpiDestroyRegion (hps, hrgnUpdate);
|
---|
528 | GpiDestroyRegion (hps, hrgnClip);
|
---|
529 | }
|
---|
530 | if (hrgnOld != NULLHANDLE)
|
---|
531 | GpiDestroyRegion (hps, hrgnOld);
|
---|
532 |
|
---|
533 | hdc = HPSToHDC (hwnd, hps, NULL, NULL);
|
---|
534 |
|
---|
535 | erased = wnd->MsgEraseBackGround (hdc);
|
---|
536 |
|
---|
537 | DeleteHDC (hdc);
|
---|
538 | WinReleasePS (hps);
|
---|
539 |
|
---|
540 | return erased;
|
---|
541 | }
|
---|
542 | //******************************************************************************
|
---|
543 | //******************************************************************************
|
---|
544 | void releaseOwnDC (HDC hps)
|
---|
545 | {
|
---|
546 | pDCData pHps = (pDCData)GpiQueryDCData ((HPS)hps);
|
---|
547 |
|
---|
548 | if (pHps) {
|
---|
549 | if (pHps->hrgnHDC)
|
---|
550 | GpiDestroyRegion (pHps->hps, pHps->hrgnHDC);
|
---|
551 |
|
---|
552 | GpiSetBitmap (pHps->hps, NULL);
|
---|
553 | O32_DeleteObject (pHps->nullBitmapHandle);
|
---|
554 | GpiDestroyPS(pHps->hps);
|
---|
555 |
|
---|
556 | if (pHps->hdc)
|
---|
557 | DevCloseDC(pHps->hdc);
|
---|
558 | }
|
---|
559 | }
|
---|
560 | //******************************************************************************
|
---|
561 | //******************************************************************************
|
---|
562 | HDC WIN32API BeginPaint (HWND hWnd, PPAINTSTRUCT_W lpps)
|
---|
563 | {
|
---|
564 | HWND hwnd = hWnd ? hWnd : HWND_DESKTOP;
|
---|
565 | pDCData pHps = NULLHANDLE;
|
---|
566 | HPS hPS_ownDC = NULLHANDLE, hpsPaint = 0;
|
---|
567 | RECTL rectl = {0, 0, 1, 1};
|
---|
568 | HRGN hrgnUpdate, hrgnOld, hrgnOldClip;
|
---|
569 | LONG lComplexity;
|
---|
570 | RECTL rectlClient;
|
---|
571 | RECTL rectlClip;
|
---|
572 |
|
---|
573 | memset(lpps, 0, sizeof(*lpps));
|
---|
574 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
575 | if(!lpps || !wnd) {
|
---|
576 | dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
|
---|
577 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
578 | return (HDC)0;
|
---|
579 | }
|
---|
580 | HWND hwndClient = wnd->getOS2WindowHandle();
|
---|
581 |
|
---|
582 | if(hwnd != HWND_DESKTOP && wnd->isOwnDC())
|
---|
583 | {
|
---|
584 | hPS_ownDC = wnd->getOwnDC();
|
---|
585 | //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
|
---|
586 | if(hPS_ownDC) {
|
---|
587 | pHps = (pDCData)GpiQueryDCData(hPS_ownDC);
|
---|
588 | if (!pHps)
|
---|
589 | {
|
---|
590 | dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
|
---|
591 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
592 | return (HDC)NULLHANDLE;
|
---|
593 | }
|
---|
594 | hpsPaint = hPS_ownDC;
|
---|
595 | }
|
---|
596 | }
|
---|
597 | if(!hpsPaint) {
|
---|
598 | hpsPaint = GetDCEx(hwnd, 0, (DCX_CACHE_W|DCX_WINDOW_W|DCX_USESTYLE_W));
|
---|
599 | pHps = (pDCData)GpiQueryDCData(hpsPaint);
|
---|
600 | if (!pHps)
|
---|
601 | {
|
---|
602 | dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
|
---|
603 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
604 | return (HDC)NULLHANDLE;
|
---|
605 | }
|
---|
606 | }
|
---|
607 |
|
---|
608 | if(WinQueryUpdateRect(hwndClient, &rectl) == FALSE) {
|
---|
609 | memset(&rectl, 0, sizeof(rectl));
|
---|
610 | dprintf (("USER32: WARNING: WinQueryUpdateRect failed (error or no update rectangle)!!"));
|
---|
611 |
|
---|
612 | mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&rectlClient);
|
---|
613 | WinOffsetRect(NULL, &rectlClient, -rectlClient.xLeft, -rectlClient.yBottom);
|
---|
614 |
|
---|
615 | hrgnOldClip = selectClientArea(wnd, pHps, &rectlClient);
|
---|
616 | //save old clip region (restored for CS_OWNDC windows in EndPaint)
|
---|
617 | wnd->SetClipRegion(hrgnOldClip);
|
---|
618 | lComplexity = RGN_NULL;
|
---|
619 | }
|
---|
620 | else {
|
---|
621 | HRGN hrgnTmp = GpiCreateRegion(pHps->hps, 1, &rectl);
|
---|
622 |
|
---|
623 | WinQueryUpdateRegion(hwndClient, hrgnTmp);
|
---|
624 |
|
---|
625 | RGNRECT rgnrect = {0, 12, 0, RECTDIR_LFRT_TOPBOT};
|
---|
626 | RECTL rectls[12], rcltemp;
|
---|
627 | GpiQueryRegionRects(pHps->hps, hrgnTmp, &rcltemp, &rgnrect, &rectls[0]);
|
---|
628 | GpiDestroyRegion(pHps->hps, hrgnTmp);
|
---|
629 |
|
---|
630 | WinValidateRect(hwndClient, &rectl, FALSE);
|
---|
631 |
|
---|
632 | mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&rectlClient);
|
---|
633 | WinIntersectRect(NULL, &rectlClip, &rectl, &rectlClient);
|
---|
634 | WinOffsetRect(NULL, &rectlClip, -rectlClient.xLeft, -rectlClient.yBottom);
|
---|
635 |
|
---|
636 | hrgnOldClip = selectClientArea(wnd, pHps, &rectlClip);
|
---|
637 |
|
---|
638 | //save old clip region (restored for CS_OWNDC windows in EndPaint)
|
---|
639 | wnd->SetClipRegion(hrgnOldClip);
|
---|
640 | memcpy(&rectl, &rectlClip, sizeof(RECTL));
|
---|
641 | lComplexity = RGN_RECT;
|
---|
642 | }
|
---|
643 |
|
---|
644 | if(hPS_ownDC == 0)
|
---|
645 | setMapMode (wnd, pHps, MM_TEXT_W);
|
---|
646 | else
|
---|
647 | setPageXForm(wnd, pHps);
|
---|
648 |
|
---|
649 | pHps->hdcType = TYPE_3;
|
---|
650 |
|
---|
651 | HideCaret(hwnd);
|
---|
652 | WinShowTrackRect(wnd->getOS2WindowHandle(), FALSE);
|
---|
653 |
|
---|
654 | if(wnd->needsEraseBkgnd() && lComplexity != RGN_NULL) {
|
---|
655 | wnd->setEraseBkgnd(FALSE);
|
---|
656 | lpps->fErase = (wnd->MsgEraseBackGround(pHps->hps) != 0);
|
---|
657 | }
|
---|
658 | else lpps->fErase = TRUE;
|
---|
659 |
|
---|
660 | lpps->hdc = (HDC)pHps->hps;
|
---|
661 |
|
---|
662 | if(lComplexity != RGN_NULL) {
|
---|
663 | long height = wnd->getClientHeight();
|
---|
664 | lpps->rcPaint.top = height - rectl.yTop;
|
---|
665 | lpps->rcPaint.left = rectl.xLeft;
|
---|
666 | lpps->rcPaint.bottom = height - rectl.yBottom;
|
---|
667 | lpps->rcPaint.right = rectl.xRight;
|
---|
668 | }
|
---|
669 | else {
|
---|
670 | lpps->rcPaint.bottom = lpps->rcPaint.top = 0;
|
---|
671 | lpps->rcPaint.right = lpps->rcPaint.left = 0;
|
---|
672 | }
|
---|
673 |
|
---|
674 | SetLastError(0);
|
---|
675 | 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));
|
---|
676 | return (HDC)pHps->hps;
|
---|
677 | }
|
---|
678 | //******************************************************************************
|
---|
679 | //******************************************************************************
|
---|
680 | BOOL WIN32API EndPaint (HWND hWnd, const PAINTSTRUCT_W *pPaint)
|
---|
681 | {
|
---|
682 | HWND hwnd = hWnd ? hWnd : HWND_DESKTOP;
|
---|
683 | HRGN hrgnOld;
|
---|
684 | pDCData pHps;
|
---|
685 |
|
---|
686 | dprintf (("USER32: EndPaint(%x)", hwnd));
|
---|
687 |
|
---|
688 | if (!pPaint || !pPaint->hdc )
|
---|
689 | return TRUE;
|
---|
690 |
|
---|
691 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
692 |
|
---|
693 | if (!wnd) goto exit;
|
---|
694 |
|
---|
695 | pHps = (pDCData)GpiQueryDCData((HPS)pPaint->hdc);
|
---|
696 | if (pHps && (pHps->hdcType == TYPE_3))
|
---|
697 | {
|
---|
698 | removeClientArea(pHps);
|
---|
699 | if(hrgnOld) {
|
---|
700 | GpiSetClipRegion(pHps->hps, NULLHANDLE, &hrgnOld);
|
---|
701 | GpiDestroyRegion(pHps->hps, hrgnOld);
|
---|
702 | }
|
---|
703 | if(hwnd == HWND_DESKTOP || !wnd->isOwnDC()) {
|
---|
704 | pHps->hdcType = TYPE_1; //otherwise Open32's ReleaseDC fails
|
---|
705 | ReleaseDC(hwnd, pPaint->hdc);
|
---|
706 | }
|
---|
707 | else
|
---|
708 | if(wnd->GetClipRegion()) {
|
---|
709 | //TODO: What else do we need to restore here???
|
---|
710 | GpiSetClipRegion(pHps->hps, wnd->GetClipRegion(), &hrgnOld);
|
---|
711 | wnd->SetClipRegion(0);
|
---|
712 | pHps->hdcType = TYPE_1;
|
---|
713 | }
|
---|
714 | }
|
---|
715 | else {
|
---|
716 | dprintf(("EndPaint: wrong hdc %x!!", pPaint->hdc));
|
---|
717 | }
|
---|
718 | wnd->setEraseBkgnd(TRUE);
|
---|
719 | ShowCaret(hwnd);
|
---|
720 | WinShowTrackRect(wnd->getOS2WindowHandle(), TRUE);
|
---|
721 |
|
---|
722 | exit:
|
---|
723 | SetLastError(0);
|
---|
724 | return TRUE;
|
---|
725 | }
|
---|
726 | //******************************************************************************
|
---|
727 | //******************************************************************************
|
---|
728 | int WIN32API GetClipBox( HDC hdc, PRECT lpRect)
|
---|
729 | {
|
---|
730 | pDCData pHps = (pDCData)GpiQueryDCData((HPS)hdc);
|
---|
731 | RECTL rectl;
|
---|
732 | LONG lComplexity;
|
---|
733 | int rc;
|
---|
734 |
|
---|
735 | if(!hdc || !lpRect || !pHps) {
|
---|
736 | dprintf(("GDI32: GetClipBox %x %x ERROR_INVALID_PARAMETER", hdc, lpRect));
|
---|
737 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
738 | return ERROR_W;
|
---|
739 | }
|
---|
740 | if(pHps->isPrinter)
|
---|
741 | {
|
---|
742 | lpRect->left = 0;
|
---|
743 | lpRect->top = 0;
|
---|
744 | lpRect->right = GetDeviceCaps( hdc, HORZRES_W);
|
---|
745 | lpRect->bottom = GetDeviceCaps( hdc, VERTRES_W);
|
---|
746 |
|
---|
747 | rc = SIMPLEREGION_W;
|
---|
748 | }
|
---|
749 | else {
|
---|
750 | lComplexity = GpiQueryClipBox(pHps->hps, &rectl);
|
---|
751 | if(lComplexity == RGN_ERROR)
|
---|
752 | {
|
---|
753 | rc = ERROR_W;
|
---|
754 | }
|
---|
755 | else
|
---|
756 | if(lComplexity == RGN_NULL)
|
---|
757 | {
|
---|
758 | memset(lpRect, 0, sizeof(*lpRect));
|
---|
759 | rc = NULLREGION_W;
|
---|
760 | }
|
---|
761 | else {
|
---|
762 | lpRect->left = rectl.xLeft;
|
---|
763 | lpRect->right = rectl.xRight;
|
---|
764 | #if 0
|
---|
765 | lpRect->top = pHps->height - rectl.yTop;
|
---|
766 | lpRect->bottom = pHps->height - rectl.yBottom;
|
---|
767 | #else
|
---|
768 | //No conversion required as GpiQueryClipBox is affected by
|
---|
769 | //the y-inversion of the window
|
---|
770 | lpRect->top = rectl.yBottom;
|
---|
771 | lpRect->bottom = rectl.yTop;
|
---|
772 | #endif
|
---|
773 | //Convert including/including to including/excluding
|
---|
774 | if(lpRect->left != lpRect->right) {
|
---|
775 | lpRect->right++;
|
---|
776 | }
|
---|
777 | if(lpRect->top != lpRect->bottom) {
|
---|
778 | lpRect->bottom++;
|
---|
779 | }
|
---|
780 | rc = (lComplexity == RGN_RECT) ? SIMPLEREGION_W : COMPLEXREGION_W;
|
---|
781 | }
|
---|
782 | }
|
---|
783 | dprintf(("GDI32: GetClipBox of %X returned %d\n", hdc, rc));
|
---|
784 | return rc;
|
---|
785 | }
|
---|
786 | //******************************************************************************
|
---|
787 | //******************************************************************************
|
---|
788 | int WIN32API GetClipRgn( HDC hdc, HRGN hRgn)
|
---|
789 | {
|
---|
790 | int rc;
|
---|
791 |
|
---|
792 | rc = O32_GetClipRgn(hdc, hRgn);
|
---|
793 | dprintf(("GDI32: GetClipRgn %x %x returned %x", hdc, hRgn, rc));
|
---|
794 | return rc;
|
---|
795 | }
|
---|
796 | //******************************************************************************
|
---|
797 | //******************************************************************************
|
---|
798 | BOOL WIN32API GetUpdateRect (HWND hwnd, LPRECT pRect, BOOL erase)
|
---|
799 | {
|
---|
800 | if (!hwnd)
|
---|
801 | {
|
---|
802 | dprintf(("GetUpdateRect %x %x %d -> invalid handle!!", hwnd, pRect, erase));
|
---|
803 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
---|
804 | return FALSE;
|
---|
805 | }
|
---|
806 |
|
---|
807 | RECTL rectl;
|
---|
808 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
809 |
|
---|
810 | if (!wnd)
|
---|
811 | {
|
---|
812 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
---|
813 | dprintf(("GetUpdateRect %x %x %d -> invalid handle!!", hwnd, pRect, erase));
|
---|
814 | return FALSE;
|
---|
815 | }
|
---|
816 |
|
---|
817 | dprintf(("GetUpdateRect %x %x %d", hwnd, pRect, erase));
|
---|
818 |
|
---|
819 | BOOL updateRegionExists = WinQueryUpdateRect (wnd->getOS2WindowHandle(), pRect ? &rectl : NULL);
|
---|
820 | if (!pRect) {
|
---|
821 | return (updateRegionExists);
|
---|
822 | }
|
---|
823 |
|
---|
824 | if (updateRegionExists)
|
---|
825 | {
|
---|
826 | //CB: for PM empty rect is valid
|
---|
827 | if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) {
|
---|
828 | if(pRect) {
|
---|
829 | pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
|
---|
830 | }
|
---|
831 | return FALSE;
|
---|
832 | }
|
---|
833 | #if 0
|
---|
834 | //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
|
---|
835 | // if (wnd->isOwnDC() && wnd->getOwnDC())
|
---|
836 | if (wnd->isOwnDC())
|
---|
837 | {
|
---|
838 | pDCData pHps = NULL;
|
---|
839 | pHps = (pDCData)GpiQueryDCData(wnd->getOwnDC());
|
---|
840 | if (!pHps)
|
---|
841 | {
|
---|
842 | SetLastError(ERROR_INVALID_HANDLE_W);
|
---|
843 | return FALSE;
|
---|
844 | }
|
---|
845 | GpiConvert (pHps->hps, CVTC_DEVICE, CVTC_WORLD, 2, (PPOINTL)&rectl);
|
---|
846 | }
|
---|
847 | else
|
---|
848 | {
|
---|
849 | #endif
|
---|
850 | long height = wnd->getClientHeight();
|
---|
851 | rectl.yTop = height - rectl.yTop;
|
---|
852 | rectl.yBottom = height - rectl.yBottom;
|
---|
853 | ////////// }
|
---|
854 |
|
---|
855 | if (pRect)
|
---|
856 | WINRECT_FROM_PMRECT (*pRect, rectl);
|
---|
857 |
|
---|
858 | if (erase)
|
---|
859 | sendEraseBkgnd (wnd);
|
---|
860 | }
|
---|
861 | else
|
---|
862 | {
|
---|
863 | if(pRect) {
|
---|
864 | pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
|
---|
865 | }
|
---|
866 | }
|
---|
867 |
|
---|
868 | return updateRegionExists;
|
---|
869 | }
|
---|
870 | //******************************************************************************
|
---|
871 | //functions for WM_NCPAINT
|
---|
872 | //******************************************************************************
|
---|
873 | INT SYSTEM GetOS2UpdateRgn(HWND hwnd,HRGN hrgn)
|
---|
874 | {
|
---|
875 | return O32_GetUpdateRgn(hwnd,hrgn,FALSE);
|
---|
876 | }
|
---|
877 | //******************************************************************************
|
---|
878 | //******************************************************************************
|
---|
879 | BOOL GetOS2UpdateRect(Win32BaseWindow *window, LPRECT pRect)
|
---|
880 | {
|
---|
881 | RECTL rectl;
|
---|
882 | BOOL updateRegionExists = WinQueryUpdateRect(window->getOS2WindowHandle(),pRect ? &rectl:NULL);
|
---|
883 |
|
---|
884 | if (!pRect)
|
---|
885 | return (updateRegionExists);
|
---|
886 |
|
---|
887 | if (updateRegionExists)
|
---|
888 | {
|
---|
889 | //CB: for PM empty rect is valid
|
---|
890 | if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) return FALSE;
|
---|
891 | mapOS2ToWin32Rect(window->getWindowHeight(), (PRECTLOS2)&rectl,pRect);
|
---|
892 | }
|
---|
893 | else
|
---|
894 | pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
|
---|
895 |
|
---|
896 | return updateRegionExists;
|
---|
897 | }
|
---|
898 | //******************************************************************************
|
---|
899 | //******************************************************************************
|
---|
900 | int WIN32API GetUpdateRgn (HWND hwnd, HRGN hrgn, BOOL erase)
|
---|
901 | {
|
---|
902 | LONG Complexity;
|
---|
903 |
|
---|
904 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
905 |
|
---|
906 | if (!wnd)
|
---|
907 | {
|
---|
908 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
---|
909 | return ERROR_W;
|
---|
910 | }
|
---|
911 |
|
---|
912 | Complexity = O32_GetUpdateRgn (wnd->getOS2WindowHandle(), hrgn, FALSE);
|
---|
913 | if (erase && (Complexity > NULLREGION_W)) sendEraseBkgnd(wnd);
|
---|
914 |
|
---|
915 | return Complexity;
|
---|
916 | }
|
---|
917 | //******************************************************************************
|
---|
918 | //******************************************************************************
|
---|
919 | int WIN32API ReleaseDC (HWND hwnd, HDC hdc)
|
---|
920 | {
|
---|
921 | BOOL isOwnDC = FALSE;
|
---|
922 | int rc;
|
---|
923 |
|
---|
924 | if (hwnd)
|
---|
925 | {
|
---|
926 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
---|
927 | if(wnd == NULL) {
|
---|
928 | dprintf(("ERROR: ReleaseDC %x %x failed", hwnd, hdc));
|
---|
929 | return 0;
|
---|
930 | }
|
---|
931 | //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
|
---|
932 | // isOwnDC = wnd->isOwnDC() && wnd->getOwnDC();
|
---|
933 | isOwnDC = wnd->isOwnDC() && (wnd->getOwnDC() == hdc);
|
---|
934 | if(!isOwnDC)
|
---|
935 | {
|
---|
936 | pDCData pHps = (pDCData)GpiQueryDCData((HPS)hdc);
|
---|
937 | if(pHps && pHps->psType == MICRO_CACHED) {
|
---|
938 | removeClientArea(pHps);
|
---|
939 | if(pHps->hrgnVis) {
|
---|
940 | GreDestroyRegion(pHps->hps, pHps->hrgnVis);
|
---|
941 | pHps->hrgnVis = 0;
|
---|
942 | }
|
---|
943 | }
|
---|
944 | else {
|
---|
945 | dprintf(("ERROR: ReleaseDC: pHps == NULL!!"));
|
---|
946 | DebugInt3();
|
---|
947 | }
|
---|
948 | }
|
---|
949 | }
|
---|
950 |
|
---|
951 | if(isOwnDC) {
|
---|
952 | rc = TRUE;
|
---|
953 | }
|
---|
954 | else {
|
---|
955 | rc = O32_ReleaseDC (0, hdc);
|
---|
956 | }
|
---|
957 |
|
---|
958 | dprintf(("ReleaseDC %x %x", hwnd, hdc));
|
---|
959 | return (rc);
|
---|
960 | }
|
---|
961 | //******************************************************************************
|
---|
962 | // This implementation of GetDCEx supports
|
---|
963 | // DCX_WINDOW
|
---|
964 | // DCX_CACHE
|
---|
965 | // DCX_EXCLUDERGN (complex regions allowed)
|
---|
966 | // DCX_INTERSECTRGN (complex regions allowed)
|
---|
967 | // DCX_USESTYLE
|
---|
968 | // DCX_CLIPSIBLINGS
|
---|
969 | // DCX_CLIPCHILDREN
|
---|
970 | // DCX_PARENTCLIP
|
---|
971 | //
|
---|
972 | //TODO: WM_SETREDRAW affects drawingAllowed flag!!
|
---|
973 | //******************************************************************************
|
---|
974 | HDC WIN32API GetDCEx (HWND hwnd, HRGN hrgn, ULONG flags)
|
---|
975 | {
|
---|
976 | Win32BaseWindow *wnd = NULL;
|
---|
977 | HWND hWindow;
|
---|
978 | BOOL success;
|
---|
979 | pDCData pHps = NULL;
|
---|
980 | HPS hps = NULLHANDLE;
|
---|
981 | BOOL drawingAllowed = TRUE;
|
---|
982 | BOOL isWindowOwnDC;
|
---|
983 | BOOL creatingOwnDC = FALSE;
|
---|
984 | PS_Type psType;
|
---|
985 |
|
---|
986 | if(hwnd == 0) {
|
---|
987 | dprintf(("error: GetDCEx window %x not found", hwnd));
|
---|
988 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
---|
989 | return 0;
|
---|
990 | }
|
---|
991 |
|
---|
992 | if (hwnd)
|
---|
993 | {
|
---|
994 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
995 | if(wnd == NULL) {
|
---|
996 | dprintf (("ERROR: User32: GetDCEx bad window handle %X!!!!!", hwnd));
|
---|
997 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
---|
998 | return 0;
|
---|
999 | }
|
---|
1000 | hWindow = wnd->getOS2WindowHandle();
|
---|
1001 | }
|
---|
1002 |
|
---|
1003 | isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : (wnd->isOwnDC()))
|
---|
1004 | && !(flags & DCX_CACHE_W));
|
---|
1005 |
|
---|
1006 | if(isWindowOwnDC)
|
---|
1007 | {
|
---|
1008 | hps = wnd->getOwnDC();
|
---|
1009 | if (hps)
|
---|
1010 | {
|
---|
1011 | pDCData pHps = (pDCData)GpiQueryDCData (hps);
|
---|
1012 | if (!pHps)
|
---|
1013 | goto error;
|
---|
1014 |
|
---|
1015 | if(flags & DCX_WINDOW_W)
|
---|
1016 | removeClientArea(pHps);
|
---|
1017 | else
|
---|
1018 | selectClientArea(wnd, pHps, NULL);
|
---|
1019 |
|
---|
1020 | setPageXForm (wnd, pHps);
|
---|
1021 | pHps->hdcType = TYPE_1;
|
---|
1022 |
|
---|
1023 | dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x hdc %x", hwnd, hrgn, flags, wnd, hps));
|
---|
1024 | return (HDC)hps;
|
---|
1025 | }
|
---|
1026 | else
|
---|
1027 | creatingOwnDC = TRUE;
|
---|
1028 | }
|
---|
1029 |
|
---|
1030 | if(isWindowOwnDC)
|
---|
1031 | {
|
---|
1032 | SIZEL sizel = {0,0};
|
---|
1033 | hps = GpiCreatePS (WinQueryAnchorBlock (hWindow),
|
---|
1034 | WinOpenWindowDC (hWindow),
|
---|
1035 | &sizel, PU_PELS | GPIT_MICRO | GPIA_ASSOC );
|
---|
1036 | psType = MICRO;
|
---|
1037 | }
|
---|
1038 | else
|
---|
1039 | {
|
---|
1040 | if (hWindow == HWND_DESKTOP) {
|
---|
1041 | hps = WinGetScreenPS (hWindow);
|
---|
1042 | }
|
---|
1043 | else {
|
---|
1044 | int clipstyle = 0;
|
---|
1045 | int clipwnd = HWND_TOP;
|
---|
1046 | if(flags & (DCX_USESTYLE_W)) {
|
---|
1047 | int style = wnd->getStyle();
|
---|
1048 | if(style & WS_CLIPCHILDREN_W) {
|
---|
1049 | clipstyle |= PSF_CLIPCHILDREN;
|
---|
1050 | }
|
---|
1051 | if(style & WS_CLIPSIBLINGS_W) {
|
---|
1052 | clipstyle |= PSF_CLIPSIBLINGS;
|
---|
1053 | }
|
---|
1054 | if(wnd->fHasParentDC()) {
|
---|
1055 | clipstyle |= PSF_PARENTCLIP;
|
---|
1056 | }
|
---|
1057 | }
|
---|
1058 | if(flags & DCX_CLIPSIBLINGS_W) {
|
---|
1059 | clipstyle |= PSF_CLIPSIBLINGS;
|
---|
1060 | }
|
---|
1061 | if(flags & DCX_CLIPCHILDREN_W) {
|
---|
1062 | clipstyle |= PSF_CLIPCHILDREN;
|
---|
1063 | }
|
---|
1064 | if(flags & DCX_PARENTCLIP_W) {
|
---|
1065 | clipstyle |= PSF_PARENTCLIP;
|
---|
1066 | }
|
---|
1067 | if(clipstyle) {
|
---|
1068 | dprintf2(("WinGetClipPS style %x", clipstyle));
|
---|
1069 | hps = WinGetClipPS(hWindow, clipwnd, clipstyle);
|
---|
1070 | }
|
---|
1071 | else hps = WinGetPS (hWindow);
|
---|
1072 | }
|
---|
1073 | psType = MICRO_CACHED;
|
---|
1074 | }
|
---|
1075 |
|
---|
1076 | if (!hps)
|
---|
1077 | goto error;
|
---|
1078 |
|
---|
1079 | HPSToHDC (hWindow, hps, NULL, NULL);
|
---|
1080 | pHps = (pDCData)GpiQueryDCData (hps);
|
---|
1081 |
|
---|
1082 | if(!(flags & DCX_WINDOW_W))
|
---|
1083 | {
|
---|
1084 | selectClientArea(wnd, pHps, NULL);
|
---|
1085 | }
|
---|
1086 | else removeClientArea(pHps);
|
---|
1087 |
|
---|
1088 |
|
---|
1089 | setMapMode(wnd, pHps, MM_TEXT_W);
|
---|
1090 |
|
---|
1091 | if ((flags & DCX_EXCLUDERGN_W) || (flags & DCX_INTERSECTRGN_W))
|
---|
1092 | {
|
---|
1093 | ULONG BytesNeeded;
|
---|
1094 | PRGNDATA_W RgnData;
|
---|
1095 | PRECT pr;
|
---|
1096 | int i;
|
---|
1097 | RECTL rectl;
|
---|
1098 |
|
---|
1099 | if (!hrgn)
|
---|
1100 | goto error;
|
---|
1101 |
|
---|
1102 | success = TRUE;
|
---|
1103 | if (flags & DCX_EXCLUDERGN_W)
|
---|
1104 | {
|
---|
1105 | #if 0 //CB: todo
|
---|
1106 | long height;
|
---|
1107 |
|
---|
1108 | BytesNeeded = GetRegionData (hrgn, 0, NULL);
|
---|
1109 | RgnData = (PRGNDATA_W)_alloca (BytesNeeded);
|
---|
1110 | if (RgnData == NULL)
|
---|
1111 | goto error;
|
---|
1112 | GetRegionData (hrgn, BytesNeeded, RgnData);
|
---|
1113 |
|
---|
1114 | i = RgnData->rdh.nCount;
|
---|
1115 | pr = (PRECT)(RgnData->Buffer);
|
---|
1116 |
|
---|
1117 | if (flags & DCX_WINDOW_W)
|
---|
1118 | height = wnd->getWindowHeight();
|
---|
1119 | else height = wnd->getClientHeight();
|
---|
1120 |
|
---|
1121 | for (; (i > 0) && success; i--, pr++) {
|
---|
1122 | LONG y = pr->yBottom;
|
---|
1123 |
|
---|
1124 | pr->yBottom = height - pr->yTop;
|
---|
1125 | pr->yTop = height - y;
|
---|
1126 | success &= GpiExcludeClipRectangle (pHps->hps, pr);
|
---|
1127 | }
|
---|
1128 | #endif
|
---|
1129 | }
|
---|
1130 | else //DCX_INTERSECTRGN_W
|
---|
1131 | {
|
---|
1132 | //SvL: I'm getting paint problems when clipping a dc created in GetDCEx
|
---|
1133 | // with a region that covers the entire window (RealPlayer 7 Update 1)
|
---|
1134 | // Using SelectClipRgn here doesn't make any difference.
|
---|
1135 | if(ExtSelectClipRgn(pHps->hps, hrgn, RGN_AND_W) == ERROR_W) {
|
---|
1136 | dprintf(("ExtSelectClipRgn failed!!"));
|
---|
1137 | }
|
---|
1138 | }
|
---|
1139 | if (!success)
|
---|
1140 | goto error;
|
---|
1141 | }
|
---|
1142 |
|
---|
1143 | if (creatingOwnDC)
|
---|
1144 | wnd->setOwnDC ((HDC)hps);
|
---|
1145 |
|
---|
1146 | pHps->psType = psType;
|
---|
1147 | pHps->hdcType = TYPE_1;
|
---|
1148 | //TODO: WM_SETREDRAW affects drawingAllowed flag!!
|
---|
1149 | GpiSetDrawControl (hps, DCTL_DISPLAY, drawingAllowed ? DCTL_ON : DCTL_OFF);
|
---|
1150 |
|
---|
1151 | dprintf (("User32: GetDCEx hwnd %x (%x %x) -> hdc %x", hwnd, hrgn, flags, pHps->hps));
|
---|
1152 | return (HDC)pHps->hps;
|
---|
1153 |
|
---|
1154 | error:
|
---|
1155 | /* Something went wrong; clean up
|
---|
1156 | */
|
---|
1157 | dprintf(("ERROR: GetDCEx hwnd %x (%x %x) FAILED!", hwnd, hrgn, flags));
|
---|
1158 | DebugInt3();
|
---|
1159 | if (pHps)
|
---|
1160 | {
|
---|
1161 | if (pHps->hps)
|
---|
1162 | {
|
---|
1163 | if(pHps->psType == MICRO_CACHED)
|
---|
1164 | WinReleasePS(pHps->hps);
|
---|
1165 | else
|
---|
1166 | GpiDestroyPS(pHps->hps);
|
---|
1167 | }
|
---|
1168 |
|
---|
1169 | if (pHps->hdc) DevCloseDC(pHps->hdc);
|
---|
1170 | if (pHps->hrgnHDC) GpiDestroyRegion(pHps->hps, pHps->hrgnHDC);
|
---|
1171 |
|
---|
1172 | O32_DeleteObject (pHps->nullBitmapHandle);
|
---|
1173 | }
|
---|
1174 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
1175 | return NULL;
|
---|
1176 | }
|
---|
1177 | //******************************************************************************
|
---|
1178 | //******************************************************************************
|
---|
1179 | HDC WIN32API GetDC (HWND hwnd)
|
---|
1180 | {
|
---|
1181 | if(!hwnd)
|
---|
1182 | return GetDCEx( GetDesktopWindow(), 0, DCX_CACHE_W | DCX_WINDOW_W );
|
---|
1183 | return GetDCEx (hwnd, NULL, 0);
|
---|
1184 | }
|
---|
1185 | //******************************************************************************
|
---|
1186 | //******************************************************************************
|
---|
1187 | HDC WIN32API GetWindowDC (HWND hwnd)
|
---|
1188 | {
|
---|
1189 | if (!hwnd) hwnd = GetDesktopWindow();
|
---|
1190 | return GetDCEx (hwnd, NULL, DCX_WINDOW_W);
|
---|
1191 | }
|
---|
1192 | //******************************************************************************
|
---|
1193 | // This implementation of RedrawWindow supports
|
---|
1194 | // RDW_ERASE
|
---|
1195 | // RDW_NOERASE
|
---|
1196 | // RDW_INTERNALPAINT
|
---|
1197 | // RDW_NOINTERNALPAINT
|
---|
1198 | // RDW_INVALIDATE
|
---|
1199 | // RDW_VALIDATE
|
---|
1200 | // RDW_ERASENOW
|
---|
1201 | // RDW_UPDATENOW
|
---|
1202 | //******************************************************************************
|
---|
1203 | BOOL WIN32API RedrawWindow(HWND hwnd, const RECT* pRect, HRGN hrgn, DWORD redraw)
|
---|
1204 | {
|
---|
1205 | Win32BaseWindow *wnd;
|
---|
1206 |
|
---|
1207 | if(pRect) {
|
---|
1208 | dprintf(("RedrawWindow %x (%d,%d)(%d,%d) %x %x", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom, hrgn, redraw));
|
---|
1209 | }
|
---|
1210 | else dprintf(("RedrawWindow %x %x %x %x", hwnd, pRect, hrgn, redraw));
|
---|
1211 |
|
---|
1212 | if (hwnd == NULLHANDLE)
|
---|
1213 | {
|
---|
1214 | #if 1
|
---|
1215 | // Don't do this for now (causes lots of desktop repaints in WordPad)
|
---|
1216 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
1217 | return FALSE;
|
---|
1218 | #else
|
---|
1219 | hwnd = HWND_DESKTOP;
|
---|
1220 | wnd = Win32BaseWindow::GetWindowFromOS2Handle(OSLIB_HWND_DESKTOP);
|
---|
1221 |
|
---|
1222 | if (!wnd)
|
---|
1223 | {
|
---|
1224 | dprintf(("USER32:dc: RedrawWindow can't find desktop window %08xh\n",
|
---|
1225 | hwnd));
|
---|
1226 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
1227 | return FALSE;
|
---|
1228 | }
|
---|
1229 | #endif
|
---|
1230 | }
|
---|
1231 | else
|
---|
1232 | {
|
---|
1233 | wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
---|
1234 |
|
---|
1235 | if (!wnd)
|
---|
1236 | {
|
---|
1237 | dprintf(("USER32:dc: RedrawWindow can't find window %08xh\n",
|
---|
1238 | hwnd));
|
---|
1239 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
1240 | return FALSE;
|
---|
1241 | }
|
---|
1242 | //TODO: If frame, exclude client window from update
|
---|
1243 | if(redraw & RDW_FRAME_W) {
|
---|
1244 | hwnd = wnd->getOS2WindowHandle();
|
---|
1245 | }
|
---|
1246 | else hwnd = wnd->getOS2WindowHandle();
|
---|
1247 |
|
---|
1248 | }
|
---|
1249 |
|
---|
1250 | BOOL IncludeChildren = redraw & RDW_ALLCHILDREN_W ? TRUE : FALSE;
|
---|
1251 | BOOL success = TRUE;
|
---|
1252 | HPS hpsTemp = NULLHANDLE;
|
---|
1253 | HRGN hrgnTemp = NULLHANDLE;
|
---|
1254 | RECTL rectl;
|
---|
1255 |
|
---|
1256 | if (hrgn)
|
---|
1257 | {
|
---|
1258 | ULONG BytesNeeded;
|
---|
1259 | PRGNDATA_W RgnData;
|
---|
1260 | PRECTL pr;
|
---|
1261 | int i;
|
---|
1262 | LONG height = wnd ? wnd->getClientHeight() : OSLibQueryScreenHeight();
|
---|
1263 |
|
---|
1264 | if (!hrgn)
|
---|
1265 | goto error;
|
---|
1266 |
|
---|
1267 | BytesNeeded = O32_GetRegionData (hrgn, 0, NULL);
|
---|
1268 | RgnData = (PRGNDATA_W)_alloca (BytesNeeded);
|
---|
1269 | if (RgnData == NULL)
|
---|
1270 | goto error;
|
---|
1271 | O32_GetRegionData (hrgn, BytesNeeded, RgnData);
|
---|
1272 |
|
---|
1273 | pr = (PRECTL)(RgnData->Buffer);
|
---|
1274 | for (i = RgnData->rdh.nCount; i > 0; i--, pr++) {
|
---|
1275 | LONG temp = pr->yTop;
|
---|
1276 | pr->yTop = height - pr->yBottom;
|
---|
1277 | pr->yBottom = height - temp;
|
---|
1278 | }
|
---|
1279 |
|
---|
1280 | hpsTemp = WinGetScreenPS (HWND_DESKTOP);
|
---|
1281 | hrgnTemp = GpiCreateRegion (hpsTemp, RgnData->rdh.nCount, (PRECTL)(RgnData->Buffer));
|
---|
1282 | if (!hrgnTemp) goto error;
|
---|
1283 | }
|
---|
1284 | else if (pRect)
|
---|
1285 | {
|
---|
1286 | LONG height = wnd ? wnd->getClientHeight() : OSLibQueryScreenHeight();
|
---|
1287 |
|
---|
1288 | PMRECT_FROM_WINRECT (rectl, *pRect);
|
---|
1289 | rectl.yTop = height - rectl.yTop;
|
---|
1290 | rectl.yBottom = height - rectl.yBottom;
|
---|
1291 | }
|
---|
1292 |
|
---|
1293 | if (redraw & RDW_INVALIDATE_W)
|
---|
1294 | {
|
---|
1295 | //TODO: SvL: pingpong.exe doesn't have RDW_NOERASE, but doesn't want WM_ERASEBKGND msgs
|
---|
1296 | if (redraw & RDW_ERASE_W) {
|
---|
1297 | wnd->setEraseBkgnd(TRUE);
|
---|
1298 | }
|
---|
1299 |
|
---|
1300 | if (!pRect && !hrgn)
|
---|
1301 | success = WinInvalidateRect (hwnd, NULL, IncludeChildren);
|
---|
1302 | else
|
---|
1303 | if (hrgn)
|
---|
1304 | success = WinInvalidateRegion (hwnd, hrgnTemp, IncludeChildren);
|
---|
1305 | else
|
---|
1306 | success = WinInvalidateRect (hwnd, &rectl, IncludeChildren);
|
---|
1307 |
|
---|
1308 | if (!success) goto error;
|
---|
1309 | }
|
---|
1310 | else if (redraw & RDW_VALIDATE_W)
|
---|
1311 | {
|
---|
1312 | if (redraw & RDW_NOERASE_W)
|
---|
1313 | wnd->setEraseBkgnd(FALSE);
|
---|
1314 |
|
---|
1315 | if (WinQueryUpdateRect (hwnd, NULL))
|
---|
1316 | {
|
---|
1317 | if (!pRect && !hrgn)
|
---|
1318 | success = WinValidateRect (hwnd, NULL, IncludeChildren);
|
---|
1319 | else
|
---|
1320 | if (hrgn)
|
---|
1321 | success = WinValidateRegion (hwnd, hrgnTemp, IncludeChildren);
|
---|
1322 | else
|
---|
1323 | success = WinValidateRect (hwnd, &rectl, IncludeChildren);
|
---|
1324 | if (!success) goto error;
|
---|
1325 | }
|
---|
1326 | }
|
---|
1327 |
|
---|
1328 | if(WinQueryUpdateRect(hwnd, NULL))
|
---|
1329 | {
|
---|
1330 | //TODO: Does this work if RDW_ALLCHILDREN is set??
|
---|
1331 | if(redraw & RDW_UPDATENOW_W) {
|
---|
1332 | wnd->MsgPaint (0, FALSE);
|
---|
1333 | }
|
---|
1334 | else
|
---|
1335 | // if((redraw & RDW_ERASE_W) && (redraw & RDW_ERASENOW_W))
|
---|
1336 | if(redraw & RDW_ERASENOW_W && wnd->needsEraseBkgnd())
|
---|
1337 | wnd->setEraseBkgnd(sendEraseBkgnd(wnd) == 0);
|
---|
1338 | }
|
---|
1339 | else if((redraw & RDW_INTERNALPAINT_W) && !(redraw & RDW_INVALIDATE_W))
|
---|
1340 | {
|
---|
1341 | if(redraw & RDW_UPDATENOW_W)
|
---|
1342 | wnd->MsgPaint (0, FALSE);
|
---|
1343 | else PostMessageA(hwnd, WINWM_PAINT, 0, 0);
|
---|
1344 | }
|
---|
1345 |
|
---|
1346 | error:
|
---|
1347 | /* clean up */
|
---|
1348 | if (hrgnTemp)
|
---|
1349 | GpiDestroyRegion (hpsTemp, hrgnTemp);
|
---|
1350 |
|
---|
1351 | if (hpsTemp)
|
---|
1352 | WinReleasePS (hpsTemp);
|
---|
1353 |
|
---|
1354 | if (!success)
|
---|
1355 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
1356 |
|
---|
1357 | return (success);
|
---|
1358 | }
|
---|
1359 | //******************************************************************************
|
---|
1360 | //******************************************************************************
|
---|
1361 | BOOL WIN32API UpdateWindow (HWND hwnd)
|
---|
1362 | {
|
---|
1363 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
---|
1364 |
|
---|
1365 | if(!wnd) {
|
---|
1366 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
---|
1367 | return FALSE;
|
---|
1368 | }
|
---|
1369 |
|
---|
1370 | dprintf (("User32: UpdateWindow hwnd %x", hwnd));
|
---|
1371 | ////SvL: This doesn't work right (Wine uses RDW_NOCHILDREN_W -> doesn't work here)
|
---|
1372 | //// Breaks vpbuddy
|
---|
1373 | //// return RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW_W | RDW_ALLCHILDREN_W);
|
---|
1374 | WinUpdateWindow(wnd->getOS2WindowHandle());
|
---|
1375 | return TRUE;
|
---|
1376 | }
|
---|
1377 | //******************************************************************************
|
---|
1378 | //******************************************************************************
|
---|
1379 | BOOL WIN32API InvalidateRect (HWND hwnd, const RECT *pRect, BOOL erase)
|
---|
1380 | {
|
---|
1381 | BOOL result;
|
---|
1382 |
|
---|
1383 | if(pRect) {
|
---|
1384 | dprintf(("InvalidateRect %x (%d,%d)(%d,%d) erase=%d", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom, erase));
|
---|
1385 | }
|
---|
1386 | else dprintf(("InvalidateRect %x NULL erase=%d", hwnd, erase));
|
---|
1387 | result = RedrawWindow (hwnd, pRect, NULLHANDLE,
|
---|
1388 | RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
|
---|
1389 | (erase ? RDW_ERASE_W : 0) |
|
---|
1390 | (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
|
---|
1391 | return (result);
|
---|
1392 | }
|
---|
1393 | //******************************************************************************
|
---|
1394 | //******************************************************************************
|
---|
1395 | BOOL WIN32API InvalidateRgn (HWND hwnd, HRGN hrgn, BOOL erase)
|
---|
1396 | {
|
---|
1397 | BOOL result;
|
---|
1398 |
|
---|
1399 | dprintf(("InvalidateRgn %x %x erase=%d", hwnd, hrgn, erase));
|
---|
1400 | result = RedrawWindow (hwnd, NULL, hrgn,
|
---|
1401 | RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
|
---|
1402 | (erase ? RDW_ERASE_W : 0) |
|
---|
1403 | (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
|
---|
1404 | return (result);
|
---|
1405 | }
|
---|
1406 | //******************************************************************************
|
---|
1407 | //TODO: Change for client rectangle!!!!!
|
---|
1408 | //******************************************************************************
|
---|
1409 | BOOL setPMRgnIntoWinRgn (HRGN hrgnPM, HRGN hrgnWin, LONG height)
|
---|
1410 | {
|
---|
1411 | BOOL rc;
|
---|
1412 | HPS hps = WinGetScreenPS (HWND_DESKTOP);
|
---|
1413 | RGNRECT rgnRect;
|
---|
1414 | rgnRect.ircStart = 1;
|
---|
1415 | rgnRect.crc = 0;
|
---|
1416 | rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT; // doesn't make a difference because we're getting them all
|
---|
1417 |
|
---|
1418 | rc = GpiQueryRegionRects (hps, hrgnPM, NULL, &rgnRect, NULL);
|
---|
1419 |
|
---|
1420 | if (rc && (rgnRect.crcReturned > 0))
|
---|
1421 | {
|
---|
1422 | PRECTL Rcls = new RECTL[rgnRect.crcReturned];
|
---|
1423 | PRECTL pRcl = Rcls;
|
---|
1424 |
|
---|
1425 | if (Rcls != NULL)
|
---|
1426 | {
|
---|
1427 | rgnRect.crc = rgnRect.crcReturned;
|
---|
1428 | rc = GpiQueryRegionRects (hps, hrgnPM, NULL, &rgnRect, Rcls);
|
---|
1429 |
|
---|
1430 | rc = O32_SetRectRgn (hrgnWin, pRcl->xLeft,
|
---|
1431 | pRcl->xRight,
|
---|
1432 | height - pRcl->yTop,
|
---|
1433 | height - pRcl->yBottom);
|
---|
1434 |
|
---|
1435 | if (rgnRect.crcReturned > 1)
|
---|
1436 | {
|
---|
1437 | int i;
|
---|
1438 | HRGN temp;
|
---|
1439 | temp = O32_CreateRectRgn (0, 0, 1, 1);
|
---|
1440 |
|
---|
1441 | for (i = 1, pRcl++; rc && (i < rgnRect.crcReturned); i++, pRcl++)
|
---|
1442 | {
|
---|
1443 | rc = O32_SetRectRgn (temp, pRcl->xLeft,
|
---|
1444 | pRcl->xRight,
|
---|
1445 | height - pRcl->yTop,
|
---|
1446 | height - pRcl->yBottom);
|
---|
1447 | rc &= O32_CombineRgn (hrgnWin, hrgnWin, temp, RGN_OR_W);
|
---|
1448 | }
|
---|
1449 | O32_DeleteObject (temp);
|
---|
1450 | }
|
---|
1451 | delete[] Rcls;
|
---|
1452 | }
|
---|
1453 | else
|
---|
1454 | {
|
---|
1455 | rc = FALSE;
|
---|
1456 | }
|
---|
1457 | }
|
---|
1458 | else
|
---|
1459 | {
|
---|
1460 | rc = O32_SetRectRgn (hrgnWin, 0, 0, 0, 0);
|
---|
1461 | }
|
---|
1462 |
|
---|
1463 | WinReleasePS (hps);
|
---|
1464 | return (rc);
|
---|
1465 | }
|
---|
1466 | //******************************************************************************
|
---|
1467 | //TODO: Check if this one works correctly...
|
---|
1468 | //******************************************************************************
|
---|
1469 | BOOL WIN32API ScrollDC(HDC hDC, int dx, int dy, const RECT *pScroll,
|
---|
1470 | const RECT *pClip, HRGN hrgnUpdate, LPRECT pRectUpdate)
|
---|
1471 | {
|
---|
1472 | BOOL rc = TRUE;
|
---|
1473 |
|
---|
1474 | dprintf (("USER32: ScrollDC %x (%d,%d), %x %x %x %x", hDC, dx, dy, pScroll, pClip, hrgnUpdate, pRectUpdate));
|
---|
1475 |
|
---|
1476 | if (!hDC)
|
---|
1477 | {
|
---|
1478 | return (FALSE);
|
---|
1479 | }
|
---|
1480 |
|
---|
1481 | pDCData pHps = (pDCData)GpiQueryDCData ((HPS)hDC);
|
---|
1482 | HWND hwnd = pHps->hwnd;
|
---|
1483 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
---|
1484 |
|
---|
1485 | if ((hwnd == NULLHANDLE) || !wnd)
|
---|
1486 | {
|
---|
1487 | return (FALSE);
|
---|
1488 | }
|
---|
1489 |
|
---|
1490 | POINTL ptl[2] = { 0, 0, dx, dy };
|
---|
1491 |
|
---|
1492 | GpiConvert (pHps->hps, CVTC_WORLD, CVTC_DEVICE, 2, ptl);
|
---|
1493 | dx = (int)(ptl[1].x - ptl[0].x);
|
---|
1494 | dy = (int)(ptl[1].y - ptl[0].y);
|
---|
1495 |
|
---|
1496 | RECT scrollRect;
|
---|
1497 | RECT clipRect;
|
---|
1498 |
|
---|
1499 | if (pClip)
|
---|
1500 | {
|
---|
1501 | memcpy(&clipRect, pClip, sizeof(clipRect));
|
---|
1502 |
|
---|
1503 | if ((pHps->graphicsMode == GM_COMPATIBLE_W) &&
|
---|
1504 | (clipRect.left != clipRect.right) &&
|
---|
1505 | (clipRect.bottom != clipRect.top))
|
---|
1506 | {
|
---|
1507 | if (abs((int)pHps->viewportXExt) <= abs((int)pHps->windowExt.cx))
|
---|
1508 | clipRect.right -= abs(pHps->worldXDeltaFor1Pixel);
|
---|
1509 | else
|
---|
1510 | clipRect.left += abs(pHps->worldXDeltaFor1Pixel);
|
---|
1511 |
|
---|
1512 | if (abs((int)pHps->viewportYExt) <= abs((int)pHps->windowExt.cy))
|
---|
1513 | clipRect.bottom -= abs(pHps->worldYDeltaFor1Pixel);
|
---|
1514 | else
|
---|
1515 | clipRect.top += abs(pHps->worldYDeltaFor1Pixel);
|
---|
1516 | }
|
---|
1517 | GpiConvert(pHps->hps, CVTC_WORLD, CVTC_DEVICE, 2, (PPOINTL)&clipRect);
|
---|
1518 | if (clipRect.right < clipRect.left) {
|
---|
1519 | ULONG temp = clipRect.left;
|
---|
1520 | clipRect.left = clipRect.right;
|
---|
1521 | clipRect.right = temp;
|
---|
1522 | }
|
---|
1523 | if (clipRect.bottom < clipRect.top) {
|
---|
1524 | ULONG temp = clipRect.top;
|
---|
1525 | clipRect.top = clipRect.bottom;
|
---|
1526 | clipRect.bottom = temp;
|
---|
1527 | }
|
---|
1528 | }
|
---|
1529 |
|
---|
1530 | if (pScroll)
|
---|
1531 | {
|
---|
1532 | memcpy(&scrollRect, pScroll, sizeof(scrollRect));
|
---|
1533 |
|
---|
1534 | if ((pHps->graphicsMode == GM_COMPATIBLE_W) &&
|
---|
1535 | (scrollRect.left != scrollRect.right) &&
|
---|
1536 | (scrollRect.top != scrollRect.bottom))
|
---|
1537 | {
|
---|
1538 | if (abs((int)pHps->viewportXExt) <= abs((int)pHps->windowExt.cx))
|
---|
1539 | scrollRect.right -= abs(pHps->worldXDeltaFor1Pixel);
|
---|
1540 | else
|
---|
1541 | scrollRect.left += abs(pHps->worldXDeltaFor1Pixel);
|
---|
1542 |
|
---|
1543 | if (abs((int)pHps->viewportYExt) <= abs((int)pHps->windowExt.cy))
|
---|
1544 | scrollRect.bottom -= abs(pHps->worldYDeltaFor1Pixel);
|
---|
1545 | else
|
---|
1546 | scrollRect.top += abs(pHps->worldYDeltaFor1Pixel);
|
---|
1547 | }
|
---|
1548 | GpiConvert (pHps->hps, CVTC_WORLD, CVTC_DEVICE, 2, (PPOINTL)&scrollRect);
|
---|
1549 | if (scrollRect.right < scrollRect.left) {
|
---|
1550 | ULONG temp = scrollRect.left;
|
---|
1551 | scrollRect.left = scrollRect.right;
|
---|
1552 | scrollRect.right = temp;
|
---|
1553 | }
|
---|
1554 | if (scrollRect.bottom < scrollRect.top) {
|
---|
1555 | ULONG temp = scrollRect.top;
|
---|
1556 | scrollRect.top = scrollRect.bottom;
|
---|
1557 | scrollRect.bottom = temp;
|
---|
1558 | }
|
---|
1559 | }
|
---|
1560 | RECTL rectlUpdate;
|
---|
1561 | HRGN hrgn;
|
---|
1562 | RECTL clientRect;
|
---|
1563 | RECTL clipOS2;
|
---|
1564 | RECTL scrollOS2;
|
---|
1565 | PRECTL pScrollOS2 = NULL;
|
---|
1566 | PRECTL pClipOS2 = NULL;
|
---|
1567 |
|
---|
1568 | mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&clientRect);
|
---|
1569 |
|
---|
1570 | if(pScroll) {
|
---|
1571 | mapWin32ToOS2RectClientToFrame(wnd, &scrollRect, (PRECTLOS2)&scrollOS2);
|
---|
1572 | pScrollOS2 = &scrollOS2;
|
---|
1573 |
|
---|
1574 | //Scroll rectangle relative to client area
|
---|
1575 | WinIntersectRect ((HAB) 0, pScrollOS2, pScrollOS2, &clientRect);
|
---|
1576 | }
|
---|
1577 | else {
|
---|
1578 | pScrollOS2 = &clientRect;
|
---|
1579 | }
|
---|
1580 |
|
---|
1581 | if(pClip) {
|
---|
1582 | mapWin32ToOS2RectClientToFrame(wnd, &clipRect, (PRECTLOS2)&clipOS2);
|
---|
1583 | pClipOS2 = &clipOS2;
|
---|
1584 |
|
---|
1585 | //Clip rectangle relative to client area
|
---|
1586 | WinIntersectRect((HAB) 0, pClipOS2, pClipOS2, &clientRect);
|
---|
1587 | }
|
---|
1588 | else {
|
---|
1589 | pClipOS2 = &clientRect;
|
---|
1590 | }
|
---|
1591 |
|
---|
1592 | LONG lComplexity = WinScrollWindow(hwnd, dx, dy, pScrollOS2,
|
---|
1593 | pClipOS2, hrgn, &rectlUpdate, 0);
|
---|
1594 | if (lComplexity == RGN_ERROR)
|
---|
1595 | {
|
---|
1596 | return (FALSE);
|
---|
1597 | }
|
---|
1598 |
|
---|
1599 | RECT winRectUpdate;
|
---|
1600 |
|
---|
1601 | mapOS2ToWin32Rect(wnd->getWindowHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate);
|
---|
1602 |
|
---|
1603 | if (pRectUpdate)
|
---|
1604 | *pRectUpdate = winRectUpdate;
|
---|
1605 |
|
---|
1606 | if (hrgnUpdate)
|
---|
1607 | rc = setPMRgnIntoWinRgn(hrgn, hrgnUpdate, wnd->getWindowHeight());
|
---|
1608 |
|
---|
1609 | return (rc);
|
---|
1610 | }
|
---|
1611 | //******************************************************************************
|
---|
1612 | //******************************************************************************
|
---|
1613 | BOOL WIN32API ScrollWindow(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip)
|
---|
1614 | {
|
---|
1615 | Win32BaseWindow *window;
|
---|
1616 | APIRET rc;
|
---|
1617 | RECTL clientRect;
|
---|
1618 | RECTL scrollRect;
|
---|
1619 | RECTL clipRect;
|
---|
1620 | PRECTL pScrollOS2 = NULL;
|
---|
1621 | PRECTL pClipOS2 = NULL;
|
---|
1622 | ULONG scrollFlags = SW_INVALIDATERGN;
|
---|
1623 |
|
---|
1624 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1625 | if(!window) {
|
---|
1626 | dprintf(("ScrollWindow, window %x not found", hwnd));
|
---|
1627 | return 0;
|
---|
1628 | }
|
---|
1629 | dprintf(("ScrollWindow %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip));
|
---|
1630 |
|
---|
1631 | mapWin32ToOS2Rect(window->getWindowHeight(), window->getClientRectPtr(), (PRECTLOS2)&clientRect);
|
---|
1632 |
|
---|
1633 | if(pScroll) {
|
---|
1634 | mapWin32ToOS2RectClientToFrame(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect);
|
---|
1635 | pScrollOS2 = &scrollRect;
|
---|
1636 |
|
---|
1637 | //Scroll rectangle relative to client area
|
---|
1638 | WinIntersectRect ((HAB) 0, pScrollOS2, pScrollOS2, &clientRect);
|
---|
1639 | }
|
---|
1640 | else {
|
---|
1641 | pScrollOS2 = &clientRect;
|
---|
1642 | scrollFlags |= SW_SCROLLCHILDREN;
|
---|
1643 | }
|
---|
1644 |
|
---|
1645 | if(pClip) {
|
---|
1646 | mapWin32ToOS2RectClientToFrame(window,(RECT *)pClip, (PRECTLOS2)&clipRect);
|
---|
1647 | pClipOS2 = &clipRect;
|
---|
1648 |
|
---|
1649 | //Clip rectangle relative to client area
|
---|
1650 | WinIntersectRect ((HAB) 0, pClipOS2, pClipOS2, &clientRect);
|
---|
1651 | }
|
---|
1652 | else {
|
---|
1653 | pClipOS2 = &clientRect;
|
---|
1654 | }
|
---|
1655 |
|
---|
1656 | dy = revertDy (window, dy);
|
---|
1657 |
|
---|
1658 | rc = WinScrollWindow(window->getOS2WindowHandle(), dx, dy,
|
---|
1659 | pScrollOS2, pClipOS2, NULLHANDLE,
|
---|
1660 | NULL, scrollFlags);
|
---|
1661 |
|
---|
1662 | return (rc != RGN_ERROR);
|
---|
1663 | }
|
---|
1664 | //******************************************************************************
|
---|
1665 | //******************************************************************************
|
---|
1666 | INT WIN32API ScrollWindowEx(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip,
|
---|
1667 | HRGN hrgnUpdate, PRECT pRectUpdate, UINT scrollFlag)
|
---|
1668 | {
|
---|
1669 | Win32BaseWindow *window;
|
---|
1670 | APIRET rc;
|
---|
1671 | RECTL clientRect;
|
---|
1672 | RECTL scrollRect;
|
---|
1673 | RECTL clipRect;
|
---|
1674 | PRECTL pScrollOS2 = NULL;
|
---|
1675 | PRECTL pClipOS2 = NULL;
|
---|
1676 | ULONG scrollFlags = 0;
|
---|
1677 | int regionType = ERROR_W;
|
---|
1678 |
|
---|
1679 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1680 | if(!window) {
|
---|
1681 | dprintf(("ScrollWindowEx, window %x not found", hwnd));
|
---|
1682 | return 0;
|
---|
1683 | }
|
---|
1684 |
|
---|
1685 | dprintf(("ScrollWindowEx %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip));
|
---|
1686 |
|
---|
1687 | dy = revertDy (window, dy);
|
---|
1688 |
|
---|
1689 | if (scrollFlag & SW_INVALIDATE_W) scrollFlags |= SW_INVALIDATERGN;
|
---|
1690 | if (scrollFlag & SW_SCROLLCHILDREN_W) scrollFlags |= SW_SCROLLCHILDREN;
|
---|
1691 |
|
---|
1692 | mapWin32ToOS2Rect(window->getWindowHeight(), window->getClientRectPtr(), (PRECTLOS2)&clientRect);
|
---|
1693 |
|
---|
1694 | if(pScroll) {
|
---|
1695 | mapWin32ToOS2RectClientToFrame(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect);
|
---|
1696 | pScrollOS2 = &scrollRect;
|
---|
1697 |
|
---|
1698 | //Scroll rectangle relative to client area
|
---|
1699 | WinIntersectRect ((HAB) 0, pScrollOS2, pScrollOS2, &clientRect);
|
---|
1700 | }
|
---|
1701 | else {
|
---|
1702 | pScrollOS2 = &clientRect;
|
---|
1703 | scrollFlags |= SW_SCROLLCHILDREN; //TODO: ?????
|
---|
1704 | }
|
---|
1705 |
|
---|
1706 | if(pClip) {
|
---|
1707 | mapWin32ToOS2RectClientToFrame(window,(RECT *)pClip, (PRECTLOS2)&clipRect);
|
---|
1708 | pClipOS2 = &clipRect;
|
---|
1709 |
|
---|
1710 | //Clip rectangle relative to client area
|
---|
1711 | WinIntersectRect ((HAB) 0, pClipOS2, pClipOS2, &clientRect);
|
---|
1712 | }
|
---|
1713 | else {
|
---|
1714 | pClipOS2 = &clientRect;
|
---|
1715 | }
|
---|
1716 |
|
---|
1717 | RECTL rectlUpdate;
|
---|
1718 | HRGN hrgn;
|
---|
1719 |
|
---|
1720 | if (scrollFlag & SW_SMOOTHSCROLL_W)
|
---|
1721 | {
|
---|
1722 | INT time = (scrollFlag >> 16) & 0xFFFF;
|
---|
1723 |
|
---|
1724 | //CB: todo, scroll in several steps
|
---|
1725 | // is time in ms? time <-> iteration count?
|
---|
1726 | }
|
---|
1727 |
|
---|
1728 | LONG lComplexity = WinScrollWindow (window->getOS2WindowHandle(), dx, dy,
|
---|
1729 | pScrollOS2,
|
---|
1730 | pClipOS2,
|
---|
1731 | hrgn, &rectlUpdate, scrollFlags);
|
---|
1732 | if (lComplexity == RGN_ERROR)
|
---|
1733 | {
|
---|
1734 | return ERROR_W;
|
---|
1735 | }
|
---|
1736 |
|
---|
1737 | RECT winRectUpdate;
|
---|
1738 |
|
---|
1739 | mapOS2ToWin32Rect(window->getWindowHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate);
|
---|
1740 |
|
---|
1741 | if (pRectUpdate)
|
---|
1742 | *pRectUpdate = winRectUpdate;
|
---|
1743 |
|
---|
1744 | if (hrgnUpdate)
|
---|
1745 | rc = setPMRgnIntoWinRgn (hrgn, hrgnUpdate, window->getWindowHeight());
|
---|
1746 |
|
---|
1747 | #if 0
|
---|
1748 | //SvL: WinScrollWindow already invalidates the area; no need to do it again
|
---|
1749 | //(call to invalidateRect was wrong; has to include erase flag)
|
---|
1750 | if ((scrollFlag & SW_INVALIDATE_W) &&
|
---|
1751 | ((lComplexity == RGN_RECT) || (lComplexity == RGN_COMPLEX)))
|
---|
1752 | {
|
---|
1753 | rc = InvalidateRect (hwnd, &winRectUpdate, (scrollFlag & SW_ERASE_W) ? 1 : 0);
|
---|
1754 | if (rc == FALSE)
|
---|
1755 | {
|
---|
1756 | return (0);
|
---|
1757 | }
|
---|
1758 | }
|
---|
1759 | #endif
|
---|
1760 |
|
---|
1761 | switch (lComplexity)
|
---|
1762 | {
|
---|
1763 | case RGN_NULL:
|
---|
1764 | regionType = NULLREGION_W;
|
---|
1765 | break;
|
---|
1766 | case RGN_RECT:
|
---|
1767 | regionType = SIMPLEREGION_W;
|
---|
1768 | break;
|
---|
1769 | case RGN_COMPLEX:
|
---|
1770 | regionType = COMPLEXREGION_W;
|
---|
1771 | break;
|
---|
1772 | default:
|
---|
1773 | regionType = ERROR_W;
|
---|
1774 | break;
|
---|
1775 | }
|
---|
1776 |
|
---|
1777 | return (regionType);
|
---|
1778 | }
|
---|
1779 | //******************************************************************************
|
---|
1780 | //******************************************************************************
|
---|
1781 | HWND WIN32API WindowFromDC(HDC hdc)
|
---|
1782 | {
|
---|
1783 | pDCData pHps = (pDCData)GpiQueryDCData( (HPS)hdc );
|
---|
1784 |
|
---|
1785 | dprintf2(("USER32: WindowFromDC %x", hdc));
|
---|
1786 | if ( pHps )
|
---|
1787 | return Win32BaseWindow::OS2ToWin32Handle(pHps->hwnd);
|
---|
1788 | else
|
---|
1789 | return 0;
|
---|
1790 | }
|
---|
1791 | //******************************************************************************
|
---|
1792 | //******************************************************************************
|
---|
1793 | INT WIN32API ExcludeUpdateRgn( HDC hDC, HWND hWnd)
|
---|
1794 | {
|
---|
1795 | dprintf(("USER32: ExcludeUpdateRgn\n"));
|
---|
1796 | hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
|
---|
1797 |
|
---|
1798 | return O32_ExcludeUpdateRgn(hDC,hWnd);
|
---|
1799 | }
|
---|
1800 | //******************************************************************************
|
---|
1801 | //******************************************************************************
|
---|
1802 | BOOL WIN32API ValidateRect( HWND hwnd, const RECT * lprc)
|
---|
1803 | {
|
---|
1804 | if(lprc) {
|
---|
1805 | dprintf(("USER32: ValidateRect %x (%d,%d)(%d,%d)", hwnd, lprc->left, lprc->top, lprc->right, lprc->bottom));
|
---|
1806 | }
|
---|
1807 | else dprintf(("USER32: ValidateRect %x", hwnd));
|
---|
1808 |
|
---|
1809 | return RedrawWindow( hwnd, lprc, 0, RDW_VALIDATE_W | RDW_NOCHILDREN_W | (hwnd==0 ? RDW_UPDATENOW_W : 0));
|
---|
1810 | }
|
---|
1811 | //******************************************************************************
|
---|
1812 | //******************************************************************************
|
---|
1813 | BOOL WIN32API ValidateRgn( HWND hwnd, HRGN hrgn)
|
---|
1814 | {
|
---|
1815 | dprintf(("USER32: ValidateRgn %x %x", hwnd, hrgn));
|
---|
1816 | return RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE_W | RDW_NOCHILDREN_W | (hwnd==0 ? RDW_UPDATENOW_W : 0));
|
---|
1817 | }
|
---|
1818 | /*****************************************************************************
|
---|
1819 | * Name : int WIN32API GetWindowRgn
|
---|
1820 | * Purpose : The GetWindowRgn function obtains a copy of the window region of a window.
|
---|
1821 | * Parameters: HWND hWnd handle to window whose window region is to be obtained
|
---|
1822 | * HRGN hRgn handle to region that receives a copy of the window region
|
---|
1823 | * Variables :
|
---|
1824 | * Result : NULLREGION, SIMPLEREGION, COMPLEXREGION, ERROR
|
---|
1825 | * Remark :
|
---|
1826 | * Status : UNTESTED STUB
|
---|
1827 | *
|
---|
1828 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
1829 | *****************************************************************************/
|
---|
1830 |
|
---|
1831 | int WIN32API GetWindowRgn(HWND hwnd, HRGN hRgn)
|
---|
1832 | {
|
---|
1833 | Win32BaseWindow *window;
|
---|
1834 | HRGN hWindowRegion;
|
---|
1835 |
|
---|
1836 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1837 | if(!window) {
|
---|
1838 | dprintf(("SetWindowContextHelpId, window %x not found", hwnd));
|
---|
1839 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
---|
1840 | return 0;
|
---|
1841 | }
|
---|
1842 | dprintf(("USER32:GetWindowRgn (%x,%x)", hwnd, hRgn));
|
---|
1843 | hWindowRegion = window->GetWindowRegion();
|
---|
1844 |
|
---|
1845 | return O32_CombineRgn(hRgn, hWindowRegion, 0, RGN_COPY_W);
|
---|
1846 | }
|
---|
1847 | /*****************************************************************************
|
---|
1848 | * Name : int WIN32API SetWindowRgn
|
---|
1849 | * Purpose : The SetWindowRgn function sets the window region of a window. The
|
---|
1850 | * window region determines the area within the window where the
|
---|
1851 | * operating system permits drawing. The operating system does not
|
---|
1852 | * display any portion of a window that lies outside of the window region
|
---|
1853 | * When this function is called, the system sends the WM_WINDOWPOSCHANGING and
|
---|
1854 | * WM_WINDOWPOSCHANGED messages to the window.
|
---|
1855 | *
|
---|
1856 | * Parameters: HWND hWnd handle to window whose window region is to be set
|
---|
1857 | * HRGN hRgn handle to region
|
---|
1858 | * BOOL bRedraw window redraw flag
|
---|
1859 | * Variables :
|
---|
1860 | * Result : If the function succeeds, the return value is non-zero.
|
---|
1861 | * If the function fails, the return value is zero.
|
---|
1862 | * Remark :
|
---|
1863 | * Status : UNTESTED STUB
|
---|
1864 | *
|
---|
1865 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
1866 | *****************************************************************************/
|
---|
1867 |
|
---|
1868 | int WIN32API SetWindowRgn(HWND hwnd,
|
---|
1869 | HRGN hRgn,
|
---|
1870 | BOOL bRedraw)
|
---|
1871 | {
|
---|
1872 | Win32BaseWindow *window;
|
---|
1873 | HRGN hWindowRegion;
|
---|
1874 |
|
---|
1875 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1876 | if(!window) {
|
---|
1877 | dprintf(("SetWindowContextHelpId, window %x not found", hwnd));
|
---|
1878 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
---|
1879 | return 0;
|
---|
1880 | }
|
---|
1881 | dprintf(("USER32:SetWindowRgn (%x,%x,%d)", hwnd, hRgn, bRedraw));
|
---|
1882 | if(window->GetWindowRegion()) {
|
---|
1883 | O32_DeleteObject(window->GetWindowRegion());
|
---|
1884 | }
|
---|
1885 | window->SetWindowRegion(hRgn);
|
---|
1886 | if(bRedraw) {
|
---|
1887 | RedrawWindow(hwnd, 0, 0, RDW_UPDATENOW_W);
|
---|
1888 | }
|
---|
1889 | //TODO:
|
---|
1890 | // When this function is called, the system sends the WM_WINDOWPOSCHANGING and
|
---|
1891 | // WM_WINDOWPOSCHANGED messages to the window.
|
---|
1892 | return 1;
|
---|
1893 | }
|
---|
1894 | //******************************************************************************
|
---|
1895 | //******************************************************************************
|
---|