Fixed bdftopcf command.
[wine/hacks.git] / objects / dcvalues.c
blob0b2315098ec378c14b198df5fac34d6ea2661887
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"
11 #include "dc.h"
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 ) \
17 { \
18 func_type ret = 0; \
19 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
20 if (dc) \
21 { \
22 ret = dc->dc_field; \
23 GDI_ReleaseObj( hdc ); \
24 } \
25 return ret; \
28 #define DC_GET_VAL( func_type, func_name, dc_field ) \
29 func_type##16 WINAPI func_name##16( HDC16 hdc ) \
30 { \
31 return func_name( hdc ); \
32 } \
34 func_type WINAPI func_name( HDC hdc ) \
35 { \
36 func_type ret = 0; \
37 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
38 if (dc) \
39 { \
40 ret = dc->dc_field; \
41 GDI_ReleaseObj( hdc ); \
42 } \
43 return ret; \
46 #define DC_GET_X_Y( func_type, func_name, ret_x, ret_y ) \
47 func_type WINAPI func_name( HDC16 hdc ) \
48 { \
49 func_type ret = 0; \
50 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
51 if (dc) \
52 { \
53 ret = MAKELONG( dc->ret_x, dc->ret_y ); \
54 GDI_ReleaseObj( hdc ); \
55 } \
56 return ret; \
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 ) \
65 { \
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 ); \
71 return TRUE; \
72 } \
74 BOOL WINAPI func_name( HDC hdc, LP##type pt ) \
75 { \
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 ); \
81 return TRUE; \
84 #define DC_SET_MODE( func_name, dc_field, min_val, max_val ) \
85 INT16 WINAPI func_name##16( HDC16 hdc, INT16 mode ) \
86 { \
87 return func_name( hdc, mode ); \
88 } \
90 INT WINAPI func_name( HDC hdc, INT mode ) \
91 { \
92 INT prevMode; \
93 DC *dc; \
94 if ((mode < min_val) || (mode > max_val)) { \
95 SetLastError(ERROR_INVALID_PARAMETER); \
96 return 0; \
97 } \
98 if (!(dc = DC_GetDCPtr( hdc ))) return 0; \
99 if (dc->funcs->p##func_name) { \
100 prevMode = dc->funcs->p##func_name( dc, mode ); \
101 } else { \
102 prevMode = dc->dc_field; \
103 dc->dc_field = mode; \
105 GDI_ReleaseObj( hdc ); \
106 return prevMode; \
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 )