user32/tests: Added SetWindowPos test that incorrectly sets focus.
[wine] / include / wine / gdi_driver.h
1 /*
2  * Definitions for Wine GDI drivers
3  *
4  * Copyright 2011 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_WINE_GDI_DRIVER_H
22 #define __WINE_WINE_GDI_DRIVER_H
23
24 struct gdi_dc_funcs;
25
26 typedef struct gdi_physdev
27 {
28     const struct gdi_dc_funcs *funcs;
29     struct gdi_physdev        *next;
30     HDC                        hdc;
31 } *PHYSDEV;
32
33 struct bitblt_coords
34 {
35     int  log_x;     /* original position and size, in logical coords */
36     int  log_y;
37     int  log_width;
38     int  log_height;
39     int  x;         /* mapped position and size, in device coords */
40     int  y;
41     int  width;
42     int  height;
43     RECT visrect;   /* rectangle clipped to the visible part, in device coords */
44     DWORD layout;   /* DC layout */
45 };
46
47 struct gdi_image_bits
48 {
49     void   *ptr;       /* pointer to the bits */
50     BOOL    is_copy;   /* whether this is a copy of the bits that can be modified */
51     void  (*free)(struct gdi_image_bits *);  /* callback for freeing the bits */
52     void   *param;     /* extra parameter for callback private use */
53 };
54
55 struct brush_pattern
56 {
57     HBITMAP               bitmap;   /* bitmap handle for DDB patterns */
58     BITMAPINFO           *info;     /* DIB info */
59     struct gdi_image_bits bits;     /* DIB bits */
60     UINT                  usage;    /* color usage for DIB info */
61 };
62
63 struct gdi_dc_funcs
64 {
65     INT      (*pAbortDoc)(PHYSDEV);
66     BOOL     (*pAbortPath)(PHYSDEV);
67     BOOL     (*pAlphaBlend)(PHYSDEV,struct bitblt_coords*,PHYSDEV,struct bitblt_coords*,BLENDFUNCTION);
68     BOOL     (*pAngleArc)(PHYSDEV,INT,INT,DWORD,FLOAT,FLOAT);
69     BOOL     (*pArc)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
70     BOOL     (*pArcTo)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
71     BOOL     (*pBeginPath)(PHYSDEV);
72     DWORD    (*pBlendImage)(PHYSDEV,BITMAPINFO*,const struct gdi_image_bits*,struct bitblt_coords*,struct bitblt_coords*,BLENDFUNCTION);
73     INT      (*pChoosePixelFormat)(PHYSDEV,const PIXELFORMATDESCRIPTOR *);
74     BOOL     (*pChord)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
75     BOOL     (*pCloseFigure)(PHYSDEV);
76     BOOL     (*pCopyBitmap)(HBITMAP,HBITMAP);
77     BOOL     (*pCreateBitmap)(PHYSDEV,HBITMAP);
78     BOOL     (*pCreateCompatibleDC)(PHYSDEV,PHYSDEV*);
79     BOOL     (*pCreateDC)(PHYSDEV*,LPCWSTR,LPCWSTR,LPCWSTR,const DEVMODEW*);
80     BOOL     (*pDeleteBitmap)(HBITMAP);
81     BOOL     (*pDeleteDC)(PHYSDEV);
82     BOOL     (*pDeleteObject)(PHYSDEV,HGDIOBJ);
83     INT      (*pDescribePixelFormat)(PHYSDEV,INT,UINT,PIXELFORMATDESCRIPTOR *);
84     DWORD    (*pDeviceCapabilities)(LPSTR,LPCSTR,LPCSTR,WORD,LPSTR,LPDEVMODEA);
85     BOOL     (*pEllipse)(PHYSDEV,INT,INT,INT,INT);
86     INT      (*pEndDoc)(PHYSDEV);
87     INT      (*pEndPage)(PHYSDEV);
88     BOOL     (*pEndPath)(PHYSDEV);
89     BOOL     (*pEnumFonts)(PHYSDEV,LPLOGFONTW,FONTENUMPROCW,LPARAM);
90     INT      (*pEnumICMProfiles)(PHYSDEV,ICMENUMPROCW,LPARAM);
91     INT      (*pExcludeClipRect)(PHYSDEV,INT,INT,INT,INT);
92     INT      (*pExtDeviceMode)(LPSTR,HWND,LPDEVMODEA,LPSTR,LPSTR,LPDEVMODEA,LPSTR,DWORD);
93     INT      (*pExtEscape)(PHYSDEV,INT,INT,LPCVOID,INT,LPVOID);
94     BOOL     (*pExtFloodFill)(PHYSDEV,INT,INT,COLORREF,UINT);
95     INT      (*pExtSelectClipRgn)(PHYSDEV,HRGN,INT);
96     BOOL     (*pExtTextOut)(PHYSDEV,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*);
97     BOOL     (*pFillPath)(PHYSDEV);
98     BOOL     (*pFillRgn)(PHYSDEV,HRGN,HBRUSH);
99     BOOL     (*pFlattenPath)(PHYSDEV);
100     BOOL     (*pFontIsLinked)(PHYSDEV);
101     BOOL     (*pFrameRgn)(PHYSDEV,HRGN,HBRUSH,INT,INT);
102     BOOL     (*pGdiComment)(PHYSDEV,UINT,CONST BYTE*);
103     BOOL     (*pGdiRealizationInfo)(PHYSDEV,void*);
104     UINT     (*pGetBoundsRect)(PHYSDEV,RECT*,UINT);
105     BOOL     (*pGetCharABCWidths)(PHYSDEV,UINT,UINT,LPABC);
106     BOOL     (*pGetCharABCWidthsI)(PHYSDEV,UINT,UINT,WORD*,LPABC);
107     BOOL     (*pGetCharWidth)(PHYSDEV,UINT,UINT,LPINT);
108     INT      (*pGetDeviceCaps)(PHYSDEV,INT);
109     BOOL     (*pGetDeviceGammaRamp)(PHYSDEV,LPVOID);
110     DWORD    (*pGetFontData)(PHYSDEV,DWORD,DWORD,LPVOID,DWORD);
111     DWORD    (*pGetFontUnicodeRanges)(PHYSDEV,LPGLYPHSET);
112     DWORD    (*pGetGlyphIndices)(PHYSDEV,LPCWSTR,INT,LPWORD,DWORD);
113     DWORD    (*pGetGlyphOutline)(PHYSDEV,UINT,UINT,LPGLYPHMETRICS,DWORD,LPVOID,const MAT2*);
114     BOOL     (*pGetICMProfile)(PHYSDEV,LPDWORD,LPWSTR);
115     DWORD    (*pGetImage)(PHYSDEV,HBITMAP,BITMAPINFO*,struct gdi_image_bits*,struct bitblt_coords*);
116     DWORD    (*pGetKerningPairs)(PHYSDEV,DWORD,LPKERNINGPAIR);
117     COLORREF (*pGetNearestColor)(PHYSDEV,COLORREF);
118     UINT     (*pGetOutlineTextMetrics)(PHYSDEV,UINT,LPOUTLINETEXTMETRICW);
119     COLORREF (*pGetPixel)(PHYSDEV,INT,INT);
120     INT      (*pGetPixelFormat)(PHYSDEV);
121     UINT     (*pGetSystemPaletteEntries)(PHYSDEV,UINT,UINT,LPPALETTEENTRY);
122     UINT     (*pGetTextCharsetInfo)(PHYSDEV,LPFONTSIGNATURE,DWORD);
123     BOOL     (*pGetTextExtentExPoint)(PHYSDEV,LPCWSTR,INT,INT,LPINT,LPINT,LPSIZE);
124     BOOL     (*pGetTextExtentExPointI)(PHYSDEV,const WORD*,INT,INT,LPINT,LPINT,LPSIZE);
125     INT      (*pGetTextFace)(PHYSDEV,INT,LPWSTR);
126     BOOL     (*pGetTextMetrics)(PHYSDEV,TEXTMETRICW*);
127     BOOL     (*pGradientFill)(PHYSDEV,TRIVERTEX*,ULONG,void*,ULONG,ULONG);
128     INT      (*pIntersectClipRect)(PHYSDEV,INT,INT,INT,INT);
129     BOOL     (*pInvertRgn)(PHYSDEV,HRGN);
130     BOOL     (*pLineTo)(PHYSDEV,INT,INT);
131     BOOL     (*pModifyWorldTransform)(PHYSDEV,const XFORM*,DWORD);
132     BOOL     (*pMoveTo)(PHYSDEV,INT,INT);
133     INT      (*pOffsetClipRgn)(PHYSDEV,INT,INT);
134     BOOL     (*pOffsetViewportOrgEx)(PHYSDEV,INT,INT,POINT*);
135     BOOL     (*pOffsetWindowOrgEx)(PHYSDEV,INT,INT,POINT*);
136     BOOL     (*pPaintRgn)(PHYSDEV,HRGN);
137     BOOL     (*pPatBlt)(PHYSDEV,struct bitblt_coords*,DWORD);
138     BOOL     (*pPie)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
139     BOOL     (*pPolyBezier)(PHYSDEV,const POINT*,DWORD);
140     BOOL     (*pPolyBezierTo)(PHYSDEV,const POINT*,DWORD);
141     BOOL     (*pPolyDraw)(PHYSDEV,const POINT*,const BYTE *,DWORD);
142     BOOL     (*pPolyPolygon)(PHYSDEV,const POINT*,const INT*,UINT);
143     BOOL     (*pPolyPolyline)(PHYSDEV,const POINT*,const DWORD*,DWORD);
144     BOOL     (*pPolygon)(PHYSDEV,const POINT*,INT);
145     BOOL     (*pPolyline)(PHYSDEV,const POINT*,INT);
146     BOOL     (*pPolylineTo)(PHYSDEV,const POINT*,INT);
147     DWORD    (*pPutImage)(PHYSDEV,HBITMAP,HRGN,BITMAPINFO*,const struct gdi_image_bits*,struct bitblt_coords*,struct bitblt_coords*,DWORD);
148     UINT     (*pRealizeDefaultPalette)(PHYSDEV);
149     UINT     (*pRealizePalette)(PHYSDEV,HPALETTE,BOOL);
150     BOOL     (*pRectangle)(PHYSDEV,INT,INT,INT,INT);
151     HDC      (*pResetDC)(PHYSDEV,const DEVMODEW*);
152     BOOL     (*pRestoreDC)(PHYSDEV,INT);
153     BOOL     (*pRoundRect)(PHYSDEV,INT,INT,INT,INT,INT,INT);
154     INT      (*pSaveDC)(PHYSDEV);
155     BOOL     (*pScaleViewportExtEx)(PHYSDEV,INT,INT,INT,INT,SIZE*);
156     BOOL     (*pScaleWindowExtEx)(PHYSDEV,INT,INT,INT,INT,SIZE*);
157     HBITMAP  (*pSelectBitmap)(PHYSDEV,HBITMAP);
158     HBRUSH   (*pSelectBrush)(PHYSDEV,HBRUSH,const struct brush_pattern*);
159     BOOL     (*pSelectClipPath)(PHYSDEV,INT);
160     HFONT    (*pSelectFont)(PHYSDEV,HFONT);
161     HPALETTE (*pSelectPalette)(PHYSDEV,HPALETTE,BOOL);
162     HPEN     (*pSelectPen)(PHYSDEV,HPEN,const struct brush_pattern*);
163     INT      (*pSetArcDirection)(PHYSDEV,INT);
164     COLORREF (*pSetBkColor)(PHYSDEV,COLORREF);
165     INT      (*pSetBkMode)(PHYSDEV,INT);
166     UINT     (*pSetBoundsRect)(PHYSDEV,RECT*,UINT);
167     COLORREF (*pSetDCBrushColor)(PHYSDEV, COLORREF);
168     COLORREF (*pSetDCPenColor)(PHYSDEV, COLORREF);
169     INT      (*pSetDIBitsToDevice)(PHYSDEV,INT,INT,DWORD,DWORD,INT,INT,UINT,UINT,LPCVOID,BITMAPINFO*,UINT);
170     VOID     (*pSetDeviceClipping)(PHYSDEV,HRGN);
171     BOOL     (*pSetDeviceGammaRamp)(PHYSDEV,LPVOID);
172     DWORD    (*pSetLayout)(PHYSDEV,DWORD);
173     INT      (*pSetMapMode)(PHYSDEV,INT);
174     DWORD    (*pSetMapperFlags)(PHYSDEV,DWORD);
175     COLORREF (*pSetPixel)(PHYSDEV,INT,INT,COLORREF);
176     BOOL     (*pSetPixelFormat)(PHYSDEV,INT,const PIXELFORMATDESCRIPTOR *);
177     INT      (*pSetPolyFillMode)(PHYSDEV,INT);
178     INT      (*pSetROP2)(PHYSDEV,INT);
179     INT      (*pSetRelAbs)(PHYSDEV,INT);
180     INT      (*pSetStretchBltMode)(PHYSDEV,INT);
181     UINT     (*pSetTextAlign)(PHYSDEV,UINT);
182     INT      (*pSetTextCharacterExtra)(PHYSDEV,INT);
183     COLORREF (*pSetTextColor)(PHYSDEV,COLORREF);
184     BOOL     (*pSetTextJustification)(PHYSDEV,INT,INT);
185     BOOL     (*pSetViewportExtEx)(PHYSDEV,INT,INT,SIZE*);
186     BOOL     (*pSetViewportOrgEx)(PHYSDEV,INT,INT,POINT*);
187     BOOL     (*pSetWindowExtEx)(PHYSDEV,INT,INT,SIZE*);
188     BOOL     (*pSetWindowOrgEx)(PHYSDEV,INT,INT,POINT*);
189     BOOL     (*pSetWorldTransform)(PHYSDEV,const XFORM*);
190     INT      (*pStartDoc)(PHYSDEV,const DOCINFOW*);
191     INT      (*pStartPage)(PHYSDEV);
192     BOOL     (*pStretchBlt)(PHYSDEV,struct bitblt_coords*,PHYSDEV,struct bitblt_coords*,DWORD);
193     INT      (*pStretchDIBits)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT,const void*,BITMAPINFO*,UINT,DWORD);
194     BOOL     (*pStrokeAndFillPath)(PHYSDEV);
195     BOOL     (*pStrokePath)(PHYSDEV);
196     BOOL     (*pSwapBuffers)(PHYSDEV);
197     BOOL     (*pUnrealizePalette)(HPALETTE);
198     BOOL     (*pWidenPath)(PHYSDEV);
199     BOOL     (*pwglCopyContext)(HGLRC,HGLRC,UINT);
200     HGLRC    (*pwglCreateContext)(PHYSDEV);
201     HGLRC    (*pwglCreateContextAttribsARB)(PHYSDEV,HGLRC,const int*);
202     BOOL     (*pwglDeleteContext)(HGLRC);
203     PROC     (*pwglGetProcAddress)(LPCSTR);
204     BOOL     (*pwglMakeContextCurrentARB)(PHYSDEV,PHYSDEV,HGLRC);
205     BOOL     (*pwglMakeCurrent)(PHYSDEV,HGLRC);
206     BOOL     (*pwglSetPixelFormatWINE)(PHYSDEV,INT,const PIXELFORMATDESCRIPTOR*);
207     BOOL     (*pwglShareLists)(HGLRC,HGLRC);
208     BOOL     (*pwglUseFontBitmapsA)(PHYSDEV,DWORD,DWORD,DWORD);
209     BOOL     (*pwglUseFontBitmapsW)(PHYSDEV,DWORD,DWORD,DWORD);
210
211     /* priority order for the driver on the stack */
212     UINT       priority;
213 };
214
215 /* increment this when you change the DC function table */
216 #define WINE_GDI_DRIVER_VERSION 28
217
218 #define GDI_PRIORITY_NULL_DRV        0  /* null driver */
219 #define GDI_PRIORITY_FONT_DRV      100  /* any font driver */
220 #define GDI_PRIORITY_GRAPHICS_DRV  200  /* any graphics driver */
221 #define GDI_PRIORITY_DIB_DRV       300  /* the DIB driver */
222 #define GDI_PRIORITY_PATH_DRV      400  /* the path driver */
223
224 static inline PHYSDEV get_physdev_entry_point( PHYSDEV dev, size_t offset )
225 {
226     while (!((void **)dev->funcs)[offset / sizeof(void *)]) dev = dev->next;
227     return dev;
228 }
229
230 #define GET_NEXT_PHYSDEV(dev,func) \
231     get_physdev_entry_point( (dev)->next, FIELD_OFFSET(struct gdi_dc_funcs,func))
232
233 static inline void push_dc_driver( PHYSDEV *dev, PHYSDEV physdev, const struct gdi_dc_funcs *funcs )
234 {
235     while ((*dev)->funcs->priority > funcs->priority) dev = &(*dev)->next;
236     physdev->funcs = funcs;
237     physdev->next = *dev;
238     physdev->hdc = (*dev)->hdc;
239     *dev = physdev;
240 }
241
242 #endif /* __WINE_WINE_GDI_DRIVER_H */