4 * Copyright 1993 Alexandre Julliard
11 #include <X11/Xutil.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
29 #define MAGIC_DONTCARE 0xffff
35 typedef struct tagGDIOBJHDR
46 WORD version
; /* 0: driver version */
47 WORD technology
; /* 2: device technology */
48 WORD horzSize
; /* 4: width of display in mm */
49 WORD vertSize
; /* 6: height of display in mm */
50 WORD horzRes
; /* 8: width of display in pixels */
51 WORD vertRes
; /* 10: width of display in pixels */
52 WORD bitsPixel
; /* 12: bits per pixel */
53 WORD planes
; /* 14: color planes */
54 WORD numBrushes
; /* 16: device-specific brushes */
55 WORD numPens
; /* 18: device-specific pens */
56 WORD numMarkers
; /* 20: device-specific markers */
57 WORD numFonts
; /* 22: device-specific fonts */
58 WORD numColors
; /* 24: size of color table */
59 WORD pdeviceSize
; /* 26: size of PDEVICE structure */
60 WORD curveCaps
; /* 28: curve capabilities */
61 WORD lineCaps
; /* 30: line capabilities */
62 WORD polygonalCaps
; /* 32: polygon capabilities */
63 WORD textCaps
; /* 34: text capabilities */
64 WORD clipCaps
; /* 36: clipping capabilities */
65 WORD rasterCaps
; /* 38: raster capabilities */
66 WORD aspectX
; /* 40: relative width of device pixel */
67 WORD aspectY
; /* 42: relative height of device pixel */
68 WORD aspectXY
; /* 44: relative diagonal width of device pixel */
69 WORD pad1
[21]; /* 46-86: reserved */
70 WORD logPixelsX
; /* 88: pixels / logical X inch */
71 WORD logPixelsY
; /* 90: pixels / logical Y inch */
72 WORD pad2
[6]; /* 92-102: reserved */
73 WORD sizePalette
; /* 104: entries in system palette */
74 WORD numReserved
; /* 106: reserved entries */
75 WORD colorRes
; /* 108: color resolution */
83 /* Device independent DC information */
90 HRGN hClipRgn
; /* Clip region (may be 0) */
91 HRGN hVisRgn
; /* Visible region (must never be 0) */
92 HRGN hGCClipRgn
; /* GC clip region (ClipRgn AND VisRgn) */
97 HBITMAP hFirstBitmap
; /* Bitmap selected at creation of the DC */
106 COLORREF backgroundColor
;
113 WORD textAlign
; /* Text alignment from SetTextAlign() */
114 short charExtra
; /* Spacing from SetTextCharacterExtra() */
115 short breakTotalExtra
; /* Total extra space for justification */
116 short breakCount
; /* Break char. count */
117 short breakExtra
; /* breakTotalExtra / breakCount */
118 short breakRem
; /* breakTotalExtra % breakCount */
123 short DCOrgX
; /* DC origin */
125 short CursPosX
; /* Current position */
148 /* X physical brush */
157 /* X physical font */
160 XFontStruct
* fstruct
;
164 /* X physical palette information */
167 HANDLE hMapping
; /* Color mapping table (or 0 for identity) */
168 HANDLE hRevMapping
; /* Reverse color mapping table */
172 /* X-specific DC information */
175 GC gc
; /* X Window GC */
192 /* other devices (e.g. printer) */
197 #define DC_MEMORY 1 /* It is a memory DC */
198 #define DC_SAVED 2 /* It is a saved DC */
200 /* Last 32 bytes are reserved for stock object handles */
202 /* Stupid overloading (see DefWindowProc, case WM_ERASEBKGND) */
203 #define GDI_HEAP_SIZE (COLOR_BTNHIGHLIGHT+1)
205 #define GDI_HEAP_SIZE 0xffe0
208 /* First handle possible for stock objects (must be >= GDI_HEAP_SIZE) */
209 #define FIRST_STOCK_HANDLE GDI_HEAP_SIZE
211 /* Stock objects handles */
213 #define NB_STOCK_OBJECTS (SYSTEM_FIXED_FONT + 1)
215 #define STOCK_WHITE_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+WHITE_BRUSH))
216 #define STOCK_LTGRAY_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+LTGRAY_BRUSH))
217 #define STOCK_GRAY_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+GRAY_BRUSH))
218 #define STOCK_DKGRAY_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+DKGRAY_BRUSH))
219 #define STOCK_BLACK_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+BLACK_BRUSH))
220 #define STOCK_NULL_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+NULL_BRUSH))
221 #define STOCK_HOLLOW_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+HOLLOW_BRUSH))
222 #define STOCK_WHITE_PEN ((HPEN)(FIRST_STOCK_HANDLE+WHITE_PEN))
223 #define STOCK_BLACK_PEN ((HPEN)(FIRST_STOCK_HANDLE+BLACK_PEN))
224 #define STOCK_NULL_PEN ((HPEN)(FIRST_STOCK_HANDLE+NULL_PEN))
225 #define STOCK_OEM_FIXED_FONT ((HFONT)(FIRST_STOCK_HANDLE+OEM_FIXED_FONT))
226 #define STOCK_ANSI_FIXED_FONT ((HFONT)(FIRST_STOCK_HANDLE+ANSI_FIXED_FONT))
227 #define STOCK_ANSI_VAR_FONT ((HFONT)(FIRST_STOCK_HANDLE+ANSI_VAR_FONT))
228 #define STOCK_SYSTEM_FONT ((HFONT)(FIRST_STOCK_HANDLE+SYSTEM_FONT))
229 #define STOCK_DEVICE_DEFAULT_FONT ((HFONT)(FIRST_STOCK_HANDLE+DEVICE_DEFAULT_FONT))
230 #define STOCK_DEFAULT_PALETTE ((HPALETTE)(FIRST_STOCK_HANDLE+DEFAULT_PALETTE))
231 #define STOCK_SYSTEM_FIXED_FONT ((HFONT)(FIRST_STOCK_HANDLE+SYSTEM_FIXED_FONT))
233 #define FIRST_STOCK_FONT STOCK_OEM_FIXED_FONT
234 #define LAST_STOCK_FONT STOCK_SYSTEM_FIXED_FONT
236 #define LAST_STOCK_HANDLE ((DWORD)STOCK_SYSTEM_FIXED_FONT)
238 /* Device <-> logical coords conversion */
240 #define XDPTOLP(dc,x) \
241 (((x)-(dc)->w.VportOrgX) * (dc)->w.WndExtX / (dc)->w.VportExtX+(dc)->w.WndOrgX)
242 #define YDPTOLP(dc,y) \
243 (((y)-(dc)->w.VportOrgY) * (dc)->w.WndExtY / (dc)->w.VportExtY+(dc)->w.WndOrgY)
244 #define XLPTODP(dc,x) \
245 (((x)-(dc)->w.WndOrgX) * (dc)->w.VportExtX / (dc)->w.WndExtX+(dc)->w.VportOrgX)
246 #define YLPTODP(dc,y) \
247 (((y)-(dc)->w.WndOrgY) * (dc)->w.VportExtY / (dc)->w.WndExtY+(dc)->w.VportOrgY)
254 #define GDI_HEAP_ALLOC(size) LocalAlloc (LMEM_FIXED,size)
255 #define GDI_HEAP_LIN_ADDR(handle) LocalLock (handle)
256 #define GDI_HEAP_SEG_ADDR(handle) LocalLock (handle)
257 #define GDI_HEAP_FREE(handle) LocalFree (handle)
261 extern LPSTR GDI_Heap
;
262 extern WORD GDI_HeapSel
;
264 #define GDI_HEAP_ALLOC(size) \
265 LOCAL_Alloc( GDI_HeapSel, LMEM_FIXED, (size) )
266 #define GDI_HEAP_REALLOC(handle,size) \
267 LOCAL_ReAlloc( GDI_HeapSel, (handle), (size), LMEM_FIXED )
268 #define GDI_HEAP_FREE(handle) \
269 LOCAL_Free( GDI_HeapSel, (handle) )
270 #define GDI_HEAP_LIN_ADDR(handle) \
271 ((handle) ? PTR_SEG_OFF_TO_LIN(GDI_HeapSel, (handle)) : NULL)
272 #define GDI_HEAP_SEG_ADDR(handle) \
273 ((handle) ? MAKELONG((handle), GDI_HeapSel) : 0)
277 extern BOOL
GDI_Init(void);
278 extern HANDLE
GDI_AllocObject( WORD
, WORD
);
279 extern BOOL
GDI_FreeObject( HANDLE
);
280 extern GDIOBJHDR
* GDI_GetObjPtr( HANDLE
, WORD
);
282 extern Display
* display
;
283 extern Screen
* screen
;
284 extern Window rootWindow
;
285 extern int screenWidth
, screenHeight
, screenDepth
;
286 extern int desktopX
, desktopY
; /* misc/main.c */