Implemented FormatMessage for sparc. Since the va_list is stored in
[wine/dcerpc.git] / objects / dcvalues.c
blobdfc0dcef7ce7e971e0f36f4a2b6b95ef46b1eed2
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 "winbase.h"
24 #include "winerror.h"
26 #include "gdi.h"
29 /***********************************************************************
30 * SetBkMode (GDI32.@)
32 INT WINAPI SetBkMode( HDC hdc, INT mode )
34 INT ret;
35 DC *dc;
36 if ((mode <= 0) || (mode > BKMODE_LAST))
38 SetLastError(ERROR_INVALID_PARAMETER);
39 return 0;
41 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
42 if (dc->funcs->pSetBkMode)
43 ret = dc->funcs->pSetBkMode( dc->physDev, mode );
44 else
46 ret = dc->backgroundMode;
47 dc->backgroundMode = mode;
49 GDI_ReleaseObj( hdc );
50 return ret;
54 /***********************************************************************
55 * SetROP2 (GDI32.@)
57 INT WINAPI SetROP2( HDC hdc, INT mode )
59 INT ret;
60 DC *dc;
61 if ((mode < R2_BLACK) || (mode > R2_WHITE))
63 SetLastError(ERROR_INVALID_PARAMETER);
64 return 0;
66 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
67 if (dc->funcs->pSetROP2)
68 ret = dc->funcs->pSetROP2( dc->physDev, mode );
69 else
71 ret = dc->ROPmode;
72 dc->ROPmode = mode;
74 GDI_ReleaseObj( hdc );
75 return ret;
79 /***********************************************************************
80 * SetRelAbs (GDI32.@)
82 INT WINAPI SetRelAbs( HDC hdc, INT mode )
84 INT ret;
85 DC *dc;
86 if ((mode != ABSOLUTE) && (mode != RELATIVE))
88 SetLastError(ERROR_INVALID_PARAMETER);
89 return 0;
91 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
92 if (dc->funcs->pSetRelAbs)
93 ret = dc->funcs->pSetRelAbs( dc->physDev, mode );
94 else
96 ret = dc->relAbsMode;
97 dc->relAbsMode = mode;
99 GDI_ReleaseObj( hdc );
100 return ret;
104 /***********************************************************************
105 * SetPolyFillMode (GDI32.@)
107 INT WINAPI SetPolyFillMode( HDC hdc, INT mode )
109 INT ret;
110 DC *dc;
111 if ((mode <= 0) || (mode > POLYFILL_LAST))
113 SetLastError(ERROR_INVALID_PARAMETER);
114 return 0;
116 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
117 if (dc->funcs->pSetPolyFillMode)
118 ret = dc->funcs->pSetPolyFillMode( dc->physDev, mode );
119 else
121 ret = dc->polyFillMode;
122 dc->polyFillMode = mode;
124 GDI_ReleaseObj( hdc );
125 return ret;
129 /***********************************************************************
130 * SetStretchBltMode (GDI32.@)
132 INT WINAPI SetStretchBltMode( HDC hdc, INT mode )
134 INT ret;
135 DC *dc;
136 if ((mode <= 0) || (mode > MAXSTRETCHBLTMODE))
138 SetLastError(ERROR_INVALID_PARAMETER);
139 return 0;
141 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
142 if (dc->funcs->pSetStretchBltMode)
143 ret = dc->funcs->pSetStretchBltMode( dc->physDev, mode );
144 else
146 ret = dc->stretchBltMode;
147 dc->stretchBltMode = mode;
149 GDI_ReleaseObj( hdc );
150 return ret;
154 /***********************************************************************
155 * GetBkColor (GDI32.@)
157 COLORREF WINAPI GetBkColor( HDC hdc )
159 COLORREF ret = 0;
160 DC * dc = DC_GetDCPtr( hdc );
161 if (dc)
163 ret = dc->backgroundColor;
164 GDI_ReleaseObj( hdc );
166 return ret;
170 /***********************************************************************
171 * GetBkMode (GDI32.@)
173 INT WINAPI GetBkMode( HDC hdc )
175 INT ret = 0;
176 DC * dc = DC_GetDCPtr( hdc );
177 if (dc)
179 ret = dc->backgroundMode;
180 GDI_ReleaseObj( hdc );
182 return ret;
186 /***********************************************************************
187 * GetMapMode (GDI32.@)
189 INT WINAPI GetMapMode( HDC hdc )
191 INT ret = 0;
192 DC * dc = DC_GetDCPtr( hdc );
193 if (dc)
195 ret = dc->MapMode;
196 GDI_ReleaseObj( hdc );
198 return ret;
202 /***********************************************************************
203 * GetPolyFillMode (GDI32.@)
205 INT WINAPI GetPolyFillMode( HDC hdc )
207 INT ret = 0;
208 DC * dc = DC_GetDCPtr( hdc );
209 if (dc)
211 ret = dc->polyFillMode;
212 GDI_ReleaseObj( hdc );
214 return ret;
218 /***********************************************************************
219 * GetROP2 (GDI32.@)
221 INT WINAPI GetROP2( HDC hdc )
223 INT ret = 0;
224 DC * dc = DC_GetDCPtr( hdc );
225 if (dc)
227 ret = dc->ROPmode;
228 GDI_ReleaseObj( hdc );
230 return ret;
234 /***********************************************************************
235 * GetStretchBltMode (GDI32.@)
237 INT WINAPI GetStretchBltMode( HDC hdc )
239 INT ret = 0;
240 DC * dc = DC_GetDCPtr( hdc );
241 if (dc)
243 ret = dc->stretchBltMode;
244 GDI_ReleaseObj( hdc );
246 return ret;
250 /***********************************************************************
251 * GetTextColor (GDI32.@)
253 COLORREF WINAPI GetTextColor( HDC hdc )
255 COLORREF ret = 0;
256 DC * dc = DC_GetDCPtr( hdc );
257 if (dc)
259 ret = dc->textColor;
260 GDI_ReleaseObj( hdc );
262 return ret;
266 /***********************************************************************
267 * GetTextAlign (GDI32.@)
269 UINT WINAPI GetTextAlign( HDC hdc )
271 UINT ret = 0;
272 DC * dc = DC_GetDCPtr( hdc );
273 if (dc)
275 ret = dc->textAlign;
276 GDI_ReleaseObj( hdc );
278 return ret;
282 /***********************************************************************
283 * GetArcDirection (GDI32.@)
285 INT WINAPI GetArcDirection( HDC hdc )
287 INT ret = 0;
288 DC * dc = DC_GetDCPtr( hdc );
289 if (dc)
291 ret = dc->ArcDirection;
292 GDI_ReleaseObj( hdc );
294 return ret;
298 /***********************************************************************
299 * GetGraphicsMode (GDI32.@)
301 INT WINAPI GetGraphicsMode( HDC hdc )
303 INT ret = 0;
304 DC * dc = DC_GetDCPtr( hdc );
305 if (dc)
307 ret = dc->GraphicsMode;
308 GDI_ReleaseObj( hdc );
310 return ret;
314 /***********************************************************************
315 * GetBrushOrgEx (GDI32.@)
317 BOOL WINAPI GetBrushOrgEx( HDC hdc, LPPOINT pt )
319 DC * dc = DC_GetDCPtr( hdc );
320 if (!dc) return FALSE;
321 pt->x = dc->brushOrgX;
322 pt->y = dc->brushOrgY;
323 GDI_ReleaseObj( hdc );
324 return TRUE;
328 /***********************************************************************
329 * GetCurrentPositionEx (GDI32.@)
331 BOOL WINAPI GetCurrentPositionEx( HDC hdc, LPPOINT pt )
333 DC * dc = DC_GetDCPtr( hdc );
334 if (!dc) return FALSE;
335 pt->x = dc->CursPosX;
336 pt->y = dc->CursPosY;
337 GDI_ReleaseObj( hdc );
338 return TRUE;
342 /***********************************************************************
343 * GetViewportExtEx (GDI32.@)
345 BOOL WINAPI GetViewportExtEx( HDC hdc, LPSIZE size )
347 DC * dc = DC_GetDCPtr( hdc );
348 if (!dc) return FALSE;
349 size->cx = dc->vportExtX;
350 size->cy = dc->vportExtY;
351 GDI_ReleaseObj( hdc );
352 return TRUE;
356 /***********************************************************************
357 * GetViewportOrgEx (GDI32.@)
359 BOOL WINAPI GetViewportOrgEx( HDC hdc, LPPOINT pt )
361 DC * dc = DC_GetDCPtr( hdc );
362 if (!dc) return FALSE;
363 pt->x = dc->vportOrgX;
364 pt->y = dc->vportOrgY;
365 GDI_ReleaseObj( hdc );
366 return TRUE;
370 /***********************************************************************
371 * GetWindowExtEx (GDI32.@)
373 BOOL WINAPI GetWindowExtEx( HDC hdc, LPSIZE size )
375 DC * dc = DC_GetDCPtr( hdc );
376 if (!dc) return FALSE;
377 size->cx = dc->wndExtX;
378 size->cy = dc->wndExtY;
379 GDI_ReleaseObj( hdc );
380 return TRUE;
384 /***********************************************************************
385 * GetWindowOrgEx (GDI32.@)
387 BOOL WINAPI GetWindowOrgEx( HDC hdc, LPPOINT pt )
389 DC * dc = DC_GetDCPtr( hdc );
390 if (!dc) return FALSE;
391 pt->x = dc->wndOrgX;
392 pt->y = dc->wndOrgY;
393 GDI_ReleaseObj( hdc );
394 return TRUE;
398 /**** 16-bit functions ****/
401 /***********************************************************************
402 * SetBkMode (GDI.2)
404 INT16 WINAPI SetBkMode16( HDC16 hdc, INT16 mode )
406 return SetBkMode( hdc, mode );
409 /***********************************************************************
410 * SetROP2 (GDI.4)
412 INT16 WINAPI SetROP216( HDC16 hdc, INT16 mode )
414 return SetROP2( hdc, mode );
417 /***********************************************************************
418 * SetRelAbs (GDI.5)
420 INT16 WINAPI SetRelAbs16( HDC16 hdc, INT16 mode )
422 return SetRelAbs( hdc, mode );
425 /***********************************************************************
426 * SetPolyFillMode (GDI.6)
428 INT16 WINAPI SetPolyFillMode16( HDC16 hdc, INT16 mode )
430 return SetPolyFillMode( hdc, mode );
433 /***********************************************************************
434 * SetStretchBltMode (GDI.7)
436 INT16 WINAPI SetStretchBltMode16( HDC16 hdc, INT16 mode )
438 return SetStretchBltMode( hdc, mode );
441 /***********************************************************************
442 * GetBkColor (GDI.75)
444 COLORREF WINAPI GetBkColor16( HDC16 hdc )
446 return GetBkColor( hdc );
449 /***********************************************************************
450 * GetBkMode (GDI.76)
452 INT16 WINAPI GetBkMode16( HDC16 hdc )
454 return GetBkMode( hdc );
457 /***********************************************************************
458 * GetCurrentPosition (GDI.78)
460 DWORD WINAPI GetCurrentPosition16( HDC16 hdc )
462 POINT pt32;
463 if (!GetCurrentPositionEx( hdc, &pt32 )) return 0;
464 return MAKELONG( pt32.x, pt32.y );
467 /***********************************************************************
468 * GetMapMode (GDI.81)
470 INT16 WINAPI GetMapMode16( HDC16 hdc )
472 return GetMapMode( hdc );
475 /***********************************************************************
476 * GetPolyFillMode (GDI.84)
478 INT16 WINAPI GetPolyFillMode16( HDC16 hdc )
480 return GetPolyFillMode( hdc );
483 /***********************************************************************
484 * GetROP2 (GDI.85)
486 INT16 WINAPI GetROP216( HDC16 hdc )
488 return GetROP2( hdc );
491 /***********************************************************************
492 * GetRelAbs (GDI.86)
494 INT16 WINAPI GetRelAbs16( HDC16 hdc )
496 return GetRelAbs( hdc, 0 );
499 /***********************************************************************
500 * GetStretchBltMode (GDI.88)
502 INT16 WINAPI GetStretchBltMode16( HDC16 hdc )
504 return GetStretchBltMode( hdc );
507 /***********************************************************************
508 * GetTextColor (GDI.90)
510 COLORREF WINAPI GetTextColor16( HDC16 hdc )
512 return GetTextColor( hdc );
515 /***********************************************************************
516 * GetViewportExt (GDI.94)
518 DWORD WINAPI GetViewportExt16( HDC16 hdc )
520 SIZE size;
521 if (!GetViewportExtEx( hdc, &size )) return 0;
522 return MAKELONG( size.cx, size.cy );
525 /***********************************************************************
526 * GetViewportOrg (GDI.95)
528 DWORD WINAPI GetViewportOrg16( HDC16 hdc )
530 POINT pt;
531 if (!GetViewportOrgEx( hdc, &pt )) return 0;
532 return MAKELONG( pt.x, pt.y );
536 /***********************************************************************
537 * GetWindowExt (GDI.96)
539 DWORD WINAPI GetWindowExt16( HDC16 hdc )
541 SIZE size;
542 if (!GetWindowExtEx( hdc, &size )) return 0;
543 return MAKELONG( size.cx, size.cy );
546 /***********************************************************************
547 * GetWindowOrg (GDI.97)
549 DWORD WINAPI GetWindowOrg16( HDC16 hdc )
551 POINT pt;
552 if (!GetWindowOrgEx( hdc, &pt )) return 0;
553 return MAKELONG( pt.x, pt.y );
556 /***********************************************************************
557 * InquireVisRgn (GDI.131)
559 HRGN16 WINAPI InquireVisRgn16( HDC16 hdc )
561 HRGN16 ret = 0;
562 DC * dc = DC_GetDCPtr( hdc );
563 if (dc)
565 ret = dc->hVisRgn;
566 GDI_ReleaseObj( hdc );
568 return ret;
571 /***********************************************************************
572 * GetBrushOrg (GDI.149)
574 DWORD WINAPI GetBrushOrg16( HDC16 hdc )
576 POINT pt;
577 if (!GetBrushOrgEx( hdc, &pt )) return 0;
578 return MAKELONG( pt.x, pt.y );
581 /***********************************************************************
582 * GetClipRgn (GDI.173)
584 HRGN16 WINAPI GetClipRgn16( HDC16 hdc )
586 HRGN16 ret = 0;
587 DC * dc = DC_GetDCPtr( hdc );
588 if (dc)
590 ret = dc->hClipRgn;
591 GDI_ReleaseObj( hdc );
593 return ret;
596 /***********************************************************************
597 * GetTextAlign (GDI.345)
599 UINT16 WINAPI GetTextAlign16( HDC16 hdc )
601 return GetTextAlign( hdc );
604 /***********************************************************************
605 * GetCurLogFont (GDI.411)
607 HFONT16 WINAPI GetCurLogFont16( HDC16 hdc )
609 HFONT16 ret = 0;
610 DC * dc = DC_GetDCPtr( hdc );
611 if (dc)
613 ret = dc->hFont;
614 GDI_ReleaseObj( hdc );
616 return ret;
619 /***********************************************************************
620 * GetBrushOrgEx (GDI.469)
622 BOOL16 WINAPI GetBrushOrgEx16( HDC16 hdc, LPPOINT16 pt )
624 POINT pt32;
625 if (!GetBrushOrgEx( hdc, &pt32 )) return FALSE;
626 pt->x = pt32.x;
627 pt->y = pt32.y;
628 return TRUE;
631 /***********************************************************************
632 * GetCurrentPositionEx (GDI.470)
634 BOOL16 WINAPI GetCurrentPositionEx16( HDC16 hdc, LPPOINT16 pt )
636 POINT pt32;
637 if (!GetCurrentPositionEx( hdc, &pt32 )) return FALSE;
638 pt->x = pt32.x;
639 pt->y = pt32.y;
640 return TRUE;
643 /***********************************************************************
644 * GetViewportExtEx (GDI.472)
646 BOOL16 WINAPI GetViewportExtEx16( HDC16 hdc, LPSIZE16 size )
648 SIZE size32;
649 if (!GetViewportExtEx( hdc, &size32 )) return FALSE;
650 size->cx = size32.cx;
651 size->cy = size32.cy;
652 return TRUE;
655 /***********************************************************************
656 * GetViewportOrgEx (GDI.473)
658 BOOL16 WINAPI GetViewportOrgEx16( HDC16 hdc, LPPOINT16 pt )
660 POINT pt32;
661 if (!GetViewportOrgEx( hdc, &pt32 )) return FALSE;
662 pt->x = pt32.x;
663 pt->y = pt32.y;
664 return TRUE;
667 /***********************************************************************
668 * GetWindowExtEx (GDI.474)
670 BOOL16 WINAPI GetWindowExtEx16( HDC16 hdc, LPSIZE16 size )
672 SIZE size32;
673 if (!GetWindowExtEx( hdc, &size32 )) return FALSE;
674 size->cx = size32.cx;
675 size->cy = size32.cy;
676 return TRUE;
679 /***********************************************************************
680 * GetWindowOrgEx (GDI.475)
682 BOOL16 WINAPI GetWindowOrgEx16( HDC16 hdc, LPPOINT16 pt )
684 POINT pt32;
685 if (!GetWindowOrgEx( hdc, &pt32 )) return FALSE;
686 pt->x = pt32.x;
687 pt->y = pt32.y;
688 return TRUE;
691 /***********************************************************************
692 * GetArcDirection (GDI.524)
694 INT16 WINAPI GetArcDirection16( HDC16 hdc )
696 return GetArcDirection( hdc );