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/ogl.h"
34 static char _buf
[1024]; // a temp buffer to use inplace of wxBuffer, which is deprecated.
36 static char hexArray
[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
39 static void DecToHex(int dec
, char *buf
)
41 int firstDigit
= (int)(dec
/16.0);
42 int secondDigit
= (int)(dec
- (firstDigit
*16.0));
43 buf
[0] = hexArray
[firstDigit
];
44 buf
[1] = hexArray
[secondDigit
];
48 // 16-bit unsigned integer
49 static unsigned int getshort(FILE *fp
)
52 c
= getc(fp
); c1
= getc(fp
);
53 unsigned int res
= ((unsigned int) c
) + (((unsigned int) c1
) << 8);
57 // 16-bit signed integer
58 static int getsignedshort(FILE *fp
)
61 c
= getc(fp
); c1
= getc(fp
);
62 int testRes
= ((unsigned int) c
) + (((unsigned int) c1
) << 8);
63 unsigned long res1
= ((unsigned int) c
) + (((unsigned int) c1
) << 8);
66 res
= (int)(res1
- 65536);
73 static long getint(FILE *fp
)
76 c
= getc(fp
); c1
= getc(fp
); c2
= getc(fp
); c3
= getc(fp
);
77 long res
= (long)((long) c
) +
85 /* Placeable metafile header
86 struct mfPLACEABLEHEADER {
89 RECT bbox; // 4x16 bit
91 DWORD reserved; // 32-bit
92 WORD checksum; // 16-bit
96 wxMetaRecord::~wxMetaRecord(void)
98 if (points
) delete[] points
;
99 if (stringParam
) delete[] stringParam
;
102 wxXMetaFile::wxXMetaFile(const wxChar
*file
)
115 Handle table gdiObjects
116 ------------ ----------
118 [1]----param2--- wxBrush
122 The handle table works as follows.
123 When a GDI object is created whilst reading in the
124 metafile, the (e.g.) createpen record is added to the
125 first free entry in the handle table. The createpen
126 record's param1 is a pointer to the actual wxPen, and
127 its param2 is the index into the gdiObjects list, which only
128 grows and never shrinks (unlike the handle table.)
130 When SelectObject(index) is found, the index in the file
131 refers to the position in the handle table. BUT we then
132 set param2 to be the position of the wxPen in gdiObjects,
133 i.e. to param2 of the CreatePen record, itself found in
136 When an object is deleted, the entry in the handletable is
137 NULLed but the gdiObjects entry is not removed (no point, and
138 allows us to create all GDI objects in advance of playing the
143 static wxMetaRecord
*HandleTable
[100];
144 static int HandleTableSize
= 0;
146 void DeleteMetaRecordHandle(int index
)
148 HandleTable
[index
] = NULL
;
151 int AddMetaRecordHandle(wxMetaRecord
*record
)
153 for (int i
= 0; i
< HandleTableSize
; i
++)
156 HandleTable
[i
] = record
;
159 // No free spaces in table, so append.
161 HandleTable
[HandleTableSize
] = record
;
163 return (HandleTableSize
- 1);
166 bool wxXMetaFile::ReadFile(const wxChar
*file
)
170 FILE *handle
= wxFopen(file
, wxT("rb"));
171 if (!handle
) return FALSE
;
173 // Read placeable metafile header, if any
174 long key
= getint(handle
);
176 if (key
== (long) 0x9AC6CDD7)
178 long hmf
= getshort(handle
);
179 int iLeft
, iTop
, iRight
, iBottom
;
180 iLeft
= getsignedshort(handle
);
181 iTop
= getsignedshort(handle
);
182 iRight
= getsignedshort(handle
);
183 iBottom
= getsignedshort(handle
);
185 left
= (double)iLeft
;
187 right
= (double)iRight
;
188 bottom
= (double)iBottom
;
190 int inch
= getshort(handle
);
191 long reserved
= getint(handle
);
192 int checksum
= getshort(handle
);
194 double widthInUnits = (double)right - left;
195 double heightInUnits = (double)bottom - top;
196 *width = (int)((widthInUnits*1440.0)/inch);
197 *height = (int)((heightInUnits*1440.0)/inch);
203 int mtType
= getshort(handle
);
205 if (mtType
!= 1 && mtType
!= 2)
211 int mtHeaderSize
= getshort(handle
);
212 int mtVersion
= getshort(handle
);
214 if (mtVersion
!= 0x0300 && mtVersion
!= 0x0100)
220 long mtSize
= getint(handle
);
221 int mtNoObjects
= getshort(handle
);
222 long mtMaxRecord
= getint(handle
);
223 int mtNoParameters
= getshort(handle
);
225 while (!feof(handle
))
227 long rdSize
= getint(handle
); // 4 bytes
228 int rdFunction
= getshort(handle
); // 2 bytes
234 case META_SETBKCOLOR
:
236 wxMetaRecord
*rec
= new wxMetaRecord(META_SETBKCOLOR
);
237 long colorref
= getint(handle
); // COLORREF
238 rec
->param1
= GetRValue(colorref
);
239 rec
->param2
= GetGValue(colorref
);
240 rec
->param3
= GetBValue(colorref
);
241 metaRecords
.Append(rec
);
246 wxMetaRecord
*rec
= new wxMetaRecord(META_SETBKMODE
);
247 rec
->param1
= getshort(handle
); // Background mode
248 if (rec
->param1
== OPAQUE
) rec
->param1
= wxSOLID
;
249 else rec
->param1
= wxTRANSPARENT
;
250 metaRecords
.Append(rec
);
253 case META_SETMAPMODE
:
255 wxMetaRecord
*rec
= new wxMetaRecord(META_SETMAPMODE
);
256 rec
->param1
= getshort(handle
);
257 metaRecords
.Append(rec
);
260 // case META_SETROP2:
261 // case META_SETRELABS:
262 // case META_SETPOLYFILLMODE:
263 // case META_SETSTRETCHBLTMODE:
264 // case META_SETTEXTCHAREXTRA:
265 case META_SETTEXTCOLOR
:
267 wxMetaRecord
*rec
= new wxMetaRecord(META_SETTEXTCOLOR
);
268 long colorref
= getint(handle
); // COLORREF
269 rec
->param1
= GetRValue(colorref
);
270 rec
->param2
= GetGValue(colorref
);
271 rec
->param3
= GetBValue(colorref
);
272 metaRecords
.Append(rec
);
275 // case META_SETTEXTJUSTIFICATION:
276 case META_SETWINDOWORG
:
278 wxMetaRecord
*rec
= new wxMetaRecord(META_SETWINDOWORG
);
279 rec
->param2
= getshort(handle
);
280 rec
->param1
= getshort(handle
);
281 metaRecords
.Append(rec
);
284 case META_SETWINDOWEXT
:
286 wxMetaRecord
*rec
= new wxMetaRecord(META_SETWINDOWEXT
);
287 rec
->param2
= getshort(handle
);
288 rec
->param1
= getshort(handle
);
289 metaRecords
.Append(rec
);
292 // case META_SETVIEWPORTORG:
293 // case META_SETVIEWPORTEXT:
294 // case META_OFFSETWINDOWORG:
295 // case META_SCALEWINDOWEXT:
296 // case META_OFFSETVIEWPORTORG:
297 // case META_SCALEVIEWPORTEXT:
300 wxMetaRecord
*rec
= new wxMetaRecord(META_LINETO
);
301 rec
->param1
= getshort(handle
); // x1
302 rec
->param2
= getshort(handle
); // y1
303 metaRecords
.Append(rec
);
308 wxMetaRecord
*rec
= new wxMetaRecord(META_MOVETO
);
309 rec
->param1
= getshort(handle
); // x1
310 rec
->param2
= getshort(handle
); // y1
311 metaRecords
.Append(rec
);
314 case META_EXCLUDECLIPRECT
:
316 wxMetaRecord
*rec
= new wxMetaRecord(META_EXCLUDECLIPRECT
);
317 rec
->param4
= getshort(handle
); // y2
318 rec
->param3
= getshort(handle
); // x2
319 rec
->param2
= getshort(handle
); // y1
320 rec
->param1
= getshort(handle
); // x1
321 metaRecords
.Append(rec
);
324 case META_INTERSECTCLIPRECT
:
326 wxMetaRecord
*rec
= new wxMetaRecord(META_INTERSECTCLIPRECT
);
327 rec
->param4
= getshort(handle
); // y2
328 rec
->param3
= getshort(handle
); // x2
329 rec
->param2
= getshort(handle
); // y1
330 rec
->param1
= getshort(handle
); // x1
331 metaRecords
.Append(rec
);
334 // case META_ARC: // DO!!!
337 wxMetaRecord
*rec
= new wxMetaRecord(META_ELLIPSE
);
338 rec
->param4
= getshort(handle
); // y2
339 rec
->param3
= getshort(handle
); // x2
340 rec
->param2
= getshort(handle
); // y1
341 rec
->param1
= getshort(handle
); // x1
342 metaRecords
.Append(rec
);
345 // case META_FLOODFILL:
346 // case META_PIE: // DO!!!
349 wxMetaRecord
*rec
= new wxMetaRecord(META_RECTANGLE
);
350 rec
->param4
= getshort(handle
); // y2
351 rec
->param3
= getshort(handle
); // x2
352 rec
->param2
= getshort(handle
); // y1
353 rec
->param1
= getshort(handle
); // x1
354 metaRecords
.Append(rec
);
359 wxMetaRecord
*rec
= new wxMetaRecord(META_ROUNDRECT
);
360 rec
->param6
= getshort(handle
); // width
361 rec
->param5
= getshort(handle
); // height
362 rec
->param4
= getshort(handle
); // y2
363 rec
->param3
= getshort(handle
); // x2
364 rec
->param2
= getshort(handle
); // y1
365 rec
->param1
= getshort(handle
); // x1
366 metaRecords
.Append(rec
);
373 wxMetaRecord
*rec
= new wxMetaRecord(META_SETPIXEL
);
374 rec
->param1
= getshort(handle
); // x1
375 rec
->param2
= getshort(handle
); // y1
376 rec
->param3
= getint(handle
); // COLORREF
377 metaRecords
.Append(rec
);
380 // case META_OFFSETCLIPRGN:
383 wxMetaRecord
*rec
= new wxMetaRecord(META_TEXTOUT
);
384 int count
= getshort(handle
);
385 rec
->stringParam
= new wxChar
[count
+1];
386 fread((void *)rec
->stringParam
, sizeof(wxChar
), count
, handle
);
387 rec
->stringParam
[count
] = 0;
388 rec
->param2
= getshort(handle
); // Y
389 rec
->param1
= getshort(handle
); // X
390 metaRecords
.Append(rec
);
394 case META_EXTTEXTOUT:
396 wxMetaRecord *rec = new wxMetaRecord(META_EXTTEXTOUT);
397 int cellSpacing = getshort(handle);
398 int count = getshort(handle);
399 rec->stringParam = new char[count+1];
400 fread((void *)rec->stringParam, sizeof(char), count, handle);
401 rec->stringParam[count] = 0;
403 int rectY2 = getshort(handle);
404 int rectX2 = getshort(handle);
405 int rectY1 = getshort(handle);
406 int rectX1 = getshort(handle);
407 int rectType = getshort(handle);
408 rec->param2 = getshort(handle); // Y
409 rec->param1 = getshort(handle); // X
410 metaRecords.Append(rec);
415 // case META_STRETCHBLT:
418 wxMetaRecord
*rec
= new wxMetaRecord(META_POLYGON
);
419 rec
->param1
= getshort(handle
);
420 rec
->points
= new wxRealPoint
[(int)rec
->param1
];
421 for (int i
= 0; i
< rec
->param1
; i
++)
423 rec
->points
[i
].x
= getshort(handle
);
424 rec
->points
[i
].y
= getshort(handle
);
427 metaRecords
.Append(rec
);
432 wxMetaRecord
*rec
= new wxMetaRecord(META_POLYLINE
);
433 rec
->param1
= (long)getshort(handle
);
434 rec
->points
= new wxRealPoint
[(int)rec
->param1
];
435 for (int i
= 0; i
< rec
->param1
; i
++)
437 rec
->points
[i
].x
= getshort(handle
);
438 rec
->points
[i
].y
= getshort(handle
);
441 metaRecords
.Append(rec
);
445 // case META_RESTOREDC:
446 // case META_FILLREGION:
447 // case META_FRAMEREGION:
448 // case META_INVERTREGION:
449 // case META_PAINTREGION:
450 // case META_SELECTCLIPREGION: // DO THIS!
451 case META_SELECTOBJECT
:
453 wxMetaRecord
*rec
= new wxMetaRecord(META_SELECTOBJECT
);
454 rec
->param1
= (long)getshort(handle
); // Position of object in gdiObjects list
455 metaRecords
.Append(rec
);
456 // param2 gives the index into gdiObjects, which is different from
457 // the index into the handle table.
458 rec
->param2
= HandleTable
[(int)rec
->param1
]->param2
;
461 // case META_SETTEXTALIGN:
462 // case META_DRAWTEXT:
464 // case META_SETMAPPERFLAGS:
465 // case META_EXTTEXTOUT:
466 // case META_SETDIBTODEV:
467 // case META_SELECTPALETTE:
468 // case META_REALIZEPALETTE:
469 // case META_ANIMATEPALETTE:
470 // case META_SETPALENTRIES:
471 // case META_POLYPOLYGON:
472 // case META_RESIZEPALETTE:
473 // case META_DIBBITBLT:
474 // case META_DIBSTRETCHBLT:
475 case META_DIBCREATEPATTERNBRUSH
:
477 wxMetaRecord
*rec
= new wxMetaRecord(META_DIBCREATEPATTERNBRUSH
);
478 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
480 metaRecords
.Append(rec
);
481 gdiObjects
.Append(rec
);
482 AddMetaRecordHandle(rec
);
483 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
486 // case META_STRETCHDIB:
487 // case META_EXTFLOODFILL:
488 // case META_RESETDC:
489 // case META_STARTDOC:
490 // case META_STARTPAGE:
491 // case META_ENDPAGE:
492 // case META_ABORTDOC:
494 case META_DELETEOBJECT
:
496 int index
= getshort(handle
);
497 DeleteMetaRecordHandle(index
);
500 case META_CREATEPALETTE
:
502 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEPALETTE
);
503 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
505 metaRecords
.Append(rec
);
506 gdiObjects
.Append(rec
);
507 AddMetaRecordHandle(rec
);
508 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
511 case META_CREATEBRUSH
:
513 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBRUSH
);
514 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
515 metaRecords
.Append(rec
);
516 gdiObjects
.Append(rec
);
517 AddMetaRecordHandle(rec
);
518 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
521 case META_CREATEPATTERNBRUSH
:
523 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEPATTERNBRUSH
);
524 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
525 metaRecords
.Append(rec
);
526 gdiObjects
.Append(rec
);
527 AddMetaRecordHandle(rec
);
528 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
531 case META_CREATEPENINDIRECT
:
533 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEPENINDIRECT
);
534 int msStyle
= getshort(handle
); // Style: 2 bytes
535 int x
= getshort(handle
); // X: 2 bytes
536 int y
= getshort(handle
); // Y: 2 bytes
537 long colorref
= getint(handle
); // COLORREF 4 bytes
540 if (msStyle
== PS_DOT
)
542 else if (msStyle
== PS_DASH
)
543 style
= wxSHORT_DASH
;
544 else if (msStyle
== PS_NULL
)
545 style
= wxTRANSPARENT
;
546 else style
= wxSOLID
;
548 wxColour
colour(GetRValue(colorref
), GetGValue(colorref
), GetBValue(colorref
));
549 rec
->param1
= (long)wxThePenList
->FindOrCreatePen(colour
, x
, style
);
550 metaRecords
.Append(rec
);
551 gdiObjects
.Append(rec
);
553 AddMetaRecordHandle(rec
);
554 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
556 // For some reason, the size of this record is sometimes 9 words!!!
557 // instead of the usual 8. So read 2 characters extra.
560 (void) getshort(handle
);
564 case META_CREATEFONTINDIRECT
:
566 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEFONTINDIRECT
);
567 int lfHeight
= getshort(handle
); // 2 bytes
568 int lfWidth
= getshort(handle
); // 2 bytes
569 int lfEsc
= getshort(handle
); // 2 bytes
570 int lfOrient
= getshort(handle
); // 2 bytes
571 int lfWeight
= getshort(handle
); // 2 bytes
572 char lfItalic
= getc(handle
); // 1 byte
573 char lfUnderline
= getc(handle
); // 1 byte
574 char lfStrikeout
= getc(handle
); // 1 byte
575 char lfCharSet
= getc(handle
); // 1 byte
576 char lfOutPrecision
= getc(handle
); // 1 byte
577 char lfClipPrecision
= getc(handle
); // 1 byte
578 char lfQuality
= getc(handle
); // 1 byte
579 char lfPitchAndFamily
= getc(handle
); // 1 byte (18th)
581 // Read the rest of the record, which is total record size
582 // minus the number of bytes already read (18 record, 6 metarecord
584 fread((void *)lfFacename
, sizeof(char), (int)((2*rdSize
) - 18 - 6), handle
);
587 if (lfPitchAndFamily
& FF_MODERN
)
589 else if (lfPitchAndFamily
& FF_MODERN
)
591 else if (lfPitchAndFamily
& FF_ROMAN
)
593 else if (lfPitchAndFamily
& FF_SWISS
)
595 else if (lfPitchAndFamily
& FF_DECORATIVE
)
596 family
= wxDECORATIVE
;
603 else if (lfWeight
== 400)
605 else if (lfWeight
== 900)
607 else weight
= wxNORMAL
;
615 // About how many pixels per inch???
616 int logPixelsY
= 100;
617 int pointSize
= (int)(lfHeight
*72.0/logPixelsY
);
620 wxTheFontList
->FindOrCreateFont(pointSize
, family
, style
, weight
, (lfUnderline
!= 0));
622 rec
->param1
= (long) theFont
;
623 metaRecords
.Append(rec
);
624 gdiObjects
.Append(rec
);
625 AddMetaRecordHandle(rec
);
626 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
629 case META_CREATEBRUSHINDIRECT
:
631 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBRUSHINDIRECT
);
632 int msStyle
= getshort(handle
); // Style: 2 bytes
633 long colorref
= getint(handle
); // COLORREF: 4 bytes
634 int hatchStyle
= getshort(handle
); // Hatch style 2 bytes
644 style
= wxBDIAGONAL_HATCH
;
647 style
= wxCROSSDIAG_HATCH
;
650 style
= wxFDIAGONAL_HATCH
;
653 style
= wxHORIZONTAL_HATCH
;
656 style
= wxVERTICAL_HATCH
;
660 style
= wxCROSS_HATCH
;
670 if (msStyle
== PS_DOT
)
672 else if (msStyle
== PS_DASH
)
673 style
= wxSHORT_DASH
;
674 else if (msStyle
== PS_NULL
)
675 style
= wxTRANSPARENT
;
676 else style
= wxSOLID
;
678 wxColour
colour(GetRValue(colorref
), GetGValue(colorref
), GetBValue(colorref
));
679 rec
->param1
= (long)wxTheBrushList
->FindOrCreateBrush(colour
, style
);
680 metaRecords
.Append(rec
);
681 gdiObjects
.Append(rec
);
682 AddMetaRecordHandle(rec
);
683 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
686 case META_CREATEBITMAPINDIRECT
:
688 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBITMAPINDIRECT
);
689 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
691 metaRecords
.Append(rec
);
692 gdiObjects
.Append(rec
);
693 AddMetaRecordHandle(rec
);
694 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
697 case META_CREATEBITMAP
:
699 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBITMAP
);
700 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
702 metaRecords
.Append(rec
);
703 gdiObjects
.Append(rec
);
704 AddMetaRecordHandle(rec
);
705 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
708 case META_CREATEREGION
:
710 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEREGION
);
711 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
713 metaRecords
.Append(rec
);
714 gdiObjects
.Append(rec
);
715 AddMetaRecordHandle(rec
);
716 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
721 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
730 wxXMetaFile::~wxXMetaFile(void)
732 wxNode
*node
= metaRecords
.GetFirst();
735 wxMetaRecord
*rec
= (wxMetaRecord
*)node
->GetData();
737 wxNode
*next
= node
->GetNext();
743 bool wxXMetaFile::SetClipboard(int width
, int height
)
748 bool wxXMetaFile::Play(wxDC
*dc
)
750 wxNode
*node
= metaRecords
.GetFirst();
753 wxMetaRecord
*rec
= (wxMetaRecord
*)node
->GetData();
754 int rdFunction
= rec
->metaFunction
;
758 case META_SETBKCOLOR
:
766 case META_SETMAPMODE
:
770 // case META_SETROP2:
771 // case META_SETRELABS:
772 // case META_SETPOLYFILLMODE:
773 // case META_SETSTRETCHBLTMODE:
774 // case META_SETTEXTCHAREXTRA:
775 case META_SETTEXTCOLOR
:
779 // case META_SETTEXTJUSTIFICATION:
780 case META_SETWINDOWORG
:
784 case META_SETWINDOWEXT
:
788 // case META_SETVIEWPORTORG:
789 // case META_SETVIEWPORTEXT:
790 // case META_OFFSETWINDOWORG:
791 // case META_SCALEWINDOWEXT:
792 // case META_OFFSETVIEWPORTORG:
793 // case META_SCALEVIEWPORTEXT:
796 long x1
= rec
->param1
;
797 long y1
= rec
->param2
;
798 dc
->DrawLine((long) lastX
, (long) lastY
, x1
, y1
);
803 lastX
= (double)rec
->param1
;
804 lastY
= (double)rec
->param2
;
807 case META_EXCLUDECLIPRECT
:
811 case META_INTERSECTCLIPRECT
:
815 // case META_ARC: // DO!!!
820 // case META_FLOODFILL:
821 // case META_PIE: // DO!!!
824 dc
->DrawRectangle((long)rec
->param1
, (long)rec
->param2
,
825 (long)rec
->param3
- rec
->param1
,
826 (long)rec
->param4
- rec
->param2
);
831 dc
->DrawRoundedRectangle((long)rec
->param1
, (long)rec
->param2
,
832 (long)rec
->param3
- rec
->param1
,
833 (long)rec
->param4
- rec
->param2
,
841 // rec->param1 = getshort(handle); // x1
842 // rec->param2 = getshort(handle); // y1
843 // rec->param3 = getint(handle); // COLORREF
846 // case META_OFFSETCLIPRGN:
850 int count = getshort(handle);
851 rec->stringParam = new char[count+1];
852 fread((void *)rec->stringParam, sizeof(char), count, handle);
853 rec->stringParam[count] = 0;
854 rec->param2 = getshort(handle); // Y
855 rec->param1 = getshort(handle); // X
860 // case META_STRETCHBLT:
864 rec->param1 = getshort(handle);
865 rec->points = new wxRealPoint[(int)rec->param1];
866 for (int i = 0; i < rec->param1; i++)
868 rec->points[i].x = getshort(handle);
869 rec->points[i].y = getshort(handle);
877 wxMetaRecord *rec = new wxMetaRecord(META_POLYLINE);
878 rec->param1 = (long)getshort(handle);
879 rec->points = new wxRealPoint[(int)rec->param1];
880 for (int i = 0; i < rec->param1; i++)
882 rec->points[i].x = getshort(handle);
883 rec->points[i].y = getshort(handle);
889 // case META_RESTOREDC:
890 // case META_FILLREGION:
891 // case META_FRAMEREGION:
892 // case META_INVERTREGION:
893 // case META_PAINTREGION:
894 // case META_SELECTCLIPREGION: // DO THIS!
895 case META_SELECTOBJECT
:
898 wxMetaRecord *rec = new wxMetaRecord(META_SELECTOBJECT);
899 rec->param1 = (long)getshort(handle); // Position of object in gdiObjects list
903 // case META_SETTEXTALIGN:
904 // case META_DRAWTEXT:
906 // case META_SETMAPPERFLAGS:
907 // case META_EXTTEXTOUT:
908 // case META_SETDIBTODEV:
909 // case META_SELECTPALETTE:
910 // case META_REALIZEPALETTE:
911 // case META_ANIMATEPALETTE:
912 // case META_SETPALENTRIES:
913 // case META_POLYPOLYGON:
914 // case META_RESIZEPALETTE:
915 // case META_DIBBITBLT:
916 // case META_DIBSTRETCHBLT:
917 case META_DIBCREATEPATTERNBRUSH
:
920 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
924 // case META_STRETCHDIB:
925 // case META_EXTFLOODFILL:
926 // case META_RESETDC:
927 // case META_STARTDOC:
928 // case META_STARTPAGE:
929 // case META_ENDPAGE:
930 // case META_ABORTDOC:
932 // case META_DELETEOBJECT: // DO!!
933 case META_CREATEPALETTE
:
936 wxMetaRecord *rec = new wxMetaRecord(META_CREATEPALETTE);
937 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
941 case META_CREATEBRUSH
:
944 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
948 case META_CREATEPATTERNBRUSH
:
951 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
955 case META_CREATEPENINDIRECT
:
958 int msStyle = getshort(handle); // Style: 2 bytes
959 int x = getshort(handle); // X: 2 bytes
960 int y = getshort(handle); // Y: 2 bytes
961 int colorref = getint(handle); // COLORREF 4 bytes
964 if (msStyle == PS_DOT)
966 else if (msStyle == PS_DASH)
967 style = wxSHORT_DASH;
968 else if (msStyle == PS_NULL)
969 style = wxTRANSPARENT;
970 else style = wxSOLID;
972 wxColour colour(GetRValue(colorref), GetGValue(colorref), GetBValue(colorref));
973 rec->param1 = (long)wxThePenList->FindOrCreatePen(&colour, x, style);
977 case META_CREATEFONTINDIRECT
:
980 int lfHeight = getshort(handle);
981 int lfWidth = getshort(handle);
982 int lfEsc = getshort(handle);
983 int lfOrient = getshort(handle);
984 int lfWeight = getshort(handle);
985 char lfItalic = getc(handle);
986 char lfUnderline = getc(handle);
987 char lfStrikeout = getc(handle);
988 char lfCharSet = getc(handle);
989 char lfOutPrecision = getc(handle);
990 char lfClipPrecision = getc(handle);
991 char lfQuality = getc(handle);
992 char lfPitchAndFamily = getc(handle);
994 fread((void *)lfFacename, sizeof(char), 32, handle);
997 if (lfPitchAndFamily & FF_MODERN)
999 else if (lfPitchAndFamily & FF_MODERN)
1001 else if (lfPitchAndFamily & FF_ROMAN)
1003 else if (lfPitchAndFamily & FF_SWISS)
1005 else if (lfPitchAndFamily & FF_DECORATIVE)
1006 family = wxDECORATIVE;
1011 if (lfWeight == 300)
1013 else if (lfWeight == 400)
1015 else if (lfWeight == 900)
1017 else weight = wxNORMAL;
1025 // About how many pixels per inch???
1026 int logPixelsY = 100;
1027 int pointSize = (int)(lfHeight*72.0/logPixelsY);
1030 wxTheFontList->FindOrCreateFont(pointSize, family, style, weight, (bool)lfUnderline);
1032 rec->param1 = (long)theFont;
1036 case META_CREATEBRUSHINDIRECT
:
1039 int msStyle = getshort(handle); // Style: 2 bytes
1040 int colorref = getint(handle); // COLORREF: 4 bytes
1041 int hatchStyle = getshort(handle); // Hatch style 2 bytes
1044 if (msStyle == PS_DOT)
1046 else if (msStyle == PS_DASH)
1047 style = wxSHORT_DASH;
1048 else if (msStyle == PS_NULL)
1049 style = wxTRANSPARENT;
1050 else style = wxSOLID;
1052 wxColour colour(GetRValue(colorref), GetGValue(colorref), GetBValue(colorref));
1053 rec->param1 = (long)wxTheBrushList->FindOrCreateBrush(&colour, wxSOLID);
1057 case META_CREATEBITMAPINDIRECT
:
1060 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
1064 case META_CREATEBITMAP
:
1067 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
1071 case META_CREATEREGION
:
1073 dc
->DestroyClippingRegion();
1075 rec->param1 = getshort(handle); // Style: 2 bytes
1084 node
= node
->GetNext();