2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 CLIPPING_UpdateGCRegion(DC
* Dc
)
29 PROSRGNDATA CombinedRegion
;
31 if (Dc
->w
.hGCClipRgn
== NULL
)
32 Dc
->w
.hGCClipRgn
= NtGdiCreateRectRgn(0, 0, 0, 0);
34 if (Dc
->w
.hClipRgn
== NULL
)
35 NtGdiCombineRgn(Dc
->w
.hGCClipRgn
, Dc
->w
.hVisRgn
, 0, RGN_COPY
);
37 NtGdiCombineRgn(Dc
->w
.hGCClipRgn
, Dc
->w
.hClipRgn
, Dc
->w
.hVisRgn
, RGN_AND
);
38 NtGdiOffsetRgn(Dc
->w
.hGCClipRgn
, Dc
->w
.DCOrgX
, Dc
->w
.DCOrgY
);
40 if((CombinedRegion
= RGNDATA_LockRgn(Dc
->w
.hGCClipRgn
)))
42 if (Dc
->CombinedClip
!= NULL
)
43 IntEngDeleteClipRegion(Dc
->CombinedClip
);
45 Dc
->CombinedClip
= IntEngCreateClipRegion(
46 CombinedRegion
->rdh
.nCount
,
47 (PRECTL
)CombinedRegion
->Buffer
,
48 (PRECTL
)&CombinedRegion
->rdh
.rcBound
);
50 RGNDATA_UnlockRgn(CombinedRegion
);
53 if ( NULL
== Dc
->CombinedClip
)
55 DPRINT1("IntEngCreateClipRegion() failed\n");
59 return NtGdiOffsetRgn(Dc
->w
.hGCClipRgn
, -Dc
->w
.DCOrgX
, -Dc
->w
.DCOrgY
);
63 NtGdiSelectVisRgn(HDC hdc
, HRGN hrgn
)
70 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
73 if (!(dc
= DC_LockDc(hdc
)))
75 SetLastWin32Error(ERROR_INVALID_HANDLE
);
79 dc
->w
.flags
&= ~DC_DIRTY
;
81 if (dc
->w
.hVisRgn
== NULL
)
83 dc
->w
.hVisRgn
= NtGdiCreateRectRgn(0, 0, 0, 0);
84 GDIOBJ_CopyOwnership(GdiHandleTable
, hdc
, dc
->w
.hVisRgn
);
87 retval
= NtGdiCombineRgn(dc
->w
.hVisRgn
, hrgn
, 0, RGN_COPY
);
88 if ( retval
!= ERROR
)
90 NtGdiOffsetRgn(dc
->w
.hVisRgn
, -dc
->w
.DCOrgX
, -dc
->w
.DCOrgY
);
91 CLIPPING_UpdateGCRegion(dc
);
99 int STDCALL
IntGdiExtSelectClipRgn(PDC dc
,
104 // dc->w.flags &= ~DC_DIRTY;
108 if (fnMode
== RGN_COPY
)
110 if (dc
->w
.hClipRgn
!= NULL
)
112 NtGdiDeleteObject(dc
->w
.hClipRgn
);
113 dc
->w
.hClipRgn
= NULL
;
119 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
129 if((Rgn
= RGNDATA_LockRgn(dc
->w
.hVisRgn
)))
131 UnsafeIntGetRgnBox(Rgn
, &rect
);
132 RGNDATA_UnlockRgn(Rgn
);
133 dc
->w
.hClipRgn
= UnsafeIntCreateRectRgnIndirect(&rect
);
137 dc
->w
.hClipRgn
= NtGdiCreateRectRgn(0, 0, 0, 0);
140 if(fnMode
== RGN_COPY
)
142 NtGdiCombineRgn(dc
->w
.hClipRgn
, hrgn
, 0, fnMode
);
145 NtGdiCombineRgn(dc
->w
.hClipRgn
, dc
->w
.hClipRgn
, hrgn
, fnMode
);
148 retval
= CLIPPING_UpdateGCRegion(dc
);
153 int STDCALL
NtGdiExtSelectClipRgn(HDC hDC
,
160 if (!(dc
= DC_LockDc(hDC
)))
162 SetLastWin32Error(ERROR_INVALID_HANDLE
);
166 retval
= IntGdiExtSelectClipRgn ( dc
, hrgn
, fnMode
);
173 IntGdiGetClipBox(HDC hDC
, LPRECT rc
)
179 if (!(dc
= DC_LockDc(hDC
)))
181 SetLastWin32Error(ERROR_INVALID_HANDLE
);
185 if (!(Rgn
= RGNDATA_LockRgn(dc
->w
.hGCClipRgn
)))
188 SetLastWin32Error(ERROR_INVALID_HANDLE
);
191 retval
= UnsafeIntGetRgnBox(Rgn
, rc
);
192 RGNDATA_UnlockRgn(Rgn
);
193 IntDPtoLP(dc
, (LPPOINT
)rc
, 2);
199 int STDCALL
NtGdiGetClipBox(HDC hDC
,
203 NTSTATUS Status
= STATUS_SUCCESS
;
206 Ret
= IntGdiGetClipBox(hDC
, &Saferect
);
217 Status
= _SEH_GetExceptionCode();
221 if(!NT_SUCCESS(Status
))
224 SetLastNtError(Status
);
231 int STDCALL
NtGdiGetMetaRgn(HDC hDC
,
238 int STDCALL
NtGdiExcludeClipRect(HDC hDC
,
247 PDC dc
= DC_LockDc(hDC
);
251 SetLastWin32Error(ERROR_INVALID_HANDLE
);
255 Rect
.left
= LeftRect
;
257 Rect
.right
= RightRect
;
258 Rect
.bottom
= BottomRect
;
260 IntLPtoDP(dc
, (LPPOINT
)&Rect
, 2);
262 NewRgn
= UnsafeIntCreateRectRgnIndirect(&Rect
);
271 dc
->w
.hClipRgn
= NtGdiCreateRectRgn(0, 0, 0, 0);
272 NtGdiCombineRgn(dc
->w
.hClipRgn
, dc
->w
.hVisRgn
, NewRgn
, RGN_DIFF
);
273 Result
= SIMPLEREGION
;
277 Result
= NtGdiCombineRgn(dc
->w
.hClipRgn
, dc
->w
.hClipRgn
, NewRgn
, RGN_DIFF
);
279 NtGdiDeleteObject(NewRgn
);
282 CLIPPING_UpdateGCRegion(dc
);
289 int STDCALL
NtGdiIntersectClipRect(HDC hDC
,
298 PDC dc
= DC_LockDc(hDC
);
300 DPRINT("NtGdiIntersectClipRect(%x, %d,%d-%d,%d)\n",
301 hDC
, LeftRect
, TopRect
, RightRect
, BottomRect
);
305 SetLastWin32Error(ERROR_INVALID_HANDLE
);
309 Rect
.left
= LeftRect
;
311 Rect
.right
= RightRect
;
312 Rect
.bottom
= BottomRect
;
314 IntLPtoDP(dc
, (LPPOINT
)&Rect
, 2);
316 NewRgn
= UnsafeIntCreateRectRgnIndirect(&Rect
);
321 else if (!dc
->w
.hClipRgn
)
323 dc
->w
.hClipRgn
= NewRgn
;
324 Result
= SIMPLEREGION
;
328 Result
= NtGdiCombineRgn(dc
->w
.hClipRgn
, dc
->w
.hClipRgn
, NewRgn
, RGN_AND
);
329 NtGdiDeleteObject(NewRgn
);
332 CLIPPING_UpdateGCRegion(dc
);
339 int STDCALL
NtGdiOffsetClipRgn(HDC hDC
,
346 if(!(dc
= DC_LockDc(hDC
)))
348 SetLastWin32Error(ERROR_INVALID_HANDLE
);
352 if(dc
->w
.hClipRgn
!= NULL
)
354 Result
= NtGdiOffsetRgn(dc
->w
.hClipRgn
,
357 CLIPPING_UpdateGCRegion(dc
);
368 BOOL STDCALL
NtGdiPtVisible(HDC hDC
,
375 if(!(dc
= DC_LockDc(hDC
)))
377 SetLastWin32Error(ERROR_INVALID_HANDLE
);
381 rgn
= dc
->w
.hGCClipRgn
;
384 return (rgn
? NtGdiPtInRegion(rgn
, X
, Y
) : FALSE
);
387 BOOL STDCALL
NtGdiRectVisible(HDC hDC
,
388 CONST PRECT UnsafeRect
)
390 NTSTATUS Status
= STATUS_SUCCESS
;
392 PDC dc
= DC_LockDc(hDC
);
398 SetLastWin32Error(ERROR_INVALID_HANDLE
);
404 ProbeForRead(UnsafeRect
,
411 Status
= _SEH_GetExceptionCode();
415 if(!NT_SUCCESS(Status
))
418 SetLastNtError(Status
);
422 if (dc
->w
.hGCClipRgn
)
424 if((Rgn
= (PROSRGNDATA
)RGNDATA_LockRgn(dc
->w
.hGCClipRgn
)))
426 IntLPtoDP(dc
, (LPPOINT
)&Rect
, 2);
427 Result
= UnsafeIntRectInRegion(Rgn
, &Rect
);
428 RGNDATA_UnlockRgn(Rgn
);
437 NtGdiSelectClipRgn(HDC hDC
, HRGN hRgn
)
439 return NtGdiExtSelectClipRgn(hDC
, hRgn
, RGN_COPY
);
442 int STDCALL
NtGdiSetMetaRgn(HDC hDC
)