Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * DC device-independent Get/SetXXX functions |
| 3 | * |
| 4 | * Copyright 1993 Alexandre Julliard |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 5 | * |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 8 | #include "winbase.h" |
| 9 | #include "winerror.h" |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 10 | #include "gdi.h" |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 11 | #include "dc.h" |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 12 | |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 13 | #define COLORREF16 COLORREF /*hack*/ |
| 14 | |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 15 | #define DC_GET_VAL_16( func_type, func_name, dc_field ) \ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 16 | func_type WINAPI func_name( HDC16 hdc ) \ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 17 | { \ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 18 | func_type ret = 0; \ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 19 | DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 20 | if (dc) \ |
| 21 | { \ |
| 22 | ret = dc->dc_field; \ |
| 23 | GDI_ReleaseObj( hdc ); \ |
| 24 | } \ |
| 25 | return ret; \ |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 26 | } |
| 27 | |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 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 | } \ |
| 33 | \ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 34 | func_type WINAPI func_name( HDC hdc ) \ |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 35 | { \ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 36 | func_type ret = 0; \ |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 37 | DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 38 | if (dc) \ |
| 39 | { \ |
| 40 | ret = dc->dc_field; \ |
| 41 | GDI_ReleaseObj( hdc ); \ |
| 42 | } \ |
| 43 | return ret; \ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | #define DC_GET_X_Y( func_type, func_name, ret_x, ret_y ) \ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 47 | func_type WINAPI func_name( HDC16 hdc ) \ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 48 | { \ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 49 | func_type ret = 0; \ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 50 | DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 51 | if (dc) \ |
| 52 | { \ |
| 53 | ret = MAKELONG( dc->ret_x, dc->ret_y ); \ |
| 54 | GDI_ReleaseObj( hdc ); \ |
| 55 | } \ |
| 56 | return ret; \ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 57 | } |
| 58 | |
François Gouget | 241c730 | 1998-10-28 10:47:09 +0000 | [diff] [blame] | 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. |
| 62 | */ |
| 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 ) \ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 65 | { \ |
| 66 | DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \ |
| 67 | if (!dc) return FALSE; \ |
François Gouget | 241c730 | 1998-10-28 10:47:09 +0000 | [diff] [blame] | 68 | ((LPPOINT16)pt)->x = dc->ret_x; \ |
| 69 | ((LPPOINT16)pt)->y = dc->ret_y; \ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 70 | GDI_ReleaseObj( hdc ); \ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 71 | return TRUE; \ |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 72 | } \ |
| 73 | \ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 74 | BOOL WINAPI func_name( HDC hdc, LP##type pt ) \ |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 75 | { \ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 76 | DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \ |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 77 | if (!dc) return FALSE; \ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 78 | ((LPPOINT)pt)->x = dc->ret_x; \ |
| 79 | ((LPPOINT)pt)->y = dc->ret_y; \ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 80 | GDI_ReleaseObj( hdc ); \ |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 81 | return TRUE; \ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 84 | #define DC_SET_MODE( func_name, dc_field, min_val, max_val ) \ |
| 85 | INT16 WINAPI func_name##16( HDC16 hdc, INT16 mode ) \ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 86 | { \ |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 87 | return func_name( hdc, mode ); \ |
| 88 | } \ |
| 89 | \ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 90 | INT WINAPI func_name( HDC hdc, INT mode ) \ |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 91 | { \ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 92 | INT prevMode; \ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 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; \ |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 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; \ |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 104 | } \ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 105 | GDI_ReleaseObj( hdc ); \ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 106 | return prevMode; \ |
| 107 | } |
| 108 | |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 109 | /*********************************************************************** |
| 110 | * SetBkMode (GDI.2) (GDI32.306) |
| 111 | * |
| 112 | */ |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 113 | DC_SET_MODE( SetBkMode, w.backgroundMode, TRANSPARENT, OPAQUE ) |
| 114 | |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 115 | /*********************************************************************** |
| 116 | * SetROP2 (GDI.4) (GDI32.331) |
| 117 | */ |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 118 | DC_SET_MODE( SetROP2, w.ROPmode, R2_BLACK, R2_WHITE ) |
| 119 | |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 120 | /*********************************************************************** |
| 121 | * SetRelAbs (GDI.5) (GDI32.333) |
| 122 | */ |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 123 | DC_SET_MODE( SetRelAbs, w.relAbsMode, ABSOLUTE, RELATIVE ) |
| 124 | |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 125 | /*********************************************************************** |
| 126 | * SetPolyFillMode (GDI.6) (GDI32.330) |
| 127 | */ |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 128 | DC_SET_MODE( SetPolyFillMode, w.polyFillMode, ALTERNATE, WINDING ) |
| 129 | |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 130 | /*********************************************************************** |
| 131 | * SetStretchBltMode (GDI.7) (GDI32.334) |
| 132 | */ |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 133 | DC_SET_MODE( SetStretchBltMode, w.stretchBltMode, BLACKONWHITE, HALFTONE ) |
| 134 | |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 135 | /*********************************************************************** |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 136 | * GetBkColor (GDI.75) (GDI32.145) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 137 | */ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 138 | DC_GET_VAL( COLORREF, GetBkColor, w.backgroundColor ) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 139 | |
| 140 | /*********************************************************************** |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 141 | * GetBkMode (GDI.76) (GDI32.146) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 142 | */ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 143 | DC_GET_VAL( INT, GetBkMode, w.backgroundMode ) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 144 | |
| 145 | /*********************************************************************** |
| 146 | * GetCurrentPosition16 (GDI.78) |
| 147 | */ |
| 148 | DC_GET_X_Y( DWORD, GetCurrentPosition16, w.CursPosX, w.CursPosY ) |
| 149 | |
| 150 | /*********************************************************************** |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 151 | * GetMapMode (GDI.81) (GDI32.196) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 152 | */ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 153 | DC_GET_VAL( INT, GetMapMode, w.MapMode ) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 154 | |
| 155 | /*********************************************************************** |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 156 | * GetPolyFillMode (GDI.84) (GDI32.213) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 157 | */ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 158 | DC_GET_VAL( INT, GetPolyFillMode, w.polyFillMode ) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 159 | |
| 160 | /*********************************************************************** |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 161 | * GetROP2 (GDI.85) (GDI32.214) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 162 | */ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 163 | DC_GET_VAL( INT, GetROP2, w.ROPmode ) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 164 | |
| 165 | /*********************************************************************** |
| 166 | * GetRelAbs16 (GDI.86) |
| 167 | */ |
| 168 | DC_GET_VAL_16( INT16, GetRelAbs16, w.relAbsMode ) |
| 169 | |
| 170 | /*********************************************************************** |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 171 | * GetStretchBltMode (GDI.88) (GDI32.221) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 172 | */ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 173 | DC_GET_VAL( INT, GetStretchBltMode, w.stretchBltMode ) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 174 | |
| 175 | /*********************************************************************** |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 176 | * GetTextColor (GDI.90) (GDI32.227) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 177 | */ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 178 | DC_GET_VAL( COLORREF, GetTextColor, w.textColor ) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 179 | |
| 180 | /*********************************************************************** |
| 181 | * GetViewportExt16 (GDI.94) |
| 182 | */ |
| 183 | DC_GET_X_Y( DWORD, GetViewportExt16, vportExtX, vportExtY ) |
| 184 | |
| 185 | /*********************************************************************** |
| 186 | * GetViewportOrg16 (GDI.95) |
| 187 | */ |
| 188 | DC_GET_X_Y( DWORD, GetViewportOrg16, vportOrgX, vportOrgY ) |
| 189 | |
| 190 | /*********************************************************************** |
| 191 | * GetWindowExt16 (GDI.96) |
| 192 | */ |
| 193 | DC_GET_X_Y( DWORD, GetWindowExt16, wndExtX, wndExtY ) |
| 194 | |
| 195 | /*********************************************************************** |
| 196 | * GetWindowOrg16 (GDI.97) |
| 197 | */ |
| 198 | DC_GET_X_Y( DWORD, GetWindowOrg16, wndOrgX, wndOrgY ) |
| 199 | |
| 200 | /*********************************************************************** |
| 201 | * InquireVisRgn16 (GDI.131) |
| 202 | */ |
| 203 | DC_GET_VAL_16( HRGN16, InquireVisRgn16, w.hVisRgn ) |
| 204 | |
| 205 | /*********************************************************************** |
| 206 | * GetClipRgn16 (GDI.173) |
| 207 | */ |
| 208 | DC_GET_VAL_16( HRGN16, GetClipRgn16, w.hClipRgn ) |
| 209 | |
| 210 | /*********************************************************************** |
| 211 | * GetBrushOrg16 (GDI.149) |
| 212 | */ |
| 213 | DC_GET_X_Y( DWORD, GetBrushOrg16, w.brushOrgX, w.brushOrgY ) |
| 214 | |
| 215 | /*********************************************************************** |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 216 | * GetTextAlign (GDI.345) (GDI32,224) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 217 | */ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 218 | DC_GET_VAL( UINT, GetTextAlign, w.textAlign ) |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 219 | |
| 220 | /*********************************************************************** |
| 221 | * GetCurLogFont16 (GDI.411) |
| 222 | */ |
| 223 | DC_GET_VAL_16( HFONT16, GetCurLogFont16, w.hFont ) |
| 224 | |
| 225 | /*********************************************************************** |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 226 | * GetArcDirection (GDI.524) (GDI32.141) |
| 227 | */ |
| 228 | DC_GET_VAL( INT, GetArcDirection, w.ArcDirection ) |
| 229 | |
| 230 | /*********************************************************************** |
| 231 | * GetGraphicsMode (GDI32.188) |
| 232 | */ |
| 233 | DC_GET_VAL( INT, GetGraphicsMode, w.GraphicsMode) |
| 234 | |
| 235 | /*********************************************************************** |
Patrik Stridvall | 3a9c476 | 1999-10-31 02:07:05 +0000 | [diff] [blame] | 236 | * GetBrushOrgEx (GDI.469) (GDI32.148) |
| 237 | */ |
| 238 | DC_GET_VAL_EX( GetBrushOrgEx, w.brushOrgX, w.brushOrgY, POINT ) /* */ |
| 239 | |
| 240 | /*********************************************************************** |
| 241 | * GetCurrentPositionEx (GDI.470) (GDI32.167) |
| 242 | */ |
| 243 | DC_GET_VAL_EX( GetCurrentPositionEx, w.CursPosX, w.CursPosY, POINT ) |
| 244 | |
| 245 | /*********************************************************************** |
| 246 | * GetViewportExtEx (GDI.472 GDI32.239) |
| 247 | */ |
| 248 | DC_GET_VAL_EX( GetViewportExtEx, vportExtX, vportExtY, SIZE ) |
| 249 | |
| 250 | /*********************************************************************** |
| 251 | * GetViewportOrgEx (GDI.473) (GDI32.240) |
| 252 | */ |
| 253 | DC_GET_VAL_EX( GetViewportOrgEx, vportOrgX, vportOrgY, POINT ) |
| 254 | |
| 255 | /*********************************************************************** |
| 256 | * GetWindowExtEx (GDI.474) (GDI32.242) |
| 257 | */ |
| 258 | DC_GET_VAL_EX( GetWindowExtEx, wndExtX, wndExtY, SIZE ) |
| 259 | |
| 260 | /*********************************************************************** |
| 261 | * GetWindowOrgEx (GDI.475) (GDI32.243) |
| 262 | */ |
| 263 | DC_GET_VAL_EX( GetWindowOrgEx, wndOrgX, wndOrgY, POINT ) |