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 hexArray
[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
36 static void DecToHex(int dec
, char *buf
)
38 int firstDigit
= (int)(dec
/16.0);
39 int secondDigit
= (int)(dec
- (firstDigit
*16.0));
40 buf
[0] = hexArray
[firstDigit
];
41 buf
[1] = hexArray
[secondDigit
];
45 // 16-bit unsigned integer
46 static unsigned int getshort(FILE *fp
)
49 c
= getc(fp
); c1
= getc(fp
);
50 unsigned int res
= ((unsigned int) c
) + (((unsigned int) c1
) << 8);
54 // 16-bit signed integer
55 static int getsignedshort(FILE *fp
)
58 c
= getc(fp
); c1
= getc(fp
);
59 int testRes
= ((unsigned int) c
) + (((unsigned int) c1
) << 8);
60 unsigned long res1
= ((unsigned int) c
) + (((unsigned int) c1
) << 8);
63 res
= (int)(res1
- 65536);
70 static long getint(FILE *fp
)
73 c
= getc(fp
); c1
= getc(fp
); c2
= getc(fp
); c3
= getc(fp
);
74 long res
= (long)((long) c
) +
82 /* Placeable metafile header
83 struct mfPLACEABLEHEADER {
86 RECT bbox; // 4x16 bit
88 DWORD reserved; // 32-bit
89 WORD checksum; // 16-bit
93 wxMetaRecord::~wxMetaRecord(void)
95 if (points
) delete[] points
;
96 if (stringParam
) delete[] stringParam
;
99 wxXMetaFile::wxXMetaFile(char *file
)
112 Handle table gdiObjects
113 ------------ ----------
115 [1]----param2--- wxBrush
119 The handle table works as follows.
120 When a GDI object is created whilst reading in the
121 metafile, the (e.g.) createpen record is added to the
122 first free entry in the handle table. The createpen
123 record's param1 is a pointer to the actual wxPen, and
124 its param2 is the index into the gdiObjects list, which only
125 grows and never shrinks (unlike the handle table.)
127 When SelectObject(index) is found, the index in the file
128 refers to the position in the handle table. BUT we then
129 set param2 to be the position of the wxPen in gdiObjects,
130 i.e. to param2 of the CreatePen record, itself found in
133 When an object is deleted, the entry in the handletable is
134 NULLed but the gdiObjects entry is not removed (no point, and
135 allows us to create all GDI objects in advance of playing the
140 static wxMetaRecord
*HandleTable
[100];
141 static int HandleTableSize
= 0;
143 void DeleteMetaRecordHandle(int index
)
145 HandleTable
[index
] = NULL
;
148 int AddMetaRecordHandle(wxMetaRecord
*record
)
150 for (int i
= 0; i
< HandleTableSize
; i
++)
153 HandleTable
[i
] = record
;
156 // No free spaces in table, so append.
158 HandleTable
[HandleTableSize
] = record
;
160 return (HandleTableSize
- 1);
163 bool wxXMetaFile::ReadFile(char *file
)
167 FILE *handle
= fopen(file
, "rb");
168 if (!handle
) return FALSE
;
170 // Read placeable metafile header, if any
171 long key
= getint(handle
);
173 if (key
== (long) 0x9AC6CDD7)
175 long hmf
= getshort(handle
);
176 int iLeft
, iTop
, iRight
, iBottom
;
177 iLeft
= getsignedshort(handle
);
178 iTop
= getsignedshort(handle
);
179 iRight
= getsignedshort(handle
);
180 iBottom
= getsignedshort(handle
);
182 left
= (double)iLeft
;
184 right
= (double)iRight
;
185 bottom
= (double)iBottom
;
187 int inch
= getshort(handle
);
188 long reserved
= getint(handle
);
189 int checksum
= getshort(handle
);
191 double widthInUnits = (double)right - left;
192 double heightInUnits = (double)bottom - top;
193 *width = (int)((widthInUnits*1440.0)/inch);
194 *height = (int)((heightInUnits*1440.0)/inch);
200 int mtType
= getshort(handle
);
202 if (mtType
!= 1 && mtType
!= 2)
208 int mtHeaderSize
= getshort(handle
);
209 int mtVersion
= getshort(handle
);
211 if (mtVersion
!= 0x0300 && mtVersion
!= 0x0100)
217 long mtSize
= getint(handle
);
218 int mtNoObjects
= getshort(handle
);
219 long mtMaxRecord
= getint(handle
);
220 int mtNoParameters
= getshort(handle
);
222 while (!feof(handle
))
224 long rdSize
= getint(handle
); // 4 bytes
225 int rdFunction
= getshort(handle
); // 2 bytes
231 case META_SETBKCOLOR
:
233 wxMetaRecord
*rec
= new wxMetaRecord(META_SETBKCOLOR
);
234 long colorref
= getint(handle
); // COLORREF
235 rec
->param1
= GetRValue(colorref
);
236 rec
->param2
= GetGValue(colorref
);
237 rec
->param3
= GetBValue(colorref
);
238 metaRecords
.Append(rec
);
243 wxMetaRecord
*rec
= new wxMetaRecord(META_SETBKMODE
);
244 rec
->param1
= getshort(handle
); // Background mode
245 if (rec
->param1
== OPAQUE
) rec
->param1
= wxSOLID
;
246 else rec
->param1
= wxTRANSPARENT
;
247 metaRecords
.Append(rec
);
250 case META_SETMAPMODE
:
252 wxMetaRecord
*rec
= new wxMetaRecord(META_SETMAPMODE
);
253 rec
->param1
= getshort(handle
);
254 metaRecords
.Append(rec
);
257 // case META_SETROP2:
258 // case META_SETRELABS:
259 // case META_SETPOLYFILLMODE:
260 // case META_SETSTRETCHBLTMODE:
261 // case META_SETTEXTCHAREXTRA:
262 case META_SETTEXTCOLOR
:
264 wxMetaRecord
*rec
= new wxMetaRecord(META_SETTEXTCOLOR
);
265 long colorref
= getint(handle
); // COLORREF
266 rec
->param1
= GetRValue(colorref
);
267 rec
->param2
= GetGValue(colorref
);
268 rec
->param3
= GetBValue(colorref
);
269 metaRecords
.Append(rec
);
272 // case META_SETTEXTJUSTIFICATION:
273 case META_SETWINDOWORG
:
275 wxMetaRecord
*rec
= new wxMetaRecord(META_SETWINDOWORG
);
276 rec
->param2
= getshort(handle
);
277 rec
->param1
= getshort(handle
);
278 metaRecords
.Append(rec
);
281 case META_SETWINDOWEXT
:
283 wxMetaRecord
*rec
= new wxMetaRecord(META_SETWINDOWEXT
);
284 rec
->param2
= getshort(handle
);
285 rec
->param1
= getshort(handle
);
286 metaRecords
.Append(rec
);
289 // case META_SETVIEWPORTORG:
290 // case META_SETVIEWPORTEXT:
291 // case META_OFFSETWINDOWORG:
292 // case META_SCALEWINDOWEXT:
293 // case META_OFFSETVIEWPORTORG:
294 // case META_SCALEVIEWPORTEXT:
297 wxMetaRecord
*rec
= new wxMetaRecord(META_LINETO
);
298 rec
->param1
= getshort(handle
); // x1
299 rec
->param2
= getshort(handle
); // y1
300 metaRecords
.Append(rec
);
305 wxMetaRecord
*rec
= new wxMetaRecord(META_MOVETO
);
306 rec
->param1
= getshort(handle
); // x1
307 rec
->param2
= getshort(handle
); // y1
308 metaRecords
.Append(rec
);
311 case META_EXCLUDECLIPRECT
:
313 wxMetaRecord
*rec
= new wxMetaRecord(META_EXCLUDECLIPRECT
);
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_INTERSECTCLIPRECT
:
323 wxMetaRecord
*rec
= new wxMetaRecord(META_INTERSECTCLIPRECT
);
324 rec
->param4
= getshort(handle
); // y2
325 rec
->param3
= getshort(handle
); // x2
326 rec
->param2
= getshort(handle
); // y1
327 rec
->param1
= getshort(handle
); // x1
328 metaRecords
.Append(rec
);
331 // case META_ARC: // DO!!!
334 wxMetaRecord
*rec
= new wxMetaRecord(META_ELLIPSE
);
335 rec
->param4
= getshort(handle
); // y2
336 rec
->param3
= getshort(handle
); // x2
337 rec
->param2
= getshort(handle
); // y1
338 rec
->param1
= getshort(handle
); // x1
339 metaRecords
.Append(rec
);
342 // case META_FLOODFILL:
343 // case META_PIE: // DO!!!
346 wxMetaRecord
*rec
= new wxMetaRecord(META_RECTANGLE
);
347 rec
->param4
= getshort(handle
); // y2
348 rec
->param3
= getshort(handle
); // x2
349 rec
->param2
= getshort(handle
); // y1
350 rec
->param1
= getshort(handle
); // x1
351 metaRecords
.Append(rec
);
356 wxMetaRecord
*rec
= new wxMetaRecord(META_ROUNDRECT
);
357 rec
->param6
= getshort(handle
); // width
358 rec
->param5
= getshort(handle
); // height
359 rec
->param4
= getshort(handle
); // y2
360 rec
->param3
= getshort(handle
); // x2
361 rec
->param2
= getshort(handle
); // y1
362 rec
->param1
= getshort(handle
); // x1
363 metaRecords
.Append(rec
);
370 wxMetaRecord
*rec
= new wxMetaRecord(META_SETPIXEL
);
371 rec
->param1
= getshort(handle
); // x1
372 rec
->param2
= getshort(handle
); // y1
373 rec
->param3
= getint(handle
); // COLORREF
374 metaRecords
.Append(rec
);
377 // case META_OFFSETCLIPRGN:
380 wxMetaRecord
*rec
= new wxMetaRecord(META_TEXTOUT
);
381 int count
= getshort(handle
);
382 rec
->stringParam
= new char[count
+1];
383 fread((void *)rec
->stringParam
, sizeof(char), count
, handle
);
384 rec
->stringParam
[count
] = 0;
385 rec
->param2
= getshort(handle
); // Y
386 rec
->param1
= getshort(handle
); // X
387 metaRecords
.Append(rec
);
391 case META_EXTTEXTOUT:
393 wxMetaRecord *rec = new wxMetaRecord(META_EXTTEXTOUT);
394 int cellSpacing = getshort(handle);
395 int count = getshort(handle);
396 rec->stringParam = new char[count+1];
397 fread((void *)rec->stringParam, sizeof(char), count, handle);
398 rec->stringParam[count] = 0;
400 int rectY2 = getshort(handle);
401 int rectX2 = getshort(handle);
402 int rectY1 = getshort(handle);
403 int rectX1 = getshort(handle);
404 int rectType = getshort(handle);
405 rec->param2 = getshort(handle); // Y
406 rec->param1 = getshort(handle); // X
407 metaRecords.Append(rec);
412 // case META_STRETCHBLT:
415 wxMetaRecord
*rec
= new wxMetaRecord(META_POLYGON
);
416 rec
->param1
= getshort(handle
);
417 rec
->points
= new wxRealPoint
[(int)rec
->param1
];
418 for (int i
= 0; i
< rec
->param1
; i
++)
420 rec
->points
[i
].x
= getshort(handle
);
421 rec
->points
[i
].y
= getshort(handle
);
424 metaRecords
.Append(rec
);
429 wxMetaRecord
*rec
= new wxMetaRecord(META_POLYLINE
);
430 rec
->param1
= (long)getshort(handle
);
431 rec
->points
= new wxRealPoint
[(int)rec
->param1
];
432 for (int i
= 0; i
< rec
->param1
; i
++)
434 rec
->points
[i
].x
= getshort(handle
);
435 rec
->points
[i
].y
= getshort(handle
);
438 metaRecords
.Append(rec
);
442 // case META_RESTOREDC:
443 // case META_FILLREGION:
444 // case META_FRAMEREGION:
445 // case META_INVERTREGION:
446 // case META_PAINTREGION:
447 // case META_SELECTCLIPREGION: // DO THIS!
448 case META_SELECTOBJECT
:
450 wxMetaRecord
*rec
= new wxMetaRecord(META_SELECTOBJECT
);
451 rec
->param1
= (long)getshort(handle
); // Position of object in gdiObjects list
452 metaRecords
.Append(rec
);
453 // param2 gives the index into gdiObjects, which is different from
454 // the index into the handle table.
455 rec
->param2
= HandleTable
[(int)rec
->param1
]->param2
;
458 // case META_SETTEXTALIGN:
459 // case META_DRAWTEXT:
461 // case META_SETMAPPERFLAGS:
462 // case META_EXTTEXTOUT:
463 // case META_SETDIBTODEV:
464 // case META_SELECTPALETTE:
465 // case META_REALIZEPALETTE:
466 // case META_ANIMATEPALETTE:
467 // case META_SETPALENTRIES:
468 // case META_POLYPOLYGON:
469 // case META_RESIZEPALETTE:
470 // case META_DIBBITBLT:
471 // case META_DIBSTRETCHBLT:
472 case META_DIBCREATEPATTERNBRUSH
:
474 wxMetaRecord
*rec
= new wxMetaRecord(META_DIBCREATEPATTERNBRUSH
);
475 fread((void *)wxBuffer
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
477 metaRecords
.Append(rec
);
478 gdiObjects
.Append(rec
);
479 AddMetaRecordHandle(rec
);
480 rec
->param2
= (long)(gdiObjects
.Number() - 1);
483 // case META_STRETCHDIB:
484 // case META_EXTFLOODFILL:
485 // case META_RESETDC:
486 // case META_STARTDOC:
487 // case META_STARTPAGE:
488 // case META_ENDPAGE:
489 // case META_ABORTDOC:
491 case META_DELETEOBJECT
:
493 int index
= getshort(handle
);
494 DeleteMetaRecordHandle(index
);
497 case META_CREATEPALETTE
:
499 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEPALETTE
);
500 fread((void *)wxBuffer
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
502 metaRecords
.Append(rec
);
503 gdiObjects
.Append(rec
);
504 AddMetaRecordHandle(rec
);
505 rec
->param2
= (long)(gdiObjects
.Number() - 1);
508 case META_CREATEBRUSH
:
510 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBRUSH
);
511 fread((void *)wxBuffer
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
512 metaRecords
.Append(rec
);
513 gdiObjects
.Append(rec
);
514 AddMetaRecordHandle(rec
);
515 rec
->param2
= (long)(gdiObjects
.Number() - 1);
518 case META_CREATEPATTERNBRUSH
:
520 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEPATTERNBRUSH
);
521 fread((void *)wxBuffer
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
522 metaRecords
.Append(rec
);
523 gdiObjects
.Append(rec
);
524 AddMetaRecordHandle(rec
);
525 rec
->param2
= (long)(gdiObjects
.Number() - 1);
528 case META_CREATEPENINDIRECT
:
530 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEPENINDIRECT
);
531 int msStyle
= getshort(handle
); // Style: 2 bytes
532 int x
= getshort(handle
); // X: 2 bytes
533 int y
= getshort(handle
); // Y: 2 bytes
534 long colorref
= getint(handle
); // COLORREF 4 bytes
537 if (msStyle
== PS_DOT
)
539 else if (msStyle
== PS_DASH
)
540 style
= wxSHORT_DASH
;
541 else if (msStyle
== PS_NULL
)
542 style
= wxTRANSPARENT
;
543 else style
= wxSOLID
;
545 wxColour
colour(GetRValue(colorref
), GetGValue(colorref
), GetBValue(colorref
));
546 rec
->param1
= (long)wxThePenList
->FindOrCreatePen(colour
, x
, style
);
547 metaRecords
.Append(rec
);
548 gdiObjects
.Append(rec
);
550 AddMetaRecordHandle(rec
);
551 rec
->param2
= (long)(gdiObjects
.Number() - 1);
553 // For some reason, the size of this record is sometimes 9 words!!!
554 // instead of the usual 8. So read 2 characters extra.
557 (void) getshort(handle
);
561 case META_CREATEFONTINDIRECT
:
563 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEFONTINDIRECT
);
564 int lfHeight
= getshort(handle
); // 2 bytes
565 int lfWidth
= getshort(handle
); // 2 bytes
566 int lfEsc
= getshort(handle
); // 2 bytes
567 int lfOrient
= getshort(handle
); // 2 bytes
568 int lfWeight
= getshort(handle
); // 2 bytes
569 char lfItalic
= getc(handle
); // 1 byte
570 char lfUnderline
= getc(handle
); // 1 byte
571 char lfStrikeout
= getc(handle
); // 1 byte
572 char lfCharSet
= getc(handle
); // 1 byte
573 char lfOutPrecision
= getc(handle
); // 1 byte
574 char lfClipPrecision
= getc(handle
); // 1 byte
575 char lfQuality
= getc(handle
); // 1 byte
576 char lfPitchAndFamily
= getc(handle
); // 1 byte (18th)
578 // Read the rest of the record, which is total record size
579 // minus the number of bytes already read (18 record, 6 metarecord
581 fread((void *)lfFacename
, sizeof(char), (int)((2*rdSize
) - 18 - 6), handle
);
584 if (lfPitchAndFamily
& FF_MODERN
)
586 else if (lfPitchAndFamily
& FF_MODERN
)
588 else if (lfPitchAndFamily
& FF_ROMAN
)
590 else if (lfPitchAndFamily
& FF_SWISS
)
592 else if (lfPitchAndFamily
& FF_DECORATIVE
)
593 family
= wxDECORATIVE
;
600 else if (lfWeight
== 400)
602 else if (lfWeight
== 900)
604 else weight
= wxNORMAL
;
612 // About how many pixels per inch???
613 int logPixelsY
= 100;
614 int pointSize
= (int)(lfHeight
*72.0/logPixelsY
);
617 wxTheFontList
->FindOrCreateFont(pointSize
, family
, style
, weight
, (lfUnderline
!= 0));
619 rec
->param1
= (long) theFont
;
620 metaRecords
.Append(rec
);
621 gdiObjects
.Append(rec
);
622 AddMetaRecordHandle(rec
);
623 rec
->param2
= (long)(gdiObjects
.Number() - 1);
626 case META_CREATEBRUSHINDIRECT
:
628 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBRUSHINDIRECT
);
629 int msStyle
= getshort(handle
); // Style: 2 bytes
630 long colorref
= getint(handle
); // COLORREF: 4 bytes
631 int hatchStyle
= getshort(handle
); // Hatch style 2 bytes
641 style
= wxBDIAGONAL_HATCH
;
644 style
= wxCROSSDIAG_HATCH
;
647 style
= wxFDIAGONAL_HATCH
;
650 style
= wxHORIZONTAL_HATCH
;
653 style
= wxVERTICAL_HATCH
;
657 style
= wxCROSS_HATCH
;
667 if (msStyle
== PS_DOT
)
669 else if (msStyle
== PS_DASH
)
670 style
= wxSHORT_DASH
;
671 else if (msStyle
== PS_NULL
)
672 style
= wxTRANSPARENT
;
673 else style
= wxSOLID
;
675 wxColour
colour(GetRValue(colorref
), GetGValue(colorref
), GetBValue(colorref
));
676 rec
->param1
= (long)wxTheBrushList
->FindOrCreateBrush(colour
, style
);
677 metaRecords
.Append(rec
);
678 gdiObjects
.Append(rec
);
679 AddMetaRecordHandle(rec
);
680 rec
->param2
= (long)(gdiObjects
.Number() - 1);
683 case META_CREATEBITMAPINDIRECT
:
685 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBITMAPINDIRECT
);
686 fread((void *)wxBuffer
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
688 metaRecords
.Append(rec
);
689 gdiObjects
.Append(rec
);
690 AddMetaRecordHandle(rec
);
691 rec
->param2
= (long)(gdiObjects
.Number() - 1);
694 case META_CREATEBITMAP
:
696 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBITMAP
);
697 fread((void *)wxBuffer
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
699 metaRecords
.Append(rec
);
700 gdiObjects
.Append(rec
);
701 AddMetaRecordHandle(rec
);
702 rec
->param2
= (long)(gdiObjects
.Number() - 1);
705 case META_CREATEREGION
:
707 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEREGION
);
708 fread((void *)wxBuffer
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
710 metaRecords
.Append(rec
);
711 gdiObjects
.Append(rec
);
712 AddMetaRecordHandle(rec
);
713 rec
->param2
= (long)(gdiObjects
.Number() - 1);
718 fread((void *)wxBuffer
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
727 wxXMetaFile::~wxXMetaFile(void)
729 wxNode
*node
= metaRecords
.First();
732 wxMetaRecord
*rec
= (wxMetaRecord
*)node
->Data();
734 wxNode
*next
= node
->Next();
740 bool wxXMetaFile::SetClipboard(int width
, int height
)
745 bool wxXMetaFile::Play(wxDC
*dc
)
747 wxNode
*node
= metaRecords
.First();
750 wxMetaRecord
*rec
= (wxMetaRecord
*)node
->Data();
751 int rdFunction
= rec
->metaFunction
;
755 case META_SETBKCOLOR
:
763 case META_SETMAPMODE
:
767 // case META_SETROP2:
768 // case META_SETRELABS:
769 // case META_SETPOLYFILLMODE:
770 // case META_SETSTRETCHBLTMODE:
771 // case META_SETTEXTCHAREXTRA:
772 case META_SETTEXTCOLOR
:
776 // case META_SETTEXTJUSTIFICATION:
777 case META_SETWINDOWORG
:
781 case META_SETWINDOWEXT
:
785 // case META_SETVIEWPORTORG:
786 // case META_SETVIEWPORTEXT:
787 // case META_OFFSETWINDOWORG:
788 // case META_SCALEWINDOWEXT:
789 // case META_OFFSETVIEWPORTORG:
790 // case META_SCALEVIEWPORTEXT:
793 long x1
= rec
->param1
;
794 long y1
= rec
->param2
;
795 dc
->DrawLine((long) lastX
, (long) lastY
, x1
, y1
);
800 lastX
= (double)rec
->param1
;
801 lastY
= (double)rec
->param2
;
804 case META_EXCLUDECLIPRECT
:
808 case META_INTERSECTCLIPRECT
:
812 // case META_ARC: // DO!!!
817 // case META_FLOODFILL:
818 // case META_PIE: // DO!!!
821 dc
->DrawRectangle((long)rec
->param1
, (long)rec
->param2
,
822 (long)rec
->param3
- rec
->param1
,
823 (long)rec
->param4
- rec
->param2
);
828 dc
->DrawRoundedRectangle((long)rec
->param1
, (long)rec
->param2
,
829 (long)rec
->param3
- rec
->param1
,
830 (long)rec
->param4
- rec
->param2
,
838 // rec->param1 = getshort(handle); // x1
839 // rec->param2 = getshort(handle); // y1
840 // rec->param3 = getint(handle); // COLORREF
843 // case META_OFFSETCLIPRGN:
847 int count = getshort(handle);
848 rec->stringParam = new char[count+1];
849 fread((void *)rec->stringParam, sizeof(char), count, handle);
850 rec->stringParam[count] = 0;
851 rec->param2 = getshort(handle); // Y
852 rec->param1 = getshort(handle); // X
857 // case META_STRETCHBLT:
861 rec->param1 = getshort(handle);
862 rec->points = new wxRealPoint[(int)rec->param1];
863 for (int i = 0; i < rec->param1; i++)
865 rec->points[i].x = getshort(handle);
866 rec->points[i].y = getshort(handle);
874 wxMetaRecord *rec = new wxMetaRecord(META_POLYLINE);
875 rec->param1 = (long)getshort(handle);
876 rec->points = new wxRealPoint[(int)rec->param1];
877 for (int i = 0; i < rec->param1; i++)
879 rec->points[i].x = getshort(handle);
880 rec->points[i].y = getshort(handle);
886 // case META_RESTOREDC:
887 // case META_FILLREGION:
888 // case META_FRAMEREGION:
889 // case META_INVERTREGION:
890 // case META_PAINTREGION:
891 // case META_SELECTCLIPREGION: // DO THIS!
892 case META_SELECTOBJECT
:
895 wxMetaRecord *rec = new wxMetaRecord(META_SELECTOBJECT);
896 rec->param1 = (long)getshort(handle); // Position of object in gdiObjects list
900 // case META_SETTEXTALIGN:
901 // case META_DRAWTEXT:
903 // case META_SETMAPPERFLAGS:
904 // case META_EXTTEXTOUT:
905 // case META_SETDIBTODEV:
906 // case META_SELECTPALETTE:
907 // case META_REALIZEPALETTE:
908 // case META_ANIMATEPALETTE:
909 // case META_SETPALENTRIES:
910 // case META_POLYPOLYGON:
911 // case META_RESIZEPALETTE:
912 // case META_DIBBITBLT:
913 // case META_DIBSTRETCHBLT:
914 case META_DIBCREATEPATTERNBRUSH
:
917 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
921 // case META_STRETCHDIB:
922 // case META_EXTFLOODFILL:
923 // case META_RESETDC:
924 // case META_STARTDOC:
925 // case META_STARTPAGE:
926 // case META_ENDPAGE:
927 // case META_ABORTDOC:
929 // case META_DELETEOBJECT: // DO!!
930 case META_CREATEPALETTE
:
933 wxMetaRecord *rec = new wxMetaRecord(META_CREATEPALETTE);
934 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
938 case META_CREATEBRUSH
:
941 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
945 case META_CREATEPATTERNBRUSH
:
948 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
952 case META_CREATEPENINDIRECT
:
955 int msStyle = getshort(handle); // Style: 2 bytes
956 int x = getshort(handle); // X: 2 bytes
957 int y = getshort(handle); // Y: 2 bytes
958 int colorref = getint(handle); // COLORREF 4 bytes
961 if (msStyle == PS_DOT)
963 else if (msStyle == PS_DASH)
964 style = wxSHORT_DASH;
965 else if (msStyle == PS_NULL)
966 style = wxTRANSPARENT;
967 else style = wxSOLID;
969 wxColour colour(GetRValue(colorref), GetGValue(colorref), GetBValue(colorref));
970 rec->param1 = (long)wxThePenList->FindOrCreatePen(&colour, x, style);
974 case META_CREATEFONTINDIRECT
:
977 int lfHeight = getshort(handle);
978 int lfWidth = getshort(handle);
979 int lfEsc = getshort(handle);
980 int lfOrient = getshort(handle);
981 int lfWeight = getshort(handle);
982 char lfItalic = getc(handle);
983 char lfUnderline = getc(handle);
984 char lfStrikeout = getc(handle);
985 char lfCharSet = getc(handle);
986 char lfOutPrecision = getc(handle);
987 char lfClipPrecision = getc(handle);
988 char lfQuality = getc(handle);
989 char lfPitchAndFamily = getc(handle);
991 fread((void *)lfFacename, sizeof(char), 32, handle);
994 if (lfPitchAndFamily & FF_MODERN)
996 else if (lfPitchAndFamily & FF_MODERN)
998 else if (lfPitchAndFamily & FF_ROMAN)
1000 else if (lfPitchAndFamily & FF_SWISS)
1002 else if (lfPitchAndFamily & FF_DECORATIVE)
1003 family = wxDECORATIVE;
1008 if (lfWeight == 300)
1010 else if (lfWeight == 400)
1012 else if (lfWeight == 900)
1014 else weight = wxNORMAL;
1022 // About how many pixels per inch???
1023 int logPixelsY = 100;
1024 int pointSize = (int)(lfHeight*72.0/logPixelsY);
1027 wxTheFontList->FindOrCreateFont(pointSize, family, style, weight, (bool)lfUnderline);
1029 rec->param1 = (long)theFont;
1033 case META_CREATEBRUSHINDIRECT
:
1036 int msStyle = getshort(handle); // Style: 2 bytes
1037 int colorref = getint(handle); // COLORREF: 4 bytes
1038 int hatchStyle = getshort(handle); // Hatch style 2 bytes
1041 if (msStyle == PS_DOT)
1043 else if (msStyle == PS_DASH)
1044 style = wxSHORT_DASH;
1045 else if (msStyle == PS_NULL)
1046 style = wxTRANSPARENT;
1047 else style = wxSOLID;
1049 wxColour colour(GetRValue(colorref), GetGValue(colorref), GetBValue(colorref));
1050 rec->param1 = (long)wxTheBrushList->FindOrCreateBrush(&colour, wxSOLID);
1054 case META_CREATEBITMAPINDIRECT
:
1057 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
1061 case META_CREATEBITMAP
:
1064 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
1068 case META_CREATEREGION
:
1070 dc
->DestroyClippingRegion();
1072 rec->param1 = getshort(handle); // Style: 2 bytes
1081 node
= node
->Next();