Fix value renaming. Cleanup code, fix a few leaks.
[wine/multimedia.git] / objects / dcvalues.c
blob09bbdadbb44a73c52f94868573835d6740da20ec
1 /*
2 * DC device-independent Get/SetXXX functions
4 * Copyright 1993 Alexandre Julliard
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.
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.
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
21 #include "config.h"
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winerror.h"
28 #include "wownt32.h"
30 #include "gdi.h"
31 #include "gdi_private.h"
34 /***********************************************************************
35 * SetBkMode (GDI32.@)
37 INT WINAPI SetBkMode( HDC hdc, INT mode )
39 INT ret;
40 DC *dc;
41 if ((mode <= 0) || (mode > BKMODE_LAST))
43 SetLastError(ERROR_INVALID_PARAMETER);
44 return 0;
46 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
47 if (dc->funcs->pSetBkMode)
48 ret = dc->funcs->pSetBkMode( dc->physDev, mode );
49 else
51 ret = dc->backgroundMode;
52 dc->backgroundMode = mode;
54 GDI_ReleaseObj( hdc );
55 return ret;
59 /***********************************************************************
60 * SetROP2 (GDI32.@)
62 INT WINAPI SetROP2( HDC hdc, INT mode )
64 INT ret;
65 DC *dc;
66 if ((mode < R2_BLACK) || (mode > R2_WHITE))
68 SetLastError(ERROR_INVALID_PARAMETER);
69 return 0;
71 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
72 if (dc->funcs->pSetROP2)
73 ret = dc->funcs->pSetROP2( dc->physDev, mode );
74 else
76 ret = dc->ROPmode;
77 dc->ROPmode = mode;
79 GDI_ReleaseObj( hdc );
80 return ret;
84 /***********************************************************************
85 * SetRelAbs (GDI32.@)
87 INT WINAPI SetRelAbs( HDC hdc, INT mode )
89 INT ret;
90 DC *dc;
91 if ((mode != ABSOLUTE) && (mode != RELATIVE))
93 SetLastError(ERROR_INVALID_PARAMETER);
94 return 0;
96 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
97 if (dc->funcs->pSetRelAbs)
98 ret = dc->funcs->pSetRelAbs( dc->physDev, mode );
99 else
101 ret = dc->relAbsMode;
102 dc->relAbsMode = mode;
104 GDI_ReleaseObj( hdc );
105 return ret;
109 /***********************************************************************
110 * SetPolyFillMode (GDI32.@)
112 INT WINAPI SetPolyFillMode( HDC hdc, INT mode )
114 INT ret;
115 DC *dc;
116 if ((mode <= 0) || (mode > POLYFILL_LAST))
118 SetLastError(ERROR_INVALID_PARAMETER);
119 return 0;
121 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
122 if (dc->funcs->pSetPolyFillMode)
123 ret = dc->funcs->pSetPolyFillMode( dc->physDev, mode );
124 else
126 ret = dc->polyFillMode;
127 dc->polyFillMode = mode;
129 GDI_ReleaseObj( hdc );
130 return ret;
134 /***********************************************************************
135 * SetStretchBltMode (GDI32.@)
137 INT WINAPI SetStretchBltMode( HDC hdc, INT mode )
139 INT ret;
140 DC *dc;
141 if ((mode <= 0) || (mode > MAXSTRETCHBLTMODE))
143 SetLastError(ERROR_INVALID_PARAMETER);
144 return 0;
146 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
147 if (dc->funcs->pSetStretchBltMode)
148 ret = dc->funcs->pSetStretchBltMode( dc->physDev, mode );
149 else
151 ret = dc->stretchBltMode;
152 dc->stretchBltMode = mode;
154 GDI_ReleaseObj( hdc );
155 return ret;
159 /***********************************************************************
160 * GetBkColor (GDI32.@)
162 COLORREF WINAPI GetBkColor( HDC hdc )
164 COLORREF ret = 0;
165 DC * dc = DC_GetDCPtr( hdc );
166 if (dc)
168 ret = dc->backgroundColor;
169 GDI_ReleaseObj( hdc );
171 return ret;
175 /***********************************************************************
176 * GetBkMode (GDI32.@)
178 INT WINAPI GetBkMode( HDC hdc )
180 INT ret = 0;
181 DC * dc = DC_GetDCPtr( hdc );
182 if (dc)
184 ret = dc->backgroundMode;
185 GDI_ReleaseObj( hdc );
187 return ret;
191 /***********************************************************************
192 * GetMapMode (GDI32.@)
194 INT WINAPI GetMapMode( HDC hdc )
196 INT ret = 0;
197 DC * dc = DC_GetDCPtr( hdc );
198 if (dc)
200 ret = dc->MapMode;
201 GDI_ReleaseObj( hdc );
203 return ret;
207 /***********************************************************************
208 * GetPolyFillMode (GDI32.@)
210 INT WINAPI GetPolyFillMode( HDC hdc )
212 INT ret = 0;
213 DC * dc = DC_GetDCPtr( hdc );
214 if (dc)
216 ret = dc->polyFillMode;
217 GDI_ReleaseObj( hdc );
219 return ret;
223 /***********************************************************************
224 * GetROP2 (GDI32.@)
226 INT WINAPI GetROP2( HDC hdc )
228 INT ret = 0;
229 DC * dc = DC_GetDCPtr( hdc );
230 if (dc)
232 ret = dc->ROPmode;
233 GDI_ReleaseObj( hdc );
235 return ret;
239 /***********************************************************************
240 * GetStretchBltMode (GDI32.@)
242 INT WINAPI GetStretchBltMode( HDC hdc )
244 INT ret = 0;
245 DC * dc = DC_GetDCPtr( hdc );
246 if (dc)
248 ret = dc->stretchBltMode;
249 GDI_ReleaseObj( hdc );
251 return ret;
255 /***********************************************************************
256 * GetTextColor (GDI32.@)
258 COLORREF WINAPI GetTextColor( HDC hdc )
260 COLORREF ret = 0;
261 DC * dc = DC_GetDCPtr( hdc );
262 if (dc)
264 ret = dc->textColor;
265 GDI_ReleaseObj( hdc );
267 return ret;
271 /***********************************************************************
272 * GetTextAlign (GDI32.@)
274 UINT WINAPI GetTextAlign( HDC hdc )
276 UINT ret = 0;
277 DC * dc = DC_GetDCPtr( hdc );
278 if (dc)
280 ret = dc->textAlign;
281 GDI_ReleaseObj( hdc );
283 return ret;
287 /***********************************************************************
288 * GetArcDirection (GDI32.@)
290 INT WINAPI GetArcDirection( HDC hdc )
292 INT ret = 0;
293 DC * dc = DC_GetDCPtr( hdc );
294 if (dc)
296 ret = dc->ArcDirection;
297 GDI_ReleaseObj( hdc );
299 return ret;
303 /***********************************************************************
304 * GetGraphicsMode (GDI32.@)
306 INT WINAPI GetGraphicsMode( HDC hdc )
308 INT ret = 0;
309 DC * dc = DC_GetDCPtr( hdc );
310 if (dc)
312 ret = dc->GraphicsMode;
313 GDI_ReleaseObj( hdc );
315 return ret;
319 /***********************************************************************
320 * GetBrushOrgEx (GDI32.@)
322 BOOL WINAPI GetBrushOrgEx( HDC hdc, LPPOINT pt )
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;
333 /***********************************************************************
334 * GetCurrentPositionEx (GDI32.@)
336 BOOL WINAPI GetCurrentPositionEx( HDC hdc, LPPOINT pt )
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;
347 /***********************************************************************
348 * GetViewportExtEx (GDI32.@)
350 BOOL WINAPI GetViewportExtEx( HDC hdc, LPSIZE size )
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;
361 /***********************************************************************
362 * GetViewportOrgEx (GDI32.@)
364 BOOL WINAPI GetViewportOrgEx( HDC hdc, LPPOINT pt )
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;
375 /***********************************************************************
376 * GetWindowExtEx (GDI32.@)
378 BOOL WINAPI GetWindowExtEx( HDC hdc, LPSIZE size )
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;
389 /***********************************************************************
390 * GetWindowOrgEx (GDI32.@)
392 BOOL WINAPI GetWindowOrgEx( HDC hdc, LPPOINT pt )
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;
403 /**** 16-bit functions ***/
405 /***********************************************************************
406 * InquireVisRgn (GDI.131)
408 HRGN16 WINAPI InquireVisRgn16( HDC16 hdc )
410 HRGN16 ret = 0;
411 DC * dc = DC_GetDCPtr( HDC_32(hdc) );
412 if (dc)
414 ret = HRGN_16(dc->hVisRgn);
415 GDI_ReleaseObj( HDC_32(hdc) );
417 return ret;
421 /***********************************************************************
422 * GetClipRgn (GDI.173)
424 HRGN16 WINAPI GetClipRgn16( HDC16 hdc )
426 HRGN16 ret = 0;
427 DC * dc = DC_GetDCPtr( HDC_32(hdc) );
428 if (dc)
430 ret = HRGN_16(dc->hClipRgn);
431 GDI_ReleaseObj( HDC_32(hdc) );
433 return ret;