Moved hGCClipRgn handling to the graphics driver.
[wine] / objects / dcvalues.c
1 /*
2  * DC device-independent Get/SetXXX functions
3  *
4  * Copyright 1993 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include <stdarg.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winerror.h"
28 #include "wownt32.h"
29
30 #include "gdi.h"
31 #include "gdi_private.h"
32
33
34 /***********************************************************************
35  *              SetBkMode (GDI32.@)
36  */
37 INT WINAPI SetBkMode( HDC hdc, INT mode )
38 {
39     INT ret;
40     DC *dc;
41     if ((mode <= 0) || (mode > BKMODE_LAST))
42     {
43         SetLastError(ERROR_INVALID_PARAMETER);
44         return 0;
45     }
46     if (!(dc = DC_GetDCPtr( hdc ))) return 0;
47     if (dc->funcs->pSetBkMode)
48         ret = dc->funcs->pSetBkMode( dc->physDev, mode );
49     else
50     {
51         ret = dc->backgroundMode;
52         dc->backgroundMode = mode;
53     }
54     GDI_ReleaseObj( hdc );
55     return ret;
56 }
57
58
59 /***********************************************************************
60  *              SetROP2 (GDI32.@)
61  */
62 INT WINAPI SetROP2( HDC hdc, INT mode )
63 {
64     INT ret;
65     DC *dc;
66     if ((mode < R2_BLACK) || (mode > R2_WHITE))
67     {
68         SetLastError(ERROR_INVALID_PARAMETER);
69         return 0;
70     }
71     if (!(dc = DC_GetDCPtr( hdc ))) return 0;
72     if (dc->funcs->pSetROP2)
73         ret = dc->funcs->pSetROP2( dc->physDev, mode );
74     else
75     {
76         ret = dc->ROPmode;
77         dc->ROPmode = mode;
78     }
79     GDI_ReleaseObj( hdc );
80     return ret;
81 }
82
83
84 /***********************************************************************
85  *              SetRelAbs (GDI32.@)
86  */
87 INT WINAPI SetRelAbs( HDC hdc, INT mode )
88 {
89     INT ret;
90     DC *dc;
91     if ((mode != ABSOLUTE) && (mode != RELATIVE))
92     {
93         SetLastError(ERROR_INVALID_PARAMETER);
94         return 0;
95     }
96     if (!(dc = DC_GetDCPtr( hdc ))) return 0;
97     if (dc->funcs->pSetRelAbs)
98         ret = dc->funcs->pSetRelAbs( dc->physDev, mode );
99     else
100     {
101         ret = dc->relAbsMode;
102         dc->relAbsMode = mode;
103     }
104     GDI_ReleaseObj( hdc );
105     return ret;
106 }
107
108
109 /***********************************************************************
110  *              SetPolyFillMode (GDI32.@)
111  */
112 INT WINAPI SetPolyFillMode( HDC hdc, INT mode )
113 {
114     INT ret;
115     DC *dc;
116     if ((mode <= 0) || (mode > POLYFILL_LAST))
117     {
118         SetLastError(ERROR_INVALID_PARAMETER);
119         return 0;
120     }
121     if (!(dc = DC_GetDCPtr( hdc ))) return 0;
122     if (dc->funcs->pSetPolyFillMode)
123         ret = dc->funcs->pSetPolyFillMode( dc->physDev, mode );
124     else
125     {
126         ret = dc->polyFillMode;
127         dc->polyFillMode = mode;
128     }
129     GDI_ReleaseObj( hdc );
130     return ret;
131 }
132
133
134 /***********************************************************************
135  *              SetStretchBltMode (GDI32.@)
136  */
137 INT WINAPI SetStretchBltMode( HDC hdc, INT mode )
138 {
139     INT ret;
140     DC *dc;
141     if ((mode <= 0) || (mode > MAXSTRETCHBLTMODE))
142     {
143         SetLastError(ERROR_INVALID_PARAMETER);
144         return 0;
145     }
146     if (!(dc = DC_GetDCPtr( hdc ))) return 0;
147     if (dc->funcs->pSetStretchBltMode)
148         ret = dc->funcs->pSetStretchBltMode( dc->physDev, mode );
149     else
150     {
151         ret = dc->stretchBltMode;
152         dc->stretchBltMode = mode;
153     }
154     GDI_ReleaseObj( hdc );
155     return ret;
156 }
157
158
159 /***********************************************************************
160  *              GetBkColor (GDI32.@)
161  */
162 COLORREF WINAPI GetBkColor( HDC hdc )
163 {
164     COLORREF ret = 0;
165     DC * dc = DC_GetDCPtr( hdc );
166     if (dc)
167     {
168         ret = dc->backgroundColor;
169         GDI_ReleaseObj( hdc );
170     }
171     return ret;
172 }
173
174
175 /***********************************************************************
176  *              GetBkMode (GDI32.@)
177  */
178 INT WINAPI GetBkMode( HDC hdc )
179 {
180     INT ret = 0;
181     DC * dc = DC_GetDCPtr( hdc );
182     if (dc)
183     {
184         ret = dc->backgroundMode;
185         GDI_ReleaseObj( hdc );
186     }
187     return ret;
188 }
189
190
191 /***********************************************************************
192  *              GetMapMode (GDI32.@)
193  */
194 INT WINAPI GetMapMode( HDC hdc )
195 {
196     INT ret = 0;
197     DC * dc = DC_GetDCPtr( hdc );
198     if (dc)
199     {
200         ret = dc->MapMode;
201         GDI_ReleaseObj( hdc );
202     }
203     return ret;
204 }
205
206
207 /***********************************************************************
208  *              GetPolyFillMode (GDI32.@)
209  */
210 INT WINAPI GetPolyFillMode( HDC hdc )
211 {
212     INT ret = 0;
213     DC * dc = DC_GetDCPtr( hdc );
214     if (dc)
215     {
216         ret = dc->polyFillMode;
217         GDI_ReleaseObj( hdc );
218     }
219     return ret;
220 }
221
222
223 /***********************************************************************
224  *              GetROP2 (GDI32.@)
225  */
226 INT WINAPI GetROP2( HDC hdc )
227 {
228     INT ret = 0;
229     DC * dc = DC_GetDCPtr( hdc );
230     if (dc)
231     {
232         ret = dc->ROPmode;
233         GDI_ReleaseObj( hdc );
234     }
235     return ret;
236 }
237
238
239 /***********************************************************************
240  *              GetStretchBltMode (GDI32.@)
241  */
242 INT WINAPI GetStretchBltMode( HDC hdc )
243 {
244     INT ret = 0;
245     DC * dc = DC_GetDCPtr( hdc );
246     if (dc)
247     {
248         ret = dc->stretchBltMode;
249         GDI_ReleaseObj( hdc );
250     }
251     return ret;
252 }
253
254
255 /***********************************************************************
256  *              GetTextColor (GDI32.@)
257  */
258 COLORREF WINAPI GetTextColor( HDC hdc )
259 {
260     COLORREF ret = 0;
261     DC * dc = DC_GetDCPtr( hdc );
262     if (dc)
263     {
264         ret = dc->textColor;
265         GDI_ReleaseObj( hdc );
266     }
267     return ret;
268 }
269
270
271 /***********************************************************************
272  *              GetTextAlign (GDI32.@)
273  */
274 UINT WINAPI GetTextAlign( HDC hdc )
275 {
276     UINT ret = 0;
277     DC * dc = DC_GetDCPtr( hdc );
278     if (dc)
279     {
280         ret = dc->textAlign;
281         GDI_ReleaseObj( hdc );
282     }
283     return ret;
284 }
285
286
287 /***********************************************************************
288  *              GetArcDirection (GDI32.@)
289  */
290 INT WINAPI GetArcDirection( HDC hdc )
291 {
292     INT ret = 0;
293     DC * dc = DC_GetDCPtr( hdc );
294     if (dc)
295     {
296         ret = dc->ArcDirection;
297         GDI_ReleaseObj( hdc );
298     }
299     return ret;
300 }
301
302
303 /***********************************************************************
304  *              GetGraphicsMode (GDI32.@)
305  */
306 INT WINAPI GetGraphicsMode( HDC hdc )
307 {
308     INT ret = 0;
309     DC * dc = DC_GetDCPtr( hdc );
310     if (dc)
311     {
312         ret = dc->GraphicsMode;
313         GDI_ReleaseObj( hdc );
314     }
315     return ret;
316 }
317
318
319 /***********************************************************************
320  *              GetBrushOrgEx (GDI32.@)
321  */
322 BOOL WINAPI GetBrushOrgEx( HDC hdc, LPPOINT pt )
323 {
324     DC * dc = DC_GetDCPtr( hdc );
325     if (!dc) return FALSE;
326     pt->x = dc->brushOrgX;
327     pt->y = dc->brushOrgY;
328     GDI_ReleaseObj( hdc );
329     return TRUE;
330 }
331
332
333 /***********************************************************************
334  *              GetCurrentPositionEx (GDI32.@)
335  */
336 BOOL WINAPI GetCurrentPositionEx( HDC hdc, LPPOINT pt )
337 {
338     DC * dc = DC_GetDCPtr( hdc );
339     if (!dc) return FALSE;
340     pt->x = dc->CursPosX;
341     pt->y = dc->CursPosY;
342     GDI_ReleaseObj( hdc );
343     return TRUE;
344 }
345
346
347 /***********************************************************************
348  *              GetViewportExtEx (GDI32.@)
349  */
350 BOOL WINAPI GetViewportExtEx( HDC hdc, LPSIZE size )
351 {
352     DC * dc = DC_GetDCPtr( hdc );
353     if (!dc) return FALSE;
354     size->cx = dc->vportExtX;
355     size->cy = dc->vportExtY;
356     GDI_ReleaseObj( hdc );
357     return TRUE;
358 }
359
360
361 /***********************************************************************
362  *              GetViewportOrgEx (GDI32.@)
363  */
364 BOOL WINAPI GetViewportOrgEx( HDC hdc, LPPOINT pt )
365 {
366     DC * dc = DC_GetDCPtr( hdc );
367     if (!dc) return FALSE;
368     pt->x = dc->vportOrgX;
369     pt->y = dc->vportOrgY;
370     GDI_ReleaseObj( hdc );
371     return TRUE;
372 }
373
374
375 /***********************************************************************
376  *              GetWindowExtEx (GDI32.@)
377  */
378 BOOL WINAPI GetWindowExtEx( HDC hdc, LPSIZE size )
379 {
380     DC * dc = DC_GetDCPtr( hdc );
381     if (!dc) return FALSE;
382     size->cx = dc->wndExtX;
383     size->cy = dc->wndExtY;
384     GDI_ReleaseObj( hdc );
385     return TRUE;
386 }
387
388
389 /***********************************************************************
390  *              GetWindowOrgEx (GDI32.@)
391  */
392 BOOL WINAPI GetWindowOrgEx( HDC hdc, LPPOINT pt )
393 {
394     DC * dc = DC_GetDCPtr( hdc );
395     if (!dc) return FALSE;
396     pt->x = dc->wndOrgX;
397     pt->y = dc->wndOrgY;
398     GDI_ReleaseObj( hdc );
399     return TRUE;
400 }
401
402
403 /**** 16-bit functions ***/
404
405 /***********************************************************************
406  *              InquireVisRgn   (GDI.131)
407  */
408 HRGN16 WINAPI InquireVisRgn16( HDC16 hdc )
409 {
410     HRGN16 ret = 0;
411     DC * dc = DC_GetDCPtr( HDC_32(hdc) );
412     if (dc)
413     {
414         ret = HRGN_16(dc->hVisRgn);
415         GDI_ReleaseObj( HDC_32(hdc) );
416     }
417     return ret;
418 }
419
420
421 /***********************************************************************
422  *              GetClipRgn (GDI.173)
423  */
424 HRGN16 WINAPI GetClipRgn16( HDC16 hdc )
425 {
426     HRGN16 ret = 0;
427     DC * dc = DC_GetDCPtr( HDC_32(hdc) );
428     if (dc)
429     {
430         ret = HRGN_16(dc->hClipRgn);
431         GDI_ReleaseObj( HDC_32(hdc) );
432     }
433     return ret;
434 }