4 * Copyright 1993 Alexandre Julliard
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
28 #define MAGIC_DONTCARE 0xffff
30 typedef struct tagGDIOBJHDR
46 #define OBJ_METAFILE 9
49 #define OBJ_ENHMETADC 12
50 #define OBJ_ENHMETAFILE 13
53 typedef struct tagDeviceCaps
55 WORD version
; /* 0: driver version */
56 WORD technology
; /* 2: device technology */
57 WORD horzSize
; /* 4: width of display in mm */
58 WORD vertSize
; /* 6: height of display in mm */
59 WORD horzRes
; /* 8: width of display in pixels */
60 WORD vertRes
; /* 10: width of display in pixels */
61 WORD bitsPixel
; /* 12: bits per pixel */
62 WORD planes
; /* 14: color planes */
63 WORD numBrushes
; /* 16: device-specific brushes */
64 WORD numPens
; /* 18: device-specific pens */
65 WORD numMarkers
; /* 20: device-specific markers */
66 WORD numFonts
; /* 22: device-specific fonts */
67 WORD numColors
; /* 24: size of color table */
68 WORD pdeviceSize
; /* 26: size of PDEVICE structure */
69 WORD curveCaps
; /* 28: curve capabilities */
70 WORD lineCaps
; /* 30: line capabilities */
71 WORD polygonalCaps
; /* 32: polygon capabilities */
72 WORD textCaps
; /* 34: text capabilities */
73 WORD clipCaps
; /* 36: clipping capabilities */
74 WORD rasterCaps
; /* 38: raster capabilities */
75 WORD aspectX
; /* 40: relative width of device pixel */
76 WORD aspectY
; /* 42: relative height of device pixel */
77 WORD aspectXY
; /* 44: relative diagonal width of device pixel */
78 WORD pad1
[21]; /* 46-86: reserved */
79 WORD logPixelsX
; /* 88: pixels / logical X inch */
80 WORD logPixelsY
; /* 90: pixels / logical Y inch */
81 WORD pad2
[6]; /* 92-102: reserved */
82 WORD sizePalette
; /* 104: entries in system palette */
83 WORD numReserved
; /* 106: reserved entries */
84 WORD colorRes
; /* 108: color resolution */
88 /* Device independent DC information */
92 const DeviceCaps
*devCaps
;
94 HRGN16 hClipRgn
; /* Clip region (may be 0) */
95 HRGN16 hVisRgn
; /* Visible region (must never be 0) */
96 HRGN16 hGCClipRgn
; /* GC clip region (ClipRgn AND VisRgn) */
101 HBITMAP16 hFirstBitmap
; /* Bitmap selected at creation of the DC */
112 COLORREF backgroundColor
;
119 WORD textAlign
; /* Text alignment from SetTextAlign() */
120 short charExtra
; /* Spacing from SetTextCharacterExtra() */
121 short breakTotalExtra
; /* Total extra space for justification */
122 short breakCount
; /* Break char. count */
123 short breakExtra
; /* breakTotalExtra / breakCount */
124 short breakRem
; /* breakTotalExtra % breakCount */
129 INT32 GraphicsMode
; /* Graphics mode */
130 INT32 DCOrgX
; /* DC origin */
132 INT32 CursPosX
; /* Current position */
135 BOOL32 UseWorldXform
; /* Should we use the world transform? */
136 /* (i.e. is it not equal to the */
137 /* identity transformation?) */
138 XFORM WorldXform
; /* World transform */
141 typedef X11DRV_PDEVICE X_DC_INFO
; /* Temporary */
146 HDC32 hSelf
; /* Handle to this DC */
147 const struct tagDC_FUNCS
*funcs
; /* DC function table */
148 void *physDev
; /* Physical device (driver-specific) */
153 INT32 wndOrgX
; /* Window origin */
155 INT32 wndExtX
; /* Window extent */
157 INT32 vportOrgX
; /* Viewport origin */
159 INT32 vportExtX
; /* Viewport extent */
166 /* other devices (e.g. printer) */
170 /* Device functions for the Wine driver interface */
171 typedef struct tagDC_FUNCS
173 BOOL32 (*pArc
)(DC
*,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
);
174 BOOL32 (*pBitBlt
)(DC
*,INT32
,INT32
,INT32
,INT32
,DC
*,INT32
,INT32
,DWORD
);
175 BOOL32 (*pChord
)(DC
*,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
);
176 BOOL32 (*pCreateDC
)(DC
*,LPCSTR
,LPCSTR
,LPCSTR
,const DEVMODE16
*);
177 BOOL32 (*pDeleteDC
)(DC
*);
178 BOOL32 (*pDeleteObject
)(HGDIOBJ16
);
179 BOOL32 (*pEllipse
)(DC
*,INT32
,INT32
,INT32
,INT32
);
180 BOOL32 (*pEnumDeviceFonts
)(DC
*,LPLOGFONT16
,DEVICEFONTENUMPROC
,LPARAM
);
181 INT32 (*pEscape
)(DC
*,INT32
,INT32
,SEGPTR
,SEGPTR
);
182 INT32 (*pExcludeClipRect
)(DC
*,INT32
,INT32
,INT32
,INT32
);
183 INT32 (*pExcludeVisRect
)(DC
*,INT32
,INT32
,INT32
,INT32
);
184 BOOL32 (*pExtFloodFill
)(DC
*,INT32
,INT32
,COLORREF
,UINT32
);
185 BOOL32 (*pExtTextOut
)(DC
*,INT32
,INT32
,UINT32
,const RECT32
*,LPCSTR
,UINT32
,const INT32
*);
186 BOOL32 (*pGetCharWidth
)(DC
*,UINT32
,UINT32
,LPINT32
);
187 COLORREF (*pGetPixel
)(DC
*,INT32
,INT32
);
188 BOOL32 (*pGetTextExtentPoint
)(DC
*,LPCSTR
,INT32
,LPSIZE32
);
189 BOOL32 (*pGetTextMetrics
)(DC
*,TEXTMETRIC32A
*);
190 INT32 (*pIntersectClipRect
)(DC
*,INT32
,INT32
,INT32
,INT32
);
191 INT32 (*pIntersectVisRect
)(DC
*,INT32
,INT32
,INT32
,INT32
);
192 BOOL32 (*pLineTo
)(DC
*,INT32
,INT32
);
193 BOOL32 (*pMoveToEx
)(DC
*,INT32
,INT32
,LPPOINT32
);
194 INT32 (*pOffsetClipRgn
)(DC
*,INT32
,INT32
);
195 BOOL32 (*pOffsetViewportOrg
)(DC
*,INT32
,INT32
);
196 BOOL32 (*pOffsetWindowOrg
)(DC
*,INT32
,INT32
);
197 BOOL32 (*pPaintRgn
)(DC
*,HRGN32
);
198 BOOL32 (*pPatBlt
)(DC
*,INT32
,INT32
,INT32
,INT32
,DWORD
);
199 BOOL32 (*pPie
)(DC
*,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
);
200 BOOL32 (*pPolyPolygon
)(DC
*,LPPOINT32
,LPINT32
,UINT32
);
201 BOOL32 (*pPolygon
)(DC
*,LPPOINT32
,INT32
);
202 BOOL32 (*pPolyline
)(DC
*,LPPOINT32
,INT32
);
203 UINT32 (*pRealizePalette
)(DC
*);
204 BOOL32 (*pRectangle
)(DC
*,INT32
,INT32
,INT32
,INT32
);
205 BOOL32 (*pRestoreDC
)(DC
*,INT32
);
206 BOOL32 (*pRoundRect
)(DC
*,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
);
207 INT32 (*pSaveDC
)(DC
*);
208 BOOL32 (*pScaleViewportExt
)(DC
*,INT32
,INT32
,INT32
,INT32
);
209 BOOL32 (*pScaleWindowExt
)(DC
*,INT32
,INT32
,INT32
,INT32
);
210 INT32 (*pSelectClipRgn
)(DC
*,HRGN32
);
211 HANDLE32 (*pSelectObject
)(DC
*,HANDLE32
);
212 HPALETTE32 (*pSelectPalette
)(DC
*,HPALETTE32
,BOOL32
);
213 COLORREF (*pSetBkColor
)(DC
*,COLORREF
);
214 WORD (*pSetBkMode
)(DC
*,WORD
);
215 VOID (*pSetDeviceClipping
)(DC
*);
216 INT32 (*pSetDIBitsToDevice
)(DC
*,INT32
,INT32
,DWORD
,DWORD
,INT32
,INT32
,UINT32
,UINT32
,LPCVOID
,const BITMAPINFO
*,UINT32
);
217 INT32 (*pSetMapMode
)(DC
*,INT32
);
218 DWORD (*pSetMapperFlags
)(DC
*,DWORD
);
219 COLORREF (*pSetPixel
)(DC
*,INT32
,INT32
,COLORREF
);
220 WORD (*pSetPolyFillMode
)(DC
*,WORD
);
221 WORD (*pSetROP2
)(DC
*,WORD
);
222 WORD (*pSetRelAbs
)(DC
*,WORD
);
223 WORD (*pSetStretchBltMode
)(DC
*,WORD
);
224 WORD (*pSetTextAlign
)(DC
*,WORD
);
225 INT32 (*pSetTextCharacterExtra
)(DC
*,INT32
);
226 DWORD (*pSetTextColor
)(DC
*,DWORD
);
227 INT32 (*pSetTextJustification
)(DC
*,INT32
,INT32
);
228 BOOL32 (*pSetViewportExt
)(DC
*,INT32
,INT32
);
229 BOOL32 (*pSetViewportOrg
)(DC
*,INT32
,INT32
);
230 BOOL32 (*pSetWindowExt
)(DC
*,INT32
,INT32
);
231 BOOL32 (*pSetWindowOrg
)(DC
*,INT32
,INT32
);
232 BOOL32 (*pStretchBlt
)(DC
*,INT32
,INT32
,INT32
,INT32
,DC
*,INT32
,INT32
,INT32
,INT32
,DWORD
);
233 INT32 (*pStretchDIBits
)(DC
*,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,INT32
,LPSTR
,LPBITMAPINFO
,WORD
,DWORD
);
237 #define DCHC_INVALIDVISRGN 0x0001
238 #define DCHC_DELETEDC 0x0002
240 #define DCHF_INVALIDATEVISRGN 0x0001
241 #define DCHF_VALIDATEVISRGN 0x0002
244 #define DC_MEMORY 0x0001 /* It is a memory DC */
245 #define DC_SAVED 0x0002 /* It is a saved DC */
246 #define DC_DIRTY 0x0004 /* hVisRgn has to be updated */
247 #define DC_THUNKHOOK 0x0008 /* DC hook is in the 16-bit code */
249 /* Last 32 bytes are reserved for stock object handles */
250 #define GDI_HEAP_SIZE 0xffe0
252 /* First handle possible for stock objects (must be >= GDI_HEAP_SIZE) */
253 #define FIRST_STOCK_HANDLE GDI_HEAP_SIZE
255 /* Stock objects handles */
257 #define NB_STOCK_OBJECTS (DEFAULT_GUI_FONT + 1)
259 #define STOCK_WHITE_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+WHITE_BRUSH))
260 #define STOCK_LTGRAY_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+LTGRAY_BRUSH))
261 #define STOCK_GRAY_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+GRAY_BRUSH))
262 #define STOCK_DKGRAY_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+DKGRAY_BRUSH))
263 #define STOCK_BLACK_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+BLACK_BRUSH))
264 #define STOCK_NULL_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+NULL_BRUSH))
265 #define STOCK_HOLLOW_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+HOLLOW_BRUSH))
266 #define STOCK_WHITE_PEN ((HPEN16)(FIRST_STOCK_HANDLE+WHITE_PEN))
267 #define STOCK_BLACK_PEN ((HPEN16)(FIRST_STOCK_HANDLE+BLACK_PEN))
268 #define STOCK_NULL_PEN ((HPEN16)(FIRST_STOCK_HANDLE+NULL_PEN))
269 #define STOCK_OEM_FIXED_FONT ((HFONT16)(FIRST_STOCK_HANDLE+OEM_FIXED_FONT))
270 #define STOCK_ANSI_FIXED_FONT ((HFONT16)(FIRST_STOCK_HANDLE+ANSI_FIXED_FONT))
271 #define STOCK_ANSI_VAR_FONT ((HFONT16)(FIRST_STOCK_HANDLE+ANSI_VAR_FONT))
272 #define STOCK_SYSTEM_FONT ((HFONT16)(FIRST_STOCK_HANDLE+SYSTEM_FONT))
273 #define STOCK_DEVICE_DEFAULT_FONT ((HFONT16)(FIRST_STOCK_HANDLE+DEVICE_DEFAULT_FONT))
274 #define STOCK_DEFAULT_PALETTE ((HPALETTE16)(FIRST_STOCK_HANDLE+DEFAULT_PALETTE))
275 #define STOCK_SYSTEM_FIXED_FONT ((HFONT16)(FIRST_STOCK_HANDLE+SYSTEM_FIXED_FONT))
276 #define STOCK_DEFAULT_GUI_FONT ((HFONT16)(FIRST_STOCK_HANDLE+DEFAULT_GUI_FONT))
278 #define FIRST_STOCK_FONT STOCK_OEM_FIXED_FONT
279 #define LAST_STOCK_FONT STOCK_DEFAULT_GUI_FONT
281 #define LAST_STOCK_HANDLE ((DWORD)STOCK_DEFAULT_GUI_FONT)
283 /* Device <-> logical coords conversion */
285 #define XDPTOLP(dc,x) \
286 (((x)-(dc)->vportOrgX) * (dc)->wndExtX / (dc)->vportExtX+(dc)->wndOrgX)
287 #define YDPTOLP(dc,y) \
288 (((y)-(dc)->vportOrgY) * (dc)->wndExtY / (dc)->vportExtY+(dc)->wndOrgY)
289 #define XLPTODP(dc,x) \
290 (((x)-(dc)->wndOrgX) * (dc)->vportExtX / (dc)->wndExtX+(dc)->vportOrgX)
291 #define YLPTODP(dc,y) \
292 (((y)-(dc)->wndOrgY) * (dc)->vportExtY / (dc)->wndExtY+(dc)->vportOrgY)
294 /* Device <-> logical size conversion */
296 #define XDSTOLS(dc,x) \
297 ((x) * (dc)->wndExtX / (dc)->vportExtX)
298 #define YDSTOLS(dc,y) \
299 ((y) * (dc)->wndExtY / (dc)->vportExtY)
300 #define XLSTODS(dc,x) \
301 ((x) * (dc)->vportExtX / (dc)->wndExtX)
302 #define YLSTODS(dc,y) \
303 ((y) * (dc)->vportExtY / (dc)->wndExtY)
307 extern WORD GDI_HeapSel
;
309 #define GDI_HEAP_ALLOC(size) \
310 LOCAL_Alloc( GDI_HeapSel, LMEM_FIXED, (size) )
311 #define GDI_HEAP_ALLOC_MOVEABLE(size) \
312 LOCAL_Alloc( GDI_HeapSel, LMEM_MOVEABLE, (size) )
313 #define GDI_HEAP_REALLOC(handle,size) \
314 LOCAL_ReAlloc( GDI_HeapSel, (handle), (size), LMEM_FIXED )
315 #define GDI_HEAP_FREE(handle) \
316 LOCAL_Free( GDI_HeapSel, (handle) )
318 #define GDI_HEAP_LOCK(handle) \
319 LOCAL_Lock( GDI_HeapSel, (handle) )
320 #define GDI_HEAP_LOCK_SEGPTR(handle) \
321 LOCAL_LockSegptr( GDI_HeapSel, (handle) )
322 #define GDI_HEAP_UNLOCK(handle) \
323 ((((HGDIOBJ16)(handle) >= FIRST_STOCK_HANDLE) && \
324 ((HGDIOBJ16)(handle)<=LAST_STOCK_HANDLE)) ? \
325 0 : LOCAL_Unlock( GDI_HeapSel, (handle) ))
327 extern BOOL32
GDI_Init(void);
328 extern HGDIOBJ16
GDI_AllocObject( WORD
, WORD
);
329 extern BOOL32
GDI_FreeObject( HGDIOBJ16
);
330 extern GDIOBJHDR
* GDI_GetObjPtr( HGDIOBJ16
, WORD
);
332 extern BOOL32
DRIVER_RegisterDriver( LPCSTR name
, const DC_FUNCTIONS
*funcs
);
333 extern const DC_FUNCTIONS
*DRIVER_FindDriver( LPCSTR name
);
334 extern BOOL32
DRIVER_UnregisterDriver( LPCSTR name
);
336 extern Display
* display
;
337 extern Screen
* screen
;
338 extern Window rootWindow
;
339 extern int screenWidth
, screenHeight
, screenDepth
;
341 #endif /* __WINE_GDI_H */