Release 940405
[wine/gsoc-2012-control.git] / include / gdi.h
blob3ec95eaac7c27f872677762c53d096124a8079d7
1 /*
2 * GDI definitions
4 * Copyright 1993 Alexandre Julliard
5 */
7 #ifndef GDI_H
8 #define GDI_H
10 #include <X11/Xlib.h>
12 #include "windows.h"
13 #include "segmem.h"
14 #include "heap.h"
16 /* GDI objects magic numbers */
17 #define PEN_MAGIC 0x4f47
18 #define BRUSH_MAGIC 0x4f48
19 #define FONT_MAGIC 0x4f49
20 #define PALETTE_MAGIC 0x4f4a
21 #define BITMAP_MAGIC 0x4f4b
22 #define REGION_MAGIC 0x4f4c
23 #define DC_MAGIC 0x4f4d
24 #define DISABLED_DC_MAGIC 0x4f4e
25 #define META_DC_MAGIC 0x4f4f
26 #define METAFILE_MAGIC 0x4f50
27 #define METAFILE_DC_MAGIC 0x4f51
30 typedef struct tagREGION
32 WORD type;
33 RECT box;
34 Pixmap pixmap;
35 } REGION;
37 typedef struct tagGDIOBJHDR
39 HANDLE hNext;
40 WORD wMagic;
41 DWORD dwCount;
42 WORD wMetaList;
43 } GDIOBJHDR;
45 typedef struct tagBRUSHOBJ
47 GDIOBJHDR header;
48 LOGBRUSH logbrush WINE_PACKED;
49 } BRUSHOBJ;
51 typedef struct tagPENOBJ
53 GDIOBJHDR header;
54 LOGPEN logpen WINE_PACKED;
55 } PENOBJ;
57 typedef struct tagPALETTEOBJ
59 GDIOBJHDR header;
60 LOGPALETTE logpalette WINE_PACKED;
61 } PALETTEOBJ;
63 typedef struct tagFONTOBJ
65 GDIOBJHDR header;
66 LOGFONT logfont WINE_PACKED;
67 } FONTOBJ;
69 typedef struct tagBITMAPOBJ
71 GDIOBJHDR header;
72 BITMAP bitmap;
73 Pixmap pixmap;
74 SIZE size; /* For SetBitmapDimension() */
75 } BITMAPOBJ;
77 typedef struct tagRGNOBJ
79 GDIOBJHDR header;
80 REGION region;
81 } RGNOBJ;
83 typedef struct
85 WORD version; /* 0: driver version */
86 WORD technology; /* 2: device technology */
87 WORD horzSize; /* 4: width of display in mm */
88 WORD vertSize; /* 6: height of display in mm */
89 WORD horzRes; /* 8: width of display in pixels */
90 WORD vertRes; /* 10: width of display in pixels */
91 WORD bitsPixel; /* 12: bits per pixel */
92 WORD planes; /* 14: color planes */
93 WORD numBrushes; /* 16: device-specific brushes */
94 WORD numPens; /* 18: device-specific pens */
95 WORD numMarkers; /* 20: device-specific markers */
96 WORD numFonts; /* 22: device-specific fonts */
97 WORD numColors; /* 24: size of color table */
98 WORD pdeviceSize; /* 26: size of PDEVICE structure */
99 WORD curveCaps; /* 28: curve capabilities */
100 WORD lineCaps; /* 30: line capabilities */
101 WORD polygonalCaps; /* 32: polygon capabilities */
102 WORD textCaps; /* 34: text capabilities */
103 WORD clipCaps; /* 36: clipping capabilities */
104 WORD rasterCaps; /* 38: raster capabilities */
105 WORD aspectX; /* 40: relative width of device pixel */
106 WORD aspectY; /* 42: relative height of device pixel */
107 WORD aspectXY; /* 44: relative diagonal width of device pixel */
108 WORD pad1[21]; /* 46-86: reserved */
109 WORD logPixelsX; /* 88: pixels / logical X inch */
110 WORD logPixelsY; /* 90: pixels / logical Y inch */
111 WORD pad2[6]; /* 92-102: reserved */
112 WORD sizePalette; /* 104: entries in system palette */
113 WORD numReserved; /* 106: reserved entries */
114 WORD colorRes; /* 108: color resolution */
115 } DeviceCaps;
118 /* Device independent DC information */
119 typedef struct
121 int flags;
122 DeviceCaps *devCaps;
124 HANDLE hMetaFile;
125 HRGN hClipRgn; /* Clip region */
126 HRGN hVisRgn; /* Visible region */
127 HRGN hGCClipRgn; /* GC clip region (ClipRgn AND VisRgn) */
128 HPEN hPen;
129 HBRUSH hBrush;
130 HFONT hFont;
131 HBITMAP hBitmap;
132 HANDLE hDevice;
133 HPALETTE hPalette;
135 WORD ROPmode;
136 WORD polyFillMode;
137 WORD stretchBltMode;
138 WORD relAbsMode;
139 WORD backgroundMode;
140 COLORREF backgroundColor;
141 COLORREF textColor;
142 int backgroundPixel;
143 int textPixel;
144 short brushOrgX;
145 short brushOrgY;
147 WORD textAlign; /* Text alignment from SetTextAlign() */
148 short charExtra; /* Spacing from SetTextCharacterExtra() */
149 short breakTotalExtra; /* Total extra space for justification */
150 short breakCount; /* Break char. count */
151 short breakExtra; /* breakTotalExtra / breakCount */
152 short breakRem; /* breakTotalExtra % breakCount */
154 BYTE bitsPerPixel;
156 WORD MapMode;
157 short DCOrgX; /* DC origin */
158 short DCOrgY;
159 short DCSizeX; /* DC dimensions */
160 short DCSizeY;
161 short CursPosX; /* Current position */
162 short CursPosY;
163 short WndOrgX;
164 short WndOrgY;
165 short WndExtX;
166 short WndExtY;
167 short VportOrgX;
168 short VportOrgY;
169 short VportExtX;
170 short VportExtY;
171 } WIN_DC_INFO;
174 /* X physical pen */
175 typedef struct
177 int style;
178 int pixel;
179 int width;
180 char * dashes;
181 int dash_len;
182 } X_PHYSPEN;
184 /* X physical brush */
185 typedef struct
187 int style;
188 int fillStyle;
189 int pixel;
190 Pixmap pixmap;
191 } X_PHYSBRUSH;
193 /* X physical font */
194 typedef struct
196 XFontStruct * fstruct;
197 TEXTMETRIC metrics;
198 } X_PHYSFONT;
200 /* X physical palette information */
201 typedef struct
203 HANDLE hMapping;
204 WORD mappingSize;
205 } X_PHYSPALETTE;
207 /* X-specific DC information */
208 typedef struct
210 GC gc; /* X Window GC */
211 Drawable drawable;
212 X_PHYSFONT font;
213 X_PHYSPEN pen;
214 X_PHYSBRUSH brush;
215 X_PHYSPALETTE pal;
216 } X_DC_INFO;
219 typedef struct tagDC
221 GDIOBJHDR header;
222 WORD saveLevel;
223 WIN_DC_INFO w;
224 union
226 X_DC_INFO x;
227 /* other devices (e.g. printer) */
228 } u;
229 } DC;
231 /* DC flags */
232 #define DC_MEMORY 1 /* It is a memory DC */
233 #define DC_SAVED 2 /* It is a saved DC */
235 /* Last 32 bytes are reserved for stock object handles */
236 #define GDI_HEAP_SIZE 0xffe0
238 /* First handle possible for stock objects (must be >= GDI_HEAP_SIZE) */
239 #define FIRST_STOCK_HANDLE GDI_HEAP_SIZE
241 /* Stock objects handles */
243 #define STOCK_WHITE_BRUSH (FIRST_STOCK_HANDLE + WHITE_BRUSH)
244 #define STOCK_LTGRAY_BRUSH (FIRST_STOCK_HANDLE + LTGRAY_BRUSH)
245 #define STOCK_GRAY_BRUSH (FIRST_STOCK_HANDLE + GRAY_BRUSH)
246 #define STOCK_DKGRAY_BRUSH (FIRST_STOCK_HANDLE + DKGRAY_BRUSH)
247 #define STOCK_BLACK_BRUSH (FIRST_STOCK_HANDLE + BLACK_BRUSH)
248 #define STOCK_NULL_BRUSH (FIRST_STOCK_HANDLE + NULL_BRUSH)
249 #define STOCK_HOLLOW_BRUSH (FIRST_STOCK_HANDLE + HOLLOW_BRUSH)
250 #define STOCK_WHITE_PEN (FIRST_STOCK_HANDLE + WHITE_PEN)
251 #define STOCK_BLACK_PEN (FIRST_STOCK_HANDLE + BLACK_PEN)
252 #define STOCK_NULL_PEN (FIRST_STOCK_HANDLE + NULL_PEN)
253 #define STOCK_OEM_FIXED_FONT (FIRST_STOCK_HANDLE + OEM_FIXED_FONT)
254 #define STOCK_ANSI_FIXED_FONT (FIRST_STOCK_HANDLE + ANSI_FIXED_FONT)
255 #define STOCK_ANSI_VAR_FONT (FIRST_STOCK_HANDLE + ANSI_VAR_FONT)
256 #define STOCK_SYSTEM_FONT (FIRST_STOCK_HANDLE + SYSTEM_FONT)
257 #define STOCK_DEVICE_DEFAULT_FONT (FIRST_STOCK_HANDLE + DEVICE_DEFAULT_FONT)
258 #define STOCK_DEFAULT_PALETTE (FIRST_STOCK_HANDLE + DEFAULT_PALETTE)
259 #define STOCK_SYSTEM_FIXED_FONT (FIRST_STOCK_HANDLE + SYSTEM_FIXED_FONT)
261 #define NB_STOCK_OBJECTS (SYSTEM_FIXED_FONT + 1)
263 #define FIRST_STOCK_FONT STOCK_OEM_FIXED_FONT
264 #define LAST_STOCK_FONT STOCK_SYSTEM_FIXED_FONT
268 /* Device <-> logical coords conversion */
270 #define XDPTOLP(dc,x) \
271 (((x)-(dc)->w.VportOrgX) * (dc)->w.WndExtX / (dc)->w.VportExtX+(dc)->w.WndOrgX)
272 #define YDPTOLP(dc,y) \
273 (((y)-(dc)->w.VportOrgY) * (dc)->w.WndExtY / (dc)->w.VportExtY+(dc)->w.WndOrgY)
274 #define XLPTODP(dc,x) \
275 (((x)-(dc)->w.WndOrgX) * (dc)->w.VportExtX / (dc)->w.WndExtX+(dc)->w.VportOrgX)
276 #define YLPTODP(dc,y) \
277 (((y)-(dc)->w.WndOrgY) * (dc)->w.VportExtY / (dc)->w.WndExtY+(dc)->w.VportOrgY)
280 /* GDI local heap */
282 #ifdef WINELIB
284 #define GDI_HEAP_ALLOC(f,size) LocalAlloc (f,size)
285 #define GDI_HEAP_ADDR(handle) LocalLock (handle)
286 #define GDI_HEAP_FREE(handle) LocalFree (handle)
288 #else
290 extern MDESC *GDI_Heap;
292 #define GDI_HEAP_ALLOC(f,size) ((int)HEAP_Alloc(&GDI_Heap,f,size) & 0xffff)
293 #define GDI_HEAP_ADDR(handle) ((void *)((handle)|((int)GDI_Heap & 0xffff0000)))
294 #define GDI_HEAP_FREE(handle) (HEAP_Free(&GDI_Heap,GDI_HEAP_ADDR(handle)))
296 #endif
298 extern HANDLE GDI_AllocObject( WORD, WORD );
299 extern BOOL GDI_FreeObject( HANDLE );
300 extern GDIOBJHDR * GDI_GetObjPtr( HANDLE, WORD );
302 extern Display * XT_display; /* Will be removed */
303 extern Screen * XT_screen; /* Will be removed */
305 extern Display * display;
306 extern Screen * screen;
307 extern Window rootWindow;
308 extern int screenWidth, screenHeight, screenDepth;
310 #endif /* GDI_H */