2 * DC device-independent Get/SetXXX functions
4 * Copyright 1993 Alexandre Julliard
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 ) \
18 DC * dc = DC_GetDCPtr( hdc ); \
22 GDI_ReleaseObj( hdc ); \
27 #define DC_GET_VAL( func_type, func_name, dc_field ) \
28 func_type##16 WINAPI func_name##16( HDC16 hdc ) \
30 return func_name( hdc ); \
33 func_type WINAPI func_name( HDC hdc ) \
36 DC * dc = DC_GetDCPtr( hdc ); \
40 GDI_ReleaseObj( hdc ); \
45 #define DC_GET_X_Y( func_type, func_name, ret_x, ret_y ) \
46 func_type WINAPI func_name( HDC16 hdc ) \
49 DC * dc = DC_GetDCPtr( hdc ); \
52 ret = MAKELONG( dc->ret_x, dc->ret_y ); \
53 GDI_ReleaseObj( hdc ); \
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 ) \
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 ); \
73 BOOL WINAPI func_name( HDC hdc, LP##type pt ) \
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 ); \
83 #define DC_SET_MODE( func_name, dc_field, min_val, max_val ) \
84 INT16 WINAPI func_name##16( HDC16 hdc, INT16 mode ) \
86 return func_name( hdc, mode ); \
89 INT WINAPI func_name( HDC hdc, INT mode ) \
93 if ((mode < min_val) || (mode > max_val)) { \
94 SetLastError(ERROR_INVALID_PARAMETER); \
97 if (!(dc = DC_GetDCPtr( hdc ))) return 0; \
98 if (dc->funcs->p##func_name) { \
99 prevMode = dc->funcs->p##func_name( dc, mode ); \
101 prevMode = dc->dc_field; \
102 dc->dc_field = mode; \
104 GDI_ReleaseObj( hdc ); \
108 /***********************************************************************
109 * SetBkMode (GDI.2) (GDI32.306)
112 DC_SET_MODE( SetBkMode
, backgroundMode
, TRANSPARENT
, OPAQUE
)
114 /***********************************************************************
115 * SetROP2 (GDI.4) (GDI32.331)
117 DC_SET_MODE( SetROP2
, ROPmode
, R2_BLACK
, R2_WHITE
)
119 /***********************************************************************
120 * SetRelAbs (GDI.5) (GDI32.333)
122 DC_SET_MODE( SetRelAbs
, relAbsMode
, ABSOLUTE
, RELATIVE
)
124 /***********************************************************************
125 * SetPolyFillMode (GDI.6) (GDI32.330)
127 DC_SET_MODE( SetPolyFillMode
, polyFillMode
, ALTERNATE
, WINDING
)
129 /***********************************************************************
130 * SetStretchBltMode (GDI.7) (GDI32.334)
132 DC_SET_MODE( SetStretchBltMode
, stretchBltMode
, BLACKONWHITE
, HALFTONE
)
134 /***********************************************************************
135 * GetBkColor (GDI.75) (GDI32.145)
137 DC_GET_VAL( COLORREF
, GetBkColor
, backgroundColor
)
139 /***********************************************************************
140 * GetBkMode (GDI.76) (GDI32.146)
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.196)
152 DC_GET_VAL( INT
, GetMapMode
, MapMode
)
154 /***********************************************************************
155 * GetPolyFillMode (GDI.84) (GDI32.213)
157 DC_GET_VAL( INT
, GetPolyFillMode
, polyFillMode
)
159 /***********************************************************************
160 * GetROP2 (GDI.85) (GDI32.214)
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.221)
172 DC_GET_VAL( INT
, GetStretchBltMode
, stretchBltMode
)
174 /***********************************************************************
175 * GetTextColor (GDI.90) (GDI32.227)
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,224)
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.141)
227 DC_GET_VAL( INT
, GetArcDirection
, ArcDirection
)
229 /***********************************************************************
230 * GetGraphicsMode (GDI32.188)
232 DC_GET_VAL( INT
, GetGraphicsMode
, GraphicsMode
)
234 /***********************************************************************
235 * GetBrushOrgEx (GDI.469) (GDI32.148)
237 DC_GET_VAL_EX( GetBrushOrgEx
, brushOrgX
, brushOrgY
, POINT
) /* */
239 /***********************************************************************
240 * GetCurrentPositionEx (GDI.470) (GDI32.167)
242 DC_GET_VAL_EX( GetCurrentPositionEx
, CursPosX
, CursPosY
, POINT
)
244 /***********************************************************************
245 * GetViewportExtEx (GDI.472 GDI32.239)
247 DC_GET_VAL_EX( GetViewportExtEx
, vportExtX
, vportExtY
, SIZE
)
249 /***********************************************************************
250 * GetViewportOrgEx (GDI.473) (GDI32.240)
252 DC_GET_VAL_EX( GetViewportOrgEx
, vportOrgX
, vportOrgY
, POINT
)
254 /***********************************************************************
255 * GetWindowExtEx (GDI.474) (GDI32.242)
257 DC_GET_VAL_EX( GetWindowExtEx
, wndExtX
, wndExtY
, SIZE
)
259 /***********************************************************************
260 * GetWindowOrgEx (GDI.475) (GDI32.243)
262 DC_GET_VAL_EX( GetWindowOrgEx
, wndOrgX
, wndOrgY
, POINT
)