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
);
63 // this is not used value, no need to execute it
64 int testRes
= ((unsigned int) c
) + (((unsigned int) c1
) << 8);
66 unsigned long res1
= ((unsigned int) c
) + (((unsigned int) c1
) << 8);
69 res
= (int)(res1
- 65536);
76 static long getint(FILE *fp
)
79 c
= getc(fp
); c1
= getc(fp
); c2
= getc(fp
); c3
= getc(fp
);
80 long res
= (long)((long) c
) +
88 /* Placeable metafile header
89 struct mfPLACEABLEHEADER {
92 RECT bbox; // 4x16 bit
94 DWORD reserved; // 32-bit
95 WORD checksum; // 16-bit
99 wxMetaRecord::~wxMetaRecord(void)
101 if (points
) delete[] points
;
102 if (stringParam
) delete[] stringParam
;
105 wxXMetaFile::wxXMetaFile(const wxChar
*file
)
118 Handle table gdiObjects
119 ------------ ----------
121 [1]----param2--- wxBrush
125 The handle table works as follows.
126 When a GDI object is created whilst reading in the
127 metafile, the (e.g.) createpen record is added to the
128 first free entry in the handle table. The createpen
129 record's param1 is a pointer to the actual wxPen, and
130 its param2 is the index into the gdiObjects list, which only
131 grows and never shrinks (unlike the handle table.)
133 When SelectObject(index) is found, the index in the file
134 refers to the position in the handle table. BUT we then
135 set param2 to be the position of the wxPen in gdiObjects,
136 i.e. to param2 of the CreatePen record, itself found in
139 When an object is deleted, the entry in the handletable is
140 NULLed but the gdiObjects entry is not removed (no point, and
141 allows us to create all GDI objects in advance of playing the
146 static wxMetaRecord
*HandleTable
[100];
147 static int HandleTableSize
= 0;
149 void DeleteMetaRecordHandle(int index
)
151 HandleTable
[index
] = NULL
;
154 int AddMetaRecordHandle(wxMetaRecord
*record
)
156 for (int i
= 0; i
< HandleTableSize
; i
++)
159 HandleTable
[i
] = record
;
162 // No free spaces in table, so append.
164 HandleTable
[HandleTableSize
] = record
;
166 return (HandleTableSize
- 1);
169 bool wxXMetaFile::ReadFile(const wxChar
*file
)
173 FILE *handle
= wxFopen(file
, wxT("rb"));
174 if (!handle
) return FALSE
;
176 // Read placeable metafile header, if any
177 long key
= getint(handle
);
179 if (key
== (long) 0x9AC6CDD7)
181 /* long hmf = */ getshort(handle
);
182 int iLeft
, iTop
, iRight
, iBottom
;
183 iLeft
= getsignedshort(handle
);
184 iTop
= getsignedshort(handle
);
185 iRight
= getsignedshort(handle
);
186 iBottom
= getsignedshort(handle
);
188 left
= (double)iLeft
;
190 right
= (double)iRight
;
191 bottom
= (double)iBottom
;
193 /* int inch = */ getshort(handle
);
194 /* long reserved = */ getint(handle
);
195 /* int checksum = */ getshort(handle
);
197 double widthInUnits = (double)right - left;
198 double heightInUnits = (double)bottom - top;
199 *width = (int)((widthInUnits*1440.0)/inch);
200 *height = (int)((heightInUnits*1440.0)/inch);
206 int mtType
= getshort(handle
);
208 if (mtType
!= 1 && mtType
!= 2)
214 /* int mtHeaderSize = */ getshort(handle
);
215 int mtVersion
= getshort(handle
);
217 if (mtVersion
!= 0x0300 && mtVersion
!= 0x0100)
223 /* long mtSize = */ getint(handle
);
224 /* int mtNoObjects = */ getshort(handle
);
225 /* long mtMaxRecord = */ getint(handle
);
226 /* int mtNoParameters = */ getshort(handle
);
228 while (!feof(handle
))
230 long rdSize
= getint(handle
); // 4 bytes
231 int rdFunction
= getshort(handle
); // 2 bytes
237 case META_SETBKCOLOR
:
239 wxMetaRecord
*rec
= new wxMetaRecord(META_SETBKCOLOR
);
240 long colorref
= getint(handle
); // COLORREF
241 rec
->param1
= GetRValue(colorref
);
242 rec
->param2
= GetGValue(colorref
);
243 rec
->param3
= GetBValue(colorref
);
244 metaRecords
.Append(rec
);
249 wxMetaRecord
*rec
= new wxMetaRecord(META_SETBKMODE
);
250 rec
->param1
= getshort(handle
); // Background mode
251 if (rec
->param1
== OPAQUE
) rec
->param1
= wxSOLID
;
252 else rec
->param1
= wxTRANSPARENT
;
253 metaRecords
.Append(rec
);
256 case META_SETMAPMODE
:
258 wxMetaRecord
*rec
= new wxMetaRecord(META_SETMAPMODE
);
259 rec
->param1
= getshort(handle
);
260 metaRecords
.Append(rec
);
263 // case META_SETROP2:
264 // case META_SETRELABS:
265 // case META_SETPOLYFILLMODE:
266 // case META_SETSTRETCHBLTMODE:
267 // case META_SETTEXTCHAREXTRA:
268 case META_SETTEXTCOLOR
:
270 wxMetaRecord
*rec
= new wxMetaRecord(META_SETTEXTCOLOR
);
271 long colorref
= getint(handle
); // COLORREF
272 rec
->param1
= GetRValue(colorref
);
273 rec
->param2
= GetGValue(colorref
);
274 rec
->param3
= GetBValue(colorref
);
275 metaRecords
.Append(rec
);
278 // case META_SETTEXTJUSTIFICATION:
279 case META_SETWINDOWORG
:
281 wxMetaRecord
*rec
= new wxMetaRecord(META_SETWINDOWORG
);
282 rec
->param2
= getshort(handle
);
283 rec
->param1
= getshort(handle
);
284 metaRecords
.Append(rec
);
287 case META_SETWINDOWEXT
:
289 wxMetaRecord
*rec
= new wxMetaRecord(META_SETWINDOWEXT
);
290 rec
->param2
= getshort(handle
);
291 rec
->param1
= getshort(handle
);
292 metaRecords
.Append(rec
);
295 // case META_SETVIEWPORTORG:
296 // case META_SETVIEWPORTEXT:
297 // case META_OFFSETWINDOWORG:
298 // case META_SCALEWINDOWEXT:
299 // case META_OFFSETVIEWPORTORG:
300 // case META_SCALEVIEWPORTEXT:
303 wxMetaRecord
*rec
= new wxMetaRecord(META_LINETO
);
304 rec
->param1
= getshort(handle
); // x1
305 rec
->param2
= getshort(handle
); // y1
306 metaRecords
.Append(rec
);
311 wxMetaRecord
*rec
= new wxMetaRecord(META_MOVETO
);
312 rec
->param1
= getshort(handle
); // x1
313 rec
->param2
= getshort(handle
); // y1
314 metaRecords
.Append(rec
);
317 case META_EXCLUDECLIPRECT
:
319 wxMetaRecord
*rec
= new wxMetaRecord(META_EXCLUDECLIPRECT
);
320 rec
->param4
= getshort(handle
); // y2
321 rec
->param3
= getshort(handle
); // x2
322 rec
->param2
= getshort(handle
); // y1
323 rec
->param1
= getshort(handle
); // x1
324 metaRecords
.Append(rec
);
327 case META_INTERSECTCLIPRECT
:
329 wxMetaRecord
*rec
= new wxMetaRecord(META_INTERSECTCLIPRECT
);
330 rec
->param4
= getshort(handle
); // y2
331 rec
->param3
= getshort(handle
); // x2
332 rec
->param2
= getshort(handle
); // y1
333 rec
->param1
= getshort(handle
); // x1
334 metaRecords
.Append(rec
);
337 // case META_ARC: // DO!!!
340 wxMetaRecord
*rec
= new wxMetaRecord(META_ELLIPSE
);
341 rec
->param4
= getshort(handle
); // y2
342 rec
->param3
= getshort(handle
); // x2
343 rec
->param2
= getshort(handle
); // y1
344 rec
->param1
= getshort(handle
); // x1
345 metaRecords
.Append(rec
);
348 // case META_FLOODFILL:
349 // case META_PIE: // DO!!!
352 wxMetaRecord
*rec
= new wxMetaRecord(META_RECTANGLE
);
353 rec
->param4
= getshort(handle
); // y2
354 rec
->param3
= getshort(handle
); // x2
355 rec
->param2
= getshort(handle
); // y1
356 rec
->param1
= getshort(handle
); // x1
357 metaRecords
.Append(rec
);
362 wxMetaRecord
*rec
= new wxMetaRecord(META_ROUNDRECT
);
363 rec
->param6
= getshort(handle
); // width
364 rec
->param5
= getshort(handle
); // height
365 rec
->param4
= getshort(handle
); // y2
366 rec
->param3
= getshort(handle
); // x2
367 rec
->param2
= getshort(handle
); // y1
368 rec
->param1
= getshort(handle
); // x1
369 metaRecords
.Append(rec
);
376 wxMetaRecord
*rec
= new wxMetaRecord(META_SETPIXEL
);
377 rec
->param1
= getshort(handle
); // x1
378 rec
->param2
= getshort(handle
); // y1
379 rec
->param3
= getint(handle
); // COLORREF
380 metaRecords
.Append(rec
);
383 // case META_OFFSETCLIPRGN:
386 wxMetaRecord
*rec
= new wxMetaRecord(META_TEXTOUT
);
387 int count
= getshort(handle
);
388 rec
->stringParam
= new wxChar
[count
+1];
389 fread((void *)rec
->stringParam
, sizeof(wxChar
), count
, handle
);
390 rec
->stringParam
[count
] = 0;
391 rec
->param2
= getshort(handle
); // Y
392 rec
->param1
= getshort(handle
); // X
393 metaRecords
.Append(rec
);
397 case META_EXTTEXTOUT:
399 wxMetaRecord *rec = new wxMetaRecord(META_EXTTEXTOUT);
400 int cellSpacing = getshort(handle);
401 int count = getshort(handle);
402 rec->stringParam = new char[count+1];
403 fread((void *)rec->stringParam, sizeof(char), count, handle);
404 rec->stringParam[count] = 0;
406 int rectY2 = getshort(handle);
407 int rectX2 = getshort(handle);
408 int rectY1 = getshort(handle);
409 int rectX1 = getshort(handle);
410 int rectType = getshort(handle);
411 rec->param2 = getshort(handle); // Y
412 rec->param1 = getshort(handle); // X
413 metaRecords.Append(rec);
418 // case META_STRETCHBLT:
421 wxMetaRecord
*rec
= new wxMetaRecord(META_POLYGON
);
422 rec
->param1
= getshort(handle
);
423 rec
->points
= new wxRealPoint
[(int)rec
->param1
];
424 for (int i
= 0; i
< rec
->param1
; i
++)
426 rec
->points
[i
].x
= getshort(handle
);
427 rec
->points
[i
].y
= getshort(handle
);
430 metaRecords
.Append(rec
);
435 wxMetaRecord
*rec
= new wxMetaRecord(META_POLYLINE
);
436 rec
->param1
= (long)getshort(handle
);
437 rec
->points
= new wxRealPoint
[(int)rec
->param1
];
438 for (int i
= 0; i
< rec
->param1
; i
++)
440 rec
->points
[i
].x
= getshort(handle
);
441 rec
->points
[i
].y
= getshort(handle
);
444 metaRecords
.Append(rec
);
448 // case META_RESTOREDC:
449 // case META_FILLREGION:
450 // case META_FRAMEREGION:
451 // case META_INVERTREGION:
452 // case META_PAINTREGION:
453 // case META_SELECTCLIPREGION: // DO THIS!
454 case META_SELECTOBJECT
:
456 wxMetaRecord
*rec
= new wxMetaRecord(META_SELECTOBJECT
);
457 rec
->param1
= (long)getshort(handle
); // Position of object in gdiObjects list
458 metaRecords
.Append(rec
);
459 // param2 gives the index into gdiObjects, which is different from
460 // the index into the handle table.
461 rec
->param2
= HandleTable
[(int)rec
->param1
]->param2
;
464 // case META_SETTEXTALIGN:
465 // case META_DRAWTEXT:
467 // case META_SETMAPPERFLAGS:
468 // case META_EXTTEXTOUT:
469 // case META_SETDIBTODEV:
470 // case META_SELECTPALETTE:
471 // case META_REALIZEPALETTE:
472 // case META_ANIMATEPALETTE:
473 // case META_SETPALENTRIES:
474 // case META_POLYPOLYGON:
475 // case META_RESIZEPALETTE:
476 // case META_DIBBITBLT:
477 // case META_DIBSTRETCHBLT:
478 case META_DIBCREATEPATTERNBRUSH
:
480 wxMetaRecord
*rec
= new wxMetaRecord(META_DIBCREATEPATTERNBRUSH
);
481 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
483 metaRecords
.Append(rec
);
484 gdiObjects
.Append(rec
);
485 AddMetaRecordHandle(rec
);
486 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
489 // case META_STRETCHDIB:
490 // case META_EXTFLOODFILL:
491 // case META_RESETDC:
492 // case META_STARTDOC:
493 // case META_STARTPAGE:
494 // case META_ENDPAGE:
495 // case META_ABORTDOC:
497 case META_DELETEOBJECT
:
499 int index
= getshort(handle
);
500 DeleteMetaRecordHandle(index
);
503 case META_CREATEPALETTE
:
505 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEPALETTE
);
506 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
508 metaRecords
.Append(rec
);
509 gdiObjects
.Append(rec
);
510 AddMetaRecordHandle(rec
);
511 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
514 case META_CREATEBRUSH
:
516 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBRUSH
);
517 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
518 metaRecords
.Append(rec
);
519 gdiObjects
.Append(rec
);
520 AddMetaRecordHandle(rec
);
521 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
524 case META_CREATEPATTERNBRUSH
:
526 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEPATTERNBRUSH
);
527 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
528 metaRecords
.Append(rec
);
529 gdiObjects
.Append(rec
);
530 AddMetaRecordHandle(rec
);
531 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
534 case META_CREATEPENINDIRECT
:
536 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEPENINDIRECT
);
537 int msStyle
= getshort(handle
); // Style: 2 bytes
538 int x
= getshort(handle
); // X: 2 bytes
539 /* int y = */ getshort(handle
); // Y: 2 bytes
540 long colorref
= getint(handle
); // COLORREF 4 bytes
543 if (msStyle
== PS_DOT
)
545 else if (msStyle
== PS_DASH
)
546 style
= wxSHORT_DASH
;
547 else if (msStyle
== PS_NULL
)
548 style
= wxTRANSPARENT
;
549 else style
= wxSOLID
;
551 wxColour
colour(GetRValue(colorref
), GetGValue(colorref
), GetBValue(colorref
));
552 rec
->param1
= (long)wxThePenList
->FindOrCreatePen(colour
, x
, style
);
553 metaRecords
.Append(rec
);
554 gdiObjects
.Append(rec
);
556 AddMetaRecordHandle(rec
);
557 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
559 // For some reason, the size of this record is sometimes 9 words!!!
560 // instead of the usual 8. So read 2 characters extra.
563 (void) getshort(handle
);
567 case META_CREATEFONTINDIRECT
:
569 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEFONTINDIRECT
);
570 int lfHeight
= getshort(handle
); // 2 bytes
571 /* int lfWidth = */ getshort(handle
); // 2 bytes
572 /* int lfEsc = */ getshort(handle
); // 2 bytes
573 /* int lfOrient = */ getshort(handle
); // 2 bytes
574 int lfWeight
= getshort(handle
); // 2 bytes
575 char lfItalic
= getc(handle
); // 1 byte
576 char lfUnderline
= getc(handle
); // 1 byte
577 /* char lfStrikeout = */ getc(handle
); // 1 byte
578 /* char lfCharSet = */ getc(handle
); // 1 byte
579 /* char lfOutPrecision = */ getc(handle
); // 1 byte
580 /* char lfClipPrecision = */ getc(handle
); // 1 byte
581 /* char lfQuality = */ getc(handle
); // 1 byte
582 char lfPitchAndFamily
= getc(handle
); // 1 byte (18th)
584 // Read the rest of the record, which is total record size
585 // minus the number of bytes already read (18 record, 6 metarecord
587 fread((void *)lfFacename
, sizeof(char), (int)((2*rdSize
) - 18 - 6), handle
);
590 if (lfPitchAndFamily
& FF_MODERN
)
592 else if (lfPitchAndFamily
& FF_MODERN
)
594 else if (lfPitchAndFamily
& FF_ROMAN
)
596 else if (lfPitchAndFamily
& FF_SWISS
)
598 else if (lfPitchAndFamily
& FF_DECORATIVE
)
599 family
= wxDECORATIVE
;
606 else if (lfWeight
== 400)
608 else if (lfWeight
== 900)
610 else weight
= wxNORMAL
;
618 // About how many pixels per inch???
619 int logPixelsY
= 100;
620 int pointSize
= (int)(lfHeight
*72.0/logPixelsY
);
623 wxTheFontList
->FindOrCreateFont(pointSize
, family
, style
, weight
, (lfUnderline
!= 0));
625 rec
->param1
= (long) theFont
;
626 metaRecords
.Append(rec
);
627 gdiObjects
.Append(rec
);
628 AddMetaRecordHandle(rec
);
629 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
632 case META_CREATEBRUSHINDIRECT
:
634 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBRUSHINDIRECT
);
635 int msStyle
= getshort(handle
); // Style: 2 bytes
636 long colorref
= getint(handle
); // COLORREF: 4 bytes
637 int hatchStyle
= getshort(handle
); // Hatch style 2 bytes
647 style
= wxBDIAGONAL_HATCH
;
650 style
= wxCROSSDIAG_HATCH
;
653 style
= wxFDIAGONAL_HATCH
;
656 style
= wxHORIZONTAL_HATCH
;
659 style
= wxVERTICAL_HATCH
;
663 style
= wxCROSS_HATCH
;
673 if (msStyle
== PS_DOT
)
675 else if (msStyle
== PS_DASH
)
676 style
= wxSHORT_DASH
;
677 else if (msStyle
== PS_NULL
)
678 style
= wxTRANSPARENT
;
679 else style
= wxSOLID
;
681 wxColour
colour(GetRValue(colorref
), GetGValue(colorref
), GetBValue(colorref
));
682 rec
->param1
= (long)wxTheBrushList
->FindOrCreateBrush(colour
, style
);
683 metaRecords
.Append(rec
);
684 gdiObjects
.Append(rec
);
685 AddMetaRecordHandle(rec
);
686 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
689 case META_CREATEBITMAPINDIRECT
:
691 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBITMAPINDIRECT
);
692 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
694 metaRecords
.Append(rec
);
695 gdiObjects
.Append(rec
);
696 AddMetaRecordHandle(rec
);
697 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
700 case META_CREATEBITMAP
:
702 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEBITMAP
);
703 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
705 metaRecords
.Append(rec
);
706 gdiObjects
.Append(rec
);
707 AddMetaRecordHandle(rec
);
708 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
711 case META_CREATEREGION
:
713 wxMetaRecord
*rec
= new wxMetaRecord(META_CREATEREGION
);
714 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
716 metaRecords
.Append(rec
);
717 gdiObjects
.Append(rec
);
718 AddMetaRecordHandle(rec
);
719 rec
->param2
= (long)(gdiObjects
.GetCount() - 1);
724 fread((void *)_buf
, sizeof(char), (int)((2*rdSize
) - 6), handle
);
733 wxXMetaFile::~wxXMetaFile(void)
735 wxNode
*node
= metaRecords
.GetFirst();
738 wxMetaRecord
*rec
= (wxMetaRecord
*)node
->GetData();
740 wxNode
*next
= node
->GetNext();
746 bool wxXMetaFile::SetClipboard(int WXUNUSED(width
), int WXUNUSED(height
))
751 bool wxXMetaFile::Play(wxDC
*dc
)
753 wxNode
*node
= metaRecords
.GetFirst();
756 wxMetaRecord
*rec
= (wxMetaRecord
*)node
->GetData();
757 int rdFunction
= rec
->metaFunction
;
761 case META_SETBKCOLOR
:
769 case META_SETMAPMODE
:
773 // case META_SETROP2:
774 // case META_SETRELABS:
775 // case META_SETPOLYFILLMODE:
776 // case META_SETSTRETCHBLTMODE:
777 // case META_SETTEXTCHAREXTRA:
778 case META_SETTEXTCOLOR
:
782 // case META_SETTEXTJUSTIFICATION:
783 case META_SETWINDOWORG
:
787 case META_SETWINDOWEXT
:
791 // case META_SETVIEWPORTORG:
792 // case META_SETVIEWPORTEXT:
793 // case META_OFFSETWINDOWORG:
794 // case META_SCALEWINDOWEXT:
795 // case META_OFFSETVIEWPORTORG:
796 // case META_SCALEVIEWPORTEXT:
799 long x1
= rec
->param1
;
800 long y1
= rec
->param2
;
801 dc
->DrawLine((long) lastX
, (long) lastY
, x1
, y1
);
806 lastX
= (double)rec
->param1
;
807 lastY
= (double)rec
->param2
;
810 case META_EXCLUDECLIPRECT
:
814 case META_INTERSECTCLIPRECT
:
818 // case META_ARC: // DO!!!
823 // case META_FLOODFILL:
824 // case META_PIE: // DO!!!
827 dc
->DrawRectangle((long)rec
->param1
, (long)rec
->param2
,
828 (long)rec
->param3
- rec
->param1
,
829 (long)rec
->param4
- rec
->param2
);
834 dc
->DrawRoundedRectangle((long)rec
->param1
, (long)rec
->param2
,
835 (long)rec
->param3
- rec
->param1
,
836 (long)rec
->param4
- rec
->param2
,
844 // rec->param1 = getshort(handle); // x1
845 // rec->param2 = getshort(handle); // y1
846 // rec->param3 = getint(handle); // COLORREF
849 // case META_OFFSETCLIPRGN:
853 int count = getshort(handle);
854 rec->stringParam = new char[count+1];
855 fread((void *)rec->stringParam, sizeof(char), count, handle);
856 rec->stringParam[count] = 0;
857 rec->param2 = getshort(handle); // Y
858 rec->param1 = getshort(handle); // X
863 // case META_STRETCHBLT:
867 rec->param1 = getshort(handle);
868 rec->points = new wxRealPoint[(int)rec->param1];
869 for (int i = 0; i < rec->param1; i++)
871 rec->points[i].x = getshort(handle);
872 rec->points[i].y = getshort(handle);
880 wxMetaRecord *rec = new wxMetaRecord(META_POLYLINE);
881 rec->param1 = (long)getshort(handle);
882 rec->points = new wxRealPoint[(int)rec->param1];
883 for (int i = 0; i < rec->param1; i++)
885 rec->points[i].x = getshort(handle);
886 rec->points[i].y = getshort(handle);
892 // case META_RESTOREDC:
893 // case META_FILLREGION:
894 // case META_FRAMEREGION:
895 // case META_INVERTREGION:
896 // case META_PAINTREGION:
897 // case META_SELECTCLIPREGION: // DO THIS!
898 case META_SELECTOBJECT
:
901 wxMetaRecord *rec = new wxMetaRecord(META_SELECTOBJECT);
902 rec->param1 = (long)getshort(handle); // Position of object in gdiObjects list
906 // case META_SETTEXTALIGN:
907 // case META_DRAWTEXT:
909 // case META_SETMAPPERFLAGS:
910 // case META_EXTTEXTOUT:
911 // case META_SETDIBTODEV:
912 // case META_SELECTPALETTE:
913 // case META_REALIZEPALETTE:
914 // case META_ANIMATEPALETTE:
915 // case META_SETPALENTRIES:
916 // case META_POLYPOLYGON:
917 // case META_RESIZEPALETTE:
918 // case META_DIBBITBLT:
919 // case META_DIBSTRETCHBLT:
920 case META_DIBCREATEPATTERNBRUSH
:
923 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
927 // case META_STRETCHDIB:
928 // case META_EXTFLOODFILL:
929 // case META_RESETDC:
930 // case META_STARTDOC:
931 // case META_STARTPAGE:
932 // case META_ENDPAGE:
933 // case META_ABORTDOC:
935 // case META_DELETEOBJECT: // DO!!
936 case META_CREATEPALETTE
:
939 wxMetaRecord *rec = new wxMetaRecord(META_CREATEPALETTE);
940 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
944 case META_CREATEBRUSH
:
947 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
951 case META_CREATEPATTERNBRUSH
:
954 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
958 case META_CREATEPENINDIRECT
:
961 int msStyle = getshort(handle); // Style: 2 bytes
962 int x = getshort(handle); // X: 2 bytes
963 int y = getshort(handle); // Y: 2 bytes
964 int colorref = getint(handle); // COLORREF 4 bytes
967 if (msStyle == PS_DOT)
969 else if (msStyle == PS_DASH)
970 style = wxSHORT_DASH;
971 else if (msStyle == PS_NULL)
972 style = wxTRANSPARENT;
973 else style = wxSOLID;
975 wxColour colour(GetRValue(colorref), GetGValue(colorref), GetBValue(colorref));
976 rec->param1 = (long)wxThePenList->FindOrCreatePen(&colour, x, style);
980 case META_CREATEFONTINDIRECT
:
983 int lfHeight = getshort(handle);
984 int lfWidth = getshort(handle);
985 int lfEsc = getshort(handle);
986 int lfOrient = getshort(handle);
987 int lfWeight = getshort(handle);
988 char lfItalic = getc(handle);
989 char lfUnderline = getc(handle);
990 char lfStrikeout = getc(handle);
991 char lfCharSet = getc(handle);
992 char lfOutPrecision = getc(handle);
993 char lfClipPrecision = getc(handle);
994 char lfQuality = getc(handle);
995 char lfPitchAndFamily = getc(handle);
997 fread((void *)lfFacename, sizeof(char), 32, handle);
1000 if (lfPitchAndFamily & FF_MODERN)
1002 else if (lfPitchAndFamily & FF_MODERN)
1004 else if (lfPitchAndFamily & FF_ROMAN)
1006 else if (lfPitchAndFamily & FF_SWISS)
1008 else if (lfPitchAndFamily & FF_DECORATIVE)
1009 family = wxDECORATIVE;
1014 if (lfWeight == 300)
1016 else if (lfWeight == 400)
1018 else if (lfWeight == 900)
1020 else weight = wxNORMAL;
1028 // About how many pixels per inch???
1029 int logPixelsY = 100;
1030 int pointSize = (int)(lfHeight*72.0/logPixelsY);
1033 wxTheFontList->FindOrCreateFont(pointSize, family, style, weight, (bool)lfUnderline);
1035 rec->param1 = (long)theFont;
1039 case META_CREATEBRUSHINDIRECT
:
1042 int msStyle = getshort(handle); // Style: 2 bytes
1043 int colorref = getint(handle); // COLORREF: 4 bytes
1044 int hatchStyle = getshort(handle); // Hatch style 2 bytes
1047 if (msStyle == PS_DOT)
1049 else if (msStyle == PS_DASH)
1050 style = wxSHORT_DASH;
1051 else if (msStyle == PS_NULL)
1052 style = wxTRANSPARENT;
1053 else style = wxSOLID;
1055 wxColour colour(GetRValue(colorref), GetGValue(colorref), GetBValue(colorref));
1056 rec->param1 = (long)wxTheBrushList->FindOrCreateBrush(&colour, wxSOLID);
1060 case META_CREATEBITMAPINDIRECT
:
1063 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
1067 case META_CREATEBITMAP
:
1070 fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
1074 case META_CREATEREGION
:
1076 dc
->DestroyClippingRegion();
1078 rec->param1 = getshort(handle); // Style: 2 bytes
1087 node
= node
->GetNext();