A treeview item may be TVI_ROOT.
[wine/hacks.git] / objects / dcvalues.c
bloba25c01cadd8f946d53db075b46b3ee63a3132dd9
1 /*
2 * DC device-independent Get/SetXXX functions
4 * Copyright 1993 Alexandre Julliard
6 */
8 #include "config.h"
10 #include "winbase.h"
11 #include "winerror.h"
13 #include "gdi.h"
16 /***********************************************************************
17 * SetBkMode (GDI32.@)
19 INT WINAPI SetBkMode( HDC hdc, INT mode )
21 INT ret;
22 DC *dc;
23 if ((mode <= 0) || (mode > BKMODE_LAST))
25 SetLastError(ERROR_INVALID_PARAMETER);
26 return 0;
28 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
29 if (dc->funcs->pSetBkMode)
30 ret = dc->funcs->pSetBkMode( dc, mode );
31 else
33 ret = dc->backgroundMode;
34 dc->backgroundMode = mode;
36 GDI_ReleaseObj( hdc );
37 return ret;
41 /***********************************************************************
42 * SetROP2 (GDI32.@)
44 INT WINAPI SetROP2( HDC hdc, INT mode )
46 INT ret;
47 DC *dc;
48 if ((mode < R2_BLACK) || (mode > R2_WHITE))
50 SetLastError(ERROR_INVALID_PARAMETER);
51 return 0;
53 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
54 if (dc->funcs->pSetROP2)
55 ret = dc->funcs->pSetROP2( dc, mode );
56 else
58 ret = dc->ROPmode;
59 dc->ROPmode = mode;
61 GDI_ReleaseObj( hdc );
62 return ret;
66 /***********************************************************************
67 * SetRelAbs (GDI32.@)
69 INT WINAPI SetRelAbs( HDC hdc, INT mode )
71 INT ret;
72 DC *dc;
73 if ((mode != ABSOLUTE) && (mode != RELATIVE))
75 SetLastError(ERROR_INVALID_PARAMETER);
76 return 0;
78 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
79 if (dc->funcs->pSetRelAbs)
80 ret = dc->funcs->pSetRelAbs( dc, mode );
81 else
83 ret = dc->relAbsMode;
84 dc->relAbsMode = mode;
86 GDI_ReleaseObj( hdc );
87 return ret;
91 /***********************************************************************
92 * SetPolyFillMode (GDI32.@)
94 INT WINAPI SetPolyFillMode( HDC hdc, INT mode )
96 INT ret;
97 DC *dc;
98 if ((mode <= 0) || (mode > POLYFILL_LAST))
100 SetLastError(ERROR_INVALID_PARAMETER);
101 return 0;
103 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
104 if (dc->funcs->pSetPolyFillMode)
105 ret = dc->funcs->pSetPolyFillMode( dc, mode );
106 else
108 ret = dc->polyFillMode;
109 dc->polyFillMode = mode;
111 GDI_ReleaseObj( hdc );
112 return ret;
116 /***********************************************************************
117 * SetStretchBltMode (GDI32.@)
119 INT WINAPI SetStretchBltMode( HDC hdc, INT mode )
121 INT ret;
122 DC *dc;
123 if ((mode <= 0) || (mode > MAXSTRETCHBLTMODE))
125 SetLastError(ERROR_INVALID_PARAMETER);
126 return 0;
128 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
129 if (dc->funcs->pSetStretchBltMode)
130 ret = dc->funcs->pSetStretchBltMode( dc, mode );
131 else
133 ret = dc->stretchBltMode;
134 dc->stretchBltMode = mode;
136 GDI_ReleaseObj( hdc );
137 return ret;
141 /***********************************************************************
142 * GetBkColor (GDI32.@)
144 COLORREF WINAPI GetBkColor( HDC hdc )
146 COLORREF ret = 0;
147 DC * dc = DC_GetDCPtr( hdc );
148 if (dc)
150 ret = dc->backgroundColor;
151 GDI_ReleaseObj( hdc );
153 return ret;
157 /***********************************************************************
158 * GetBkMode (GDI32.@)
160 INT WINAPI GetBkMode( HDC hdc )
162 INT ret = 0;
163 DC * dc = DC_GetDCPtr( hdc );
164 if (dc)
166 ret = dc->backgroundMode;
167 GDI_ReleaseObj( hdc );
169 return ret;
173 /***********************************************************************
174 * GetMapMode (GDI32.@)
176 INT WINAPI GetMapMode( HDC hdc )
178 INT ret = 0;
179 DC * dc = DC_GetDCPtr( hdc );
180 if (dc)
182 ret = dc->MapMode;
183 GDI_ReleaseObj( hdc );
185 return ret;
189 /***********************************************************************
190 * GetPolyFillMode (GDI32.@)
192 INT WINAPI GetPolyFillMode( HDC hdc )
194 INT ret = 0;
195 DC * dc = DC_GetDCPtr( hdc );
196 if (dc)
198 ret = dc->polyFillMode;
199 GDI_ReleaseObj( hdc );
201 return ret;
205 /***********************************************************************
206 * GetROP2 (GDI32.@)
208 INT WINAPI GetROP2( HDC hdc )
210 INT ret = 0;
211 DC * dc = DC_GetDCPtr( hdc );
212 if (dc)
214 ret = dc->ROPmode;
215 GDI_ReleaseObj( hdc );
217 return ret;
221 /***********************************************************************
222 * GetStretchBltMode (GDI32.@)
224 INT WINAPI GetStretchBltMode( HDC hdc )
226 INT ret = 0;
227 DC * dc = DC_GetDCPtr( hdc );
228 if (dc)
230 ret = dc->stretchBltMode;
231 GDI_ReleaseObj( hdc );
233 return ret;
237 /***********************************************************************
238 * GetTextColor (GDI32.@)
240 COLORREF WINAPI GetTextColor( HDC hdc )
242 COLORREF ret = 0;
243 DC * dc = DC_GetDCPtr( hdc );
244 if (dc)
246 ret = dc->textColor;
247 GDI_ReleaseObj( hdc );
249 return ret;
253 /***********************************************************************
254 * GetTextAlign (GDI32.@)
256 UINT WINAPI GetTextAlign( HDC hdc )
258 UINT ret = 0;
259 DC * dc = DC_GetDCPtr( hdc );
260 if (dc)
262 ret = dc->textAlign;
263 GDI_ReleaseObj( hdc );
265 return ret;
269 /***********************************************************************
270 * GetArcDirection (GDI32.@)
272 INT WINAPI GetArcDirection( HDC hdc )
274 INT ret = 0;
275 DC * dc = DC_GetDCPtr( hdc );
276 if (dc)
278 ret = dc->ArcDirection;
279 GDI_ReleaseObj( hdc );
281 return ret;
285 /***********************************************************************
286 * GetGraphicsMode (GDI32.@)
288 INT WINAPI GetGraphicsMode( HDC hdc )
290 INT ret = 0;
291 DC * dc = DC_GetDCPtr( hdc );
292 if (dc)
294 ret = dc->GraphicsMode;
295 GDI_ReleaseObj( hdc );
297 return ret;
301 /***********************************************************************
302 * GetBrushOrgEx (GDI32.@)
304 BOOL WINAPI GetBrushOrgEx( HDC hdc, LPPOINT pt )
306 DC * dc = DC_GetDCPtr( hdc );
307 if (!dc) return FALSE;
308 pt->x = dc->brushOrgX;
309 pt->y = dc->brushOrgY;
310 GDI_ReleaseObj( hdc );
311 return TRUE;
315 /***********************************************************************
316 * GetCurrentPositionEx (GDI32.@)
318 BOOL WINAPI GetCurrentPositionEx( HDC hdc, LPPOINT pt )
320 DC * dc = DC_GetDCPtr( hdc );
321 if (!dc) return FALSE;
322 pt->x = dc->CursPosX;
323 pt->y = dc->CursPosY;
324 GDI_ReleaseObj( hdc );
325 return TRUE;
329 /***********************************************************************
330 * GetViewportExtEx (GDI32.@)
332 BOOL WINAPI GetViewportExtEx( HDC hdc, LPSIZE size )
334 DC * dc = DC_GetDCPtr( hdc );
335 if (!dc) return FALSE;
336 size->cx = dc->vportExtX;
337 size->cy = dc->vportExtY;
338 GDI_ReleaseObj( hdc );
339 return TRUE;
343 /***********************************************************************
344 * GetViewportOrgEx (GDI32.@)
346 BOOL WINAPI GetViewportOrgEx( HDC hdc, LPPOINT pt )
348 DC * dc = DC_GetDCPtr( hdc );
349 if (!dc) return FALSE;
350 pt->x = dc->vportOrgX;
351 pt->y = dc->vportOrgY;
352 GDI_ReleaseObj( hdc );
353 return TRUE;
357 /***********************************************************************
358 * GetWindowExtEx (GDI32.@)
360 BOOL WINAPI GetWindowExtEx( HDC hdc, LPSIZE size )
362 DC * dc = DC_GetDCPtr( hdc );
363 if (!dc) return FALSE;
364 size->cx = dc->wndExtX;
365 size->cy = dc->wndExtY;
366 GDI_ReleaseObj( hdc );
367 return TRUE;
371 /***********************************************************************
372 * GetWindowOrgEx (GDI32.@)
374 BOOL WINAPI GetWindowOrgEx( HDC hdc, LPPOINT pt )
376 DC * dc = DC_GetDCPtr( hdc );
377 if (!dc) return FALSE;
378 pt->x = dc->wndOrgX;
379 pt->y = dc->wndOrgY;
380 GDI_ReleaseObj( hdc );
381 return TRUE;
385 /**** 16-bit functions ****/
388 /***********************************************************************
389 * SetBkMode (GDI.2)
391 INT16 WINAPI SetBkMode16( HDC16 hdc, INT16 mode )
393 return SetBkMode( hdc, mode );
396 /***********************************************************************
397 * SetROP2 (GDI.4)
399 INT16 WINAPI SetROP216( HDC16 hdc, INT16 mode )
401 return SetROP2( hdc, mode );
404 /***********************************************************************
405 * SetRelAbs (GDI.5)
407 INT16 WINAPI SetRelAbs16( HDC16 hdc, INT16 mode )
409 return SetRelAbs( hdc, mode );
412 /***********************************************************************
413 * SetPolyFillMode (GDI.6)
415 INT16 WINAPI SetPolyFillMode16( HDC16 hdc, INT16 mode )
417 return SetPolyFillMode( hdc, mode );
420 /***********************************************************************
421 * SetStretchBltMode (GDI.7)
423 INT16 WINAPI SetStretchBltMode16( HDC16 hdc, INT16 mode )
425 return SetStretchBltMode( hdc, mode );
428 /***********************************************************************
429 * GetBkColor (GDI.75)
431 COLORREF WINAPI GetBkColor16( HDC16 hdc )
433 return GetBkColor( hdc );
436 /***********************************************************************
437 * GetBkMode (GDI.76)
439 INT16 WINAPI GetBkMode16( HDC16 hdc )
441 return GetBkMode( hdc );
444 /***********************************************************************
445 * GetCurrentPosition (GDI.78)
447 DWORD WINAPI GetCurrentPosition16( HDC16 hdc )
449 POINT pt32;
450 if (!GetCurrentPositionEx( hdc, &pt32 )) return 0;
451 return MAKELONG( pt32.x, pt32.y );
454 /***********************************************************************
455 * GetMapMode (GDI.81)
457 INT16 WINAPI GetMapMode16( HDC16 hdc )
459 return GetMapMode( hdc );
462 /***********************************************************************
463 * GetPolyFillMode (GDI.84)
465 INT16 WINAPI GetPolyFillMode16( HDC16 hdc )
467 return GetPolyFillMode( hdc );
470 /***********************************************************************
471 * GetROP2 (GDI.85)
473 INT16 WINAPI GetROP216( HDC16 hdc )
475 return GetROP2( hdc );
478 /***********************************************************************
479 * GetRelAbs (GDI.86)
481 INT16 WINAPI GetRelAbs16( HDC16 hdc )
483 return GetRelAbs( hdc, 0 );
486 /***********************************************************************
487 * GetStretchBltMode (GDI.88)
489 INT16 WINAPI GetStretchBltMode16( HDC16 hdc )
491 return GetStretchBltMode( hdc );
494 /***********************************************************************
495 * GetTextColor (GDI.90)
497 COLORREF WINAPI GetTextColor16( HDC16 hdc )
499 return GetTextColor( hdc );
502 /***********************************************************************
503 * GetViewportExt (GDI.94)
505 DWORD WINAPI GetViewportExt16( HDC16 hdc )
507 SIZE size;
508 if (!GetViewportExtEx( hdc, &size )) return 0;
509 return MAKELONG( size.cx, size.cy );
512 /***********************************************************************
513 * GetViewportOrg (GDI.95)
515 DWORD WINAPI GetViewportOrg16( HDC16 hdc )
517 POINT pt;
518 if (!GetViewportOrgEx( hdc, &pt )) return 0;
519 return MAKELONG( pt.x, pt.y );
523 /***********************************************************************
524 * GetWindowExt (GDI.96)
526 DWORD WINAPI GetWindowExt16( HDC16 hdc )
528 SIZE size;
529 if (!GetWindowExtEx( hdc, &size )) return 0;
530 return MAKELONG( size.cx, size.cy );
533 /***********************************************************************
534 * GetWindowOrg (GDI.97)
536 DWORD WINAPI GetWindowOrg16( HDC16 hdc )
538 POINT pt;
539 if (!GetWindowOrgEx( hdc, &pt )) return 0;
540 return MAKELONG( pt.x, pt.y );
543 /***********************************************************************
544 * InquireVisRgn (GDI.131)
546 HRGN16 WINAPI InquireVisRgn16( HDC16 hdc )
548 HRGN16 ret = 0;
549 DC * dc = DC_GetDCPtr( hdc );
550 if (dc)
552 ret = dc->hVisRgn;
553 GDI_ReleaseObj( hdc );
555 return ret;
558 /***********************************************************************
559 * GetBrushOrg (GDI.149)
561 DWORD WINAPI GetBrushOrg16( HDC16 hdc )
563 POINT pt;
564 if (!GetBrushOrgEx( hdc, &pt )) return 0;
565 return MAKELONG( pt.x, pt.y );
568 /***********************************************************************
569 * GetClipRgn (GDI.173)
571 HRGN16 WINAPI GetClipRgn16( HDC16 hdc )
573 HRGN16 ret = 0;
574 DC * dc = DC_GetDCPtr( hdc );
575 if (dc)
577 ret = dc->hClipRgn;
578 GDI_ReleaseObj( hdc );
580 return ret;
583 /***********************************************************************
584 * GetTextAlign (GDI.345)
586 UINT16 WINAPI GetTextAlign16( HDC16 hdc )
588 return GetTextAlign( hdc );
591 /***********************************************************************
592 * GetCurLogFont (GDI.411)
594 HFONT16 WINAPI GetCurLogFont16( HDC16 hdc )
596 HFONT16 ret = 0;
597 DC * dc = DC_GetDCPtr( hdc );
598 if (dc)
600 ret = dc->hFont;
601 GDI_ReleaseObj( hdc );
603 return ret;
606 /***********************************************************************
607 * GetBrushOrgEx (GDI.469)
609 BOOL16 WINAPI GetBrushOrgEx16( HDC16 hdc, LPPOINT16 pt )
611 POINT pt32;
612 if (!GetBrushOrgEx( hdc, &pt32 )) return FALSE;
613 pt->x = pt32.x;
614 pt->y = pt32.y;
615 return TRUE;
618 /***********************************************************************
619 * GetCurrentPositionEx (GDI.470)
621 BOOL16 WINAPI GetCurrentPositionEx16( HDC16 hdc, LPPOINT16 pt )
623 POINT pt32;
624 if (!GetCurrentPositionEx( hdc, &pt32 )) return FALSE;
625 pt->x = pt32.x;
626 pt->y = pt32.y;
627 return TRUE;
630 /***********************************************************************
631 * GetViewportExtEx (GDI.472)
633 BOOL16 WINAPI GetViewportExtEx16( HDC16 hdc, LPSIZE16 size )
635 SIZE size32;
636 if (!GetViewportExtEx( hdc, &size32 )) return FALSE;
637 size->cx = size32.cx;
638 size->cy = size32.cy;
639 return TRUE;
642 /***********************************************************************
643 * GetViewportOrgEx (GDI.473)
645 BOOL16 WINAPI GetViewportOrgEx16( HDC16 hdc, LPPOINT16 pt )
647 POINT pt32;
648 if (!GetViewportOrgEx( hdc, &pt32 )) return FALSE;
649 pt->x = pt32.x;
650 pt->y = pt32.y;
651 return TRUE;
654 /***********************************************************************
655 * GetWindowExtEx (GDI.474)
657 BOOL16 WINAPI GetWindowExtEx16( HDC16 hdc, LPSIZE16 size )
659 SIZE size32;
660 if (!GetWindowExtEx( hdc, &size32 )) return FALSE;
661 size->cx = size32.cx;
662 size->cy = size32.cy;
663 return TRUE;
666 /***********************************************************************
667 * GetWindowOrgEx (GDI.475)
669 BOOL16 WINAPI GetWindowOrgEx16( HDC16 hdc, LPPOINT16 pt )
671 POINT pt32;
672 if (!GetWindowOrgEx( hdc, &pt32 )) return FALSE;
673 pt->x = pt32.x;
674 pt->y = pt32.y;
675 return TRUE;
678 /***********************************************************************
679 * GetArcDirection (GDI.524)
681 INT16 WINAPI GetArcDirection16( HDC16 hdc )
683 return GetArcDirection( hdc );