Release 940815
[wine/multimedia.git] / objects / dcvalues.c
blobc1fafaf6644f888fe55e2a52f323271e43f58815
1 /*
2 * DC device-independent Get/SetXXX functions
4 * Copyright 1993 Alexandre Julliard
5 */
7 static char Copyright[] = "Copyright Alexandre Julliard, 1993";
9 #include "gdi.h"
10 #include "metafile.h"
12 /* Default DC values */
13 const WIN_DC_INFO DCVAL_defaultValues =
15 0, /* flags */
16 NULL, /* devCaps */
17 0, /* hMetaFile */
18 0, /* hClipRgn */
19 0, /* hVisRgn */
20 0, /* hGCClipRgn */
21 STOCK_BLACK_PEN, /* hPen */
22 STOCK_WHITE_BRUSH, /* hBrush */
23 STOCK_SYSTEM_FONT, /* hFont */
24 0, /* hBitmap */
25 0, /* hDevice */
26 STOCK_DEFAULT_PALETTE, /* hPalette */
27 R2_COPYPEN, /* ROPmode */
28 ALTERNATE, /* polyFillMode */
29 BLACKONWHITE, /* stretchBltMode */
30 ABSOLUTE, /* relAbsMode */
31 OPAQUE, /* backgroundMode */
32 RGB( 255, 255, 255 ), /* backgroundColor */
33 RGB( 0, 0, 0 ), /* textColor */
34 0, /* backgroundPixel */
35 0, /* textPixel */
36 0, /* brushOrgX */
37 0, /* brushOrgY */
38 TA_LEFT | TA_TOP | TA_NOUPDATECP, /* textAlign */
39 0, /* charExtra */
40 0, /* breakTotalExtra */
41 0, /* breakCount */
42 0, /* breakExtra */
43 0, /* breakRem */
44 1, /* bitsPerPixel */
45 MM_TEXT, /* MapMode */
46 0, /* DCOrgX */
47 0, /* DCOrgY */
48 0, /* DCSizeX */
49 0, /* DCSizeY */
50 0, /* CursPosX */
51 0, /* CursPosY */
52 0, /* WndOrgX */
53 0, /* WndOrgY */
54 1, /* WndExtX */
55 1, /* WndExtY */
56 0, /* VportOrgX */
57 0, /* VportOrgY */
58 1, /* VportExtX */
59 1 /* VportExtY */
63 #define DC_GET_VAL( func_type, func_name, dc_field ) \
64 func_type func_name( HDC hdc ) \
65 { \
66 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
67 if (!dc) return 0; \
68 return dc->w.dc_field; \
71 #define DC_GET_X_Y( func_type, func_name, ret_x, ret_y ) \
72 func_type func_name( HDC hdc ) \
73 { \
74 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
75 if (!dc) return 0; \
76 return MAKELONG( dc->w.ret_x, dc->w.ret_y << 16 ); \
79 #define DC_GET_VAL_EX( func_name, ret_x, ret_y ) \
80 BOOL func_name( HDC hdc, LPPOINT pt ) \
81 { \
82 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
83 if (!dc) return FALSE; \
84 pt->x = dc->w.ret_x; \
85 pt->y = dc->w.ret_y; \
86 return TRUE; \
89 #define DC_SET_VAL( func_type, func_name, dc_field ) \
90 func_type func_name( HDC hdc, func_type val ) \
91 { \
92 func_type prevVal; \
93 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
94 if (!dc) return 0; \
95 prevVal = dc->w.dc_field; \
96 dc->w.dc_field = val; \
97 return prevVal; \
100 #define DC_SET_MODE( func_name, dc_field, min_val, max_val, meta_func ) \
101 WORD func_name( HDC hdc, WORD mode ) \
103 WORD prevMode; \
104 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
105 if ((mode < min_val) || (mode > max_val)) return 0; \
106 if (!dc) { \
107 dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); \
108 if (!dc) return 0; \
109 MF_MetaParam1(dc, meta_func, mode); \
110 return 1; \
112 prevMode = dc->w.dc_field; \
113 dc->w.dc_field = mode; \
114 return prevMode; \
118 DC_SET_MODE( SetBkMode, backgroundMode, TRANSPARENT, OPAQUE,
119 META_SETBKMODE ) /* GDI.2 */
120 DC_SET_MODE( SetROP2, ROPmode, R2_BLACK, R2_WHITE, META_SETROP2 ) /* GDI.4 */
121 DC_SET_MODE( SetRelAbs, relAbsMode, ABSOLUTE, RELATIVE,
122 META_SETRELABS ) /* GDI.5 */
123 DC_SET_MODE( SetPolyFillMode, polyFillMode, ALTERNATE, WINDING,
124 META_SETPOLYFILLMODE ) /* GDI.6 */
125 DC_SET_MODE( SetStretchBltMode, stretchBltMode,
126 BLACKONWHITE, COLORONCOLOR, META_SETSTRETCHBLTMODE ) /* GDI.7 */
127 DC_GET_VAL( COLORREF, GetBkColor, backgroundColor ) /* GDI.75 */
128 DC_GET_VAL( WORD, GetBkMode, backgroundMode ) /* GDI.76 */
129 DC_GET_X_Y( DWORD, GetCurrentPosition, CursPosX, CursPosY ) /* GDI.78 */
130 DC_GET_VAL( WORD, GetMapMode, MapMode ) /* GDI.81 */
131 DC_GET_VAL( WORD, GetPolyFillMode, polyFillMode ) /* GDI.84 */
132 DC_GET_VAL( WORD, GetROP2, ROPmode ) /* GDI.85 */
133 DC_GET_VAL( WORD, GetRelAbs, relAbsMode ) /* GDI.86 */
134 DC_GET_VAL( WORD, GetStretchBltMode, stretchBltMode ) /* GDI.88 */
135 DC_GET_VAL( COLORREF, GetTextColor, textColor ) /* GDI.90 */
136 DC_GET_X_Y( DWORD, GetViewportExt, VportExtX, VportExtY ) /* GDI.94 */
137 DC_GET_X_Y( DWORD, GetViewportOrg, VportOrgX, VportOrgY ) /* GDI.95 */
138 DC_GET_X_Y( DWORD, GetWindowExt, WndExtX, WndExtY ) /* GDI.96 */
139 DC_GET_X_Y( DWORD, GetWindowOrg, WndOrgX, WndOrgY ) /* GDI.97 */
140 DC_GET_VAL( HRGN, InquireVisRgn, hVisRgn ) /* GDI.131 */
141 DC_GET_X_Y( DWORD, GetBrushOrg, brushOrgX, brushOrgY ) /* GDI.149 */
142 DC_GET_VAL( HRGN, GetClipRgn, hClipRgn ) /* GDI.173 */
143 DC_GET_VAL( WORD, GetTextAlign, textAlign ) /* GDI.345 */
144 DC_SET_VAL( WORD, SetTextAlign, textAlign ) /* GDI.346 */
145 DC_GET_VAL( HFONT, GetCurLogFont, hFont ) /* GDI.411 */
146 DC_GET_VAL_EX( GetBrushOrgEx, brushOrgX, brushOrgY ) /* GDI.469 */
147 DC_GET_VAL_EX( GetCurrentPositionEx, CursPosX, CursPosY ) /* GDI.470 */
148 DC_GET_VAL_EX( GetViewportExtEx, VportExtX, VportExtY ) /* GDI.472 */
149 DC_GET_VAL_EX( GetViewportOrgEx, VportOrgX, VportOrgY ) /* GDI.473 */
150 DC_GET_VAL_EX( GetWindowExtEx, WndExtX, WndExtY ) /* GDI.474 */
151 DC_GET_VAL_EX( GetWindowOrgEx, WndOrgX, WndOrgY ) /* GDI.475 */