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