1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Metafile utilities: reading a placeable metafile independently
5 // Author: Julian Smart
9 // Copyright: (c) Julian Smart
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
17 #include "wx/metafile.h"
20 #define GetRValue(rgb) ((unsigned char)(rgb))
21 #define GetGValue(rgb) ((unsigned char)(((int)(rgb)) >> 8))
22 #define GetBValue(rgb) ((unsigned char)((rgb)>>16))
25 /* Metafile Functions */
26 // some compilers have them in their include files
28 #ifndef META_SETBKCOLOR
29 #define META_SETBKCOLOR 0x0201
31 #ifndef META_SETBKMODE
32 #define META_SETBKMODE 0x0102
34 #ifndef META_SETMAPMODE
35 #define META_SETMAPMODE 0x0103
38 #define META_SETROP2 0x0104
40 #ifndef META_SETRELABS
41 #define META_SETRELABS 0x0105
43 #ifndef META_SETPOLYFILLMODE
44 #define META_SETPOLYFILLMODE 0x0106
46 #ifndef META_SETSTRETCHBLTMODE
47 #define META_SETSTRETCHBLTMODE 0x0107
49 #ifndef META_SETTEXTCHAREXTRA
50 #define META_SETTEXTCHAREXTRA 0x0108
52 #ifndef META_SETTEXTCOLOR
53 #define META_SETTEXTCOLOR 0x0209
55 #ifndef META_SETTEXTJUSTIFICATION
56 #define META_SETTEXTJUSTIFICATION 0x020A
58 #ifndef META_SETWINDOWORG
59 #define META_SETWINDOWORG 0x020B
61 #ifndef META_SETWINDOWEXT
62 #define META_SETWINDOWEXT 0x020C
64 #ifndef META_SETVIEWPORTORG
65 #define META_SETVIEWPORTORG 0x020D
67 #ifndef META_SETVIEWPORTEXT
68 #define META_SETVIEWPORTEXT 0x020E
70 #ifndef META_OFFSETWINDOWORG
71 #define META_OFFSETWINDOWORG 0x020F
73 #ifndef META_SCALEWINDOWEXT
74 #define META_SCALEWINDOWEXT 0x0410
76 #ifndef META_OFFSETVIEWPORTORG
77 #define META_OFFSETVIEWPORTORG 0x0211
79 #ifndef META_SCALEVIEWPORTEXT
80 #define META_SCALEVIEWPORTEXT 0x0412
83 #define META_LINETO 0x0213
86 #define META_MOVETO 0x0214
88 #ifndef META_EXCLUDECLIPRECT
89 #define META_EXCLUDECLIPRECT 0x0415
91 #ifndef META_INTERSECTCLIPRECT
92 #define META_INTERSECTCLIPRECT 0x0416
95 #define META_ARC 0x0817
98 #define META_ELLIPSE 0x0418
100 #ifndef META_FLOODFILL
101 #define META_FLOODFILL 0x0419
104 #define META_PIE 0x081A
106 #ifndef META_RECTANGLE
107 #define META_RECTANGLE 0x041B
109 #ifndef META_ROUNDRECT
110 #define META_ROUNDRECT 0x061C
113 #define META_PATBLT 0x061D
116 #define META_SAVEDC 0x001E
118 #ifndef META_SETPIXEL
119 #define META_SETPIXEL 0x041F
121 #ifndef META_OFFSETCLIPRGN
122 #define META_OFFSETCLIPRGN 0x0220
125 #define META_TEXTOUT 0x0521
128 #define META_BITBLT 0x0922
130 #ifndef META_STRETCHBLT
131 #define META_STRETCHBLT 0x0B23
134 #define META_POLYGON 0x0324
136 #ifndef META_POLYLINE
137 #define META_POLYLINE 0x0325
140 #define META_ESCAPE 0x0626
142 #ifndef META_RESTOREDC
143 #define META_RESTOREDC 0x0127
145 #ifndef META_FILLREGION
146 #define META_FILLREGION 0x0228
148 #ifndef META_FRAMEREGION
149 #define META_FRAMEREGION 0x0429
151 #ifndef META_INVERTREGION
152 #define META_INVERTREGION 0x012A
154 #ifndef META_PAINTREGION
155 #define META_PAINTREGION 0x012B
157 #ifndef META_SELECTCLIPREGION
158 #define META_SELECTCLIPREGION 0x012C
160 #ifndef META_SELECTOBJECT
161 #define META_SELECTOBJECT 0x012D
163 #ifndef META_SETTEXTALIGN
164 #define META_SETTEXTALIGN 0x012E
166 #ifndef META_DRAWTEXT
167 #define META_DRAWTEXT 0x062F
171 #define META_CHORD 0x0830
173 #ifndef META_SETMAPPERFLAGS
174 #define META_SETMAPPERFLAGS 0x0231
176 #ifndef META_EXTTEXTOUT
177 #define META_EXTTEXTOUT 0x0a32
179 #ifndef META_SETDIBTODEV
180 #define META_SETDIBTODEV 0x0d33
182 #ifndef META_SELECTPALETTE
183 #define META_SELECTPALETTE 0x0234
185 #ifndef META_REALIZEPALETTE
186 #define META_REALIZEPALETTE 0x0035
188 #ifndef META_ANIMATEPALETTE
189 #define META_ANIMATEPALETTE 0x0436
191 #ifndef META_SETPALENTRIES
192 #define META_SETPALENTRIES 0x0037
194 #ifndef META_POLYPOLYGON
195 #define META_POLYPOLYGON 0x0538
197 #ifndef META_RESIZEPALETTE
198 #define META_RESIZEPALETTE 0x0139
201 #ifndef META_DIBBITBLT
202 #define META_DIBBITBLT 0x0940
204 #ifndef META_DIBSTRETCHBLT
205 #define META_DIBSTRETCHBLT 0x0b41
207 #ifndef META_DIBCREATEPATTERNBRUSH
208 #define META_DIBCREATEPATTERNBRUSH 0x0142
210 #ifndef META_STRETCHDIB
211 #define META_STRETCHDIB 0x0f43
214 #ifndef META_EXTFLOODFILL
215 #define META_EXTFLOODFILL 0x0548
219 #define META_RESETDC 0x014C
221 #ifndef META_STARTDOC
222 #define META_STARTDOC 0x014D
224 #ifndef META_STARTPAGE
225 #define META_STARTPAGE 0x004F
228 #define META_ENDPAGE 0x0050
230 #ifndef META_ABORTDOC
231 #define META_ABORTDOC 0x0052
234 #define META_ENDDOC 0x005E
237 #ifndef META_DELETEOBJECT
238 #define META_DELETEOBJECT 0x01f0
241 #ifndef META_CREATEPALETTE
242 #define META_CREATEPALETTE 0x00f7
244 #ifndef META_CREATEBRUSH
245 #define META_CREATEBRUSH 0x00F8
247 #ifndef META_CREATEPATTERNBRUSH
248 #define META_CREATEPATTERNBRUSH 0x01F9
250 #ifndef META_CREATEPENINDIRECT
251 #define META_CREATEPENINDIRECT 0x02FA
253 #ifndef META_CREATEFONTINDIRECT
254 #define META_CREATEFONTINDIRECT 0x02FB
256 #ifndef META_CREATEBRUSHINDIRECT
257 #define META_CREATEBRUSHINDIRECT 0x02FC
259 #ifndef META_CREATEBITMAPINDIRECT
260 #define META_CREATEBITMAPINDIRECT 0x02FD
262 #ifndef META_CREATEBITMAP
263 #define META_CREATEBITMAP 0x06FE
265 #ifndef META_CREATEREGION
266 #define META_CREATEREGION 0x06FF
269 /* Background Modes */
271 #define TRANSPARENT 1
290 #ifndef PS_DASHDOTDOT
291 #define PS_DASHDOTDOT 4
296 #ifndef PS_INSIDEFRAME
297 #define PS_INSIDEFRAME 6
300 /* PitchAndFamily family values (high 4 bits) */
302 #define FF_DONTCARE 0x00
305 #define FF_ROMAN 0x10
308 #define FF_SWISS 0x20
311 #define FF_MODERN 0x30
314 #define FF_SCRIPT 0x40
316 #ifndef FF_DECORATIVE
317 #define FF_DECORATIVE 0x50
328 #define BS_HOLLOW BS_NULL
339 #ifndef BS_DIBPATTERN
340 #define BS_DIBPATTERN 5
344 #ifndef HS_HORIZONTAL
345 #define HS_HORIZONTAL 0
348 #define HS_VERTICAL 1
351 #define HS_FDIAGONAL 2
354 #define HS_BDIAGONAL 3
360 #define HS_DIAGCROSS 5
363 class WXDLLIMPEXP_OGL wxMetaRecord
: public wxObject
378 wxMetaRecord(int fun
)
380 metaFunction
= fun
; points
= NULL
; stringParam
= NULL
;
386 class WXDLLIMPEXP_OGL wxXMetaFile
: public wxObject
399 wxList gdiObjects
; // List of wxMetaRecord objects created with Create...,
400 // referenced by position in list by SelectObject
401 wxXMetaFile(const wxChar
* file
= NULL
);
404 // After this is called, the metafile cannot be used for anything
405 // since it is now owned by the clipboard.
406 bool SetClipboard(int width
= 0, int height
= 0);
409 inline bool Ok(void) const { return ok
; }
410 bool ReadFile(const wxChar
*file
);