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

Last change on this file since 5710 was 5710, checked in by sandervl, 24 years ago

BeginPaint must return logical points

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