2 * DC device-independent Get/SetXXX functions
4 * Copyright 1993 Alexandre Julliard
13 #define COLORREF16 COLORREF /*hack*/
15 #define DC_GET_VAL_16( func_type, func_name, dc_field ) \
16 func_type WINAPI func_name( HDC16 hdc ) \
19 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
23 GDI_ReleaseObj( hdc ); \
28 #define DC_GET_VAL( func_type, func_name, dc_field ) \
29 func_type##16 WINAPI func_name##16( HDC16 hdc ) \
31 return func_name( hdc ); \
34 func_type WINAPI func_name( HDC hdc ) \
37 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
41 GDI_ReleaseObj( hdc ); \
46 #define DC_GET_X_Y( func_type, func_name, ret_x, ret_y ) \
47 func_type WINAPI func_name( HDC16 hdc ) \
50 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
53 ret = MAKELONG( dc->ret_x, dc->ret_y ); \
54 GDI_ReleaseObj( hdc ); \
59 /* DC_GET_VAL_EX is used to define functions returning a POINT or a SIZE. It is
60 * important that the function has the right signature, for the implementation
61 * we can do whatever we want.
63 #define DC_GET_VAL_EX( func_name, ret_x, ret_y, type ) \
64 BOOL16 WINAPI func_name##16( HDC16 hdc, LP##type##16 pt ) \
66 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
67 if (!dc) return FALSE; \
68 ((LPPOINT16)pt)->x = dc->ret_x; \
69 ((LPPOINT16)pt)->y = dc->ret_y; \
70 GDI_ReleaseObj( hdc ); \
74 BOOL WINAPI func_name( HDC hdc, LP##type pt ) \
76 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
77 if (!dc) return FALSE; \
78 ((LPPOINT)pt)->x = dc->ret_x; \
79 ((LPPOINT)pt)->y = dc->ret_y; \
80 GDI_ReleaseObj( hdc ); \
84 #define DC_SET_MODE( func_name, dc_field, min_val, max_val ) \
85 INT16 WINAPI func_name##16( HDC16 hdc, INT16 mode ) \
87 return func_name( hdc, mode ); \
90 INT WINAPI func_name( HDC hdc, INT mode ) \
94 if ((mode < min_val) || (mode > max_val)) { \
95 SetLastError(ERROR_INVALID_PARAMETER); \
98 if (!(dc = DC_GetDCPtr( hdc ))) return 0; \
99 if (dc->funcs->p##func_name) { \
100 prevMode = dc->funcs->p##func_name( dc, mode ); \
102 prevMode = dc->dc_field; \
103 dc->dc_field = mode; \
105 GDI_ReleaseObj( hdc ); \
109 /***********************************************************************
110 * SetBkMode (GDI.2) (GDI32.306)
113 DC_SET_MODE( SetBkMode
, w
.backgroundMode
, TRANSPARENT
, OPAQUE
)
115 /***********************************************************************
116 * SetROP2 (GDI.4) (GDI32.331)
118 DC_SET_MODE( SetROP2
, w
.ROPmode
, R2_BLACK
, R2_WHITE
)
120 /***********************************************************************
121 * SetRelAbs (GDI.5) (GDI32.333)
123 DC_SET_MODE( SetRelAbs
, w
.relAbsMode
, ABSOLUTE
, RELATIVE
)
125 /***********************************************************************
126 * SetPolyFillMode (GDI.6) (GDI32.330)
128 DC_SET_MODE( SetPolyFillMode
, w
.polyFillMode
, ALTERNATE
, WINDING
)
130 /***********************************************************************
131 * SetStretchBltMode (GDI.7) (GDI32.334)
133 DC_SET_MODE( SetStretchBltMode
, w
.stretchBltMode
, BLACKONWHITE
, HALFTONE
)
135 /***********************************************************************
136 * GetBkColor (GDI.75) (GDI32.145)
138 DC_GET_VAL( COLORREF
, GetBkColor
, w
.backgroundColor
)
140 /***********************************************************************
141 * GetBkMode (GDI.76) (GDI32.146)
143 DC_GET_VAL( INT
, GetBkMode
, w
.backgroundMode
)
145 /***********************************************************************
146 * GetCurrentPosition16 (GDI.78)
148 DC_GET_X_Y( DWORD
, GetCurrentPosition16
, w
.CursPosX
, w
.CursPosY
)
150 /***********************************************************************
151 * GetMapMode (GDI.81) (GDI32.196)
153 DC_GET_VAL( INT
, GetMapMode
, w
.MapMode
)
155 /***********************************************************************
156 * GetPolyFillMode (GDI.84) (GDI32.213)
158 DC_GET_VAL( INT
, GetPolyFillMode
, w
.polyFillMode
)
160 /***********************************************************************
161 * GetROP2 (GDI.85) (GDI32.214)
163 DC_GET_VAL( INT
, GetROP2
, w
.ROPmode
)
165 /***********************************************************************
166 * GetRelAbs16 (GDI.86)
168 DC_GET_VAL_16( INT16
, GetRelAbs16
, w
.relAbsMode
)
170 /***********************************************************************
171 * GetStretchBltMode (GDI.88) (GDI32.221)
173 DC_GET_VAL( INT
, GetStretchBltMode
, w
.stretchBltMode
)
175 /***********************************************************************
176 * GetTextColor (GDI.90) (GDI32.227)
178 DC_GET_VAL( COLORREF
, GetTextColor
, w
.textColor
)
180 /***********************************************************************
181 * GetViewportExt16 (GDI.94)
183 DC_GET_X_Y( DWORD
, GetViewportExt16
, vportExtX
, vportExtY
)
185 /***********************************************************************
186 * GetViewportOrg16 (GDI.95)
188 DC_GET_X_Y( DWORD
, GetViewportOrg16
, vportOrgX
, vportOrgY
)
190 /***********************************************************************
191 * GetWindowExt16 (GDI.96)
193 DC_GET_X_Y( DWORD
, GetWindowExt16
, wndExtX
, wndExtY
)
195 /***********************************************************************
196 * GetWindowOrg16 (GDI.97)
198 DC_GET_X_Y( DWORD
, GetWindowOrg16
, wndOrgX
, wndOrgY
)
200 /***********************************************************************
201 * InquireVisRgn16 (GDI.131)
203 DC_GET_VAL_16( HRGN16
, InquireVisRgn16
, w
.hVisRgn
)
205 /***********************************************************************
206 * GetClipRgn16 (GDI.173)
208 DC_GET_VAL_16( HRGN16
, GetClipRgn16
, w
.hClipRgn
)
210 /***********************************************************************
211 * GetBrushOrg16 (GDI.149)
213 DC_GET_X_Y( DWORD
, GetBrushOrg16
, w
.brushOrgX
, w
.brushOrgY
)
215 /***********************************************************************
216 * GetTextAlign (GDI.345) (GDI32,224)
218 DC_GET_VAL( UINT
, GetTextAlign
, w
.textAlign
)
220 /***********************************************************************
221 * GetCurLogFont16 (GDI.411)
223 DC_GET_VAL_16( HFONT16
, GetCurLogFont16
, w
.hFont
)
225 /***********************************************************************
226 * GetArcDirection (GDI.524) (GDI32.141)
228 DC_GET_VAL( INT
, GetArcDirection
, w
.ArcDirection
)
230 /***********************************************************************
231 * GetGraphicsMode (GDI32.188)
233 DC_GET_VAL( INT
, GetGraphicsMode
, w
.GraphicsMode
)
235 /***********************************************************************
236 * GetBrushOrgEx (GDI.469) (GDI32.148)
238 DC_GET_VAL_EX( GetBrushOrgEx
, w
.brushOrgX
, w
.brushOrgY
, POINT
) /* */
240 /***********************************************************************
241 * GetCurrentPositionEx (GDI.470) (GDI32.167)
243 DC_GET_VAL_EX( GetCurrentPositionEx
, w
.CursPosX
, w
.CursPosY
, POINT
)
245 /***********************************************************************
246 * GetViewportExtEx (GDI.472 GDI32.239)
248 DC_GET_VAL_EX( GetViewportExtEx
, vportExtX
, vportExtY
, SIZE
)
250 /***********************************************************************
251 * GetViewportOrgEx (GDI.473) (GDI32.240)
253 DC_GET_VAL_EX( GetViewportOrgEx
, vportOrgX
, vportOrgY
, POINT
)
255 /***********************************************************************
256 * GetWindowExtEx (GDI.474) (GDI32.242)
258 DC_GET_VAL_EX( GetWindowExtEx
, wndExtX
, wndExtY
, SIZE
)
260 /***********************************************************************
261 * GetWindowOrgEx (GDI.475) (GDI32.243)
263 DC_GET_VAL_EX( GetWindowOrgEx
, wndOrgX
, wndOrgY
, POINT
)