Added TASK_GetPtr/TASK_GetCurrent functions to get the TDB for a task
[wine/multimedia.git] / objects / dcvalues.c
blob76aba4a97209af47854c2528b949f098d5a7bce5
1 /*
2 * DC device-independent Get/SetXXX functions
4 * Copyright 1993 Alexandre Julliard
6 */
8 #include "winbase.h"
9 #include "winerror.h"
10 #include "gdi.h"
12 #define COLORREF16 COLORREF /*hack*/
14 #define DC_GET_VAL_16( func_type, func_name, dc_field ) \
15 func_type WINAPI func_name( HDC16 hdc ) \
16 { \
17 func_type ret = 0; \
18 DC * dc = DC_GetDCPtr( hdc ); \
19 if (dc) \
20 { \
21 ret = dc->dc_field; \
22 GDI_ReleaseObj( hdc ); \
23 } \
24 return ret; \
27 #define DC_GET_VAL( func_type, func_name, dc_field ) \
28 func_type##16 WINAPI func_name##16( HDC16 hdc ) \
29 { \
30 return func_name( hdc ); \
31 } \
33 func_type WINAPI func_name( HDC hdc ) \
34 { \
35 func_type ret = 0; \
36 DC * dc = DC_GetDCPtr( hdc ); \
37 if (dc) \
38 { \
39 ret = dc->dc_field; \
40 GDI_ReleaseObj( hdc ); \
41 } \
42 return ret; \
45 #define DC_GET_X_Y( func_type, func_name, ret_x, ret_y ) \
46 func_type WINAPI func_name( HDC16 hdc ) \
47 { \
48 func_type ret = 0; \
49 DC * dc = DC_GetDCPtr( hdc ); \
50 if (dc) \
51 { \
52 ret = MAKELONG( dc->ret_x, dc->ret_y ); \
53 GDI_ReleaseObj( hdc ); \
54 } \
55 return ret; \
58 /* DC_GET_VAL_EX is used to define functions returning a POINT or a SIZE. It is
59 * important that the function has the right signature, for the implementation
60 * we can do whatever we want.
62 #define DC_GET_VAL_EX( func_name, ret_x, ret_y, type ) \
63 BOOL16 WINAPI func_name##16( HDC16 hdc, LP##type##16 pt ) \
64 { \
65 DC * dc = DC_GetDCPtr( hdc ); \
66 if (!dc) return FALSE; \
67 ((LPPOINT16)pt)->x = dc->ret_x; \
68 ((LPPOINT16)pt)->y = dc->ret_y; \
69 GDI_ReleaseObj( hdc ); \
70 return TRUE; \
71 } \
73 BOOL WINAPI func_name( HDC hdc, LP##type pt ) \
74 { \
75 DC * dc = DC_GetDCPtr( hdc ); \
76 if (!dc) return FALSE; \
77 ((LPPOINT)pt)->x = dc->ret_x; \
78 ((LPPOINT)pt)->y = dc->ret_y; \
79 GDI_ReleaseObj( hdc ); \
80 return TRUE; \
83 #define DC_SET_MODE( func_name, dc_field, min_val, max_val ) \
84 INT16 WINAPI func_name##16( HDC16 hdc, INT16 mode ) \
85 { \
86 return func_name( hdc, mode ); \
87 } \
89 INT WINAPI func_name( HDC hdc, INT mode ) \
90 { \
91 INT prevMode; \
92 DC *dc; \
93 if ((mode < min_val) || (mode > max_val)) { \
94 SetLastError(ERROR_INVALID_PARAMETER); \
95 return 0; \
96 } \
97 if (!(dc = DC_GetDCPtr( hdc ))) return 0; \
98 if (dc->funcs->p##func_name) { \
99 prevMode = dc->funcs->p##func_name( dc, mode ); \
100 } else { \
101 prevMode = dc->dc_field; \
102 dc->dc_field = mode; \
104 GDI_ReleaseObj( hdc ); \
105 return prevMode; \
108 /***********************************************************************
109 * SetBkMode (GDI.2) (GDI32.@)
112 DC_SET_MODE( SetBkMode, backgroundMode, TRANSPARENT, OPAQUE )
114 /***********************************************************************
115 * SetROP2 (GDI.4) (GDI32.@)
117 DC_SET_MODE( SetROP2, ROPmode, R2_BLACK, R2_WHITE )
119 /***********************************************************************
120 * SetRelAbs (GDI.5) (GDI32.@)
122 DC_SET_MODE( SetRelAbs, relAbsMode, ABSOLUTE, RELATIVE )
124 /***********************************************************************
125 * SetPolyFillMode (GDI.6) (GDI32.@)
127 DC_SET_MODE( SetPolyFillMode, polyFillMode, ALTERNATE, WINDING )
129 /***********************************************************************
130 * SetStretchBltMode (GDI.7) (GDI32.@)
132 DC_SET_MODE( SetStretchBltMode, stretchBltMode, BLACKONWHITE, HALFTONE )
134 /***********************************************************************
135 * GetBkColor (GDI.75) (GDI32.@)
137 DC_GET_VAL( COLORREF, GetBkColor, backgroundColor )
139 /***********************************************************************
140 * GetBkMode (GDI.76) (GDI32.@)
142 DC_GET_VAL( INT, GetBkMode, backgroundMode )
144 /***********************************************************************
145 * GetCurrentPosition16 (GDI.78)
147 DC_GET_X_Y( DWORD, GetCurrentPosition16, CursPosX, CursPosY )
149 /***********************************************************************
150 * GetMapMode (GDI.81) (GDI32.@)
152 DC_GET_VAL( INT, GetMapMode, MapMode )
154 /***********************************************************************
155 * GetPolyFillMode (GDI.84) (GDI32.@)
157 DC_GET_VAL( INT, GetPolyFillMode, polyFillMode )
159 /***********************************************************************
160 * GetROP2 (GDI.85) (GDI32.@)
162 DC_GET_VAL( INT, GetROP2, ROPmode )
164 /***********************************************************************
165 * GetRelAbs16 (GDI.86)
167 DC_GET_VAL_16( INT16, GetRelAbs16, relAbsMode )
169 /***********************************************************************
170 * GetStretchBltMode (GDI.88) (GDI32.@)
172 DC_GET_VAL( INT, GetStretchBltMode, stretchBltMode )
174 /***********************************************************************
175 * GetTextColor (GDI.90) (GDI32.@)
177 DC_GET_VAL( COLORREF, GetTextColor, textColor )
179 /***********************************************************************
180 * GetViewportExt16 (GDI.94)
182 DC_GET_X_Y( DWORD, GetViewportExt16, vportExtX, vportExtY )
184 /***********************************************************************
185 * GetViewportOrg16 (GDI.95)
187 DC_GET_X_Y( DWORD, GetViewportOrg16, vportOrgX, vportOrgY )
189 /***********************************************************************
190 * GetWindowExt16 (GDI.96)
192 DC_GET_X_Y( DWORD, GetWindowExt16, wndExtX, wndExtY )
194 /***********************************************************************
195 * GetWindowOrg16 (GDI.97)
197 DC_GET_X_Y( DWORD, GetWindowOrg16, wndOrgX, wndOrgY )
199 /***********************************************************************
200 * InquireVisRgn16 (GDI.131)
202 DC_GET_VAL_16( HRGN16, InquireVisRgn16, hVisRgn )
204 /***********************************************************************
205 * GetClipRgn16 (GDI.173)
207 DC_GET_VAL_16( HRGN16, GetClipRgn16, hClipRgn )
209 /***********************************************************************
210 * GetBrushOrg16 (GDI.149)
212 DC_GET_X_Y( DWORD, GetBrushOrg16, brushOrgX, brushOrgY )
214 /***********************************************************************
215 * GetTextAlign (GDI.345) (GDI32.@)
217 DC_GET_VAL( UINT, GetTextAlign, textAlign )
219 /***********************************************************************
220 * GetCurLogFont16 (GDI.411)
222 DC_GET_VAL_16( HFONT16, GetCurLogFont16, hFont )
224 /***********************************************************************
225 * GetArcDirection (GDI.524) (GDI32.@)
227 DC_GET_VAL( INT, GetArcDirection, ArcDirection )
229 /***********************************************************************
230 * GetGraphicsMode (GDI32.@)
232 DC_GET_VAL( INT, GetGraphicsMode, GraphicsMode)
234 /***********************************************************************
235 * GetBrushOrgEx (GDI.469) (GDI32.@)
237 DC_GET_VAL_EX( GetBrushOrgEx, brushOrgX, brushOrgY, POINT ) /* */
239 /***********************************************************************
240 * GetCurrentPositionEx (GDI.470) (GDI32.@)
242 DC_GET_VAL_EX( GetCurrentPositionEx, CursPosX, CursPosY, POINT )
244 /***********************************************************************
245 * GetViewportExtEx (GDI.472 GDI32.@)
247 DC_GET_VAL_EX( GetViewportExtEx, vportExtX, vportExtY, SIZE )
249 /***********************************************************************
250 * GetViewportOrgEx (GDI.473) (GDI32.@)
252 DC_GET_VAL_EX( GetViewportOrgEx, vportOrgX, vportOrgY, POINT )
254 /***********************************************************************
255 * GetWindowExtEx (GDI.474) (GDI32.@)
257 DC_GET_VAL_EX( GetWindowExtEx, wndExtX, wndExtY, SIZE )
259 /***********************************************************************
260 * GetWindowOrgEx (GDI.475) (GDI32.@)
262 DC_GET_VAL_EX( GetWindowOrgEx, wndOrgX, wndOrgY, POINT )