[PRINTING]
[reactos.git] / reactos / win32ss / gdi / gdi32 / wine / 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 <limits.h>
25 #include <math.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 struct gdi_obj_funcs
47 {
48 HGDIOBJ (*pSelectObject)( HGDIOBJ handle, HDC hdc );
49 INT (*pGetObjectA)( HGDIOBJ handle, INT count, LPVOID buffer );
50 INT (*pGetObjectW)( HGDIOBJ handle, INT count, LPVOID buffer );
51 BOOL (*pUnrealizeObject)( HGDIOBJ handle );
52 BOOL (*pDeleteObject)( HGDIOBJ handle );
53 };
54
55 typedef struct tagWINEDC
56 {
57 HDC hdc;
58 PHYSDEV physDev; /* current top of the physdev stack */
59 LONG refcount; /* thread refcount */
60 INT saveLevel;
61 struct gdi_physdev NullPhysDev;
62 HFONT hFont;
63 HBRUSH hBrush;
64 HPEN hPen;
65 HPALETTE hPalette;
66 } WINEDC, DC;
67
68 /* brush.c */
69 extern BOOL get_brush_bitmap_info( HBRUSH handle, BITMAPINFO *info, void **bits, UINT *usage ) DECLSPEC_HIDDEN;
70
71 /* dc.c */
72 extern DC *alloc_dc_ptr( WORD magic ) DECLSPEC_HIDDEN;
73 extern void free_dc_ptr( DC *dc ) DECLSPEC_HIDDEN;
74 extern DC *get_dc_ptr( HDC hdc ) DECLSPEC_HIDDEN;
75 extern void release_dc_ptr( DC *dc ) DECLSPEC_HIDDEN;
76
77 /* dib.c */
78 extern int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) DECLSPEC_HIDDEN;
79
80 /* enhmetafile.c */
81 extern HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk ) DECLSPEC_HIDDEN;
82
83 /* gdiobj.c */
84 extern HGDIOBJ alloc_gdi_handle( void *obj, WORD type, const struct gdi_obj_funcs *funcs ) DECLSPEC_HIDDEN;
85 extern void *free_gdi_handle( HGDIOBJ handle ) DECLSPEC_HIDDEN;
86 extern HGDIOBJ get_full_gdi_handle( HGDIOBJ handle ) DECLSPEC_HIDDEN;
87 extern void *GDI_GetObjPtr( HGDIOBJ, WORD ) DECLSPEC_HIDDEN;
88 extern void GDI_ReleaseObj( HGDIOBJ ) DECLSPEC_HIDDEN;
89 extern void GDI_hdc_using_object(HGDIOBJ obj, HDC hdc) DECLSPEC_HIDDEN;
90 extern void GDI_hdc_not_using_object(HGDIOBJ obj, HDC hdc) DECLSPEC_HIDDEN;
91
92 /* metafile.c */
93 extern HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh) DECLSPEC_HIDDEN;
94 extern METAHEADER *MF_CreateMetaHeaderDisk(METAHEADER *mr, LPCVOID filename, BOOL unicode ) DECLSPEC_HIDDEN;
95
96 /* Format of comment record added by GetWinMetaFileBits */
97 #include <pshpack2.h>
98 typedef struct
99 {
100 DWORD magic; /* WMFC */
101 WORD unk04; /* 1 */
102 WORD unk06; /* 0 */
103 WORD unk08; /* 0 */
104 WORD unk0a; /* 1 */
105 WORD checksum;
106 DWORD unk0e; /* 0 */
107 DWORD num_chunks;
108 DWORD chunk_size;
109 DWORD remaining_size;
110 DWORD emf_size;
111 BYTE emf_data[1];
112 } emf_in_wmf_comment;
113 #include <poppack.h>
114
115 #define WMFC_MAGIC 0x43464d57
116 /* palette.c */
117 extern HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg) DECLSPEC_HIDDEN;
118 extern UINT WINAPI GDIRealizePalette( HDC hdc ) DECLSPEC_HIDDEN;
119
120 #define EMR_SETLINKEDUFI 119
121
122 /* Undocumented value for DIB's iUsage: Indicates a mono DIB w/o pal entries */
123 #define DIB_PAL_MONO 2
124
125 BOOL WINAPI SetVirtualResolution(HDC hdc, DWORD horz_res, DWORD vert_res, DWORD horz_size, DWORD vert_size);
126
127 static inline int get_dib_stride( int width, int bpp )
128 {
129 return ((width * bpp + 31) >> 3) & ~3;
130 }
131
132 static inline int get_dib_image_size( const BITMAPINFO *info )
133 {
134 return get_dib_stride( info->bmiHeader.biWidth, info->bmiHeader.biBitCount )
135 * abs( info->bmiHeader.biHeight );
136 }
137
138 /* only for use on sanitized BITMAPINFO structures */
139 static inline int get_dib_info_size( const BITMAPINFO *info, UINT coloruse )
140 {
141 if (info->bmiHeader.biCompression == BI_BITFIELDS)
142 return sizeof(BITMAPINFOHEADER) + 3 * sizeof(DWORD);
143 if (coloruse == DIB_PAL_COLORS)
144 return sizeof(BITMAPINFOHEADER) + info->bmiHeader.biClrUsed * sizeof(WORD);
145 return FIELD_OFFSET( BITMAPINFO, bmiColors[info->bmiHeader.biClrUsed] );
146 }
147
148 /* Special sauce for reactos */
149 #define GDIRealizePalette RealizePalette
150 #define GDISelectPalette SelectPalette
151
152 HGDIOBJ WINAPI GdiFixUpHandle(HGDIOBJ hGdiObj);
153 #define get_full_gdi_handle GdiFixUpHandle
154
155 extern void push_dc_driver_ros(PHYSDEV *dev, PHYSDEV physdev, const struct gdi_dc_funcs *funcs);
156 #define push_dc_driver push_dc_driver_ros
157
158 BOOL WINAPI SetWorldTransformForMetafile(HDC hdc, const XFORM *pxform);
159 #define SetWorldTransform SetWorldTransformForMetafile
160
161 #ifdef _M_ARM
162 #define DbgRaiseAssertionFailure() __emit(0xdefc)
163 #else
164 #define DbgRaiseAssertionFailure() __int2c()
165 #endif // _M_ARM
166
167 #undef ASSERT
168 #define ASSERT(x) if (!(x)) DbgRaiseAssertionFailure()
169
170 #endif /* __WINE_GDI_PRIVATE_H */
171