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