blob: 0b2315098ec378c14b198df5fac34d6ea2661887 [file] [log] [blame]
Alexandre Julliard401710d1993-09-04 10:09:32 +00001/*
2 * DC device-independent Get/SetXXX functions
3 *
4 * Copyright 1993 Alexandre Julliard
Alexandre Julliard234bc241994-12-10 13:02:28 +00005 *
Alexandre Julliardca22b331996-07-12 19:02:39 +00006 */
7
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00008#include "winbase.h"
9#include "winerror.h"
Alexandre Julliard401710d1993-09-04 10:09:32 +000010#include "gdi.h"
Huw D M Davies7603dea1999-04-25 09:24:23 +000011#include "dc.h"
Alexandre Julliard401710d1993-09-04 10:09:32 +000012
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000013#define COLORREF16 COLORREF /*hack*/
14
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000015#define DC_GET_VAL_16( func_type, func_name, dc_field ) \
Alexandre Julliard670cdc41997-08-24 16:00:30 +000016func_type WINAPI func_name( HDC16 hdc ) \
Alexandre Julliard401710d1993-09-04 10:09:32 +000017{ \
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000018 func_type ret = 0; \
Alexandre Julliard401710d1993-09-04 10:09:32 +000019 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000020 if (dc) \
21 { \
22 ret = dc->dc_field; \
23 GDI_ReleaseObj( hdc ); \
24 } \
25 return ret; \
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000026}
27
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000028#define DC_GET_VAL( func_type, func_name, dc_field ) \
29func_type##16 WINAPI func_name##16( HDC16 hdc ) \
30{ \
31 return func_name( hdc ); \
32} \
33 \
Alexandre Julliarda3960291999-02-26 11:11:13 +000034func_type WINAPI func_name( HDC hdc ) \
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000035{ \
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000036 func_type ret = 0; \
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000037 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000038 if (dc) \
39 { \
40 ret = dc->dc_field; \
41 GDI_ReleaseObj( hdc ); \
42 } \
43 return ret; \
Alexandre Julliard401710d1993-09-04 10:09:32 +000044}
45
46#define DC_GET_X_Y( func_type, func_name, ret_x, ret_y ) \
Alexandre Julliard670cdc41997-08-24 16:00:30 +000047func_type WINAPI func_name( HDC16 hdc ) \
Alexandre Julliard401710d1993-09-04 10:09:32 +000048{ \
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000049 func_type ret = 0; \
Alexandre Julliard401710d1993-09-04 10:09:32 +000050 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000051 if (dc) \
52 { \
53 ret = MAKELONG( dc->ret_x, dc->ret_y ); \
54 GDI_ReleaseObj( hdc ); \
55 } \
56 return ret; \
Alexandre Julliard401710d1993-09-04 10:09:32 +000057}
58
François Gouget241c7301998-10-28 10:47:09 +000059/* 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.
62 */
63#define DC_GET_VAL_EX( func_name, ret_x, ret_y, type ) \
64BOOL16 WINAPI func_name##16( HDC16 hdc, LP##type##16 pt ) \
Alexandre Julliard401710d1993-09-04 10:09:32 +000065{ \
66 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
67 if (!dc) return FALSE; \
François Gouget241c7301998-10-28 10:47:09 +000068 ((LPPOINT16)pt)->x = dc->ret_x; \
69 ((LPPOINT16)pt)->y = dc->ret_y; \
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000070 GDI_ReleaseObj( hdc ); \
Alexandre Julliard401710d1993-09-04 10:09:32 +000071 return TRUE; \
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000072} \
73 \
Alexandre Julliarda3960291999-02-26 11:11:13 +000074BOOL WINAPI func_name( HDC hdc, LP##type pt ) \
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000075{ \
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000076 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000077 if (!dc) return FALSE; \
Alexandre Julliarda3960291999-02-26 11:11:13 +000078 ((LPPOINT)pt)->x = dc->ret_x; \
79 ((LPPOINT)pt)->y = dc->ret_y; \
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000080 GDI_ReleaseObj( hdc ); \
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000081 return TRUE; \
Alexandre Julliard401710d1993-09-04 10:09:32 +000082}
83
Huw D M Davies7603dea1999-04-25 09:24:23 +000084#define DC_SET_MODE( func_name, dc_field, min_val, max_val ) \
85INT16 WINAPI func_name##16( HDC16 hdc, INT16 mode ) \
Alexandre Julliard401710d1993-09-04 10:09:32 +000086{ \
Huw D M Davies7603dea1999-04-25 09:24:23 +000087 return func_name( hdc, mode ); \
88} \
89 \
Alexandre Julliarda3960291999-02-26 11:11:13 +000090INT WINAPI func_name( HDC hdc, INT mode ) \
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000091{ \
Alexandre Julliarda3960291999-02-26 11:11:13 +000092 INT prevMode; \
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000093 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; \
Huw D M Davies7603dea1999-04-25 09:24:23 +000099 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; \
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000104 } \
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000105 GDI_ReleaseObj( hdc ); \
Alexandre Julliard401710d1993-09-04 10:09:32 +0000106 return prevMode; \
107}
108
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000109/***********************************************************************
110 * SetBkMode (GDI.2) (GDI32.306)
111 *
112 */
Huw D M Davies7603dea1999-04-25 09:24:23 +0000113DC_SET_MODE( SetBkMode, w.backgroundMode, TRANSPARENT, OPAQUE )
114
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000115/***********************************************************************
116 * SetROP2 (GDI.4) (GDI32.331)
117 */
Huw D M Davies7603dea1999-04-25 09:24:23 +0000118DC_SET_MODE( SetROP2, w.ROPmode, R2_BLACK, R2_WHITE )
119
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000120/***********************************************************************
121 * SetRelAbs (GDI.5) (GDI32.333)
122 */
Huw D M Davies7603dea1999-04-25 09:24:23 +0000123DC_SET_MODE( SetRelAbs, w.relAbsMode, ABSOLUTE, RELATIVE )
124
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000125/***********************************************************************
126 * SetPolyFillMode (GDI.6) (GDI32.330)
127 */
Huw D M Davies7603dea1999-04-25 09:24:23 +0000128DC_SET_MODE( SetPolyFillMode, w.polyFillMode, ALTERNATE, WINDING )
129
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000130/***********************************************************************
131 * SetStretchBltMode (GDI.7) (GDI32.334)
132 */
Huw D M Davies7603dea1999-04-25 09:24:23 +0000133DC_SET_MODE( SetStretchBltMode, w.stretchBltMode, BLACKONWHITE, HALFTONE )
134
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000135/***********************************************************************
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000136 * GetBkColor (GDI.75) (GDI32.145)
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000137 */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000138DC_GET_VAL( COLORREF, GetBkColor, w.backgroundColor )
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000139
140/***********************************************************************
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000141 * GetBkMode (GDI.76) (GDI32.146)
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000142 */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000143DC_GET_VAL( INT, GetBkMode, w.backgroundMode )
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000144
145/***********************************************************************
146 * GetCurrentPosition16 (GDI.78)
147 */
148DC_GET_X_Y( DWORD, GetCurrentPosition16, w.CursPosX, w.CursPosY )
149
150/***********************************************************************
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000151 * GetMapMode (GDI.81) (GDI32.196)
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000152 */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000153DC_GET_VAL( INT, GetMapMode, w.MapMode )
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000154
155/***********************************************************************
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000156 * GetPolyFillMode (GDI.84) (GDI32.213)
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000157 */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000158DC_GET_VAL( INT, GetPolyFillMode, w.polyFillMode )
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000159
160/***********************************************************************
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000161 * GetROP2 (GDI.85) (GDI32.214)
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000162 */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000163DC_GET_VAL( INT, GetROP2, w.ROPmode )
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000164
165/***********************************************************************
166 * GetRelAbs16 (GDI.86)
167 */
168DC_GET_VAL_16( INT16, GetRelAbs16, w.relAbsMode )
169
170/***********************************************************************
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000171 * GetStretchBltMode (GDI.88) (GDI32.221)
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000172 */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000173DC_GET_VAL( INT, GetStretchBltMode, w.stretchBltMode )
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000174
175/***********************************************************************
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000176 * GetTextColor (GDI.90) (GDI32.227)
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000177 */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000178DC_GET_VAL( COLORREF, GetTextColor, w.textColor )
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000179
180/***********************************************************************
181 * GetViewportExt16 (GDI.94)
182 */
183DC_GET_X_Y( DWORD, GetViewportExt16, vportExtX, vportExtY )
184
185/***********************************************************************
186 * GetViewportOrg16 (GDI.95)
187 */
188DC_GET_X_Y( DWORD, GetViewportOrg16, vportOrgX, vportOrgY )
189
190/***********************************************************************
191 * GetWindowExt16 (GDI.96)
192 */
193DC_GET_X_Y( DWORD, GetWindowExt16, wndExtX, wndExtY )
194
195/***********************************************************************
196 * GetWindowOrg16 (GDI.97)
197 */
198DC_GET_X_Y( DWORD, GetWindowOrg16, wndOrgX, wndOrgY )
199
200/***********************************************************************
201 * InquireVisRgn16 (GDI.131)
202 */
203DC_GET_VAL_16( HRGN16, InquireVisRgn16, w.hVisRgn )
204
205/***********************************************************************
206 * GetClipRgn16 (GDI.173)
207 */
208DC_GET_VAL_16( HRGN16, GetClipRgn16, w.hClipRgn )
209
210/***********************************************************************
211 * GetBrushOrg16 (GDI.149)
212 */
213DC_GET_X_Y( DWORD, GetBrushOrg16, w.brushOrgX, w.brushOrgY )
214
215/***********************************************************************
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000216 * GetTextAlign (GDI.345) (GDI32,224)
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000217 */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000218DC_GET_VAL( UINT, GetTextAlign, w.textAlign )
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000219
220/***********************************************************************
221 * GetCurLogFont16 (GDI.411)
222 */
223DC_GET_VAL_16( HFONT16, GetCurLogFont16, w.hFont )
224
225/***********************************************************************
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000226 * GetArcDirection (GDI.524) (GDI32.141)
227 */
228DC_GET_VAL( INT, GetArcDirection, w.ArcDirection )
229
230/***********************************************************************
231 * GetGraphicsMode (GDI32.188)
232 */
233DC_GET_VAL( INT, GetGraphicsMode, w.GraphicsMode)
234
235/***********************************************************************
Patrik Stridvall3a9c4761999-10-31 02:07:05 +0000236 * GetBrushOrgEx (GDI.469) (GDI32.148)
237 */
238DC_GET_VAL_EX( GetBrushOrgEx, w.brushOrgX, w.brushOrgY, POINT ) /* */
239
240/***********************************************************************
241 * GetCurrentPositionEx (GDI.470) (GDI32.167)
242 */
243DC_GET_VAL_EX( GetCurrentPositionEx, w.CursPosX, w.CursPosY, POINT )
244
245/***********************************************************************
246 * GetViewportExtEx (GDI.472 GDI32.239)
247 */
248DC_GET_VAL_EX( GetViewportExtEx, vportExtX, vportExtY, SIZE )
249
250/***********************************************************************
251 * GetViewportOrgEx (GDI.473) (GDI32.240)
252 */
253DC_GET_VAL_EX( GetViewportOrgEx, vportOrgX, vportOrgY, POINT )
254
255/***********************************************************************
256 * GetWindowExtEx (GDI.474) (GDI32.242)
257 */
258DC_GET_VAL_EX( GetWindowExtEx, wndExtX, wndExtY, SIZE )
259
260/***********************************************************************
261 * GetWindowOrgEx (GDI.475) (GDI32.243)
262 */
263DC_GET_VAL_EX( GetWindowOrgEx, wndOrgX, wndOrgY, POINT )