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