- Add more logging to resolution changes and queries.
[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
32
33 /***********************************************************************
34  *              SetBkMode (GDI32.@)
35  */
36 INT WINAPI SetBkMode( HDC hdc, INT mode )
37 {
38     INT ret;
39     DC *dc;
40     if ((mode <= 0) || (mode > BKMODE_LAST))
41     {
42         SetLastError(ERROR_INVALID_PARAMETER);
43         return 0;
44     }
45     if (!(dc = DC_GetDCPtr( hdc ))) return 0;
46     if (dc->funcs->pSetBkMode)
47         ret = dc->funcs->pSetBkMode( dc->physDev, mode );
48     else
49     {
50         ret = dc->backgroundMode;
51         dc->backgroundMode = mode;
52     }
53     GDI_ReleaseObj( hdc );
54     return ret;
55 }
56
57
58 /***********************************************************************
59  *              SetROP2 (GDI32.@)
60  */
61 INT WINAPI SetROP2( HDC hdc, INT mode )
62 {
63     INT ret;
64     DC *dc;
65     if ((mode < R2_BLACK) || (mode > R2_WHITE))
66     {
67         SetLastError(ERROR_INVALID_PARAMETER);
68         return 0;
69     }
70     if (!(dc = DC_GetDCPtr( hdc ))) return 0;
71     if (dc->funcs->pSetROP2)
72         ret = dc->funcs->pSetROP2( dc->physDev, mode );
73     else
74     {
75         ret = dc->ROPmode;
76         dc->ROPmode = mode;
77     }
78     GDI_ReleaseObj( hdc );
79     return ret;
80 }
81
82
83 /***********************************************************************
84  *              SetRelAbs (GDI32.@)
85  */
86 INT WINAPI SetRelAbs( HDC hdc, INT mode )
87 {
88     INT ret;
89     DC *dc;
90     if ((mode != ABSOLUTE) && (mode != RELATIVE))
91     {
92         SetLastError(ERROR_INVALID_PARAMETER);
93         return 0;
94     }
95     if (!(dc = DC_GetDCPtr( hdc ))) return 0;
96     if (dc->funcs->pSetRelAbs)
97         ret = dc->funcs->pSetRelAbs( dc->physDev, mode );
98     else
99     {
100         ret = dc->relAbsMode;
101         dc->relAbsMode = mode;
102     }
103     GDI_ReleaseObj( hdc );
104     return ret;
105 }
106
107
108 /***********************************************************************
109  *              SetPolyFillMode (GDI32.@)
110  */
111 INT WINAPI SetPolyFillMode( HDC hdc, INT mode )
112 {
113     INT ret;
114     DC *dc;
115     if ((mode <= 0) || (mode > POLYFILL_LAST))
116     {
117         SetLastError(ERROR_INVALID_PARAMETER);
118         return 0;
119     }
120     if (!(dc = DC_GetDCPtr( hdc ))) return 0;
121     if (dc->funcs->pSetPolyFillMode)
122         ret = dc->funcs->pSetPolyFillMode( dc->physDev, mode );
123     else
124     {
125         ret = dc->polyFillMode;
126         dc->polyFillMode = mode;
127     }
128     GDI_ReleaseObj( hdc );
129     return ret;
130 }
131
132
133 /***********************************************************************
134  *              SetStretchBltMode (GDI32.@)
135  */
136 INT WINAPI SetStretchBltMode( HDC hdc, INT mode )
137 {
138     INT ret;
139     DC *dc;
140     if ((mode <= 0) || (mode > MAXSTRETCHBLTMODE))
141     {
142         SetLastError(ERROR_INVALID_PARAMETER);
143         return 0;
144     }
145     if (!(dc = DC_GetDCPtr( hdc ))) return 0;
146     if (dc->funcs->pSetStretchBltMode)
147         ret = dc->funcs->pSetStretchBltMode( dc->physDev, mode );
148     else
149     {
150         ret = dc->stretchBltMode;
151         dc->stretchBltMode = mode;
152     }
153     GDI_ReleaseObj( hdc );
154     return ret;
155 }
156
157
158 /***********************************************************************
159  *              GetBkColor (GDI32.@)
160  */
161 COLORREF WINAPI GetBkColor( HDC hdc )
162 {
163     COLORREF ret = 0;
164     DC * dc = DC_GetDCPtr( hdc );
165     if (dc)
166     {
167         ret = dc->backgroundColor;
168         GDI_ReleaseObj( hdc );
169     }
170     return ret;
171 }
172
173
174 /***********************************************************************
175  *              GetBkMode (GDI32.@)
176  */
177 INT WINAPI GetBkMode( HDC hdc )
178 {
179     INT ret = 0;
180     DC * dc = DC_GetDCPtr( hdc );
181     if (dc)
182     {
183         ret = dc->backgroundMode;
184         GDI_ReleaseObj( hdc );
185     }
186     return ret;
187 }
188
189
190 /***********************************************************************
191  *              GetMapMode (GDI32.@)
192  */
193 INT WINAPI GetMapMode( HDC hdc )
194 {
195     INT ret = 0;
196     DC * dc = DC_GetDCPtr( hdc );
197     if (dc)
198     {
199         ret = dc->MapMode;
200         GDI_ReleaseObj( hdc );
201     }
202     return ret;
203 }
204
205
206 /***********************************************************************
207  *              GetPolyFillMode (GDI32.@)
208  */
209 INT WINAPI GetPolyFillMode( HDC hdc )
210 {
211     INT ret = 0;
212     DC * dc = DC_GetDCPtr( hdc );
213     if (dc)
214     {
215         ret = dc->polyFillMode;
216         GDI_ReleaseObj( hdc );
217     }
218     return ret;
219 }
220
221
222 /***********************************************************************
223  *              GetROP2 (GDI32.@)
224  */
225 INT WINAPI GetROP2( HDC hdc )
226 {
227     INT ret = 0;
228     DC * dc = DC_GetDCPtr( hdc );
229     if (dc)
230     {
231         ret = dc->ROPmode;
232         GDI_ReleaseObj( hdc );
233     }
234     return ret;
235 }
236
237
238 /***********************************************************************
239  *              GetStretchBltMode (GDI32.@)
240  */
241 INT WINAPI GetStretchBltMode( HDC hdc )
242 {
243     INT ret = 0;
244     DC * dc = DC_GetDCPtr( hdc );
245     if (dc)
246     {
247         ret = dc->stretchBltMode;
248         GDI_ReleaseObj( hdc );
249     }
250     return ret;
251 }
252
253
254 /***********************************************************************
255  *              GetTextColor (GDI32.@)
256  */
257 COLORREF WINAPI GetTextColor( HDC hdc )
258 {
259     COLORREF ret = 0;
260     DC * dc = DC_GetDCPtr( hdc );
261     if (dc)
262     {
263         ret = dc->textColor;
264         GDI_ReleaseObj( hdc );
265     }
266     return ret;
267 }
268
269
270 /***********************************************************************
271  *              GetTextAlign (GDI32.@)
272  */
273 UINT WINAPI GetTextAlign( HDC hdc )
274 {
275     UINT ret = 0;
276     DC * dc = DC_GetDCPtr( hdc );
277     if (dc)
278     {
279         ret = dc->textAlign;
280         GDI_ReleaseObj( hdc );
281     }
282     return ret;
283 }
284
285
286 /***********************************************************************
287  *              GetArcDirection (GDI32.@)
288  */
289 INT WINAPI GetArcDirection( HDC hdc )
290 {
291     INT ret = 0;
292     DC * dc = DC_GetDCPtr( hdc );
293     if (dc)
294     {
295         ret = dc->ArcDirection;
296         GDI_ReleaseObj( hdc );
297     }
298     return ret;
299 }
300
301
302 /***********************************************************************
303  *              GetGraphicsMode (GDI32.@)
304  */
305 INT WINAPI GetGraphicsMode( HDC hdc )
306 {
307     INT ret = 0;
308     DC * dc = DC_GetDCPtr( hdc );
309     if (dc)
310     {
311         ret = dc->GraphicsMode;
312         GDI_ReleaseObj( hdc );
313     }
314     return ret;
315 }
316
317
318 /***********************************************************************
319  *              GetBrushOrgEx (GDI32.@)
320  */
321 BOOL WINAPI GetBrushOrgEx( HDC hdc, LPPOINT pt )
322 {
323     DC * dc = DC_GetDCPtr( hdc );
324     if (!dc) return FALSE;
325     pt->x = dc->brushOrgX;
326     pt->y = dc->brushOrgY;
327     GDI_ReleaseObj( hdc );
328     return TRUE;
329 }
330
331
332 /***********************************************************************
333  *              GetCurrentPositionEx (GDI32.@)
334  */
335 BOOL WINAPI GetCurrentPositionEx( HDC hdc, LPPOINT pt )
336 {
337     DC * dc = DC_GetDCPtr( hdc );
338     if (!dc) return FALSE;
339     pt->x = dc->CursPosX;
340     pt->y = dc->CursPosY;
341     GDI_ReleaseObj( hdc );
342     return TRUE;
343 }
344
345
346 /***********************************************************************
347  *              GetViewportExtEx (GDI32.@)
348  */
349 BOOL WINAPI GetViewportExtEx( HDC hdc, LPSIZE size )
350 {
351     DC * dc = DC_GetDCPtr( hdc );
352     if (!dc) return FALSE;
353     size->cx = dc->vportExtX;
354     size->cy = dc->vportExtY;
355     GDI_ReleaseObj( hdc );
356     return TRUE;
357 }
358
359
360 /***********************************************************************
361  *              GetViewportOrgEx (GDI32.@)
362  */
363 BOOL WINAPI GetViewportOrgEx( HDC hdc, LPPOINT pt )
364 {
365     DC * dc = DC_GetDCPtr( hdc );
366     if (!dc) return FALSE;
367     pt->x = dc->vportOrgX;
368     pt->y = dc->vportOrgY;
369     GDI_ReleaseObj( hdc );
370     return TRUE;
371 }
372
373
374 /***********************************************************************
375  *              GetWindowExtEx (GDI32.@)
376  */
377 BOOL WINAPI GetWindowExtEx( HDC hdc, LPSIZE size )
378 {
379     DC * dc = DC_GetDCPtr( hdc );
380     if (!dc) return FALSE;
381     size->cx = dc->wndExtX;
382     size->cy = dc->wndExtY;
383     GDI_ReleaseObj( hdc );
384     return TRUE;
385 }
386
387
388 /***********************************************************************
389  *              GetWindowOrgEx (GDI32.@)
390  */
391 BOOL WINAPI GetWindowOrgEx( HDC hdc, LPPOINT pt )
392 {
393     DC * dc = DC_GetDCPtr( hdc );
394     if (!dc) return FALSE;
395     pt->x = dc->wndOrgX;
396     pt->y = dc->wndOrgY;
397     GDI_ReleaseObj( hdc );
398     return TRUE;
399 }
400
401
402 /**** 16-bit functions ***/
403
404 /***********************************************************************
405  *              InquireVisRgn   (GDI.131)
406  */
407 HRGN16 WINAPI InquireVisRgn16( HDC16 hdc )
408 {
409     HRGN16 ret = 0;
410     DC * dc = DC_GetDCPtr( HDC_32(hdc) );
411     if (dc)
412     {
413         ret = HRGN_16(dc->hVisRgn);
414         GDI_ReleaseObj( HDC_32(hdc) );
415     }
416     return ret;
417 }
418
419
420 /***********************************************************************
421  *              GetClipRgn (GDI.173)
422  */
423 HRGN16 WINAPI GetClipRgn16( HDC16 hdc )
424 {
425     HRGN16 ret = 0;
426     DC * dc = DC_GetDCPtr( HDC_32(hdc) );
427     if (dc)
428     {
429         ret = HRGN_16(dc->hClipRgn);
430         GDI_ReleaseObj( HDC_32(hdc) );
431     }
432     return ret;
433 }