source: trunk/src/user32/dc.cpp@ 5164

Last change on this file since 5164 was 5164, checked in by sandervl, 25 years ago

workaround for window origin changes

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