dinput: BuildActionMap and SetActionMap stubs for generic joystick.
[wine] / dlls / gdi32 / gdi_private.h
1 /*
2  * GDI definitions
3  *
4  * Copyright 1993 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #ifndef __WINE_GDI_PRIVATE_H
22 #define __WINE_GDI_PRIVATE_H
23
24 #include <math.h>
25 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "wine/gdi_driver.h"
30
31 /* Metafile defines */
32 #define META_EOF 0x0000
33 /* values of mtType in METAHEADER.  Note however that the disk image of a disk
34    based metafile has mtType == 1 */
35 #define METAFILE_MEMORY 1
36 #define METAFILE_DISK   2
37 #define MFHEADERSIZE (sizeof(METAHEADER))
38 #define MFVERSION 0x300
39
40 typedef struct {
41     EMR   emr;
42     INT   nBreakExtra;
43     INT   nBreakCount;
44 } EMRSETTEXTJUSTIFICATION, *PEMRSETTEXTJUSTIFICATION;
45
46 /* extra stock object: default 1x1 bitmap for memory DCs */
47 #define DEFAULT_BITMAP (STOCK_LAST+1)
48
49 struct gdi_obj_funcs
50 {
51     HGDIOBJ (*pSelectObject)( HGDIOBJ handle, HDC hdc );
52     INT     (*pGetObjectA)( HGDIOBJ handle, INT count, LPVOID buffer );
53     INT     (*pGetObjectW)( HGDIOBJ handle, INT count, LPVOID buffer );
54     BOOL    (*pUnrealizeObject)( HGDIOBJ handle );
55     BOOL    (*pDeleteObject)( HGDIOBJ handle );
56 };
57
58 struct hdc_list
59 {
60     HDC hdc;
61     struct hdc_list *next;
62 };
63
64 typedef struct tagGDIOBJHDR
65 {
66     WORD        type;         /* object type (one of the OBJ_* constants) */
67     WORD        system : 1;   /* system object flag */
68     WORD        deleted : 1;  /* whether DeleteObject has been called on this object */
69     DWORD       selcount;     /* number of times the object is selected in a DC */
70     const struct gdi_obj_funcs *funcs;
71     struct hdc_list *hdcs;
72 } GDIOBJHDR;
73
74 /* Device functions for the Wine driver interface */
75
76 typedef struct
77 {
78     int bit_count, width, height;
79     int stride; /* stride in bytes.  Will be -ve for bottom-up dibs (see bits). */
80     void *bits; /* points to the top-left corner of the dib. */
81
82     DWORD red_mask, green_mask, blue_mask;
83     int red_shift, green_shift, blue_shift;
84     int red_len, green_len, blue_len;
85
86     RGBQUAD *color_table;
87     DWORD color_table_size;
88
89     const struct primitive_funcs *funcs;
90 } dib_info;
91
92 typedef struct
93 {
94     DWORD count;
95     DWORD dashes[16]; /* 16 is the maximium number for a PS_USERSTYLE pen */
96     DWORD total_len;  /* total length of the dashes, should be multiplied by 2 if there are an odd number of dash lengths */
97 } dash_pattern;
98
99 typedef struct
100 {
101     int left_in_dash;
102     int cur_dash;
103     BOOL mark;
104 } dash_pos;
105
106 typedef struct
107 {
108     DWORD and;
109     DWORD xor;
110 } rop_mask;
111
112 typedef struct
113 {
114     void *and;
115     void *xor;
116 } rop_mask_bits;
117
118 typedef struct dibdrv_physdev
119 {
120     struct gdi_physdev dev;
121     dib_info dib;
122
123     HRGN clip;
124     DWORD defer;
125
126     /* pen */
127     COLORREF pen_colorref;
128     DWORD pen_color, pen_and, pen_xor;
129     dash_pattern pen_pattern;
130     dash_pos dash_pos;
131     BOOL   (* pen_line)(struct dibdrv_physdev *pdev, POINT *start, POINT *end);
132
133     /* brush */
134     UINT brush_style;
135     UINT brush_hatch;
136     INT brush_rop;   /* PatBlt, for example, can override the DC's rop2 */
137     COLORREF brush_colorref;
138     DWORD brush_color, brush_and, brush_xor;
139     dib_info brush_dib;
140     void *brush_and_bits, *brush_xor_bits;
141     BOOL   (* brush_rects)(struct dibdrv_physdev *pdev, int num, RECT *rects);
142
143     /* background */
144     DWORD bkgnd_color, bkgnd_and, bkgnd_xor;
145 } dibdrv_physdev;
146
147 #define DEFER_FORMAT     1
148 #define DEFER_PEN        2
149 #define DEFER_BRUSH      4
150
151 typedef struct gdi_dc_funcs
152 {
153     INT      (CDECL *pAbortDoc)(PHYSDEV);
154     BOOL     (CDECL *pAbortPath)(PHYSDEV);
155     BOOL     (CDECL *pAlphaBlend)(PHYSDEV,struct bitblt_coords*,PHYSDEV,struct bitblt_coords*,BLENDFUNCTION);
156     BOOL     (CDECL *pAngleArc)(PHYSDEV,INT,INT,DWORD,FLOAT,FLOAT);
157     BOOL     (CDECL *pArc)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
158     BOOL     (CDECL *pArcTo)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
159     BOOL     (CDECL *pBeginPath)(PHYSDEV);
160     INT      (CDECL *pChoosePixelFormat)(PHYSDEV,const PIXELFORMATDESCRIPTOR *);
161     BOOL     (CDECL *pChord)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
162     BOOL     (CDECL *pCloseFigure)(PHYSDEV);
163     BOOL     (CDECL *pCreateBitmap)(PHYSDEV,HBITMAP,LPVOID);
164     BOOL     (CDECL *pCreateDC)(HDC,PHYSDEV *,LPCWSTR,LPCWSTR,LPCWSTR,const DEVMODEW*);
165     HBITMAP  (CDECL *pCreateDIBSection)(PHYSDEV,HBITMAP,const BITMAPINFO *,UINT);
166     BOOL     (CDECL *pDeleteBitmap)(HBITMAP);
167     BOOL     (CDECL *pDeleteDC)(PHYSDEV);
168     BOOL     (CDECL *pDeleteObject)(PHYSDEV,HGDIOBJ);
169     INT      (CDECL *pDescribePixelFormat)(PHYSDEV,INT,UINT,PIXELFORMATDESCRIPTOR *);
170     DWORD    (CDECL *pDeviceCapabilities)(LPSTR,LPCSTR,LPCSTR,WORD,LPSTR,LPDEVMODEA);
171     BOOL     (CDECL *pEllipse)(PHYSDEV,INT,INT,INT,INT);
172     INT      (CDECL *pEndDoc)(PHYSDEV);
173     INT      (CDECL *pEndPage)(PHYSDEV);
174     BOOL     (CDECL *pEndPath)(PHYSDEV);
175     BOOL     (CDECL *pEnumDeviceFonts)(PHYSDEV,LPLOGFONTW,FONTENUMPROCW,LPARAM);
176     INT      (CDECL *pEnumICMProfiles)(PHYSDEV,ICMENUMPROCW,LPARAM);
177     INT      (CDECL *pExcludeClipRect)(PHYSDEV,INT,INT,INT,INT);
178     INT      (CDECL *pExtDeviceMode)(LPSTR,HWND,LPDEVMODEA,LPSTR,LPSTR,LPDEVMODEA,LPSTR,DWORD);
179     INT      (CDECL *pExtEscape)(PHYSDEV,INT,INT,LPCVOID,INT,LPVOID);
180     BOOL     (CDECL *pExtFloodFill)(PHYSDEV,INT,INT,COLORREF,UINT);
181     INT      (CDECL *pExtSelectClipRgn)(PHYSDEV,HRGN,INT);
182     BOOL     (CDECL *pExtTextOut)(PHYSDEV,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*);
183     BOOL     (CDECL *pFillPath)(PHYSDEV);
184     BOOL     (CDECL *pFillRgn)(PHYSDEV,HRGN,HBRUSH);
185     BOOL     (CDECL *pFlattenPath)(PHYSDEV);
186     BOOL     (CDECL *pFrameRgn)(PHYSDEV,HRGN,HBRUSH,INT,INT);
187     BOOL     (CDECL *pGdiComment)(PHYSDEV,UINT,CONST BYTE*);
188     LONG     (CDECL *pGetBitmapBits)(HBITMAP,void*,LONG);
189     BOOL     (CDECL *pGetCharWidth)(PHYSDEV,UINT,UINT,LPINT);
190     INT      (CDECL *pGetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPVOID,BITMAPINFO*,UINT);
191     INT      (CDECL *pGetDeviceCaps)(PHYSDEV,INT);
192     BOOL     (CDECL *pGetDeviceGammaRamp)(PHYSDEV,LPVOID);
193     BOOL     (CDECL *pGetICMProfile)(PHYSDEV,LPDWORD,LPWSTR);
194     COLORREF (CDECL *pGetNearestColor)(PHYSDEV,COLORREF);
195     COLORREF (CDECL *pGetPixel)(PHYSDEV,INT,INT);
196     INT      (CDECL *pGetPixelFormat)(PHYSDEV);
197     UINT     (CDECL *pGetSystemPaletteEntries)(PHYSDEV,UINT,UINT,LPPALETTEENTRY);
198     BOOL     (CDECL *pGetTextExtentExPoint)(PHYSDEV,LPCWSTR,INT,INT,LPINT,LPINT,LPSIZE);
199     BOOL     (CDECL *pGetTextMetrics)(PHYSDEV,TEXTMETRICW*);
200     INT      (CDECL *pIntersectClipRect)(PHYSDEV,INT,INT,INT,INT);
201     BOOL     (CDECL *pInvertRgn)(PHYSDEV,HRGN);
202     BOOL     (CDECL *pLineTo)(PHYSDEV,INT,INT);
203     BOOL     (CDECL *pModifyWorldTransform)(PHYSDEV,const XFORM*,DWORD);
204     BOOL     (CDECL *pMoveTo)(PHYSDEV,INT,INT);
205     INT      (CDECL *pOffsetClipRgn)(PHYSDEV,INT,INT);
206     BOOL     (CDECL *pOffsetViewportOrgEx)(PHYSDEV,INT,INT,POINT*);
207     BOOL     (CDECL *pOffsetWindowOrgEx)(PHYSDEV,INT,INT,POINT*);
208     BOOL     (CDECL *pPaintRgn)(PHYSDEV,HRGN);
209     BOOL     (CDECL *pPatBlt)(PHYSDEV,struct bitblt_coords*,DWORD);
210     BOOL     (CDECL *pPie)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
211     BOOL     (CDECL *pPolyBezier)(PHYSDEV,const POINT*,DWORD);
212     BOOL     (CDECL *pPolyBezierTo)(PHYSDEV,const POINT*,DWORD);
213     BOOL     (CDECL *pPolyDraw)(PHYSDEV,const POINT*,const BYTE *,DWORD);
214     BOOL     (CDECL *pPolyPolygon)(PHYSDEV,const POINT*,const INT*,UINT);
215     BOOL     (CDECL *pPolyPolyline)(PHYSDEV,const POINT*,const DWORD*,DWORD);
216     BOOL     (CDECL *pPolygon)(PHYSDEV,const POINT*,INT);
217     BOOL     (CDECL *pPolyline)(PHYSDEV,const POINT*,INT);
218     BOOL     (CDECL *pPolylineTo)(PHYSDEV,const POINT*,INT);
219     UINT     (CDECL *pRealizeDefaultPalette)(PHYSDEV);
220     UINT     (CDECL *pRealizePalette)(PHYSDEV,HPALETTE,BOOL);
221     BOOL     (CDECL *pRectangle)(PHYSDEV,INT,INT,INT,INT);
222     HDC      (CDECL *pResetDC)(PHYSDEV,const DEVMODEW*);
223     BOOL     (CDECL *pRestoreDC)(PHYSDEV,INT);
224     BOOL     (CDECL *pRoundRect)(PHYSDEV,INT,INT,INT,INT,INT,INT);
225     INT      (CDECL *pSaveDC)(PHYSDEV);
226     BOOL     (CDECL *pScaleViewportExtEx)(PHYSDEV,INT,INT,INT,INT,SIZE*);
227     BOOL     (CDECL *pScaleWindowExtEx)(PHYSDEV,INT,INT,INT,INT,SIZE*);
228     HBITMAP  (CDECL *pSelectBitmap)(PHYSDEV,HBITMAP);
229     HBRUSH   (CDECL *pSelectBrush)(PHYSDEV,HBRUSH);
230     BOOL     (CDECL *pSelectClipPath)(PHYSDEV,INT);
231     HFONT    (CDECL *pSelectFont)(PHYSDEV,HFONT,HANDLE);
232     HPALETTE (CDECL *pSelectPalette)(PHYSDEV,HPALETTE,BOOL);
233     HPEN     (CDECL *pSelectPen)(PHYSDEV,HPEN);
234     INT      (CDECL *pSetArcDirection)(PHYSDEV,INT);
235     LONG     (CDECL *pSetBitmapBits)(HBITMAP,const void*,LONG);
236     COLORREF (CDECL *pSetBkColor)(PHYSDEV,COLORREF);
237     INT      (CDECL *pSetBkMode)(PHYSDEV,INT);
238     COLORREF (CDECL *pSetDCBrushColor)(PHYSDEV, COLORREF);
239     COLORREF (CDECL *pSetDCPenColor)(PHYSDEV, COLORREF);
240     UINT     (CDECL *pSetDIBColorTable)(PHYSDEV,UINT,UINT,const RGBQUAD*);
241     INT      (CDECL *pSetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPCVOID,const BITMAPINFO*,UINT);
242     INT      (CDECL *pSetDIBitsToDevice)(PHYSDEV,INT,INT,DWORD,DWORD,INT,INT,UINT,UINT,LPCVOID,
243                                            const BITMAPINFO*,UINT);
244     VOID     (CDECL *pSetDeviceClipping)(PHYSDEV,HRGN,HRGN);
245     BOOL     (CDECL *pSetDeviceGammaRamp)(PHYSDEV,LPVOID);
246     DWORD    (CDECL *pSetLayout)(PHYSDEV,DWORD);
247     INT      (CDECL *pSetMapMode)(PHYSDEV,INT);
248     DWORD    (CDECL *pSetMapperFlags)(PHYSDEV,DWORD);
249     COLORREF (CDECL *pSetPixel)(PHYSDEV,INT,INT,COLORREF);
250     BOOL     (CDECL *pSetPixelFormat)(PHYSDEV,INT,const PIXELFORMATDESCRIPTOR *);
251     INT      (CDECL *pSetPolyFillMode)(PHYSDEV,INT);
252     INT      (CDECL *pSetROP2)(PHYSDEV,INT);
253     INT      (CDECL *pSetRelAbs)(PHYSDEV,INT);
254     INT      (CDECL *pSetStretchBltMode)(PHYSDEV,INT);
255     UINT     (CDECL *pSetTextAlign)(PHYSDEV,UINT);
256     INT      (CDECL *pSetTextCharacterExtra)(PHYSDEV,INT);
257     COLORREF (CDECL *pSetTextColor)(PHYSDEV,COLORREF);
258     BOOL     (CDECL *pSetTextJustification)(PHYSDEV,INT,INT);
259     BOOL     (CDECL *pSetViewportExtEx)(PHYSDEV,INT,INT,SIZE*);
260     BOOL     (CDECL *pSetViewportOrgEx)(PHYSDEV,INT,INT,POINT*);
261     BOOL     (CDECL *pSetWindowExtEx)(PHYSDEV,INT,INT,SIZE*);
262     BOOL     (CDECL *pSetWindowOrgEx)(PHYSDEV,INT,INT,POINT*);
263     BOOL     (CDECL *pSetWorldTransform)(PHYSDEV,const XFORM*);
264     INT      (CDECL *pStartDoc)(PHYSDEV,const DOCINFOW*);
265     INT      (CDECL *pStartPage)(PHYSDEV);
266     BOOL     (CDECL *pStretchBlt)(PHYSDEV,struct bitblt_coords*,PHYSDEV,struct bitblt_coords*,DWORD);
267     INT      (CDECL *pStretchDIBits)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT,const void *,
268                                        const BITMAPINFO*,UINT,DWORD);
269     BOOL     (CDECL *pStrokeAndFillPath)(PHYSDEV);
270     BOOL     (CDECL *pStrokePath)(PHYSDEV);
271     BOOL     (CDECL *pSwapBuffers)(PHYSDEV);
272     BOOL     (CDECL *pUnrealizePalette)(HPALETTE);
273     BOOL     (CDECL *pWidenPath)(PHYSDEV);
274
275     /* OpenGL32 */
276     BOOL     (CDECL *pwglCopyContext)(HGLRC, HGLRC, UINT);
277     HGLRC    (CDECL *pwglCreateContext)(PHYSDEV);
278     HGLRC    (CDECL *pwglCreateContextAttribsARB)(PHYSDEV, HGLRC, const int*);
279     BOOL     (CDECL *pwglDeleteContext)(HGLRC);
280     PROC     (CDECL *pwglGetProcAddress)(LPCSTR);
281     HDC      (CDECL *pwglGetPbufferDCARB)(PHYSDEV, void*);
282     BOOL     (CDECL *pwglMakeCurrent)(PHYSDEV, HGLRC);
283     BOOL     (CDECL *pwglMakeContextCurrentARB)(PHYSDEV, PHYSDEV, HGLRC);
284     BOOL     (CDECL *pwglSetPixelFormatWINE)(PHYSDEV,INT,const PIXELFORMATDESCRIPTOR *);
285     BOOL     (CDECL *pwglShareLists)(HGLRC hglrc1, HGLRC hglrc2);
286     BOOL     (CDECL *pwglUseFontBitmapsA)(PHYSDEV, DWORD, DWORD, DWORD);
287     BOOL     (CDECL *pwglUseFontBitmapsW)(PHYSDEV, DWORD, DWORD, DWORD);
288 } DC_FUNCTIONS;
289
290 /* It should not be necessary to access the contents of the GdiPath
291  * structure directly; if you find that the exported functions don't
292  * allow you to do what you want, then please place a new exported
293  * function that does this job in path.c.
294  */
295 typedef enum tagGdiPathState
296 {
297    PATH_Null,
298    PATH_Open,
299    PATH_Closed
300 } GdiPathState;
301
302 typedef struct tagGdiPath
303 {
304    GdiPathState state;
305    POINT      *pPoints;
306    BYTE         *pFlags;
307    int          numEntriesUsed, numEntriesAllocated;
308    BOOL       newStroke;
309 } GdiPath;
310
311 typedef struct tagGdiFont GdiFont;
312
313 typedef struct tagDC
314 {
315     GDIOBJHDR    header;
316     HDC          hSelf;            /* Handle to this DC */
317     struct gdi_physdev nulldrv;    /* physdev for the null driver */
318     struct dibdrv_physdev dibdrv;  /* physdev for the dib driver */
319     PHYSDEV      physDev;         /* Physical device (driver-specific) */
320     DWORD        thread;          /* thread owning the DC */
321     LONG         refcount;        /* thread refcount */
322     LONG         dirty;           /* dirty flag */
323     INT          saveLevel;
324     struct tagDC *saved_dc;
325     DWORD_PTR    dwHookData;
326     DCHOOKPROC   hookProc;         /* DC hook */
327
328     INT          wndOrgX;          /* Window origin */
329     INT          wndOrgY;
330     INT          wndExtX;          /* Window extent */
331     INT          wndExtY;
332     INT          vportOrgX;        /* Viewport origin */
333     INT          vportOrgY;
334     INT          vportExtX;        /* Viewport extent */
335     INT          vportExtY;
336     SIZE         virtual_res;      /* Initially HORZRES,VERTRES. Changed by SetVirtualResolution */
337     SIZE         virtual_size;     /* Initially HORZSIZE,VERTSIZE. Changed by SetVirtualResolution */
338     RECT         vis_rect;         /* visible rectangle in screen coords */
339     FLOAT        miterLimit;
340
341     int           flags;
342     DWORD         layout;
343     HRGN          hClipRgn;      /* Clip region (may be 0) */
344     HRGN          hMetaRgn;      /* Meta region (may be 0) */
345     HRGN          hMetaClipRgn;  /* Intersection of meta and clip regions (may be 0) */
346     HRGN          hVisRgn;       /* Visible region (must never be 0) */
347     HPEN          hPen;
348     HBRUSH        hBrush;
349     HFONT         hFont;
350     HBITMAP       hBitmap;
351     HANDLE        hDevice;
352     HPALETTE      hPalette;
353
354     GdiFont      *gdiFont;
355     GdiPath       path;
356
357     UINT          font_code_page;
358     WORD          ROPmode;
359     WORD          polyFillMode;
360     WORD          stretchBltMode;
361     WORD          relAbsMode;
362     WORD          backgroundMode;
363     COLORREF      backgroundColor;
364     COLORREF      textColor;
365     COLORREF      dcBrushColor;
366     COLORREF      dcPenColor;
367     short         brushOrgX;
368     short         brushOrgY;
369
370     DWORD         mapperFlags;       /* Font mapper flags */
371     WORD          textAlign;         /* Text alignment from SetTextAlign() */
372     INT           charExtra;         /* Spacing from SetTextCharacterExtra() */
373     INT           breakExtra;        /* breakTotalExtra / breakCount */
374     INT           breakRem;          /* breakTotalExtra % breakCount */
375     INT           MapMode;
376     INT           GraphicsMode;      /* Graphics mode */
377     ABORTPROC     pAbortProc;        /* AbortProc for Printing */
378     INT           CursPosX;          /* Current position */
379     INT           CursPosY;
380     INT           ArcDirection;
381     XFORM         xformWorld2Wnd;    /* World-to-window transformation */
382     XFORM         xformWorld2Vport;  /* World-to-viewport transformation */
383     XFORM         xformVport2World;  /* Inverse of the above transformation */
384     BOOL          vport2WorldValid;  /* Is xformVport2World valid? */
385     RECT          BoundsRect;        /* Current bounding rect */
386 } DC;
387
388   /* DC flags */
389 #define DC_BOUNDS_ENABLE 0x0008   /* Bounding rectangle tracking is enabled */
390 #define DC_BOUNDS_SET    0x0010   /* Bounding rectangle has been set */
391
392 /* Certain functions will do no further processing if the driver returns this.
393    Used by mfdrv for example. */
394 #define GDI_NO_MORE_WORK 2
395
396 /* Rounds a floating point number to integer. The world-to-viewport
397  * transformation process is done in floating point internally. This function
398  * is then used to round these coordinates to integer values.
399  */
400 static inline INT GDI_ROUND(double val)
401 {
402    return (int)floor(val + 0.5);
403 }
404
405 /* bitmap object */
406
407 typedef struct tagBITMAPOBJ
408 {
409     GDIOBJHDR           header;
410     BITMAP              bitmap;
411     SIZE                size;   /* For SetBitmapDimension() */
412     const DC_FUNCTIONS *funcs; /* DC function table */
413     /* For device-independent bitmaps: */
414     DIBSECTION         *dib;
415     RGBQUAD            *color_table;  /* DIB color table if <= 8bpp */
416     UINT                nb_colors;    /* number of colors in table */
417 } BITMAPOBJ;
418
419 /* bidi.c */
420
421 /* Wine_GCPW Flags */
422 /* Directionality -
423  * LOOSE means taking the directionality of the first strong character, if there is found one.
424  * FORCE means the paragraph direction is forced. (RLE/LRE)
425  */
426 #define WINE_GCPW_FORCE_LTR 0
427 #define WINE_GCPW_FORCE_RTL 1
428 #define WINE_GCPW_LOOSE_LTR 2
429 #define WINE_GCPW_LOOSE_RTL 3
430 #define WINE_GCPW_DIR_MASK 3
431 #define WINE_GCPW_LOOSE_MASK 2
432
433 extern BOOL BIDI_Reorder( HDC hDC, LPCWSTR lpString, INT uCount, DWORD dwFlags, DWORD dwWineGCP_Flags,
434                           LPWSTR lpOutString, INT uCountOut, UINT *lpOrder, WORD **lpGlyphs, INT* cGlyphs ) DECLSPEC_HIDDEN;
435
436 /* bitmap.c */
437 extern HBITMAP BITMAP_CopyBitmap( HBITMAP hbitmap ) DECLSPEC_HIDDEN;
438 extern BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, PHYSDEV physdev ) DECLSPEC_HIDDEN;
439 extern INT BITMAP_GetWidthBytes( INT bmWidth, INT bpp ) DECLSPEC_HIDDEN;
440
441 /* clipping.c */
442 extern int get_clip_box( DC *dc, RECT *rect ) DECLSPEC_HIDDEN;
443 extern void CLIPPING_UpdateGCRegion( DC * dc ) DECLSPEC_HIDDEN;
444
445 /* Return the total clip region (if any) */
446 static inline HRGN get_clip_region( DC * dc )
447 {
448     if (dc->hMetaClipRgn) return dc->hMetaClipRgn;
449     if (dc->hMetaRgn) return dc->hMetaRgn;
450     return dc->hClipRgn;
451 }
452
453 /* dc.c */
454 extern DC *alloc_dc_ptr( WORD magic ) DECLSPEC_HIDDEN;
455 extern void free_dc_ptr( DC *dc ) DECLSPEC_HIDDEN;
456 extern DC *get_dc_ptr( HDC hdc ) DECLSPEC_HIDDEN;
457 extern void release_dc_ptr( DC *dc ) DECLSPEC_HIDDEN;
458 extern void update_dc( DC *dc ) DECLSPEC_HIDDEN;
459 extern void push_dc_driver( DC * dc, PHYSDEV physdev, const DC_FUNCTIONS *funcs ) DECLSPEC_HIDDEN;
460 extern void pop_dc_driver( DC * dc, PHYSDEV physdev ) DECLSPEC_HIDDEN;
461 extern void DC_InitDC( DC * dc ) DECLSPEC_HIDDEN;
462 extern void DC_UpdateXforms( DC * dc ) DECLSPEC_HIDDEN;
463
464 /* dib.c */
465 extern int DIB_GetDIBWidthBytes( int width, int depth ) DECLSPEC_HIDDEN;
466 extern int DIB_GetDIBImageBytes( int width, int height, int depth ) DECLSPEC_HIDDEN;
467 extern int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) DECLSPEC_HIDDEN;
468 extern int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width,
469                               LONG *height, WORD *planes, WORD *bpp, DWORD *compr, DWORD *size ) DECLSPEC_HIDDEN;
470
471 /* driver.c */
472 extern const DC_FUNCTIONS null_driver DECLSPEC_HIDDEN;
473 extern const DC_FUNCTIONS dib_driver DECLSPEC_HIDDEN;
474 extern const DC_FUNCTIONS *DRIVER_get_display_driver(void) DECLSPEC_HIDDEN;
475 extern const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name ) DECLSPEC_HIDDEN;
476 extern BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size ) DECLSPEC_HIDDEN;
477
478 static inline PHYSDEV get_physdev_entry_point( PHYSDEV dev, size_t offset )
479 {
480     while (!((void **)dev->funcs)[offset / sizeof(void *)]) dev = dev->next;
481     return dev;
482 }
483
484 #define GET_DC_PHYSDEV(dc,func) get_physdev_entry_point( (dc)->physDev, FIELD_OFFSET(DC_FUNCTIONS,func))
485 #define GET_NEXT_PHYSDEV(dev,func) get_physdev_entry_point( (dev)->next, FIELD_OFFSET(DC_FUNCTIONS,func))
486
487 /* enhmetafile.c */
488 extern HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk ) DECLSPEC_HIDDEN;
489
490 /* freetype.c */
491
492 /* Undocumented structure filled in by GdiRealizationInfo */
493 typedef struct
494 {
495     DWORD flags;       /* 1 for bitmap fonts, 3 for scalable fonts */
496     DWORD cache_num;   /* keeps incrementing - num of fonts that have been created allowing for caching?? */
497     DWORD unknown2;    /* fixed for a given font - looks like it could be the order of the face in the font list or the order
498                           in which the face was first rendered. */
499 } realization_info_t;
500
501
502 extern INT WineEngAddFontResourceEx(LPCWSTR, DWORD, PVOID) DECLSPEC_HIDDEN;
503 extern HANDLE WineEngAddFontMemResourceEx(PVOID, DWORD, PVOID, LPDWORD) DECLSPEC_HIDDEN;
504 extern GdiFont* WineEngCreateFontInstance(DC*, HFONT) DECLSPEC_HIDDEN;
505 extern BOOL WineEngDestroyFontInstance(HFONT handle) DECLSPEC_HIDDEN;
506 extern DWORD WineEngEnumFonts(LPLOGFONTW, FONTENUMPROCW, LPARAM) DECLSPEC_HIDDEN;
507 extern BOOL WineEngGetCharABCWidths(GdiFont *font, UINT firstChar,
508                                     UINT lastChar, LPABC buffer) DECLSPEC_HIDDEN;
509 extern BOOL WineEngGetCharABCWidthsFloat(GdiFont *font, UINT firstChar,
510                                          UINT lastChar, LPABCFLOAT buffer) DECLSPEC_HIDDEN;
511 extern BOOL WineEngGetCharABCWidthsI(GdiFont *font, UINT firstChar,
512                                     UINT count, LPWORD pgi, LPABC buffer) DECLSPEC_HIDDEN;
513 extern BOOL WineEngGetCharWidth(GdiFont*, UINT, UINT, LPINT) DECLSPEC_HIDDEN;
514 extern DWORD WineEngGetFontData(GdiFont*, DWORD, DWORD, LPVOID, DWORD) DECLSPEC_HIDDEN;
515 extern DWORD WineEngGetFontUnicodeRanges(GdiFont *, LPGLYPHSET) DECLSPEC_HIDDEN;
516 extern DWORD WineEngGetGlyphIndices(GdiFont *font, LPCWSTR lpstr, INT count,
517                                     LPWORD pgi, DWORD flags) DECLSPEC_HIDDEN;
518 extern DWORD WineEngGetGlyphOutline(GdiFont*, UINT glyph, UINT format,
519                                     LPGLYPHMETRICS, DWORD buflen, LPVOID buf,
520                                     const MAT2*) DECLSPEC_HIDDEN;
521 extern DWORD WineEngGetKerningPairs(GdiFont*, DWORD, KERNINGPAIR *) DECLSPEC_HIDDEN;
522 extern BOOL WineEngGetLinkedHFont(DC *dc, WCHAR c, HFONT *new_hfont, UINT *glyph) DECLSPEC_HIDDEN;
523 extern UINT WineEngGetOutlineTextMetrics(GdiFont*, UINT, LPOUTLINETEXTMETRICW) DECLSPEC_HIDDEN;
524 extern UINT WineEngGetTextCharsetInfo(GdiFont *font, LPFONTSIGNATURE fs, DWORD flags) DECLSPEC_HIDDEN;
525 extern BOOL WineEngGetTextExtentExPoint(GdiFont*, LPCWSTR, INT, INT, LPINT, LPINT, LPSIZE) DECLSPEC_HIDDEN;
526 extern BOOL WineEngGetTextExtentExPointI(GdiFont*, const WORD *, INT, INT, LPINT, LPINT, LPSIZE) DECLSPEC_HIDDEN;
527 extern INT  WineEngGetTextFace(GdiFont*, INT, LPWSTR) DECLSPEC_HIDDEN;
528 extern BOOL WineEngGetTextMetrics(GdiFont*, LPTEXTMETRICW) DECLSPEC_HIDDEN;
529 extern BOOL WineEngFontIsLinked(GdiFont*) DECLSPEC_HIDDEN;
530 extern BOOL WineEngInit(void) DECLSPEC_HIDDEN;
531 extern BOOL WineEngRealizationInfo(GdiFont*, realization_info_t*) DECLSPEC_HIDDEN;
532 extern BOOL WineEngRemoveFontResourceEx(LPCWSTR, DWORD, PVOID) DECLSPEC_HIDDEN;
533
534 /* gdiobj.c */
535 extern HGDIOBJ alloc_gdi_handle( GDIOBJHDR *obj, WORD type, const struct gdi_obj_funcs *funcs ) DECLSPEC_HIDDEN;
536 extern void *free_gdi_handle( HGDIOBJ handle ) DECLSPEC_HIDDEN;
537 extern void *GDI_GetObjPtr( HGDIOBJ, WORD ) DECLSPEC_HIDDEN;
538 extern void GDI_ReleaseObj( HGDIOBJ ) DECLSPEC_HIDDEN;
539 extern void GDI_CheckNotLock(void) DECLSPEC_HIDDEN;
540 extern HGDIOBJ GDI_inc_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN;
541 extern BOOL GDI_dec_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN;
542 extern BOOL GDI_hdc_using_object(HGDIOBJ obj, HDC hdc) DECLSPEC_HIDDEN;
543 extern BOOL GDI_hdc_not_using_object(HGDIOBJ obj, HDC hdc) DECLSPEC_HIDDEN;
544
545 /* metafile.c */
546 extern HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh) DECLSPEC_HIDDEN;
547 extern METAHEADER *MF_CreateMetaHeaderDisk(METAHEADER *mr, LPCVOID filename, BOOL unicode ) DECLSPEC_HIDDEN;
548
549 /* path.c */
550
551 #define PATH_IsPathOpen(path) ((path).state==PATH_Open)
552 /* Returns TRUE if the specified path is in the open state, i.e. in the
553  * state where points will be added to the path, or FALSE otherwise. This
554  * function is implemented as a macro for performance reasons.
555  */
556
557 extern void PATH_InitGdiPath(GdiPath *pPath) DECLSPEC_HIDDEN;
558 extern void PATH_DestroyGdiPath(GdiPath *pPath) DECLSPEC_HIDDEN;
559 extern BOOL PATH_AssignGdiPath(GdiPath *pPathDest, const GdiPath *pPathSrc) DECLSPEC_HIDDEN;
560
561 extern BOOL PATH_MoveTo(DC *dc) DECLSPEC_HIDDEN;
562 extern BOOL PATH_LineTo(DC *dc, INT x, INT y) DECLSPEC_HIDDEN;
563 extern BOOL PATH_Rectangle(DC *dc, INT x1, INT y1, INT x2, INT y2) DECLSPEC_HIDDEN;
564 extern BOOL PATH_ExtTextOut(DC *dc, INT x, INT y, UINT flags, const RECT *lprc,
565                             LPCWSTR str, UINT count, const INT *dx) DECLSPEC_HIDDEN;
566 extern BOOL PATH_Ellipse(DC *dc, INT x1, INT y1, INT x2, INT y2) DECLSPEC_HIDDEN;
567 extern BOOL PATH_Arc(DC *dc, INT x1, INT y1, INT x2, INT y2,
568                      INT xStart, INT yStart, INT xEnd, INT yEnd, INT lines) DECLSPEC_HIDDEN;
569 extern BOOL PATH_PolyBezierTo(DC *dc, const POINT *pt, DWORD cbCount) DECLSPEC_HIDDEN;
570 extern BOOL PATH_PolyBezier(DC *dc, const POINT *pt, DWORD cbCount) DECLSPEC_HIDDEN;
571 extern BOOL PATH_PolyDraw(DC *dc, const POINT *pts, const BYTE *types, DWORD cbCount) DECLSPEC_HIDDEN;
572 extern BOOL PATH_PolylineTo(DC *dc, const POINT *pt, DWORD cbCount) DECLSPEC_HIDDEN;
573 extern BOOL PATH_Polyline(DC *dc, const POINT *pt, DWORD cbCount) DECLSPEC_HIDDEN;
574 extern BOOL PATH_Polygon(DC *dc, const POINT *pt, DWORD cbCount) DECLSPEC_HIDDEN;
575 extern BOOL PATH_PolyPolyline(DC *dc, const POINT *pt, const DWORD *counts, DWORD polylines) DECLSPEC_HIDDEN;
576 extern BOOL PATH_PolyPolygon(DC *dc, const POINT *pt, const INT *counts, UINT polygons) DECLSPEC_HIDDEN;
577 extern BOOL PATH_RoundRect(DC *dc, INT x1, INT y1, INT x2, INT y2, INT ell_width, INT ell_height) DECLSPEC_HIDDEN;
578
579 /* painting.c */
580 extern POINT *GDI_Bezier( const POINT *Points, INT count, INT *nPtsOut ) DECLSPEC_HIDDEN;
581
582 /* palette.c */
583 extern HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg) DECLSPEC_HIDDEN;
584 extern UINT WINAPI GDIRealizePalette( HDC hdc ) DECLSPEC_HIDDEN;
585 extern HPALETTE PALETTE_Init(void) DECLSPEC_HIDDEN;
586
587 /* region.c */
588 extern INT mirror_region( HRGN dst, HRGN src, INT width ) DECLSPEC_HIDDEN;
589 extern BOOL REGION_FrameRgn( HRGN dest, HRGN src, INT x, INT y ) DECLSPEC_HIDDEN;
590
591 typedef struct
592 {
593     INT size;
594     INT numRects;
595     RECT *rects;
596     RECT extents;
597 } WINEREGION;
598 extern const WINEREGION *get_wine_region(HRGN rgn) DECLSPEC_HIDDEN;
599 static inline void release_wine_region(HRGN rgn)
600 {
601     GDI_ReleaseObj(rgn);
602 }
603
604 /* null driver entry points */
605 extern BOOL CDECL nulldrv_AbortPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
606 extern BOOL CDECL nulldrv_AngleArc( PHYSDEV dev, INT x, INT y, DWORD radius, FLOAT start, FLOAT sweep ) DECLSPEC_HIDDEN;
607 extern BOOL CDECL nulldrv_ArcTo( PHYSDEV dev, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN;
608 extern BOOL CDECL nulldrv_BeginPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
609 extern BOOL CDECL nulldrv_CloseFigure( PHYSDEV dev ) DECLSPEC_HIDDEN;
610 extern BOOL CDECL nulldrv_EndPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
611 extern INT  CDECL nulldrv_ExcludeClipRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
612 extern INT  CDECL nulldrv_ExtSelectClipRgn( PHYSDEV dev, HRGN rgn, INT mode ) DECLSPEC_HIDDEN;
613 extern BOOL CDECL nulldrv_FillPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
614 extern BOOL CDECL nulldrv_FillRgn( PHYSDEV dev, HRGN rgn, HBRUSH brush ) DECLSPEC_HIDDEN;
615 extern BOOL CDECL nulldrv_FlattenPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
616 extern BOOL CDECL nulldrv_FrameRgn( PHYSDEV dev, HRGN rgn, HBRUSH brush, INT width, INT height ) DECLSPEC_HIDDEN;
617 extern LONG CDECL nulldrv_GetBitmapBits( HBITMAP bitmap, void *bits, LONG size ) DECLSPEC_HIDDEN;
618 extern INT  CDECL nulldrv_GetDIBits( PHYSDEV dev, HBITMAP bitmap, UINT start, UINT lines, LPVOID bits, BITMAPINFO *info, UINT coloruse ) DECLSPEC_HIDDEN;
619 extern COLORREF CDECL nulldrv_GetNearestColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
620 extern INT  CDECL nulldrv_IntersectClipRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
621 extern BOOL CDECL nulldrv_InvertRgn( PHYSDEV dev, HRGN rgn ) DECLSPEC_HIDDEN;
622 extern BOOL CDECL nulldrv_ModifyWorldTransform( PHYSDEV dev, const XFORM *xform, DWORD mode ) DECLSPEC_HIDDEN;
623 extern INT  CDECL nulldrv_OffsetClipRgn( PHYSDEV dev, INT x, INT y ) DECLSPEC_HIDDEN;
624 extern BOOL CDECL nulldrv_OffsetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) DECLSPEC_HIDDEN;
625 extern BOOL CDECL nulldrv_OffsetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) DECLSPEC_HIDDEN;
626 extern BOOL CDECL nulldrv_PolyBezier( PHYSDEV dev, const POINT *points, DWORD count ) DECLSPEC_HIDDEN;
627 extern BOOL CDECL nulldrv_PolyBezierTo( PHYSDEV dev, const POINT *points, DWORD count ) DECLSPEC_HIDDEN;
628 extern BOOL CDECL nulldrv_PolyDraw( PHYSDEV dev, const POINT *points, const BYTE *types, DWORD count ) DECLSPEC_HIDDEN;
629 extern BOOL CDECL nulldrv_PolylineTo( PHYSDEV dev, const POINT *points, INT count ) DECLSPEC_HIDDEN;
630 extern BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level ) DECLSPEC_HIDDEN;
631 extern INT  CDECL nulldrv_SaveDC( PHYSDEV dev ) DECLSPEC_HIDDEN;
632 extern BOOL CDECL nulldrv_ScaleViewportExtEx( PHYSDEV dev, INT x_num, INT x_denom, INT y_num, INT y_denom, SIZE *size ) DECLSPEC_HIDDEN;
633 extern BOOL CDECL nulldrv_ScaleWindowExtEx( PHYSDEV dev, INT x_num, INT x_denom, INT y_num, INT y_denom, SIZE *size ) DECLSPEC_HIDDEN;
634 extern BOOL CDECL nulldrv_SelectClipPath( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN;
635 extern LONG CDECL nulldrv_SetBitmapBits( HBITMAP bitmap, const void *bits, LONG size ) DECLSPEC_HIDDEN;
636 extern INT  CDECL nulldrv_SetDIBits( PHYSDEV dev, HBITMAP bitmap, UINT start, UINT lines, const void *bits, const BITMAPINFO *info, UINT coloruse ) DECLSPEC_HIDDEN;
637 extern INT  CDECL nulldrv_SetMapMode( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN;
638 extern BOOL CDECL nulldrv_SetViewportExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *size ) DECLSPEC_HIDDEN;
639 extern BOOL CDECL nulldrv_SetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) DECLSPEC_HIDDEN;
640 extern BOOL CDECL nulldrv_SetWindowExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *size ) DECLSPEC_HIDDEN;
641 extern BOOL CDECL nulldrv_SetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) DECLSPEC_HIDDEN;
642 extern BOOL CDECL nulldrv_SetWorldTransform( PHYSDEV dev, const XFORM *xform ) DECLSPEC_HIDDEN;
643 extern BOOL CDECL nulldrv_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst,
644                                       PHYSDEV src_dev, struct bitblt_coords *src, DWORD rop ) DECLSPEC_HIDDEN;
645 extern INT  CDECL nulldrv_StretchDIBits( PHYSDEV dev, INT xDst, INT yDst, INT widthDst, INT heightDst,
646                                          INT xSrc, INT ySrc, INT widthSrc, INT heightSrc, const void *bits,
647                                          const BITMAPINFO *info, UINT coloruse, DWORD rop ) DECLSPEC_HIDDEN;
648 extern BOOL CDECL nulldrv_StrokeAndFillPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
649 extern BOOL CDECL nulldrv_StrokePath( PHYSDEV dev ) DECLSPEC_HIDDEN;
650 extern BOOL CDECL nulldrv_WidenPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
651
652 static inline DC *get_nulldrv_dc( PHYSDEV dev )
653 {
654     return CONTAINING_RECORD( dev, DC, nulldrv );
655 }
656
657 /* Undocumented value for DIB's iUsage: Indicates a mono DIB w/o pal entries */
658 #define DIB_PAL_MONO 2
659
660 BOOL WINAPI FontIsLinked(HDC);
661
662 BOOL WINAPI SetVirtualResolution(HDC hdc, DWORD horz_res, DWORD vert_res, DWORD horz_size, DWORD vert_size);
663
664 #endif /* __WINE_GDI_PRIVATE_H */