1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Metafile utillities
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
23 #include <wx/metafile.h>
26 #include "wx/ogl/ogl.h"
30 static char _buf
[1024]; // a temp buffer to use inplace of wxBuffer, which is deprecated.
32 // 16-bit unsigned integer
33 static unsigned int getshort(FILE *fp
)
36 c
= getc(fp
); c1
= getc(fp
);
37 unsigned int res
= ((unsigned int) c
) + (((unsigned int) c1
) << 8);
41 // 16-bit signed integer
42 static int getsignedshort(FILE *fp
)
45 c
= getc(fp
); c1
= getc(fp
);
47 // this is not used value, no need to execute it
48 int testRes
= ((unsigned int) c
) + (((unsigned int) c1
) << 8);
50 unsigned long res1
= ((unsigned int) c
) + (((unsigned int) c1
) << 8);
53 res
= (int)(res1
- 65536);
60 static long getint(FILE *fp
)
63 c
= getc(fp
); c1
= getc(fp
); c2
= getc(fp
); c3
= getc(fp
);
64 long res
= (long)((long) c
) +
72 /* Placeable metafile header
73 struct mfPLACEABLEHEADER {
76 RECT bbox; // 4x16 bit
78 DWORD reserved; // 32-bit
79 WORD checksum; // 16-bit
83 wxMetaRecord::~wxMetaRecord(void)
85 if (points
) delete[] points
;
86 if (stringParam
) delete[] stringParam
;
89 wxXMetaFile::wxXMetaFile(const wxChar
*file
)
102 Handle table gdiObjects
103 ------------ ----------
105 [1]----param2--- wxBrush
109 The handle table works as follows.
110 When a GDI object is created while reading in the
111 metafile, the (e.g.) createpen record is added to the
112 first free entry in the handle table. The createpen
113 record's param1 is a pointer to the actual wxPen, and
114 its param2 is the index into the gdiObjects list, which only
115 grows and never shrinks (unlike the handle table.)
117 When SelectObject(index) is found, the index in the file
118 refers to the position in the handle table. BUT we then
119 set param2 to be the position of the wxPen in gdiObjects,
120 i.e. to param2 of the CreatePen record, itself found in
123 When an object is deleted, the entry in the handletable is
124 NULLed but the gdiObjects entry is not removed (no point, and
125 allows us to create all GDI objects in advance of playing the
130 static wxMetaRecord
*HandleTable
[100];
131 static int HandleTableSize
= 0;
133 void DeleteMetaRecordHandle(int index
)
135 HandleTable
[index
] = NULL
;
138 int AddMetaRecordHandle(wxMetaRecord
*record
)
140 for (int i
= 0; i
< HandleTableSize
; i
++)
143 HandleTable
[i
] = record
;
146 // No free spaces in table, so append.
148 HandleTable
[HandleTableSize
] = record
;
150 return (HandleTableSize
- 1);
153 bool wxXMetaFile::ReadFile(const wxChar
*file
)
157 FILE *handle
= wxFopen(file
, wxT("rb"));
158 if (!handle
) return false;
160 // Read placeable metafile header, if any
161 long key
= getint(handle
);
163 if (key
== (long) 0x9AC6CDD7)
165 /* long hmf = */ getshort(handle
);
166 int iLeft
, iTop
, iRight
, iBottom
;
167 iLeft
= getsignedshort(handle
);
168 iTop
= getsignedshort(handle
);
169 iRight
= getsignedshort(handle
);
170 iBottom
= getsignedshort(handle
);
172 left
= (double)iLeft
;
174 right
= (double)iRight
;
175 bottom
= (double)iBottom
;
177 /* int inch = */ getshort(handle
);
178 /* long reserved = */ getint(handle
);
179 /* int checksum = */ getshort(handle
);
181 double widthInUnits = (double)right - left;
182 double heightInUnits = (double)bottom - top;
183 *width = (int)((widthInUnits*1440.0)/inch);
184 *height = (int)((heightInUnits*1440.0)/inch);
190 int mtType
= getshort(handle
);
192 if (mtType
!= 1 && mtType
!= 2)
198 /* int mtHeaderSize = */ getshort(handle
);
199 int mtVersion
= getshort(handle
);
201 if (mtVersion
!= 0x0300 && mtVersion
!= 0x0100)
207 /* long mtSize = */ getint(handle
);
208 /* int mtNoObjects = */ getshort(handle
);
209 /* long mtMaxRecord = */ getint(handle
);
210 /* int mtNoParameters = */ getshort(handle
);
212 while (!feof(handle
))
214 long rdSize
= getint(handle
); // 4 bytes
215 int rdFunction
= getshort(handle
); // 2 bytes
221 case META_SETBKCOLOR
:
223 wxMetaRecord
*rec
= new wxMetaRecord(META_SETBKCOLOR
);
224 long colorref
= getint(handle
); // COLORREF
225 rec
->param1
= GetRValue(colorref
);
226 rec
->param2
= GetGValue(colorref
);
227 rec
->param3
= GetBValue(colorref
);
228 metaRecords
.Append(rec
);
233 wxMetaRecord
*rec
= new wxMetaRecord(META_SETBKMODE
);
234 rec
->param1
= getshort(handle
); // Background mode
235 if (rec
->param1
== OPAQUE
) rec
->param1
= wxSOLID
;
236 else rec
->param1
= wxTRANSPARENT
;
237 metaRecords
.Append(rec
);
240 case META_SETMAPMODE
:
242 wxMetaRecord
*rec
= new wxMetaRecord(META_SETMAPMODE
);
243 rec
->param1
= getshort(handle
);
244 metaRecords
.Append(rec
);
247 // case META_SETROP2:
248 // case META_SETRELABS:
249 // case META_SETPOLYFILLMODE:
250 // case META_SETSTRETCHBLTMODE:
251 // case META_SETTEXTCHAREXTRA:
252 case META_SETTEXTCOLOR
:
254 wxMetaRecord
*rec
= new wxMetaRecord(META_SETTEXTCOLOR
);
255 long colorref
= getint(handle
); // COLORREF
256 rec
->param1
= GetRValue(colorref
);
257 rec
->param2
= GetGValue(colorref
);
258 rec
->param3
= GetBValue(colorref
);
259 metaRecords
.Append(rec
);
262 // case META_SETTEXTJUSTIFICATION:
263 case META_SETWINDOWORG
:
265 wxMetaRecord
*rec
= new wxMetaRecord(META_SETWINDOWORG
);
266 rec
->param2
= getshort(handle
);
267 rec
->param1
= getshort(handle
);
268 metaRecords
.Append(rec
);
271 case META_SETWINDOWEXT
:
273 wxMetaRecord
*rec
= new wxMetaRecord(META_SETWINDOWEXT
);
274 rec
->param2
= getshort(handle
);
275 rec
->param1
= getshort(handle
);
276 metaRecords
.Append(rec
);
279 // case META_SETVIEWPORTORG:
280 // case META_SETVIEWPORTEXT:
281 // case META_OFFSETWINDOWORG:
282 // case META_SCALEWINDOWEXT:
283 // case META_OFFSETVIEWPORTORG:
284 // case META_SCALEVIEWPORTEXT:
287 wxMetaRecord
*rec
= new wxMetaRecord(META_LINETO
);
288 rec
->param1
= getshort(handle
); // x1
289 rec
->param2
= getshort(handle
); // y1
290 metaRecords
.Append(rec
);
295 wxMetaRecord
*rec
= new wxMetaRecord(META_MOVETO
);
296 rec
->param1
= getshort(handle
); // x1
297 rec
->param2
= getshort(handle
); // y1
298 metaRecords
.Append(rec
);
301 case META_EXCLUDECLIPRECT
:
303 wxMetaRecord
*rec
= new wxMetaRecord(META_EXCLUDECLIPRECT
);
304 rec
->param4
= getshort(handle
); // y2
305 rec
->param3
= getshort(handle
); // x2
306 rec
->param2
= getshort(handle
); // y1
307 rec
->param1
= getshort(handle
); // x1
308 metaRecords
.Append(rec
);
311 case META_INTERSECTCLIPRECT
:
313 wxMetaRecord
*rec
= new wxMetaRecord(META_INTERSECTCLIPRECT
);
314 rec
->param4
= getshort(handle
); // y2
315 rec
->param3
= getshort(handle
); // x2
316 rec
->param2
= getshort(handle
); // y1
317 rec
->param1
= getshort(handle
); // x1
318 metaRecords
.Append(rec
);
321 // case META_ARC: // DO!!!
324 wxMetaRecord
*rec
= new wxMetaRecord(META_ELLIPSE
);
325 rec
->param4
= getshort(handle
); // y2
326 rec
->param3
= getshort(handle
); // x2
327 rec
->param2
= getshort(handle
); // y1
328 rec
->param1
= getshort(handle
); // x1
329 metaRecords
.Append(rec
);
332 // case META_FLOODFILL:
333 // case META_PIE: // DO!!!
336 wxMetaRecord
*rec
= new wxMetaRecord(META_RECTANGLE
);
337 rec
->param4
= getshort(handle
); // y2
338 rec
->param3
= getshort(handle
); // x2
339 rec
->param2
= getshort(handle
); // y1
340 rec
->param1
= getshort(handle
); // x1
341 metaRecords
.Append(rec
);
346 wxMetaRecord
*rec
= new wxMetaRecord(META_ROUNDRECT
);
347 rec
->param6
= getshort(handle
); // width
348 rec
->param5
= getshort(handle
); // height
349 rec
->param4
= getshort(handle
); // y2
350 rec
->param3
= getshort(handle
); // x2
351 rec
->param2
= getshort(handle
); // y1
352 rec
->param1
= getshort(handle
); // x1
353 metaRecords
.Append(rec
);
360 wxMetaRecord
*rec
= new wxMetaRecord(META_SETPIXEL
);
361 rec
->param1
= getshort(handle
); // x1
362 rec
->param2
= getshort(handle
); // y1
363 rec
->param3
= getint(handle
); // COLORREF
364 metaRecords
.Append(rec
);
367 // case META_OFFSETCLIPRGN:
370 wxMetaRecord
*rec
= new wxMetaRecord(META_TEXTOUT
);
371 int count
= getshort(handle
);
372 rec
->stringParam
= new wxChar
[count
+1];
373 fread((void *)rec
->stringParam
, sizeof(wxChar
), count
, handle
);
374 rec
->stringParam
[count
] = 0;
375 rec
->param2
= getshort(handle
); // Y
376 rec
->param1
= getshort(handle
); // X
377 metaRecords
.Append(rec
);
381 case META_EXTTEXTOUT:
383 wxMetaRecord *rec = new wxMetaRecord(META_EXTTEXTOUT);
384 int cellSpacing = getshort(handle);
385 int count = getshort(handle);
386 rec->stringParam = new char[count+1];
387 fread((void *)rec->stringParam, sizeof(char), count, handle);
388 rec->stringParam[count] = 0;
390 int rectY2 = getshort(handle);
391 int rectX2 = getshort(handle);
392 int rectY1 = getshort(handle);
393 int rectX1 = getshort(handle);
394 int rectType = getshort(handle);
395 rec->param2 = getshort(handle); // Y
396 rec->param1 = getshort(handle); // X
397 metaRecords.Append(rec);
402 // case META_STRETCHBLT:
405 wxMetaRecord
*rec
= new wxMetaRecord(META_POLYGON
);
406 rec
->param1
= getshort(handle
);
407 rec
->points
= new wxRealPoint
[(int)rec
->param1
];
408 for (int i
= 0; i
< rec
->param1
; i
++)
410 rec
->points
[i
].x
= getshort(handle
);
411 rec
->points
[i
].y
= getshort(handle
);
414 metaRecords
.Append(rec
);
419 wxMetaRecord
*rec
= new wxMetaRecord(META_POLYLINE
);
420 rec
->param1
= (long)getshort(handle
);
421 rec
->points
= new wxRealPoint
[(int)rec
->param1
];
422 for (int i
= 0; i
< rec
->param1
; i
++)
424 rec
->points
[i
].x
= getshort(handle
);
425 rec
->points
[i
].y
= getshort(handle
);
428 metaRecords
.Append(rec
);
432 // case META_RESTOREDC:
433 // case META_FILLREGION:
434 // case META_FRAMEREGION:
435 // case META_INVERTREGION:
436 // case META_PAINTREGION:
437 // case META_SELECTCLIPREGION: // DO THIS!
438 case META_SELECTOBJECT
:
440 wxMetaRecord
*rec
= new wxMetaRecord(META_SELECTOBJECT
);
441 rec
->param1
= (long)getshort(handle
); // Position of object in gdiObjects list
442 metaRecords
.Append(rec
);
443 // param2 gives the index into gdiObjects, which is different from
444 // the index into the handle table.
445 rec
->param2
= HandleTable
[(int)rec
->param1
]->param2
;
448 // case META_SETTEXTALIGN:
449 // case META_DRAWTEXT:
451 // case META_SETMAPPERFLAGS:
452 // case META_EXTTEXTOUT:
453 // case META_SETDIBTODEV:
454 // case META_SELECTPALETTE:
455 // case META_REALIZEPALETTE:
456 // case META_ANIMATEPALETTE:
457 // case META_SETPALENTRIES:
458 // case META_POLYPOLYGON:
459 // case META_RESIZEPALETTE:
460 // case META_DIBBITBLT:
461 // case META_DIBSTRETCHBLT:
462 case META_DIBCREATEPATTERNBRUSH
:
464 wxMetaRecord
*rec
= new wxMetaRecord(META_DIBCREATEPATTERNBRUSH
);
465 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
467 metaRecords
.Append(rec
);
468 gdiObjects
.Append(rec
);
469 AddMetaRecordHandle(rec
);
470 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
473 // case META_STRETCHDIB:
474 // case META_EXTFLOODFILL:
475 // case META_RESETDC:
476 // case META_STARTDOC:
477 // case META_STARTPAGE:
478 // case META_ENDPAGE:
479 // case META_ABORTDOC:
481 case META_DELETEOBJECT
:
483 int index
= getshort(handle
);
484 DeleteMetaRecordHandle(index
);
487 case META_CREATEPALETTE
:
489 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEPALETTE
);
490 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
492 metaRecords
.Append(rec
);
493 gdiObjects
.Append(rec
);
494 AddMetaRecordHandle(rec
);
495 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
498 case META_CREATEBRUSH
:
500 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBRUSH
);
501 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
502 metaRecords
.Append(rec
);
503 gdiObjects
.Append(rec
);
504 AddMetaRecordHandle(rec
);
505 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
508 case META_CREATEPATTERNBRUSH
:
510 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEPATTERNBRUSH
);
511 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
512 metaRecords
.Append(rec
);
513 gdiObjects
.Append(rec
);
514 AddMetaRecordHandle(rec
);
515 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
518 case META_CREATEPENINDIRECT
:
520 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEPENINDIRECT
);
521 int msStyle
= getshort(handle
); // Style: 2 bytes
522 int x
= getshort(handle
); // X: 2 bytes
523 /* int y = */ getshort(handle
); // Y: 2 bytes
524 long colorref
= getint(handle
); // COLORREF 4 bytes
527 if (msStyle
== PS_DOT
)
529 else if (msStyle
== PS_DASH
)
530 style
= wxSHORT_DASH
;
531 else if (msStyle
== PS_NULL
)
532 style
= wxTRANSPARENT
;
533 else style
= wxSOLID
;
535 wxColour
colour(GetRValue(colorref
), GetGValue(colorref
), GetBValue(colorref
));
536 rec
->param1
= (long)wxThePenList
->FindOrCreatePen(colour
, x
, style
);
537 metaRecords
.Append(rec
);
538 gdiObjects
.Append(rec
);
540 AddMetaRecordHandle(rec
);
541 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
543 // For some reason, the size of this record is sometimes 9 words!!!
544 // instead of the usual 8. So read 2 characters extra.
547 (void) getshort(handle
);
551 case META_CREATEFONTINDIRECT
:
553 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEFONTINDIRECT
);
554 int lfHeight
= getshort(handle
); // 2 bytes
555 /* int lfWidth = */ getshort(handle
); // 2 bytes
556 /* int lfEsc = */ getshort(handle
); // 2 bytes
557 /* int lfOrient = */ getshort(handle
); // 2 bytes
558 int lfWeight
= getshort(handle
); // 2 bytes
559 char lfItalic
= (char)getc(handle
); // 1 byte
560 char lfUnderline
= (char)getc(handle
); // 1 byte
561 /* char lfStrikeout = */ getc(handle
); // 1 byte
562 /* char lfCharSet = */ getc(handle
); // 1 byte
563 /* char lfOutPrecision = */ getc(handle
); // 1 byte
564 /* char lfClipPrecision = */ getc(handle
); // 1 byte
565 /* char lfQuality = */ getc(handle
); // 1 byte
566 char lfPitchAndFamily
= (char)getc(handle
); // 1 byte (18th)
568 // Read the rest of the record, which is total record size
569 // minus the number of bytes already read (18 record, 6 metarecord
571 fread((void *)lfFacename
, sizeof(char), (int)((2*rdSize
) - 18 - 6), handle
);
574 if (lfPitchAndFamily
& FF_MODERN
)
576 else if (lfPitchAndFamily
& FF_MODERN
)
578 else if (lfPitchAndFamily
& FF_ROMAN
)
580 else if (lfPitchAndFamily
& FF_SWISS
)
582 else if (lfPitchAndFamily
& FF_DECORATIVE
)
583 family
= wxDECORATIVE
;
590 else if (lfWeight
== 400)
592 else if (lfWeight
== 900)
594 else weight
= wxNORMAL
;
602 // About how many pixels per inch???
603 int logPixelsY
= 100;
604 int pointSize
= (int)(lfHeight
*72.0/logPixelsY
);
607 wxTheFontList
->FindOrCreateFont(pointSize
, family
, style
, weight
, (lfUnderline
!= 0));
609 rec
->param1
= (long) theFont
;
610 metaRecords
.Append(rec
);
611 gdiObjects
.Append(rec
);
612 AddMetaRecordHandle(rec
);
613 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
616 case META_CREATEBRUSHINDIRECT
:
618 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBRUSHINDIRECT
);
619 int msStyle
= getshort(handle
); // Style: 2 bytes
620 long colorref
= getint(handle
); // COLORREF: 4 bytes
621 int hatchStyle
= getshort(handle
); // Hatch style 2 bytes
631 style
= wxBDIAGONAL_HATCH
;
634 style
= wxCROSSDIAG_HATCH
;
637 style
= wxFDIAGONAL_HATCH
;
640 style
= wxHORIZONTAL_HATCH
;
643 style
= wxVERTICAL_HATCH
;
647 style
= wxCROSS_HATCH
;
652 #if PS_DOT != BS_HATCHED
654 /* in microsoft/include/wingdi.h both are the same */
655 /* in fact I'm not sure why pen related PS_XXX and */
656 /* BS_XXX constants are all mixed into single style */
662 style
= wxSHORT_DASH
;
665 style
= wxTRANSPARENT
;
673 wxColour
colour(GetRValue(colorref
), GetGValue(colorref
), GetBValue(colorref
));
674 rec
->param1
= (long)wxTheBrushList
->FindOrCreateBrush(colour
, style
);
675 metaRecords
.Append(rec
);
676 gdiObjects
.Append(rec
);
677 AddMetaRecordHandle(rec
);
678 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
681 case META_CREATEBITMAPINDIRECT
:
683 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBITMAPINDIRECT
);
684 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
686 metaRecords
.Append(rec
);
687 gdiObjects
.Append(rec
);
688 AddMetaRecordHandle(rec
);
689 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
692 case META_CREATEBITMAP
:
694 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBITMAP
);
695 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
697 metaRecords
.Append(rec
);
698 gdiObjects
.Append(rec
);
699 AddMetaRecordHandle(rec
);
700 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
703 case META_CREATEREGION
:
705 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEREGION
);
706 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
708 metaRecords
.Append(rec
);
709 gdiObjects
.Append(rec
);
710 AddMetaRecordHandle(rec
);
711 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
716 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
725 wxXMetaFile::~wxXMetaFile(void)
727 wxObjectList::compatibility_iterator node
= metaRecords
.GetFirst();
730 wxMetaRecord
*rec
= (wxMetaRecord
*)node
->GetData();
732 wxObjectList::compatibility_iterator next
= node
->GetNext();
733 metaRecords
.Erase(node
);
738 bool wxXMetaFile::SetClipboard(int WXUNUSED(width
), int WXUNUSED(height
))
743 bool wxXMetaFile::Play(wxDC
*dc
)
745 wxObjectList::compatibility_iterator node
= metaRecords
.GetFirst();
748 wxMetaRecord
*rec
= (wxMetaRecord
*)node
->GetData();
749 int rdFunction
= rec
->metaFunction
;
753 case META_SETBKCOLOR
:
761 case META_SETMAPMODE
:
765 // case META_SETROP2:
766 // case META_SETRELABS:
767 // case META_SETPOLYFILLMODE:
768 // case META_SETSTRETCHBLTMODE:
769 // case META_SETTEXTCHAREXTRA:
770 case META_SETTEXTCOLOR
:
774 // case META_SETTEXTJUSTIFICATION:
775 case META_SETWINDOWORG
:
779 case META_SETWINDOWEXT
:
783 // case META_SETVIEWPORTORG:
784 // case META_SETVIEWPORTEXT:
785 // case META_OFFSETWINDOWORG:
786 // case META_SCALEWINDOWEXT:
787 // case META_OFFSETVIEWPORTORG:
788 // case META_SCALEVIEWPORTEXT:
791 long x1
= rec
->param1
;
792 long y1
= rec
->param2
;
793 dc
->DrawLine((long) lastX
, (long) lastY
, x1
, y1
);
798 lastX
= (double)rec
->param1
;
799 lastY
= (double)rec
->param2
;
802 case META_EXCLUDECLIPRECT
:
806 case META_INTERSECTCLIPRECT
:
810 // case META_ARC: // DO!!!
815 // case META_FLOODFILL:
816 // case META_PIE: // DO!!!
819 dc
->DrawRectangle((long)rec
->param1
, (long)rec
->param2
,
820 (long)rec
->param3
- rec
->param1
,
821 (long)rec
->param4
- rec
->param2
);
826 dc
->DrawRoundedRectangle((long)rec
->param1
, (long)rec
->param2
,
827 (long)rec
->param3
- rec
->param1
,
828 (long)rec
->param4
- rec
->param2
,
836 // rec->param1 = getshort(handle); // x1
837 // rec->param2 = getshort(handle); // y1
838 // rec->param3 = getint(handle); // COLORREF
841 // case META_OFFSETCLIPRGN:
845 int count = getshort(handle);
846 rec->stringParam = new char[count+1];
847 fread((void *)rec->stringParam, sizeof(char), count, handle);
848 rec->stringParam[count] = 0;
849 rec->param2 = getshort(handle); // Y
850 rec->param1 = getshort(handle); // X
855 // case META_STRETCHBLT:
859 rec->param1 = getshort(handle);
860 rec->points = new wxRealPoint[(int)rec->param1];
861 for (int i = 0; i < rec->param1; i++)
863 rec->points[i].x = getshort(handle);
864 rec->points[i].y = getshort(handle);
872 wxMetaRecord *rec = new wxMetaRecord(META_POLYLINE);
873 rec->param1 = (long)getshort(handle);
874 rec->points = new wxRealPoint[(int)rec->param1];
875 for (int i = 0; i < rec->param1; i++)
877 rec->points[i].x = getshort(handle);
878 rec->points[i].y = getshort(handle);
884 // case META_RESTOREDC:
885 // case META_FILLREGION:
886 // case META_FRAMEREGION:
887 // case META_INVERTREGION:
888 // case META_PAINTREGION:
889 // case META_SELECTCLIPREGION: // DO THIS!
890 case META_SELECTOBJECT
:
893 wxMetaRecord *rec = new wxMetaRecord(META_SELECTOBJECT);
894 rec->param1 = (long)getshort(handle); // Position of object in gdiObjects list
898 // case META_SETTEXTALIGN:
899 // case META_DRAWTEXT:
901 // case META_SETMAPPERFLAGS:
902 // case META_EXTTEXTOUT:
903 // case META_SETDIBTODEV:
904 // case META_SELECTPALETTE:
905 // case META_REALIZEPALETTE:
906 // case META_ANIMATEPALETTE:
907 // case META_SETPALENTRIES:
908 // case META_POLYPOLYGON:
909 // case META_RESIZEPALETTE:
910 // case META_DIBBITBLT:
911 // case META_DIBSTRETCHBLT:
912 case META_DIBCREATEPATTERNBRUSH
:
915 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
919 // case META_STRETCHDIB:
920 // case META_EXTFLOODFILL:
921 // case META_RESETDC:
922 // case META_STARTDOC:
923 // case META_STARTPAGE:
924 // case META_ENDPAGE:
925 // case META_ABORTDOC:
927 // case META_DELETEOBJECT: // DO!!
928 case META_CREATEPALETTE
:
931 wxMetaRecord *rec = new wxMetaRecord(META_CREATEPALETTE);
932 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
936 case META_CREATEBRUSH
:
939 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
943 case META_CREATEPATTERNBRUSH
:
946 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
950 case META_CREATEPENINDIRECT
:
953 int msStyle = getshort(handle); // Style: 2 bytes
954 int x = getshort(handle); // X: 2 bytes
955 int y = getshort(handle); // Y: 2 bytes
956 int colorref = getint(handle); // COLORREF 4 bytes
959 if (msStyle == PS_DOT)
961 else if (msStyle == PS_DASH)
962 style = wxSHORT_DASH;
963 else if (msStyle == PS_NULL)
964 style = wxTRANSPARENT;
965 else style = wxSOLID;
967 wxColour colour(GetRValue(colorref), GetGValue(colorref), GetBValue(colorref));
968 rec->param1 = (long)wxThePenList->FindOrCreatePen(&colour, x, style);
972 case META_CREATEFONTINDIRECT
:
975 int lfHeight = getshort(handle);
976 int lfWidth = getshort(handle);
977 int lfEsc = getshort(handle);
978 int lfOrient = getshort(handle);
979 int lfWeight = getshort(handle);
980 char lfItalic = getc(handle);
981 char lfUnderline = getc(handle);
982 char lfStrikeout = getc(handle);
983 char lfCharSet = getc(handle);
984 char lfOutPrecision = getc(handle);
985 char lfClipPrecision = getc(handle);
986 char lfQuality = getc(handle);
987 char lfPitchAndFamily = getc(handle);
989 fread((void *)lfFacename, sizeof(char), 32, handle);
992 if (lfPitchAndFamily & FF_MODERN)
994 else if (lfPitchAndFamily & FF_MODERN)
996 else if (lfPitchAndFamily & FF_ROMAN)
998 else if (lfPitchAndFamily & FF_SWISS)
1000 else if (lfPitchAndFamily & FF_DECORATIVE)
1001 family = wxDECORATIVE;
1006 if (lfWeight == 300)
1008 else if (lfWeight == 400)
1010 else if (lfWeight == 900)
1012 else weight = wxNORMAL;
1020 // About how many pixels per inch???
1021 int logPixelsY = 100;
1022 int pointSize = (int)(lfHeight*72.0/logPixelsY);
1025 wxTheFontList->FindOrCreateFont(pointSize, family, style, weight, (bool)lfUnderline);
1027 rec->param1 = (long)theFont;
1031 case META_CREATEBRUSHINDIRECT
:
1034 int msStyle = getshort(handle); // Style: 2 bytes
1035 int colorref = getint(handle); // COLORREF: 4 bytes
1036 int hatchStyle = getshort(handle); // Hatch style 2 bytes
1039 if (msStyle == PS_DOT)
1041 else if (msStyle == PS_DASH)
1042 style = wxSHORT_DASH;
1043 else if (msStyle == PS_NULL)
1044 style = wxTRANSPARENT;
1045 else style = wxSOLID;
1047 wxColour colour(GetRValue(colorref), GetGValue(colorref), GetBValue(colorref));
1048 rec->param1 = (long)wxTheBrushList->FindOrCreateBrush(&colour, wxSOLID);
1052 case META_CREATEBITMAPINDIRECT
:
1055 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
1059 case META_CREATEBITMAP
:
1062 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
1066 case META_CREATEREGION
:
1068 dc
->DestroyClippingRegion();
1070 rec->param1 = getshort(handle); // Style: 2 bytes
1079 node
= node
->GetNext();