1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Metafile utillities
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "mfutils.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
27 #include <wx/metafile.h>
30 #include <wx/ogl/mfutils.h>
33 static char _buf
[1024]; // a temp buffer to use inplace of wxBuffer, which is deprecated.
35 static char hexArray
[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
38 static void DecToHex(int dec
, char *buf
)
40 int firstDigit
= (int)(dec
/16.0);
41 int secondDigit
= (int)(dec
- (firstDigit
*16.0));
42 buf
[0] = hexArray
[firstDigit
];
43 buf
[1] = hexArray
[secondDigit
];
47 // 16-bit unsigned integer
48 static unsigned int getshort(FILE *fp
)
51 c
= getc(fp
); c1
= getc(fp
);
52 unsigned int res
= ((unsigned int) c
) + (((unsigned int) c1
) << 8);
56 // 16-bit signed integer
57 static int getsignedshort(FILE *fp
)
60 c
= getc(fp
); c1
= getc(fp
);
61 int testRes
= ((unsigned int) c
) + (((unsigned int) c1
) << 8);
62 unsigned long res1
= ((unsigned int) c
) + (((unsigned int) c1
) << 8);
65 res
= (int)(res1
- 65536);
72 static long getint(FILE *fp
)
75 c
= getc(fp
); c1
= getc(fp
); c2
= getc(fp
); c3
= getc(fp
);
76 long res
= (long)((long) c
) +
84 /* Placeable metafile header
85 struct mfPLACEABLEHEADER {
88 RECT bbox; // 4x16 bit
90 DWORD reserved; // 32-bit
91 WORD checksum; // 16-bit
95 wxMetaRecord::~wxMetaRecord(void)
97 if (points
) delete[] points
;
98 if (stringParam
) delete[] stringParam
;
101 wxXMetaFile::wxXMetaFile(char *file
)
114 Handle table gdiObjects
115 ------------ ----------
117 [1]----param2--- wxBrush
121 The handle table works as follows.
122 When a GDI object is created whilst reading in the
123 metafile, the (e.g.) createpen record is added to the
124 first free entry in the handle table. The createpen
125 record's param1 is a pointer to the actual wxPen, and
126 its param2 is the index into the gdiObjects list, which only
127 grows and never shrinks (unlike the handle table.)
129 When SelectObject(index) is found, the index in the file
130 refers to the position in the handle table. BUT we then
131 set param2 to be the position of the wxPen in gdiObjects,
132 i.e. to param2 of the CreatePen record, itself found in
135 When an object is deleted, the entry in the handletable is
136 NULLed but the gdiObjects entry is not removed (no point, and
137 allows us to create all GDI objects in advance of playing the
142 static wxMetaRecord
*HandleTable
[100];
143 static int HandleTableSize
= 0;
145 void DeleteMetaRecordHandle(int index
)
147 HandleTable
[index
] = NULL
;
150 int AddMetaRecordHandle(wxMetaRecord
*record
)
152 for (int i
= 0; i
< HandleTableSize
; i
++)
155 HandleTable
[i
] = record
;
158 // No free spaces in table, so append.
160 HandleTable
[HandleTableSize
] = record
;
162 return (HandleTableSize
- 1);
165 bool wxXMetaFile::ReadFile(char *file
)
169 FILE *handle
= fopen(file
, "rb");
170 if (!handle
) return FALSE
;
172 // Read placeable metafile header, if any
173 long key
= getint(handle
);
175 if (key
== (long) 0x9AC6CDD7)
177 long hmf
= getshort(handle
);
178 int iLeft
, iTop
, iRight
, iBottom
;
179 iLeft
= getsignedshort(handle
);
180 iTop
= getsignedshort(handle
);
181 iRight
= getsignedshort(handle
);
182 iBottom
= getsignedshort(handle
);
184 left
= (double)iLeft
;
186 right
= (double)iRight
;
187 bottom
= (double)iBottom
;
189 int inch
= getshort(handle
);
190 long reserved
= getint(handle
);
191 int checksum
= getshort(handle
);
193 double widthInUnits = (double)right - left;
194 double heightInUnits = (double)bottom - top;
195 *width = (int)((widthInUnits*1440.0)/inch);
196 *height = (int)((heightInUnits*1440.0)/inch);
202 int mtType
= getshort(handle
);
204 if (mtType
!= 1 && mtType
!= 2)
210 int mtHeaderSize
= getshort(handle
);
211 int mtVersion
= getshort(handle
);
213 if (mtVersion
!= 0x0300 && mtVersion
!= 0x0100)
219 long mtSize
= getint(handle
);
220 int mtNoObjects
= getshort(handle
);
221 long mtMaxRecord
= getint(handle
);
222 int mtNoParameters
= getshort(handle
);
224 while (!feof(handle
))
226 long rdSize
= getint(handle
); // 4 bytes
227 int rdFunction
= getshort(handle
); // 2 bytes
233 case META_SETBKCOLOR
:
235 wxMetaRecord
*rec
= new wxMetaRecord(META_SETBKCOLOR
);
236 long colorref
= getint(handle
); // COLORREF
237 rec
->param1
= GetRValue(colorref
);
238 rec
->param2
= GetGValue(colorref
);
239 rec
->param3
= GetBValue(colorref
);
240 metaRecords
.Append(rec
);
245 wxMetaRecord
*rec
= new wxMetaRecord(META_SETBKMODE
);
246 rec
->param1
= getshort(handle
); // Background mode
247 if (rec
->param1
== OPAQUE
) rec
->param1
= wxSOLID
;
248 else rec
->param1
= wxTRANSPARENT
;
249 metaRecords
.Append(rec
);
252 case META_SETMAPMODE
:
254 wxMetaRecord
*rec
= new wxMetaRecord(META_SETMAPMODE
);
255 rec
->param1
= getshort(handle
);
256 metaRecords
.Append(rec
);
259 // case META_SETROP2:
260 // case META_SETRELABS:
261 // case META_SETPOLYFILLMODE:
262 // case META_SETSTRETCHBLTMODE:
263 // case META_SETTEXTCHAREXTRA:
264 case META_SETTEXTCOLOR
:
266 wxMetaRecord
*rec
= new wxMetaRecord(META_SETTEXTCOLOR
);
267 long colorref
= getint(handle
); // COLORREF
268 rec
->param1
= GetRValue(colorref
);
269 rec
->param2
= GetGValue(colorref
);
270 rec
->param3
= GetBValue(colorref
);
271 metaRecords
.Append(rec
);
274 // case META_SETTEXTJUSTIFICATION:
275 case META_SETWINDOWORG
:
277 wxMetaRecord
*rec
= new wxMetaRecord(META_SETWINDOWORG
);
278 rec
->param2
= getshort(handle
);
279 rec
->param1
= getshort(handle
);
280 metaRecords
.Append(rec
);
283 case META_SETWINDOWEXT
:
285 wxMetaRecord
*rec
= new wxMetaRecord(META_SETWINDOWEXT
);
286 rec
->param2
= getshort(handle
);
287 rec
->param1
= getshort(handle
);
288 metaRecords
.Append(rec
);
291 // case META_SETVIEWPORTORG:
292 // case META_SETVIEWPORTEXT:
293 // case META_OFFSETWINDOWORG:
294 // case META_SCALEWINDOWEXT:
295 // case META_OFFSETVIEWPORTORG:
296 // case META_SCALEVIEWPORTEXT:
299 wxMetaRecord
*rec
= new wxMetaRecord(META_LINETO
);
300 rec
->param1
= getshort(handle
); // x1
301 rec
->param2
= getshort(handle
); // y1
302 metaRecords
.Append(rec
);
307 wxMetaRecord
*rec
= new wxMetaRecord(META_MOVETO
);
308 rec
->param1
= getshort(handle
); // x1
309 rec
->param2
= getshort(handle
); // y1
310 metaRecords
.Append(rec
);
313 case META_EXCLUDECLIPRECT
:
315 wxMetaRecord
*rec
= new wxMetaRecord(META_EXCLUDECLIPRECT
);
316 rec
->param4
= getshort(handle
); // y2
317 rec
->param3
= getshort(handle
); // x2
318 rec
->param2
= getshort(handle
); // y1
319 rec
->param1
= getshort(handle
); // x1
320 metaRecords
.Append(rec
);
323 case META_INTERSECTCLIPRECT
:
325 wxMetaRecord
*rec
= new wxMetaRecord(META_INTERSECTCLIPRECT
);
326 rec
->param4
= getshort(handle
); // y2
327 rec
->param3
= getshort(handle
); // x2
328 rec
->param2
= getshort(handle
); // y1
329 rec
->param1
= getshort(handle
); // x1
330 metaRecords
.Append(rec
);
333 // case META_ARC: // DO!!!
336 wxMetaRecord
*rec
= new wxMetaRecord(META_ELLIPSE
);
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
);
344 // case META_FLOODFILL:
345 // case META_PIE: // DO!!!
348 wxMetaRecord
*rec
= new wxMetaRecord(META_RECTANGLE
);
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
);
358 wxMetaRecord
*rec
= new wxMetaRecord(META_ROUNDRECT
);
359 rec
->param6
= getshort(handle
); // width
360 rec
->param5
= getshort(handle
); // height
361 rec
->param4
= getshort(handle
); // y2
362 rec
->param3
= getshort(handle
); // x2
363 rec
->param2
= getshort(handle
); // y1
364 rec
->param1
= getshort(handle
); // x1
365 metaRecords
.Append(rec
);
372 wxMetaRecord
*rec
= new wxMetaRecord(META_SETPIXEL
);
373 rec
->param1
= getshort(handle
); // x1
374 rec
->param2
= getshort(handle
); // y1
375 rec
->param3
= getint(handle
); // COLORREF
376 metaRecords
.Append(rec
);
379 // case META_OFFSETCLIPRGN:
382 wxMetaRecord
*rec
= new wxMetaRecord(META_TEXTOUT
);
383 int count
= getshort(handle
);
384 rec
->stringParam
= new wxChar
[count
+1];
385 fread((void *)rec
->stringParam
, sizeof(wxChar
), count
, handle
);
386 rec
->stringParam
[count
] = 0;
387 rec
->param2
= getshort(handle
); // Y
388 rec
->param1
= getshort(handle
); // X
389 metaRecords
.Append(rec
);
393 case META_EXTTEXTOUT:
395 wxMetaRecord *rec = new wxMetaRecord(META_EXTTEXTOUT);
396 int cellSpacing = getshort(handle);
397 int count = getshort(handle);
398 rec->stringParam = new char[count+1];
399 fread((void *)rec->stringParam, sizeof(char), count, handle);
400 rec->stringParam[count] = 0;
402 int rectY2 = getshort(handle);
403 int rectX2 = getshort(handle);
404 int rectY1 = getshort(handle);
405 int rectX1 = getshort(handle);
406 int rectType = getshort(handle);
407 rec->param2 = getshort(handle); // Y
408 rec->param1 = getshort(handle); // X
409 metaRecords.Append(rec);
414 // case META_STRETCHBLT:
417 wxMetaRecord
*rec
= new wxMetaRecord(META_POLYGON
);
418 rec
->param1
= getshort(handle
);
419 rec
->points
= new wxRealPoint
[(int)rec
->param1
];
420 for (int i
= 0; i
< rec
->param1
; i
++)
422 rec
->points
[i
].x
= getshort(handle
);
423 rec
->points
[i
].y
= getshort(handle
);
426 metaRecords
.Append(rec
);
431 wxMetaRecord
*rec
= new wxMetaRecord(META_POLYLINE
);
432 rec
->param1
= (long)getshort(handle
);
433 rec
->points
= new wxRealPoint
[(int)rec
->param1
];
434 for (int i
= 0; i
< rec
->param1
; i
++)
436 rec
->points
[i
].x
= getshort(handle
);
437 rec
->points
[i
].y
= getshort(handle
);
440 metaRecords
.Append(rec
);
444 // case META_RESTOREDC:
445 // case META_FILLREGION:
446 // case META_FRAMEREGION:
447 // case META_INVERTREGION:
448 // case META_PAINTREGION:
449 // case META_SELECTCLIPREGION: // DO THIS!
450 case META_SELECTOBJECT
:
452 wxMetaRecord
*rec
= new wxMetaRecord(META_SELECTOBJECT
);
453 rec
->param1
= (long)getshort(handle
); // Position of object in gdiObjects list
454 metaRecords
.Append(rec
);
455 // param2 gives the index into gdiObjects, which is different from
456 // the index into the handle table.
457 rec
->param2
= HandleTable
[(int)rec
->param1
]->param2
;
460 // case META_SETTEXTALIGN:
461 // case META_DRAWTEXT:
463 // case META_SETMAPPERFLAGS:
464 // case META_EXTTEXTOUT:
465 // case META_SETDIBTODEV:
466 // case META_SELECTPALETTE:
467 // case META_REALIZEPALETTE:
468 // case META_ANIMATEPALETTE:
469 // case META_SETPALENTRIES:
470 // case META_POLYPOLYGON:
471 // case META_RESIZEPALETTE:
472 // case META_DIBBITBLT:
473 // case META_DIBSTRETCHBLT:
474 case META_DIBCREATEPATTERNBRUSH
:
476 wxMetaRecord
*rec
= new wxMetaRecord(META_DIBCREATEPATTERNBRUSH
);
477 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
479 metaRecords
.Append(rec
);
480 gdiObjects
.Append(rec
);
481 AddMetaRecordHandle(rec
);
482 rec
->param2
= (long)(gdiObjects
.Number() - 1);
485 // case META_STRETCHDIB:
486 // case META_EXTFLOODFILL:
487 // case META_RESETDC:
488 // case META_STARTDOC:
489 // case META_STARTPAGE:
490 // case META_ENDPAGE:
491 // case META_ABORTDOC:
493 case META_DELETEOBJECT
:
495 int index
= getshort(handle
);
496 DeleteMetaRecordHandle(index
);
499 case META_CREATEPALETTE
:
501 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEPALETTE
);
502 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
504 metaRecords
.Append(rec
);
505 gdiObjects
.Append(rec
);
506 AddMetaRecordHandle(rec
);
507 rec
->param2
= (long)(gdiObjects
.Number() - 1);
510 case META_CREATEBRUSH
:
512 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBRUSH
);
513 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
514 metaRecords
.Append(rec
);
515 gdiObjects
.Append(rec
);
516 AddMetaRecordHandle(rec
);
517 rec
->param2
= (long)(gdiObjects
.Number() - 1);
520 case META_CREATEPATTERNBRUSH
:
522 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEPATTERNBRUSH
);
523 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
524 metaRecords
.Append(rec
);
525 gdiObjects
.Append(rec
);
526 AddMetaRecordHandle(rec
);
527 rec
->param2
= (long)(gdiObjects
.Number() - 1);
530 case META_CREATEPENINDIRECT
:
532 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEPENINDIRECT
);
533 int msStyle
= getshort(handle
); // Style: 2 bytes
534 int x
= getshort(handle
); // X: 2 bytes
535 int y
= getshort(handle
); // Y: 2 bytes
536 long colorref
= getint(handle
); // COLORREF 4 bytes
539 if (msStyle
== PS_DOT
)
541 else if (msStyle
== PS_DASH
)
542 style
= wxSHORT_DASH
;
543 else if (msStyle
== PS_NULL
)
544 style
= wxTRANSPARENT
;
545 else style
= wxSOLID
;
547 wxColour
colour(GetRValue(colorref
), GetGValue(colorref
), GetBValue(colorref
));
548 rec
->param1
= (long)wxThePenList
->FindOrCreatePen(colour
, x
, style
);
549 metaRecords
.Append(rec
);
550 gdiObjects
.Append(rec
);
552 AddMetaRecordHandle(rec
);
553 rec
->param2
= (long)(gdiObjects
.Number() - 1);
555 // For some reason, the size of this record is sometimes 9 words!!!
556 // instead of the usual 8. So read 2 characters extra.
559 (void) getshort(handle
);
563 case META_CREATEFONTINDIRECT
:
565 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEFONTINDIRECT
);
566 int lfHeight
= getshort(handle
); // 2 bytes
567 int lfWidth
= getshort(handle
); // 2 bytes
568 int lfEsc
= getshort(handle
); // 2 bytes
569 int lfOrient
= getshort(handle
); // 2 bytes
570 int lfWeight
= getshort(handle
); // 2 bytes
571 char lfItalic
= getc(handle
); // 1 byte
572 char lfUnderline
= getc(handle
); // 1 byte
573 char lfStrikeout
= getc(handle
); // 1 byte
574 char lfCharSet
= getc(handle
); // 1 byte
575 char lfOutPrecision
= getc(handle
); // 1 byte
576 char lfClipPrecision
= getc(handle
); // 1 byte
577 char lfQuality
= getc(handle
); // 1 byte
578 char lfPitchAndFamily
= getc(handle
); // 1 byte (18th)
580 // Read the rest of the record, which is total record size
581 // minus the number of bytes already read (18 record, 6 metarecord
583 fread((void *)lfFacename
, sizeof(char), (int)((2*rdSize
) - 18 - 6), handle
);
586 if (lfPitchAndFamily
& FF_MODERN
)
588 else if (lfPitchAndFamily
& FF_MODERN
)
590 else if (lfPitchAndFamily
& FF_ROMAN
)
592 else if (lfPitchAndFamily
& FF_SWISS
)
594 else if (lfPitchAndFamily
& FF_DECORATIVE
)
595 family
= wxDECORATIVE
;
602 else if (lfWeight
== 400)
604 else if (lfWeight
== 900)
606 else weight
= wxNORMAL
;
614 // About how many pixels per inch???
615 int logPixelsY
= 100;
616 int pointSize
= (int)(lfHeight
*72.0/logPixelsY
);
619 wxTheFontList
->FindOrCreateFont(pointSize
, family
, style
, weight
, (lfUnderline
!= 0));
621 rec
->param1
= (long) theFont
;
622 metaRecords
.Append(rec
);
623 gdiObjects
.Append(rec
);
624 AddMetaRecordHandle(rec
);
625 rec
->param2
= (long)(gdiObjects
.Number() - 1);
628 case META_CREATEBRUSHINDIRECT
:
630 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBRUSHINDIRECT
);
631 int msStyle
= getshort(handle
); // Style: 2 bytes
632 long colorref
= getint(handle
); // COLORREF: 4 bytes
633 int hatchStyle
= getshort(handle
); // Hatch style 2 bytes
643 style
= wxBDIAGONAL_HATCH
;
646 style
= wxCROSSDIAG_HATCH
;
649 style
= wxFDIAGONAL_HATCH
;
652 style
= wxHORIZONTAL_HATCH
;
655 style
= wxVERTICAL_HATCH
;
659 style
= wxCROSS_HATCH
;
669 if (msStyle
== PS_DOT
)
671 else if (msStyle
== PS_DASH
)
672 style
= wxSHORT_DASH
;
673 else if (msStyle
== PS_NULL
)
674 style
= wxTRANSPARENT
;
675 else style
= wxSOLID
;
677 wxColour
colour(GetRValue(colorref
), GetGValue(colorref
), GetBValue(colorref
));
678 rec
->param1
= (long)wxTheBrushList
->FindOrCreateBrush(colour
, style
);
679 metaRecords
.Append(rec
);
680 gdiObjects
.Append(rec
);
681 AddMetaRecordHandle(rec
);
682 rec
->param2
= (long)(gdiObjects
.Number() - 1);
685 case META_CREATEBITMAPINDIRECT
:
687 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBITMAPINDIRECT
);
688 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
690 metaRecords
.Append(rec
);
691 gdiObjects
.Append(rec
);
692 AddMetaRecordHandle(rec
);
693 rec
->param2
= (long)(gdiObjects
.Number() - 1);
696 case META_CREATEBITMAP
:
698 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBITMAP
);
699 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
701 metaRecords
.Append(rec
);
702 gdiObjects
.Append(rec
);
703 AddMetaRecordHandle(rec
);
704 rec
->param2
= (long)(gdiObjects
.Number() - 1);
707 case META_CREATEREGION
:
709 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEREGION
);
710 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
712 metaRecords
.Append(rec
);
713 gdiObjects
.Append(rec
);
714 AddMetaRecordHandle(rec
);
715 rec
->param2
= (long)(gdiObjects
.Number() - 1);
720 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
729 wxXMetaFile::~wxXMetaFile(void)
731 wxNode
*node
= metaRecords
.First();
734 wxMetaRecord
*rec
= (wxMetaRecord
*)node
->Data();
736 wxNode
*next
= node
->Next();
742 bool wxXMetaFile::SetClipboard(int width
, int height
)
747 bool wxXMetaFile::Play(wxDC
*dc
)
749 wxNode
*node
= metaRecords
.First();
752 wxMetaRecord
*rec
= (wxMetaRecord
*)node
->Data();
753 int rdFunction
= rec
->metaFunction
;
757 case META_SETBKCOLOR
:
765 case META_SETMAPMODE
:
769 // case META_SETROP2:
770 // case META_SETRELABS:
771 // case META_SETPOLYFILLMODE:
772 // case META_SETSTRETCHBLTMODE:
773 // case META_SETTEXTCHAREXTRA:
774 case META_SETTEXTCOLOR
:
778 // case META_SETTEXTJUSTIFICATION:
779 case META_SETWINDOWORG
:
783 case META_SETWINDOWEXT
:
787 // case META_SETVIEWPORTORG:
788 // case META_SETVIEWPORTEXT:
789 // case META_OFFSETWINDOWORG:
790 // case META_SCALEWINDOWEXT:
791 // case META_OFFSETVIEWPORTORG:
792 // case META_SCALEVIEWPORTEXT:
795 long x1
= rec
->param1
;
796 long y1
= rec
->param2
;
797 dc
->DrawLine((long) lastX
, (long) lastY
, x1
, y1
);
802 lastX
= (double)rec
->param1
;
803 lastY
= (double)rec
->param2
;
806 case META_EXCLUDECLIPRECT
:
810 case META_INTERSECTCLIPRECT
:
814 // case META_ARC: // DO!!!
819 // case META_FLOODFILL:
820 // case META_PIE: // DO!!!
823 dc
->DrawRectangle((long)rec
->param1
, (long)rec
->param2
,
824 (long)rec
->param3
- rec
->param1
,
825 (long)rec
->param4
- rec
->param2
);
830 dc
->DrawRoundedRectangle((long)rec
->param1
, (long)rec
->param2
,
831 (long)rec
->param3
- rec
->param1
,
832 (long)rec
->param4
- rec
->param2
,
840 // rec->param1 = getshort(handle); // x1
841 // rec->param2 = getshort(handle); // y1
842 // rec->param3 = getint(handle); // COLORREF
845 // case META_OFFSETCLIPRGN:
849 int count = getshort(handle);
850 rec->stringParam = new char[count+1];
851 fread((void *)rec->stringParam, sizeof(char), count, handle);
852 rec->stringParam[count] = 0;
853 rec->param2 = getshort(handle); // Y
854 rec->param1 = getshort(handle); // X
859 // case META_STRETCHBLT:
863 rec->param1 = getshort(handle);
864 rec->points = new wxRealPoint[(int)rec->param1];
865 for (int i = 0; i < rec->param1; i++)
867 rec->points[i].x = getshort(handle);
868 rec->points[i].y = getshort(handle);
876 wxMetaRecord *rec = new wxMetaRecord(META_POLYLINE);
877 rec->param1 = (long)getshort(handle);
878 rec->points = new wxRealPoint[(int)rec->param1];
879 for (int i = 0; i < rec->param1; i++)
881 rec->points[i].x = getshort(handle);
882 rec->points[i].y = getshort(handle);
888 // case META_RESTOREDC:
889 // case META_FILLREGION:
890 // case META_FRAMEREGION:
891 // case META_INVERTREGION:
892 // case META_PAINTREGION:
893 // case META_SELECTCLIPREGION: // DO THIS!
894 case META_SELECTOBJECT
:
897 wxMetaRecord *rec = new wxMetaRecord(META_SELECTOBJECT);
898 rec->param1 = (long)getshort(handle); // Position of object in gdiObjects list
902 // case META_SETTEXTALIGN:
903 // case META_DRAWTEXT:
905 // case META_SETMAPPERFLAGS:
906 // case META_EXTTEXTOUT:
907 // case META_SETDIBTODEV:
908 // case META_SELECTPALETTE:
909 // case META_REALIZEPALETTE:
910 // case META_ANIMATEPALETTE:
911 // case META_SETPALENTRIES:
912 // case META_POLYPOLYGON:
913 // case META_RESIZEPALETTE:
914 // case META_DIBBITBLT:
915 // case META_DIBSTRETCHBLT:
916 case META_DIBCREATEPATTERNBRUSH
:
919 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
923 // case META_STRETCHDIB:
924 // case META_EXTFLOODFILL:
925 // case META_RESETDC:
926 // case META_STARTDOC:
927 // case META_STARTPAGE:
928 // case META_ENDPAGE:
929 // case META_ABORTDOC:
931 // case META_DELETEOBJECT: // DO!!
932 case META_CREATEPALETTE
:
935 wxMetaRecord *rec = new wxMetaRecord(META_CREATEPALETTE);
936 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
940 case META_CREATEBRUSH
:
943 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
947 case META_CREATEPATTERNBRUSH
:
950 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
954 case META_CREATEPENINDIRECT
:
957 int msStyle = getshort(handle); // Style: 2 bytes
958 int x = getshort(handle); // X: 2 bytes
959 int y = getshort(handle); // Y: 2 bytes
960 int colorref = getint(handle); // COLORREF 4 bytes
963 if (msStyle == PS_DOT)
965 else if (msStyle == PS_DASH)
966 style = wxSHORT_DASH;
967 else if (msStyle == PS_NULL)
968 style = wxTRANSPARENT;
969 else style = wxSOLID;
971 wxColour colour(GetRValue(colorref), GetGValue(colorref), GetBValue(colorref));
972 rec->param1 = (long)wxThePenList->FindOrCreatePen(&colour, x, style);
976 case META_CREATEFONTINDIRECT
:
979 int lfHeight = getshort(handle);
980 int lfWidth = getshort(handle);
981 int lfEsc = getshort(handle);
982 int lfOrient = getshort(handle);
983 int lfWeight = getshort(handle);
984 char lfItalic = getc(handle);
985 char lfUnderline = getc(handle);
986 char lfStrikeout = getc(handle);
987 char lfCharSet = getc(handle);
988 char lfOutPrecision = getc(handle);
989 char lfClipPrecision = getc(handle);
990 char lfQuality = getc(handle);
991 char lfPitchAndFamily = getc(handle);
993 fread((void *)lfFacename, sizeof(char), 32, handle);
996 if (lfPitchAndFamily & FF_MODERN)
998 else if (lfPitchAndFamily & FF_MODERN)
1000 else if (lfPitchAndFamily & FF_ROMAN)
1002 else if (lfPitchAndFamily & FF_SWISS)
1004 else if (lfPitchAndFamily & FF_DECORATIVE)
1005 family = wxDECORATIVE;
1010 if (lfWeight == 300)
1012 else if (lfWeight == 400)
1014 else if (lfWeight == 900)
1016 else weight = wxNORMAL;
1024 // About how many pixels per inch???
1025 int logPixelsY = 100;
1026 int pointSize = (int)(lfHeight*72.0/logPixelsY);
1029 wxTheFontList->FindOrCreateFont(pointSize, family, style, weight, (bool)lfUnderline);
1031 rec->param1 = (long)theFont;
1035 case META_CREATEBRUSHINDIRECT
:
1038 int msStyle = getshort(handle); // Style: 2 bytes
1039 int colorref = getint(handle); // COLORREF: 4 bytes
1040 int hatchStyle = getshort(handle); // Hatch style 2 bytes
1043 if (msStyle == PS_DOT)
1045 else if (msStyle == PS_DASH)
1046 style = wxSHORT_DASH;
1047 else if (msStyle == PS_NULL)
1048 style = wxTRANSPARENT;
1049 else style = wxSOLID;
1051 wxColour colour(GetRValue(colorref), GetGValue(colorref), GetBValue(colorref));
1052 rec->param1 = (long)wxTheBrushList->FindOrCreateBrush(&colour, wxSOLID);
1056 case META_CREATEBITMAPINDIRECT
:
1059 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
1063 case META_CREATEBITMAP
:
1066 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
1070 case META_CREATEREGION
:
1072 dc
->DestroyClippingRegion();
1074 rec->param1 = getshort(handle); // Style: 2 bytes
1083 node
= node
->Next();