4 * Copyright 1993 Alexandre Julliard
15 /* GDI objects magic numbers */
16 #define PEN_MAGIC 0x4f47
17 #define BRUSH_MAGIC 0x4f48
18 #define FONT_MAGIC 0x4f49
19 #define PALETTE_MAGIC 0x4f4a
20 #define BITMAP_MAGIC 0x4f4b
21 #define REGION_MAGIC 0x4f4c
22 #define DC_MAGIC 0x4f4d
23 #define DISABLED_DC_MAGIC 0x4f4e
24 #define META_DC_MAGIC 0x4f4f
25 #define METAFILE_MAGIC 0x4f50
26 #define METAFILE_DC_MAGIC 0x4f51
27 #define MAGIC_DONTCARE 0xffff
29 typedef struct tagGDIOBJHDR
39 WORD version
; /* 0: driver version */
40 WORD technology
; /* 2: device technology */
41 WORD horzSize
; /* 4: width of display in mm */
42 WORD vertSize
; /* 6: height of display in mm */
43 WORD horzRes
; /* 8: width of display in pixels */
44 WORD vertRes
; /* 10: width of display in pixels */
45 WORD bitsPixel
; /* 12: bits per pixel */
46 WORD planes
; /* 14: color planes */
47 WORD numBrushes
; /* 16: device-specific brushes */
48 WORD numPens
; /* 18: device-specific pens */
49 WORD numMarkers
; /* 20: device-specific markers */
50 WORD numFonts
; /* 22: device-specific fonts */
51 WORD numColors
; /* 24: size of color table */
52 WORD pdeviceSize
; /* 26: size of PDEVICE structure */
53 WORD curveCaps
; /* 28: curve capabilities */
54 WORD lineCaps
; /* 30: line capabilities */
55 WORD polygonalCaps
; /* 32: polygon capabilities */
56 WORD textCaps
; /* 34: text capabilities */
57 WORD clipCaps
; /* 36: clipping capabilities */
58 WORD rasterCaps
; /* 38: raster capabilities */
59 WORD aspectX
; /* 40: relative width of device pixel */
60 WORD aspectY
; /* 42: relative height of device pixel */
61 WORD aspectXY
; /* 44: relative diagonal width of device pixel */
62 WORD pad1
[21]; /* 46-86: reserved */
63 WORD logPixelsX
; /* 88: pixels / logical X inch */
64 WORD logPixelsY
; /* 90: pixels / logical Y inch */
65 WORD pad2
[6]; /* 92-102: reserved */
66 WORD sizePalette
; /* 104: entries in system palette */
67 WORD numReserved
; /* 106: reserved entries */
68 WORD colorRes
; /* 108: color resolution */
72 /* Device independent DC information */
76 const DeviceCaps
*devCaps
;
78 HRGN16 hClipRgn
; /* Clip region (may be 0) */
79 HRGN16 hVisRgn
; /* Visible region (must never be 0) */
80 HRGN16 hGCClipRgn
; /* GC clip region (ClipRgn AND VisRgn) */
85 HBITMAP16 hFirstBitmap
; /* Bitmap selected at creation of the DC */
94 COLORREF backgroundColor
;
101 WORD textAlign
; /* Text alignment from SetTextAlign() */
102 short charExtra
; /* Spacing from SetTextCharacterExtra() */
103 short breakTotalExtra
; /* Total extra space for justification */
104 short breakCount
; /* Break char. count */
105 short breakExtra
; /* breakTotalExtra / breakCount */
106 short breakRem
; /* breakTotalExtra % breakCount */
111 short DCOrgX
; /* DC origin */
113 short CursPosX
; /* Current position */
125 typedef X11DRV_PDEVICE X_DC_INFO
; /* Temporary */
130 HDC32 hSelf
; /* Handle to this DC */
131 const struct tagDC_FUNCS
*funcs
; /* DC function table */
132 void *physDev
; /* Physical device (driver-specific) */
141 /* other devices (e.g. printer) */
145 /* Device functions for the Wine driver interface */
146 typedef struct tagDC_FUNCS
148 BOOL32 (*pArc
)(DC
*,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
);
149 BOOL32 (*pBitBlt
)(DC
*,INT32
,INT32
,INT32
,INT32
,DC
*,INT32
,INT32
,DWORD
);
150 BOOL32 (*pChord
)(DC
*,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
);
151 BOOL32 (*pCreateDC
)(DC
*,LPCSTR
,LPCSTR
,LPCSTR
,const DEVMODE16
*);
152 BOOL32 (*pDeleteDC
)(DC
*);
153 BOOL32 (*pDeleteObject
)(HGDIOBJ16
);
154 BOOL32 (*pEllipse
)(DC
*,INT32
,INT32
,INT32
,INT32
);
155 INT32 (*pEscape
)(DC
*,INT32
,INT32
,SEGPTR
,SEGPTR
);
156 INT32 (*pExcludeClipRect
)(DC
*,INT32
,INT32
,INT32
,INT32
);
157 INT32 (*pExcludeVisRect
)(DC
*,INT32
,INT32
,INT32
,INT32
);
158 BOOL32 (*pExtFloodFill
)(DC
*,INT32
,INT32
,COLORREF
,UINT32
);
159 BOOL32 (*pExtTextOut
)(DC
*,INT32
,INT32
,UINT32
,const RECT32
*,LPCSTR
,UINT32
,const INT32
*);
160 BOOL32 (*pFillRgn
)(DC
*,HRGN32
,HBRUSH32
);
161 BOOL32 (*pFloodFill
)(DC
*,INT32
,INT32
,COLORREF
);
162 BOOL32 (*pFrameRgn
)(DC
*,HRGN32
,HBRUSH32
,INT32
,INT32
);
163 BOOL32 (*pGetTextExtentPoint
)(DC
*,LPCSTR
,INT32
,LPSIZE32
);
164 BOOL32 (*pGetTextMetrics
)(DC
*,TEXTMETRIC32A
*);
165 INT32 (*pIntersectClipRect
)(DC
*,INT32
,INT32
,INT32
,INT32
);
166 INT32 (*pIntersectVisRect
)(DC
*,INT32
,INT32
,INT32
,INT32
);
167 BOOL32 (*pInvertRgn
)(DC
*,HRGN32
);
168 BOOL32 (*pLineTo
)(DC
*,INT32
,INT32
);
169 BOOL32 (*pMoveToEx
)(DC
*,INT32
,INT32
,LPPOINT32
);
170 INT32 (*pOffsetClipRgn
)(DC
*,INT32
,INT32
);
171 BOOL32 (*pOffsetViewportOrgEx
)(DC
*,INT32
,INT32
,LPPOINT32
);
172 BOOL32 (*pOffsetWindowOrgEx
)(DC
*,INT32
,INT32
,LPPOINT32
);
173 BOOL32 (*pPaintRgn
)(DC
*,HRGN32
);
174 BOOL32 (*pPatBlt
)(DC
*,INT32
,INT32
,INT32
,INT32
,DWORD
);
175 BOOL32 (*pPie
)(DC
*,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
);
176 BOOL32 (*pPolyPolygon
)(DC
*,LPPOINT32
,LPINT32
,UINT32
);
177 BOOL32 (*pPolygon
)(DC
*,LPPOINT32
,INT32
);
178 BOOL32 (*pPolyline
)(DC
*,LPPOINT32
,INT32
);
179 UINT32 (*pRealizePalette
)(DC
*);
180 BOOL32 (*pRectangle
)(DC
*,INT32
,INT32
,INT32
,INT32
);
181 BOOL32 (*pRestoreDC
)(DC
*,INT32
);
182 BOOL32 (*pRoundRect
)(DC
*,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
);
183 INT32 (*pSaveDC
)(DC
*);
184 BOOL32 (*pScaleViewportExtEx
)(DC
*,INT32
,INT32
,INT32
,INT32
,LPSIZE32
);
185 BOOL32 (*pScaleWindowExtEx
)(DC
*,INT32
,INT32
,INT32
,INT32
,LPSIZE32
);
186 INT32 (*pSelectClipRgn
)(DC
*,HRGN32
);
187 HANDLE32 (*pSelectObject
)(DC
*,HANDLE32
);
188 HPALETTE32 (*pSelectPalette
)(DC
*,HPALETTE32
,BOOL32
);
189 COLORREF (*pSetBkColor
)(DC
*,COLORREF
);
190 WORD (*pSetBkMode
)(DC
*,WORD
);
191 VOID (*pSetDeviceClipping
)(DC
*);
192 INT32 (*pSetDIBitsToDevice
)(DC
*,INT32
,INT32
,DWORD
,DWORD
,INT32
,INT32
,UINT32
,UINT32
,LPCVOID
,const BITMAPINFO
*,UINT32
);
193 WORD (*pSetMapMode
)(DC
*,WORD
);
194 DWORD (*pSetMapperFlags
)(DC
*,DWORD
);
195 COLORREF (*pSetPixel
)(DC
*,INT32
,INT32
,COLORREF
);
196 WORD (*pSetPolyFillMode
)(DC
*,WORD
);
197 WORD (*pSetROP2
)(DC
*,WORD
);
198 WORD (*pSetRelAbs
)(DC
*,WORD
);
199 WORD (*pSetStretchBltMode
)(DC
*,WORD
);
200 WORD (*pSetTextAlign
)(DC
*,WORD
);
201 INT32 (*pSetTextCharacterExtra
)(DC
*,INT32
);
202 DWORD (*pSetTextColor
)(DC
*,DWORD
);
203 INT32 (*pSetTextJustification
)(DC
*,INT32
,INT32
);
204 BOOL32 (*pSetViewportExtEx
)(DC
*,INT32
,INT32
,LPSIZE32
);
205 BOOL32 (*pSetViewportOrgEx
)(DC
*,INT32
,INT32
,LPPOINT32
);
206 BOOL32 (*pSetWindowExtEx
)(DC
*,INT32
,INT32
,LPSIZE32
);
207 BOOL32 (*pSetWindowOrgEx
)(DC
*,INT32
,INT32
,LPPOINT32
);
208 BOOL32 (*pStretchBlt
)(DC
*,INT32
,INT32
,INT32
,INT32
,DC
*,INT32
,INT32
,INT32
,INT32
,DWORD
);
209 INT32 (*pStretchDIBits
)(DC
*,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,LPSTR
,LPBITMAPINFO
,WORD
,DWORD
);
210 BOOL32 (*pTextOut
)(DC
*,INT32
,INT32
,LPCSTR
,INT32
);
214 #define DCHC_INVALIDVISRGN 0x0001
215 #define DCHC_DELETEDC 0x0002
217 #define DCHF_INVALIDATEVISRGN 0x0001
218 #define DCHF_VALIDATEVISRGN 0x0002
221 #define DC_MEMORY 0x0001 /* It is a memory DC */
222 #define DC_SAVED 0x0002 /* It is a saved DC */
223 #define DC_DIRTY 0x0004 /* hVisRgn has to be updated */
224 #define DC_THUNKHOOK 0x0008 /* DC hook is in the 16-bit code */
226 /* Last 32 bytes are reserved for stock object handles */
227 #define GDI_HEAP_SIZE 0xffe0
229 /* First handle possible for stock objects (must be >= GDI_HEAP_SIZE) */
230 #define FIRST_STOCK_HANDLE GDI_HEAP_SIZE
232 /* Stock objects handles */
234 #define NB_STOCK_OBJECTS (SYSTEM_FIXED_FONT + 1)
236 #define STOCK_WHITE_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+WHITE_BRUSH))
237 #define STOCK_LTGRAY_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+LTGRAY_BRUSH))
238 #define STOCK_GRAY_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+GRAY_BRUSH))
239 #define STOCK_DKGRAY_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+DKGRAY_BRUSH))
240 #define STOCK_BLACK_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+BLACK_BRUSH))
241 #define STOCK_NULL_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+NULL_BRUSH))
242 #define STOCK_HOLLOW_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+HOLLOW_BRUSH))
243 #define STOCK_WHITE_PEN ((HPEN16)(FIRST_STOCK_HANDLE+WHITE_PEN))
244 #define STOCK_BLACK_PEN ((HPEN16)(FIRST_STOCK_HANDLE+BLACK_PEN))
245 #define STOCK_NULL_PEN ((HPEN16)(FIRST_STOCK_HANDLE+NULL_PEN))
246 #define STOCK_OEM_FIXED_FONT ((HFONT16)(FIRST_STOCK_HANDLE+OEM_FIXED_FONT))
247 #define STOCK_ANSI_FIXED_FONT ((HFONT16)(FIRST_STOCK_HANDLE+ANSI_FIXED_FONT))
248 #define STOCK_ANSI_VAR_FONT ((HFONT16)(FIRST_STOCK_HANDLE+ANSI_VAR_FONT))
249 #define STOCK_SYSTEM_FONT ((HFONT16)(FIRST_STOCK_HANDLE+SYSTEM_FONT))
250 #define STOCK_DEVICE_DEFAULT_FONT ((HFONT16)(FIRST_STOCK_HANDLE+DEVICE_DEFAULT_FONT))
251 #define STOCK_DEFAULT_PALETTE ((HPALETTE16)(FIRST_STOCK_HANDLE+DEFAULT_PALETTE))
252 #define STOCK_SYSTEM_FIXED_FONT ((HFONT16)(FIRST_STOCK_HANDLE+SYSTEM_FIXED_FONT))
254 #define FIRST_STOCK_FONT STOCK_OEM_FIXED_FONT
255 #define LAST_STOCK_FONT STOCK_SYSTEM_FIXED_FONT
257 #define LAST_STOCK_HANDLE ((DWORD)STOCK_SYSTEM_FIXED_FONT)
259 /* Device <-> logical coords conversion */
261 #define XDPTOLP(dc,x) \
262 (((x)-(dc)->w.VportOrgX) * (dc)->w.WndExtX / (dc)->w.VportExtX+(dc)->w.WndOrgX)
263 #define YDPTOLP(dc,y) \
264 (((y)-(dc)->w.VportOrgY) * (dc)->w.WndExtY / (dc)->w.VportExtY+(dc)->w.WndOrgY)
265 #define XLPTODP(dc,x) \
266 (((x)-(dc)->w.WndOrgX) * (dc)->w.VportExtX / (dc)->w.WndExtX+(dc)->w.VportOrgX)
267 #define YLPTODP(dc,y) \
268 (((y)-(dc)->w.WndOrgY) * (dc)->w.VportExtY / (dc)->w.WndExtY+(dc)->w.VportOrgY)
273 extern WORD GDI_HeapSel
;
275 #define GDI_HEAP_ALLOC(size) \
276 LOCAL_Alloc( GDI_HeapSel, LMEM_FIXED, (size) )
277 #define GDI_HEAP_REALLOC(handle,size) \
278 LOCAL_ReAlloc( GDI_HeapSel, (handle), (size), LMEM_FIXED )
279 #define GDI_HEAP_FREE(handle) \
280 LOCAL_Free( GDI_HeapSel, (handle) )
281 #define GDI_HEAP_LIN_ADDR(handle) \
282 ((handle) ? PTR_SEG_OFF_TO_LIN(GDI_HeapSel, (handle)) : NULL)
283 #define GDI_HEAP_SEG_ADDR(handle) \
284 ((handle) ? PTR_SEG_OFF_TO_SEGPTR(GDI_HeapSel, (handle)) : (SEGPTR)0)
286 extern BOOL32
GDI_Init(void);
287 extern HGDIOBJ16
GDI_AllocObject( WORD
, WORD
);
288 extern BOOL32
GDI_FreeObject( HGDIOBJ16
);
289 extern GDIOBJHDR
* GDI_GetObjPtr( HGDIOBJ16
, WORD
);
291 extern BOOL32
DRIVER_RegisterDriver( LPCSTR name
, const DC_FUNCTIONS
*funcs
);
292 extern const DC_FUNCTIONS
*DRIVER_FindDriver( LPCSTR name
);
293 extern BOOL32
DRIVER_UnregisterDriver( LPCSTR name
);
295 extern Display
* display
;
296 extern Screen
* screen
;
297 extern Window rootWindow
;
298 extern int screenWidth
, screenHeight
, screenDepth
;
299 extern int desktopX
, desktopY
; /* misc/main.c */