Release 941030
[wine/multimedia.git] / include / gdi.h
blobbc553df5cc698ecd1b0873a8d6e96f54c4d0aea6
1 /*
2 * GDI definitions
4 * Copyright 1993 Alexandre Julliard
5 */
7 #ifndef GDI_H
8 #define GDI_H
10 #include <X11/Xlib.h>
11 #include <X11/Xutil.h>
13 #include "windows.h"
14 #include "segmem.h"
15 #include "heap.h"
17 /* GDI objects magic numbers */
18 #define PEN_MAGIC 0x4f47
19 #define BRUSH_MAGIC 0x4f48
20 #define FONT_MAGIC 0x4f49
21 #define PALETTE_MAGIC 0x4f4a
22 #define BITMAP_MAGIC 0x4f4b
23 #define REGION_MAGIC 0x4f4c
24 #define DC_MAGIC 0x4f4d
25 #define DISABLED_DC_MAGIC 0x4f4e
26 #define META_DC_MAGIC 0x4f4f
27 #define METAFILE_MAGIC 0x4f50
28 #define METAFILE_DC_MAGIC 0x4f51
31 typedef struct tagREGION
33 WORD type;
34 RECT box;
35 Pixmap pixmap;
36 Region xrgn;
37 } REGION;
39 typedef struct tagGDIOBJHDR
41 HANDLE hNext;
42 WORD wMagic;
43 DWORD dwCount;
44 WORD wMetaList;
45 } GDIOBJHDR;
47 typedef struct tagBRUSHOBJ
49 GDIOBJHDR header;
50 LOGBRUSH logbrush WINE_PACKED;
51 } BRUSHOBJ;
53 typedef struct tagPENOBJ
55 GDIOBJHDR header;
56 LOGPEN logpen WINE_PACKED;
57 } PENOBJ;
59 typedef struct tagPALETTEOBJ
61 GDIOBJHDR header;
62 LOGPALETTE logpalette WINE_PACKED;
63 } PALETTEOBJ;
65 typedef struct tagFONTOBJ
67 GDIOBJHDR header;
68 LOGFONT logfont WINE_PACKED;
69 } FONTOBJ;
71 typedef struct tagBITMAPOBJ
73 GDIOBJHDR header;
74 BITMAP bitmap;
75 Pixmap pixmap;
76 SIZE size; /* For SetBitmapDimension() */
77 } BITMAPOBJ;
79 typedef struct tagRGNOBJ
81 GDIOBJHDR header;
82 REGION region;
83 } RGNOBJ;
85 typedef struct
87 WORD version; /* 0: driver version */
88 WORD technology; /* 2: device technology */
89 WORD horzSize; /* 4: width of display in mm */
90 WORD vertSize; /* 6: height of display in mm */
91 WORD horzRes; /* 8: width of display in pixels */
92 WORD vertRes; /* 10: width of display in pixels */
93 WORD bitsPixel; /* 12: bits per pixel */
94 WORD planes; /* 14: color planes */
95 WORD numBrushes; /* 16: device-specific brushes */
96 WORD numPens; /* 18: device-specific pens */
97 WORD numMarkers; /* 20: device-specific markers */
98 WORD numFonts; /* 22: device-specific fonts */
99 WORD numColors; /* 24: size of color table */
100 WORD pdeviceSize; /* 26: size of PDEVICE structure */
101 WORD curveCaps; /* 28: curve capabilities */
102 WORD lineCaps; /* 30: line capabilities */
103 WORD polygonalCaps; /* 32: polygon capabilities */
104 WORD textCaps; /* 34: text capabilities */
105 WORD clipCaps; /* 36: clipping capabilities */
106 WORD rasterCaps; /* 38: raster capabilities */
107 WORD aspectX; /* 40: relative width of device pixel */
108 WORD aspectY; /* 42: relative height of device pixel */
109 WORD aspectXY; /* 44: relative diagonal width of device pixel */
110 WORD pad1[21]; /* 46-86: reserved */
111 WORD logPixelsX; /* 88: pixels / logical X inch */
112 WORD logPixelsY; /* 90: pixels / logical Y inch */
113 WORD pad2[6]; /* 92-102: reserved */
114 WORD sizePalette; /* 104: entries in system palette */
115 WORD numReserved; /* 106: reserved entries */
116 WORD colorRes; /* 108: color resolution */
117 } DeviceCaps;
120 /* Device independent DC information */
121 typedef struct
123 int flags;
124 DeviceCaps *devCaps;
126 HANDLE hMetaFile;
127 HRGN hClipRgn; /* Clip region (may be 0) */
128 HRGN hVisRgn; /* Visible region (must never be 0) */
129 HRGN hGCClipRgn; /* GC clip region (ClipRgn AND VisRgn) */
130 HPEN hPen;
131 HBRUSH hBrush;
132 HFONT hFont;
133 HBITMAP hBitmap;
134 HANDLE hDevice;
135 HPALETTE hPalette;
137 WORD ROPmode;
138 WORD polyFillMode;
139 WORD stretchBltMode;
140 WORD relAbsMode;
141 WORD backgroundMode;
142 COLORREF backgroundColor;
143 COLORREF textColor;
144 int backgroundPixel;
145 int textPixel;
146 short brushOrgX;
147 short brushOrgY;
149 WORD textAlign; /* Text alignment from SetTextAlign() */
150 short charExtra; /* Spacing from SetTextCharacterExtra() */
151 short breakTotalExtra; /* Total extra space for justification */
152 short breakCount; /* Break char. count */
153 short breakExtra; /* breakTotalExtra / breakCount */
154 short breakRem; /* breakTotalExtra % breakCount */
156 BYTE bitsPerPixel;
158 WORD MapMode;
159 short DCOrgX; /* DC origin */
160 short DCOrgY;
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_FREE(handle) (HEAP_Free(&GDI_Heap,GDI_HEAP_ADDR(handle)))
294 #define GDI_HEAP_ADDR(handle) \
295 ((void *)((handle) ? ((handle) | ((int)GDI_Heap & 0xffff0000)) : 0))
297 #endif
299 extern HANDLE GDI_AllocObject( WORD, WORD );
300 extern BOOL GDI_FreeObject( HANDLE );
301 extern GDIOBJHDR * GDI_GetObjPtr( HANDLE, WORD );
303 extern Display * display;
304 extern Screen * screen;
305 extern Window rootWindow;
306 extern int screenWidth, screenHeight, screenDepth;
308 #endif /* GDI_H */