Release 960712
[wine] / include / gdi.h
1 /*
2  * GDI definitions
3  *
4  * Copyright 1993 Alexandre Julliard
5  */
6
7 #ifndef GDI_H
8 #define GDI_H
9
10 #include <X11/Xlib.h>
11 #include <X11/Xutil.h>
12
13 #include "windows.h"
14 #include "ldt.h"
15 #include "local.h"
16
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
30
31 typedef struct tagGDIOBJHDR
32 {
33     HANDLE16    hNext;
34     WORD        wMagic;
35     DWORD       dwCount;
36     WORD        wMetaList;
37 } GDIOBJHDR;
38
39
40 typedef struct
41 {
42     WORD   version;       /*   0: driver version */
43     WORD   technology;    /*   2: device technology */
44     WORD   horzSize;      /*   4: width of display in mm */
45     WORD   vertSize;      /*   6: height of display in mm */
46     WORD   horzRes;       /*   8: width of display in pixels */
47     WORD   vertRes;       /*  10: width of display in pixels */
48     WORD   bitsPixel;     /*  12: bits per pixel */
49     WORD   planes;        /*  14: color planes */
50     WORD   numBrushes;    /*  16: device-specific brushes */
51     WORD   numPens;       /*  18: device-specific pens */
52     WORD   numMarkers;    /*  20: device-specific markers */
53     WORD   numFonts;      /*  22: device-specific fonts */
54     WORD   numColors;     /*  24: size of color table */
55     WORD   pdeviceSize;   /*  26: size of PDEVICE structure */
56     WORD   curveCaps;     /*  28: curve capabilities */
57     WORD   lineCaps;      /*  30: line capabilities */
58     WORD   polygonalCaps; /*  32: polygon capabilities */
59     WORD   textCaps;      /*  34: text capabilities */
60     WORD   clipCaps;      /*  36: clipping capabilities */
61     WORD   rasterCaps;    /*  38: raster capabilities */
62     WORD   aspectX;       /*  40: relative width of device pixel */
63     WORD   aspectY;       /*  42: relative height of device pixel */
64     WORD   aspectXY;      /*  44: relative diagonal width of device pixel */
65     WORD   pad1[21];      /*  46-86: reserved */
66     WORD   logPixelsX;    /*  88: pixels / logical X inch */
67     WORD   logPixelsY;    /*  90: pixels / logical Y inch */
68     WORD   pad2[6];       /*  92-102: reserved */
69     WORD   sizePalette;   /* 104: entries in system palette */
70     WORD   numReserved;   /* 106: reserved entries */
71     WORD   colorRes;      /* 108: color resolution */    
72 } DeviceCaps;
73
74   /* Device independent DC information */
75 typedef struct
76 {
77     int           flags;
78     DeviceCaps   *devCaps;
79
80     HANDLE16      hMetaFile;
81     HRGN16        hClipRgn;     /* Clip region (may be 0) */
82     HRGN16        hVisRgn;      /* Visible region (must never be 0) */
83     HRGN16        hGCClipRgn;   /* GC clip region (ClipRgn AND VisRgn) */
84     HPEN16        hPen;
85     HBRUSH16      hBrush;
86     HFONT16       hFont;
87     HBITMAP16     hBitmap;
88     HBITMAP16     hFirstBitmap; /* Bitmap selected at creation of the DC */
89     HANDLE16      hDevice;
90     HPALETTE16    hPalette;
91
92     WORD          ROPmode;
93     WORD          polyFillMode;
94     WORD          stretchBltMode;
95     WORD          relAbsMode;
96     WORD          backgroundMode;
97     COLORREF      backgroundColor;
98     COLORREF      textColor;
99     int           backgroundPixel;
100     int           textPixel;
101     short         brushOrgX;
102     short         brushOrgY;
103
104     WORD          textAlign;         /* Text alignment from SetTextAlign() */
105     short         charExtra;         /* Spacing from SetTextCharacterExtra() */
106     short         breakTotalExtra;   /* Total extra space for justification */
107     short         breakCount;        /* Break char. count */
108     short         breakExtra;        /* breakTotalExtra / breakCount */
109     short         breakRem;          /* breakTotalExtra % breakCount */
110
111     BYTE          bitsPerPixel;
112
113     WORD          MapMode;
114     short         DCOrgX;            /* DC origin */
115     short         DCOrgY;
116     short         CursPosX;          /* Current position */
117     short         CursPosY;
118     short         WndOrgX;
119     short         WndOrgY;
120     short         WndExtX;
121     short         WndExtY;
122     short         VportOrgX;
123     short         VportOrgY;
124     short         VportExtX;
125     short         VportExtY;
126 } WIN_DC_INFO;
127
128
129   /* X physical pen */
130 typedef struct
131 {
132     int          style;
133     int          pixel;
134     int          width;
135     char *       dashes;
136     int          dash_len;
137 } X_PHYSPEN;
138
139   /* X physical brush */
140 typedef struct
141 {
142     int          style;
143     int          fillStyle;
144     int          pixel;
145     Pixmap       pixmap;
146 } X_PHYSBRUSH;
147
148   /* X physical font */
149 typedef struct
150 {
151     XFontStruct * fstruct;
152     TEXTMETRIC16  metrics;
153 } X_PHYSFONT;
154
155   /* X physical palette information */
156 typedef struct
157 {
158     HANDLE16  hMapping;     /* Color mapping table (or 0 for identity) */
159     HANDLE16  hRevMapping;  /* Reverse color mapping table */
160     WORD      mappingSize;
161 } X_PHYSPALETTE;
162
163   /* X-specific DC information */
164 typedef struct
165 {
166     GC            gc;          /* X Window GC */
167     Drawable      drawable;
168     X_PHYSFONT    font;
169     X_PHYSPEN     pen;
170     X_PHYSBRUSH   brush;
171     X_PHYSPALETTE pal;
172 } X_DC_INFO;
173
174
175 typedef struct tagDC
176 {
177     GDIOBJHDR     header;
178     WORD          saveLevel;
179     DWORD         dwHookData;
180     FARPROC16     hookProc;
181     HDC16         hSelf;
182     WIN_DC_INFO   w;
183     union
184     {
185         X_DC_INFO x;
186         /* other devices (e.g. printer) */
187     } u;
188 } DC;
189
190   /* DC hook codes */
191 #define DCHC_INVALIDVISRGN      0x0001
192 #define DCHC_DELETEDC           0x0002
193
194 #define DCHF_INVALIDATEVISRGN   0x0001
195 #define DCHF_VALIDATEVISRGN     0x0002
196
197   /* DC flags */
198 #define DC_MEMORY     0x0001   /* It is a memory DC */
199 #define DC_SAVED      0x0002   /* It is a saved DC */
200 #define DC_DIRTY      0x0004   /* hVisRgn has to be updated */
201 #define DC_THUNKHOOK  0x0008   /* DC hook is in the 16-bit code */ 
202
203   /* Last 32 bytes are reserved for stock object handles */
204 #define GDI_HEAP_SIZE               0xffe0
205
206   /* First handle possible for stock objects (must be >= GDI_HEAP_SIZE) */
207 #define FIRST_STOCK_HANDLE          GDI_HEAP_SIZE
208
209   /* Stock objects handles */
210
211 #define NB_STOCK_OBJECTS          (SYSTEM_FIXED_FONT + 1)
212
213 #define STOCK_WHITE_BRUSH         ((HBRUSH)(FIRST_STOCK_HANDLE+WHITE_BRUSH))
214 #define STOCK_LTGRAY_BRUSH        ((HBRUSH)(FIRST_STOCK_HANDLE+LTGRAY_BRUSH))
215 #define STOCK_GRAY_BRUSH          ((HBRUSH)(FIRST_STOCK_HANDLE+GRAY_BRUSH))
216 #define STOCK_DKGRAY_BRUSH        ((HBRUSH)(FIRST_STOCK_HANDLE+DKGRAY_BRUSH))
217 #define STOCK_BLACK_BRUSH         ((HBRUSH)(FIRST_STOCK_HANDLE+BLACK_BRUSH))
218 #define STOCK_NULL_BRUSH          ((HBRUSH)(FIRST_STOCK_HANDLE+NULL_BRUSH))
219 #define STOCK_HOLLOW_BRUSH        ((HBRUSH)(FIRST_STOCK_HANDLE+HOLLOW_BRUSH))
220 #define STOCK_WHITE_PEN           ((HPEN16)(FIRST_STOCK_HANDLE+WHITE_PEN))
221 #define STOCK_BLACK_PEN           ((HPEN16)(FIRST_STOCK_HANDLE+BLACK_PEN))
222 #define STOCK_NULL_PEN            ((HPEN16)(FIRST_STOCK_HANDLE+NULL_PEN))
223 #define STOCK_OEM_FIXED_FONT      ((HFONT)(FIRST_STOCK_HANDLE+OEM_FIXED_FONT))
224 #define STOCK_ANSI_FIXED_FONT     ((HFONT)(FIRST_STOCK_HANDLE+ANSI_FIXED_FONT))
225 #define STOCK_ANSI_VAR_FONT       ((HFONT)(FIRST_STOCK_HANDLE+ANSI_VAR_FONT))
226 #define STOCK_SYSTEM_FONT         ((HFONT)(FIRST_STOCK_HANDLE+SYSTEM_FONT))
227 #define STOCK_DEVICE_DEFAULT_FONT ((HFONT)(FIRST_STOCK_HANDLE+DEVICE_DEFAULT_FONT))
228 #define STOCK_DEFAULT_PALETTE     ((HPALETTE16)(FIRST_STOCK_HANDLE+DEFAULT_PALETTE))
229 #define STOCK_SYSTEM_FIXED_FONT   ((HFONT)(FIRST_STOCK_HANDLE+SYSTEM_FIXED_FONT))
230
231 #define FIRST_STOCK_FONT          STOCK_OEM_FIXED_FONT
232 #define LAST_STOCK_FONT           STOCK_SYSTEM_FIXED_FONT
233
234 #define LAST_STOCK_HANDLE         ((DWORD)STOCK_SYSTEM_FIXED_FONT)
235
236   /* Device <-> logical coords conversion */
237
238 #define XDPTOLP(dc,x) \
239 (((x)-(dc)->w.VportOrgX) * (dc)->w.WndExtX / (dc)->w.VportExtX+(dc)->w.WndOrgX)
240 #define YDPTOLP(dc,y) \
241 (((y)-(dc)->w.VportOrgY) * (dc)->w.WndExtY / (dc)->w.VportExtY+(dc)->w.WndOrgY)
242 #define XLPTODP(dc,x) \
243 (((x)-(dc)->w.WndOrgX) * (dc)->w.VportExtX / (dc)->w.WndExtX+(dc)->w.VportOrgX)
244 #define YLPTODP(dc,y) \
245 (((y)-(dc)->w.WndOrgY) * (dc)->w.VportExtY / (dc)->w.WndExtY+(dc)->w.VportOrgY)
246
247
248   /* GDI local heap */
249
250 extern WORD GDI_HeapSel;
251
252 #define GDI_HEAP_ALLOC(size) \
253             LOCAL_Alloc( GDI_HeapSel, LMEM_FIXED, (size) )
254 #define GDI_HEAP_REALLOC(handle,size) \
255             LOCAL_ReAlloc( GDI_HeapSel, (handle), (size), LMEM_FIXED )
256 #define GDI_HEAP_FREE(handle) \
257             LOCAL_Free( GDI_HeapSel, (handle) )
258 #define GDI_HEAP_LIN_ADDR(handle)  \
259          ((handle) ? PTR_SEG_OFF_TO_LIN(GDI_HeapSel, (handle)) : NULL)
260 #define GDI_HEAP_SEG_ADDR(handle)  \
261          ((handle) ? PTR_SEG_OFF_TO_SEGPTR(GDI_HeapSel, (handle)) : (SEGPTR)0)
262
263 extern BOOL32 GDI_Init(void);
264 extern HANDLE16 GDI_AllocObject( WORD, WORD );
265 extern BOOL32 GDI_FreeObject( HANDLE16 );
266 extern GDIOBJHDR * GDI_GetObjPtr( HANDLE16, WORD );
267 extern FARPROC16 GDI_GetDefDCHook(void);
268
269 extern Display * display;
270 extern Screen * screen;
271 extern Window rootWindow;
272 extern int screenWidth, screenHeight, screenDepth;
273 extern int desktopX, desktopY;   /* misc/main.c */
274
275 #endif  /* GDI_H */