Fixed format string.
[wine/multimedia.git] / include / gdi.h
blobd29a202bb27ad02add9b188c1d54859089fe0e80
1 /*
2 * GDI definitions
4 * Copyright 1993 Alexandre Julliard
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __WINE_GDI_H
22 #define __WINE_GDI_H
24 #include "windef.h"
25 #include "wingdi.h"
26 #include "wine/wingdi16.h"
27 #include "path.h"
28 #include <math.h>
30 /* GDI objects magic numbers */
31 #define FIRST_MAGIC 0x4f47
32 #define PEN_MAGIC 0x4f47
33 #define BRUSH_MAGIC 0x4f48
34 #define FONT_MAGIC 0x4f49
35 #define PALETTE_MAGIC 0x4f4a
36 #define BITMAP_MAGIC 0x4f4b
37 #define REGION_MAGIC 0x4f4c
38 #define DC_MAGIC 0x4f4d
39 #define DISABLED_DC_MAGIC 0x4f4e
40 #define META_DC_MAGIC 0x4f4f
41 #define METAFILE_MAGIC 0x4f50
42 #define METAFILE_DC_MAGIC 0x4f51
43 #define ENHMETAFILE_MAGIC 0x4f52
44 #define ENHMETAFILE_DC_MAGIC 0x4f53
45 #define LAST_MAGIC 0x4f53
47 #define MAGIC_DONTCARE 0xffff
49 /* GDI constants for making objects private/system (naming undoc. !) */
50 #define OBJECT_PRIVATE 0x2000
51 #define OBJECT_NOSYSTEM 0x8000
53 #define GDIMAGIC(magic) ((magic) & ~(OBJECT_PRIVATE|OBJECT_NOSYSTEM))
55 struct gdi_obj_funcs
57 HGDIOBJ (*pSelectObject)( HGDIOBJ handle, void *obj, HDC hdc );
58 INT (*pGetObject16)( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
59 INT (*pGetObjectA)( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
60 INT (*pGetObjectW)( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
61 BOOL (*pUnrealizeObject)( HGDIOBJ handle, void *obj );
62 BOOL (*pDeleteObject)( HGDIOBJ handle, void *obj );
65 typedef struct tagGDIOBJHDR
67 HANDLE16 hNext;
68 WORD wMagic;
69 DWORD dwCount;
70 const struct gdi_obj_funcs *funcs;
71 } GDIOBJHDR;
74 typedef struct tagGdiFont *GdiFont;
76 typedef struct { int opaque; } *PHYSDEV; /* PHYSDEV is an opaque pointer */
78 typedef struct tagDC
80 GDIOBJHDR header;
81 HDC hSelf; /* Handle to this DC */
82 const struct tagDC_FUNCS *funcs; /* DC function table */
83 PHYSDEV physDev; /* Physical device (driver-specific) */
84 INT saveLevel;
85 DWORD dwHookData;
86 FARPROC16 hookProc; /* the original SEGPTR ... */
87 DCHOOKPROC hookThunk; /* ... and the thunk to call it */
89 INT wndOrgX; /* Window origin */
90 INT wndOrgY;
91 INT wndExtX; /* Window extent */
92 INT wndExtY;
93 INT vportOrgX; /* Viewport origin */
94 INT vportOrgY;
95 INT vportExtX; /* Viewport extent */
96 INT vportExtY;
98 int flags;
99 HRGN16 hClipRgn; /* Clip region (may be 0) */
100 HRGN16 hVisRgn; /* Visible region (must never be 0) */
101 HRGN16 hGCClipRgn; /* GC clip region (ClipRgn AND VisRgn) */
102 HPEN16 hPen;
103 HBRUSH16 hBrush;
104 HFONT16 hFont;
105 HBITMAP16 hBitmap;
106 HANDLE16 hDevice;
107 HPALETTE16 hPalette;
109 GdiFont gdiFont;
110 GdiPath path;
112 WORD ROPmode;
113 WORD polyFillMode;
114 WORD stretchBltMode;
115 WORD relAbsMode;
116 WORD backgroundMode;
117 COLORREF backgroundColor;
118 COLORREF textColor;
119 short brushOrgX;
120 short brushOrgY;
122 WORD textAlign; /* Text alignment from SetTextAlign() */
123 short charExtra; /* Spacing from SetTextCharacterExtra() */
124 short breakTotalExtra; /* Total extra space for justification */
125 short breakCount; /* Break char. count */
126 short breakExtra; /* breakTotalExtra / breakCount */
127 short breakRem; /* breakTotalExtra % breakCount */
129 RECT totalExtent;
130 BYTE bitsPerPixel;
132 INT MapMode;
133 INT GraphicsMode; /* Graphics mode */
134 ABORTPROC pAbortProc; /* AbortProc for Printing */
135 ABORTPROC16 pAbortProc16;
136 INT CursPosX; /* Current position */
137 INT CursPosY;
138 INT ArcDirection;
139 XFORM xformWorld2Wnd; /* World-to-window transformation */
140 XFORM xformWorld2Vport; /* World-to-viewport transformation */
141 XFORM xformVport2World; /* Inverse of the above transformation */
142 BOOL vport2WorldValid; /* Is xformVport2World valid? */
143 } DC;
145 /* Device functions for the Wine driver interface */
147 typedef INT (*DEVICEFONTENUMPROC)(LPENUMLOGFONTEXW,LPNEWTEXTMETRICEXW,DWORD,
148 LPARAM);
150 typedef struct tagDC_FUNCS
152 INT (*pAbortDoc)(PHYSDEV);
153 BOOL (*pAbortPath)(PHYSDEV);
154 BOOL (*pAngleArc)(PHYSDEV,INT,INT,DWORD,FLOAT,FLOAT);
155 BOOL (*pArc)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
156 BOOL (*pArcTo)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
157 BOOL (*pBeginPath)(PHYSDEV);
158 BOOL (*pBitBlt)(PHYSDEV,INT,INT,INT,INT,PHYSDEV,INT,INT,DWORD);
159 INT (*pChoosePixelFormat)(PHYSDEV,const PIXELFORMATDESCRIPTOR *);
160 BOOL (*pChord)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
161 BOOL (*pCloseFigure)(PHYSDEV);
162 BOOL (*pCreateBitmap)(PHYSDEV,HBITMAP);
163 BOOL (*pCreateDC)(DC *,PHYSDEV *,LPCSTR,LPCSTR,LPCSTR,const DEVMODEA*);
164 HBITMAP (*pCreateDIBSection)(PHYSDEV,BITMAPINFO *,UINT,LPVOID *,HANDLE,DWORD,DWORD);
165 BOOL (*pDeleteBitmap)(HBITMAP);
166 BOOL (*pDeleteDC)(PHYSDEV);
167 INT (*pDescribePixelFormat)(PHYSDEV,INT,UINT,PIXELFORMATDESCRIPTOR *);
168 DWORD (*pDeviceCapabilities)(LPSTR,LPCSTR,LPCSTR,WORD,LPSTR,LPDEVMODEA);
169 BOOL (*pEllipse)(PHYSDEV,INT,INT,INT,INT);
170 INT (*pEndDoc)(PHYSDEV);
171 INT (*pEndPage)(PHYSDEV);
172 BOOL (*pEndPath)(PHYSDEV);
173 BOOL (*pEnumDeviceFonts)(PHYSDEV,LPLOGFONTW,DEVICEFONTENUMPROC,LPARAM);
174 INT (*pExcludeClipRect)(PHYSDEV,INT,INT,INT,INT);
175 INT (*pExtDeviceMode)(LPSTR,HWND,LPDEVMODEA,LPSTR,LPSTR,LPDEVMODEA,LPSTR,DWORD);
176 INT (*pExtEscape)(PHYSDEV,INT,INT,LPCVOID,INT,LPVOID);
177 BOOL (*pExtFloodFill)(PHYSDEV,INT,INT,COLORREF,UINT);
178 INT (*pExtSelectClipRgn)(PHYSDEV,HRGN,INT);
179 BOOL (*pExtTextOut)(PHYSDEV,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*);
180 BOOL (*pFillPath)(PHYSDEV);
181 BOOL (*pFillRgn)(PHYSDEV,HRGN,HBRUSH);
182 BOOL (*pFlattenPath)(PHYSDEV);
183 BOOL (*pFrameRgn)(PHYSDEV,HRGN,HBRUSH,INT,INT);
184 LONG (*pGetBitmapBits)(HBITMAP,void*,LONG);
185 BOOL (*pGetCharWidth)(PHYSDEV,UINT,UINT,LPINT);
186 BOOL (*pGetDCOrgEx)(PHYSDEV,LPPOINT);
187 UINT (*pGetDIBColorTable)(PHYSDEV,UINT,UINT,RGBQUAD*);
188 INT (*pGetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPVOID,BITMAPINFO*,UINT);
189 INT (*pGetDeviceCaps)(PHYSDEV,INT);
190 BOOL (*pGetDeviceGammaRamp)(PHYSDEV,LPVOID);
191 COLORREF (*pGetNearestColor)(PHYSDEV,COLORREF);
192 COLORREF (*pGetPixel)(PHYSDEV,INT,INT);
193 INT (*pGetPixelFormat)(PHYSDEV);
194 UINT (*pGetSystemPaletteEntries)(PHYSDEV,UINT,UINT,LPPALETTEENTRY);
195 BOOL (*pGetTextExtentPoint)(PHYSDEV,LPCWSTR,INT,LPSIZE);
196 BOOL (*pGetTextMetrics)(PHYSDEV,TEXTMETRICW*);
197 INT (*pIntersectClipRect)(PHYSDEV,INT,INT,INT,INT);
198 BOOL (*pInvertRgn)(PHYSDEV,HRGN);
199 BOOL (*pLineTo)(PHYSDEV,INT,INT);
200 BOOL (*pMoveTo)(PHYSDEV,INT,INT);
201 INT (*pOffsetClipRgn)(PHYSDEV,INT,INT);
202 BOOL (*pOffsetViewportOrg)(PHYSDEV,INT,INT);
203 BOOL (*pOffsetWindowOrg)(PHYSDEV,INT,INT);
204 BOOL (*pPaintRgn)(PHYSDEV,HRGN);
205 BOOL (*pPatBlt)(PHYSDEV,INT,INT,INT,INT,DWORD);
206 BOOL (*pPie)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
207 BOOL (*pPolyBezier)(PHYSDEV,const POINT*,DWORD);
208 BOOL (*pPolyBezierTo)(PHYSDEV,const POINT*,DWORD);
209 BOOL (*pPolyDraw)(PHYSDEV,const POINT*,const BYTE *,DWORD);
210 BOOL (*pPolyPolygon)(PHYSDEV,const POINT*,const INT*,UINT);
211 BOOL (*pPolyPolyline)(PHYSDEV,const POINT*,const DWORD*,DWORD);
212 BOOL (*pPolygon)(PHYSDEV,const POINT*,INT);
213 BOOL (*pPolyline)(PHYSDEV,const POINT*,INT);
214 BOOL (*pPolylineTo)(PHYSDEV,const POINT*,INT);
215 UINT (*pRealizeDefaultPalette)(PHYSDEV);
216 UINT (*pRealizePalette)(PHYSDEV,HPALETTE,BOOL);
217 BOOL (*pRectangle)(PHYSDEV,INT,INT,INT,INT);
218 HDC (*pResetDC)(PHYSDEV,const DEVMODEA*);
219 BOOL (*pRestoreDC)(PHYSDEV,INT);
220 BOOL (*pRoundRect)(PHYSDEV,INT,INT,INT,INT,INT,INT);
221 INT (*pSaveDC)(PHYSDEV);
222 BOOL (*pScaleViewportExt)(PHYSDEV,INT,INT,INT,INT);
223 BOOL (*pScaleWindowExt)(PHYSDEV,INT,INT,INT,INT);
224 HBITMAP (*pSelectBitmap)(PHYSDEV,HBITMAP);
225 HBRUSH (*pSelectBrush)(PHYSDEV,HBRUSH);
226 BOOL (*pSelectClipPath)(PHYSDEV,INT);
227 HFONT (*pSelectFont)(PHYSDEV,HFONT);
228 HPALETTE (*pSelectPalette)(PHYSDEV,HPALETTE,BOOL);
229 HPEN (*pSelectPen)(PHYSDEV,HPEN);
230 LONG (*pSetBitmapBits)(HBITMAP,const void*,LONG);
231 COLORREF (*pSetBkColor)(PHYSDEV,COLORREF);
232 INT (*pSetBkMode)(PHYSDEV,INT);
233 DWORD (*pSetDCOrg)(PHYSDEV,INT,INT);
234 UINT (*pSetDIBColorTable)(PHYSDEV,UINT,UINT,const RGBQUAD*);
235 INT (*pSetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPCVOID,const BITMAPINFO*,UINT);
236 INT (*pSetDIBitsToDevice)(PHYSDEV,INT,INT,DWORD,DWORD,INT,INT,UINT,UINT,LPCVOID,
237 const BITMAPINFO*,UINT);
238 VOID (*pSetDeviceClipping)(PHYSDEV,HRGN);
239 BOOL (*pSetDeviceGammaRamp)(PHYSDEV,LPVOID);
240 INT (*pSetMapMode)(PHYSDEV,INT);
241 DWORD (*pSetMapperFlags)(PHYSDEV,DWORD);
242 COLORREF (*pSetPixel)(PHYSDEV,INT,INT,COLORREF);
243 BOOL (*pSetPixelFormat)(PHYSDEV,INT,const PIXELFORMATDESCRIPTOR *);
244 INT (*pSetPolyFillMode)(PHYSDEV,INT);
245 INT (*pSetROP2)(PHYSDEV,INT);
246 INT (*pSetRelAbs)(PHYSDEV,INT);
247 INT (*pSetStretchBltMode)(PHYSDEV,INT);
248 UINT (*pSetTextAlign)(PHYSDEV,UINT);
249 INT (*pSetTextCharacterExtra)(PHYSDEV,INT);
250 DWORD (*pSetTextColor)(PHYSDEV,DWORD);
251 INT (*pSetTextJustification)(PHYSDEV,INT,INT);
252 BOOL (*pSetViewportExt)(PHYSDEV,INT,INT);
253 BOOL (*pSetViewportOrg)(PHYSDEV,INT,INT);
254 BOOL (*pSetWindowExt)(PHYSDEV,INT,INT);
255 BOOL (*pSetWindowOrg)(PHYSDEV,INT,INT);
256 INT (*pStartDoc)(PHYSDEV,const DOCINFOA*);
257 INT (*pStartPage)(PHYSDEV);
258 BOOL (*pStretchBlt)(PHYSDEV,INT,INT,INT,INT,PHYSDEV,INT,INT,INT,INT,DWORD);
259 INT (*pStretchDIBits)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT,const void *,
260 const BITMAPINFO*,UINT,DWORD);
261 BOOL (*pStrokeAndFillPath)(PHYSDEV);
262 BOOL (*pStrokePath)(PHYSDEV);
263 BOOL (*pSwapBuffers)(PHYSDEV);
264 BOOL (*pWidenPath)(PHYSDEV);
265 } DC_FUNCTIONS;
267 /* DC hook codes */
268 #define DCHC_INVALIDVISRGN 0x0001
269 #define DCHC_DELETEDC 0x0002
271 #define DCHF_INVALIDATEVISRGN 0x0001
272 #define DCHF_VALIDATEVISRGN 0x0002
274 /* DC flags */
275 #define DC_MEMORY 0x0001 /* It is a memory DC */
276 #define DC_SAVED 0x0002 /* It is a saved DC */
277 #define DC_DIRTY 0x0004 /* hVisRgn has to be updated */
278 #define DC_THUNKHOOK 0x0008 /* DC hook is in the 16-bit code */
280 #define GDI_HEAP_SIZE 0xffe0
282 /* extra stock object: default 1x1 bitmap for memory DCs */
283 #define DEFAULT_BITMAP (STOCK_LAST+1)
285 /* Metafile defines */
287 #define META_EOF 0x0000
288 /* values of mtType in METAHEADER. Note however that the disk image of a disk
289 based metafile has mtType == 1 */
290 #define METAFILE_MEMORY 1
291 #define METAFILE_DISK 2
293 /* Rounds a floating point number to integer. The world-to-viewport
294 * transformation process is done in floating point internally. This function
295 * is then used to round these coordinates to integer values.
297 static inline INT WINE_UNUSED GDI_ROUND(FLOAT val)
299 return (int)floor(val + 0.5);
302 /* World -> Device size conversion */
304 /* Performs a world-to-viewport transformation on the specified width (which
305 * is in floating point format).
307 static inline void WINE_UNUSED INTERNAL_XWSTODS_FLOAT(DC *dc, FLOAT *width)
309 /* Perform the transformation */
310 *width = *width * dc->xformWorld2Vport.eM11;
313 /* Performs a world-to-viewport transformation on the specified width (which
314 * is in integer format).
316 static inline INT WINE_UNUSED INTERNAL_XWSTODS(DC *dc, INT width)
318 FLOAT floatWidth;
320 /* Perform operation with floating point */
321 floatWidth = (FLOAT)width;
322 INTERNAL_XWSTODS_FLOAT(dc, &floatWidth);
324 /* Round to integers */
325 return GDI_ROUND(floatWidth);
329 /* Performs a world-to-viewport transformation on the specified size (which
330 * is in floating point format).
332 static inline void WINE_UNUSED INTERNAL_YWSTODS_FLOAT(DC *dc, FLOAT *height)
334 /* Perform the transformation */
335 *height = *height * dc->xformWorld2Vport.eM22;
338 /* Performs a world-to-viewport transformation on the specified size (which
339 * is in integer format).
341 static inline INT WINE_UNUSED INTERNAL_YWSTODS(DC *dc, INT height)
343 FLOAT floatHeight;
345 /* Perform operation with floating point */
346 floatHeight = (FLOAT)height;
347 INTERNAL_YWSTODS_FLOAT(dc, &floatHeight);
349 /* Round to integers */
350 return GDI_ROUND(floatHeight);
354 /* Device -> World size conversion */
356 /* Performs a device to world transformation on the specified width (which
357 * is in floating point format).
359 static inline void INTERNAL_XDSTOWS_FLOAT(DC *dc, FLOAT *width)
361 /* Perform the transformation */
362 *width = *width * dc->xformVport2World.eM11;
365 /* Performs a device to world transformation on the specified width (which
366 * is in integer format).
368 static inline INT INTERNAL_XDSTOWS(DC *dc, INT width)
370 FLOAT floatWidth;
372 /* Perform operation with floating point */
373 floatWidth = (FLOAT)width;
374 INTERNAL_XDSTOWS_FLOAT(dc, &floatWidth);
376 /* Round to integers */
377 return GDI_ROUND(floatWidth);
381 /* Performs a device to world transformation on the specified size (which
382 * is in floating point format).
384 static inline void INTERNAL_YDSTOWS_FLOAT(DC *dc, FLOAT *height)
386 /* Perform the transformation */
387 *height = *height * dc->xformVport2World.eM22;
390 /* Performs a device to world transformation on the specified size (which
391 * is in integer format).
393 static inline INT INTERNAL_YDSTOWS(DC *dc, INT height)
395 FLOAT floatHeight;
397 /* Perform operation with floating point */
398 floatHeight = (FLOAT)height;
399 INTERNAL_YDSTOWS_FLOAT(dc, &floatHeight);
401 /* Round to integers */
402 return GDI_ROUND(floatHeight);
406 /* Device <-> logical size conversion */
408 #define XDSTOLS(dc,x) \
409 MulDiv((x), (dc)->wndExtX, (dc)->vportExtX)
410 #define YDSTOLS(dc,y) \
411 MulDiv((y), (dc)->wndExtY, (dc)->vportExtY)
412 #define XLSTODS(dc,x) \
413 MulDiv((x), (dc)->vportExtX, (dc)->wndExtX)
414 #define YLSTODS(dc,y) \
415 MulDiv((y), (dc)->vportExtY, (dc)->wndExtY)
417 /* GDI local heap */
419 extern BOOL GDI_Init(void);
420 extern void *GDI_AllocObject( WORD, WORD, HGDIOBJ *, const struct gdi_obj_funcs *funcs );
421 extern void *GDI_ReallocObject( WORD, HGDIOBJ, void *obj );
422 extern BOOL GDI_FreeObject( HGDIOBJ, void *obj );
423 extern void *GDI_GetObjPtr( HGDIOBJ, WORD );
424 extern void GDI_ReleaseObj( HGDIOBJ );
425 extern void GDI_CheckNotLock(void);
427 extern const DC_FUNCTIONS *DRIVER_load_driver( LPCSTR name );
428 extern const DC_FUNCTIONS *DRIVER_get_driver( const DC_FUNCTIONS *funcs );
429 extern void DRIVER_release_driver( const DC_FUNCTIONS *funcs );
430 extern BOOL DRIVER_GetDriverName( LPCSTR device, LPSTR driver, DWORD size );
432 extern POINT *GDI_Bezier( const POINT *Points, INT count, INT *nPtsOut );
434 extern DC * DC_AllocDC( const DC_FUNCTIONS *funcs );
435 extern DC * DC_GetDCPtr( HDC hdc );
436 extern DC * DC_GetDCUpdate( HDC hdc );
437 extern void DC_InitDC( DC * dc );
438 extern void DC_UpdateXforms( DC * dc );
440 /* clipping.c */
441 extern void CLIPPING_UpdateGCRegion( DC * dc );
443 /* enhmetafile.c */
444 extern HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk );
446 /* metafile.c */
447 extern HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh);
448 extern HMETAFILE16 MF_Create_HMETAFILE16(METAHEADER *mh);
449 extern METAHEADER *MF_CreateMetaHeaderDisk(METAHEADER *mr, LPCSTR filename);
451 /* region.c */
452 extern HRGN REGION_CropRgn( HRGN hDst, HRGN hSrc, const RECT *lpRect, const POINT *lpPt );
453 extern BOOL REGION_FrameRgn( HRGN dest, HRGN src, INT x, INT y );
455 #define WINE_GGO_GRAY16_BITMAP 0x7f
457 #endif /* __WINE_GDI_H */