2 * Window clipping functions
4 * Copyright 1993 Alexandre Julliard
7 static char Copyright
[] = "Copyright Alexandre Julliard, 1993";
15 /***********************************************************************
16 * InvalidateRgn (USER.126)
18 void InvalidateRgn( HWND hwnd
, HRGN hrgn
, BOOL erase
)
21 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
26 newRgn
= CreateRectRgn(0, 0,
27 wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
28 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
);
32 if (!(newRgn
= CreateRectRgn( 0, 0, 0, 0 ))) return;
33 if (!wndPtr
->hrgnUpdate
) CombineRgn( newRgn
, hrgn
, 0, RGN_COPY
);
34 else CombineRgn( newRgn
, wndPtr
->hrgnUpdate
, hrgn
, RGN_OR
);
36 if (wndPtr
->hrgnUpdate
) DeleteObject( wndPtr
->hrgnUpdate
);
37 wndPtr
->hrgnUpdate
= newRgn
;
38 if (erase
) wndPtr
->flags
|= WIN_ERASE_UPDATERGN
;
42 /***********************************************************************
43 * InvalidateRect (USER.125)
45 void InvalidateRect( HWND hwnd
, LPRECT rect
, BOOL erase
)
49 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
53 if (rect
) printf( "InvalidateRect: %d %d,%d-%d,%d\n", hwnd
,
54 rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
55 else printf( "InvalidateRect: %d NULL\n", hwnd
);
57 if (rect
) hrgn
= CreateRectRgnIndirect( rect
);
58 InvalidateRgn( hwnd
, hrgn
, erase
);
59 if (hrgn
) DeleteObject( hrgn
);
63 /***********************************************************************
64 * ValidateRgn (USER.128)
66 void ValidateRgn( HWND hwnd
, HRGN hrgn
)
69 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
72 if (!wndPtr
->hrgnUpdate
) return;
73 if (!hrgn
) newRgn
= 0;
76 if (!(newRgn
= CreateRectRgn( 0, 0, 0, 0 ))) return;
77 if (CombineRgn( newRgn
, wndPtr
->hrgnUpdate
, hrgn
, RGN_DIFF
) == NULLREGION
)
79 DeleteObject( newRgn
);
83 DeleteObject( wndPtr
->hrgnUpdate
);
84 wndPtr
->hrgnUpdate
= newRgn
;
85 if (!wndPtr
->hrgnUpdate
) wndPtr
->flags
&= ~WIN_ERASE_UPDATERGN
;
89 /***********************************************************************
90 * ValidateRect (USER.127)
92 void ValidateRect( HWND hwnd
, LPRECT rect
)
96 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
99 if (rect
) hrgn
= CreateRectRgnIndirect( rect
);
100 ValidateRgn( hwnd
, hrgn
);
101 if (hrgn
) DeleteObject( hrgn
);
105 /***********************************************************************
106 * GetUpdateRect (USER.190)
108 BOOL
GetUpdateRect( HWND hwnd
, LPRECT rect
, BOOL erase
)
111 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
112 if (!wndPtr
) return FALSE
;
114 retval
= (wndPtr
->hrgnUpdate
!= 0);
118 if (wndPtr
->hrgnUpdate
) GetRgnBox( wndPtr
->hrgnUpdate
, rect
);
119 else SetRectEmpty( rect
);
120 if (erase
&& wndPtr
->hrgnUpdate
)
122 HDC hdc
= GetDC( hwnd
);
125 SendMessage( hwnd
, WM_ERASEBKGND
, hdc
, 0 );
126 ReleaseDC( hwnd
, hdc
);
130 GlobalUnlock( hwnd
);
135 /***********************************************************************
136 * GetUpdateRgn (USER.237)
138 int GetUpdateRgn( HWND hwnd
, HRGN hrgn
, BOOL erase
)
141 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
142 if (!wndPtr
) return ERROR
;
144 if (erase
&& wndPtr
->hrgnUpdate
)
146 HDC hdc
= GetDC( hwnd
);
149 SendMessage( hwnd
, WM_ERASEBKGND
, hdc
, 0 );
150 ReleaseDC( hwnd
, hdc
);
153 retval
= CombineRgn( hrgn
, wndPtr
->hrgnUpdate
, 0, RGN_COPY
);
154 GlobalUnlock( hwnd
);