📄 mfutils.cpp
字号:
wxXMetaFile::~wxXMetaFile(void)
{
wxObjectList::compatibility_iterator node = metaRecords.GetFirst();
while (node)
{
wxMetaRecord *rec = (wxMetaRecord *)node->GetData();
delete rec;
wxObjectList::compatibility_iterator next = node->GetNext();
metaRecords.Erase(node);
node = next;
}
}
bool wxXMetaFile::SetClipboard(int WXUNUSED(width), int WXUNUSED(height))
{
return false;
}
bool wxXMetaFile::Play(wxDC *dc)
{
wxObjectList::compatibility_iterator node = metaRecords.GetFirst();
while (node)
{
wxMetaRecord *rec = (wxMetaRecord *)node->GetData();
int rdFunction = rec->metaFunction;
switch (rdFunction)
{
case META_SETBKCOLOR:
{
break;
}
case META_SETBKMODE:
{
break;
}
case META_SETMAPMODE:
{
break;
}
// case META_SETROP2:
// case META_SETRELABS:
// case META_SETPOLYFILLMODE:
// case META_SETSTRETCHBLTMODE:
// case META_SETTEXTCHAREXTRA:
case META_SETTEXTCOLOR:
{
break;
}
// case META_SETTEXTJUSTIFICATION:
case META_SETWINDOWORG:
{
break;
}
case META_SETWINDOWEXT:
{
break;
}
// case META_SETVIEWPORTORG:
// case META_SETVIEWPORTEXT:
// case META_OFFSETWINDOWORG:
// case META_SCALEWINDOWEXT:
// case META_OFFSETVIEWPORTORG:
// case META_SCALEVIEWPORTEXT:
case META_LINETO:
{
long x1 = rec->param1;
long y1 = rec->param2;
dc->DrawLine((long) lastX, (long) lastY, x1, y1);
break;
}
case META_MOVETO:
{
lastX = (double)rec->param1;
lastY = (double)rec->param2;
break;
}
case META_EXCLUDECLIPRECT:
{
break;
}
case META_INTERSECTCLIPRECT:
{
break;
}
// case META_ARC: // DO!!!
case META_ELLIPSE:
{
break;
}
// case META_FLOODFILL:
// case META_PIE: // DO!!!
case META_RECTANGLE:
{
dc->DrawRectangle((long)rec->param1, (long)rec->param2,
(long)rec->param3 - rec->param1,
(long)rec->param4 - rec->param2);
break;
}
case META_ROUNDRECT:
{
dc->DrawRoundedRectangle((long)rec->param1, (long)rec->param2,
(long)rec->param3 - rec->param1,
(long)rec->param4 - rec->param2,
(long)rec->param5);
break;
}
// case META_PATBLT:
// case META_SAVEDC:
case META_SETPIXEL:
{
// rec->param1 = getshort(handle); // x1
// rec->param2 = getshort(handle); // y1
// rec->param3 = getint(handle); // COLORREF
break;
}
// case META_OFFSETCLIPRGN:
case META_TEXTOUT:
{
/*
int count = getshort(handle);
rec->stringParam = new char[count+1];
fread((void *)rec->stringParam, sizeof(char), count, handle);
rec->stringParam[count] = 0;
rec->param2 = getshort(handle); // Y
rec->param1 = getshort(handle); // X
*/
break;
}
// case META_BITBLT:
// case META_STRETCHBLT:
case META_POLYGON:
{
/*
rec->param1 = getshort(handle);
rec->points = new wxRealPoint[(int)rec->param1];
for (int i = 0; i < rec->param1; i++)
{
rec->points[i].x = getshort(handle);
rec->points[i].y = getshort(handle);
}
*/
break;
}
case META_POLYLINE:
{
/*
wxMetaRecord *rec = new wxMetaRecord(META_POLYLINE);
rec->param1 = (long)getshort(handle);
rec->points = new wxRealPoint[(int)rec->param1];
for (int i = 0; i < rec->param1; i++)
{
rec->points[i].x = getshort(handle);
rec->points[i].y = getshort(handle);
}
*/
break;
}
// case META_ESCAPE:
// case META_RESTOREDC:
// case META_FILLREGION:
// case META_FRAMEREGION:
// case META_INVERTREGION:
// case META_PAINTREGION:
// case META_SELECTCLIPREGION: // DO THIS!
case META_SELECTOBJECT:
{
/*
wxMetaRecord *rec = new wxMetaRecord(META_SELECTOBJECT);
rec->param1 = (long)getshort(handle); // Position of object in gdiObjects list
*/
break;
}
// case META_SETTEXTALIGN:
// case META_DRAWTEXT:
// case META_CHORD:
// case META_SETMAPPERFLAGS:
// case META_EXTTEXTOUT:
// case META_SETDIBTODEV:
// case META_SELECTPALETTE:
// case META_REALIZEPALETTE:
// case META_ANIMATEPALETTE:
// case META_SETPALENTRIES:
// case META_POLYPOLYGON:
// case META_RESIZEPALETTE:
// case META_DIBBITBLT:
// case META_DIBSTRETCHBLT:
case META_DIBCREATEPATTERNBRUSH:
{
/*
fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
*/
break;
}
// case META_STRETCHDIB:
// case META_EXTFLOODFILL:
// case META_RESETDC:
// case META_STARTDOC:
// case META_STARTPAGE:
// case META_ENDPAGE:
// case META_ABORTDOC:
// case META_ENDDOC:
// case META_DELETEOBJECT: // DO!!
case META_CREATEPALETTE:
{
/*
wxMetaRecord *rec = new wxMetaRecord(META_CREATEPALETTE);
fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
*/
break;
}
case META_CREATEBRUSH:
{
/*
fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
*/
break;
}
case META_CREATEPATTERNBRUSH:
{
/*
fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
*/
break;
}
case META_CREATEPENINDIRECT:
{
/*
int msStyle = getshort(handle); // Style: 2 bytes
int x = getshort(handle); // X: 2 bytes
int y = getshort(handle); // Y: 2 bytes
int colorref = getint(handle); // COLORREF 4 bytes
int style;
if (msStyle == PS_DOT)
style = wxDOT;
else if (msStyle == PS_DASH)
style = wxSHORT_DASH;
else if (msStyle == PS_NULL)
style = wxTRANSPARENT;
else style = wxSOLID;
wxColour colour(GetRValue(colorref), GetGValue(colorref), GetBValue(colorref));
rec->param1 = (long)wxThePenList->FindOrCreatePen(&colour, x, style);
*/
break;
}
case META_CREATEFONTINDIRECT:
{
/*
int lfHeight = getshort(handle);
int lfWidth = getshort(handle);
int lfEsc = getshort(handle);
int lfOrient = getshort(handle);
int lfWeight = getshort(handle);
char lfItalic = getc(handle);
char lfUnderline = getc(handle);
char lfStrikeout = getc(handle);
char lfCharSet = getc(handle);
char lfOutPrecision = getc(handle);
char lfClipPrecision = getc(handle);
char lfQuality = getc(handle);
char lfPitchAndFamily = getc(handle);
char lfFacename[32];
fread((void *)lfFacename, sizeof(char), 32, handle);
int family;
if (lfPitchAndFamily & FF_MODERN)
family = wxMODERN;
else if (lfPitchAndFamily & FF_MODERN)
family = wxMODERN;
else if (lfPitchAndFamily & FF_ROMAN)
family = wxROMAN;
else if (lfPitchAndFamily & FF_SWISS)
family = wxSWISS;
else if (lfPitchAndFamily & FF_DECORATIVE)
family = wxDECORATIVE;
else
family = wxDEFAULT;
int weight;
if (lfWeight == 300)
weight = wxLIGHT;
else if (lfWeight == 400)
weight = wxNORMAL;
else if (lfWeight == 900)
weight = wxBOLD;
else weight = wxNORMAL;
int style;
if ((bool)lfItalic)
style = wxITALIC;
else
style = wxNORMAL;
// About how many pixels per inch???
int logPixelsY = 100;
int pointSize = (int)(lfHeight*72.0/logPixelsY);
wxFont *theFont =
wxTheFontList->FindOrCreateFont(pointSize, family, style, weight, (bool)lfUnderline);
rec->param1 = (long)theFont;
*/
break;
}
case META_CREATEBRUSHINDIRECT:
{
/*
int msStyle = getshort(handle); // Style: 2 bytes
int colorref = getint(handle); // COLORREF: 4 bytes
int hatchStyle = getshort(handle); // Hatch style 2 bytes
int style;
if (msStyle == PS_DOT)
style = wxDOT;
else if (msStyle == PS_DASH)
style = wxSHORT_DASH;
else if (msStyle == PS_NULL)
style = wxTRANSPARENT;
else style = wxSOLID;
wxColour colour(GetRValue(colorref), GetGValue(colorref), GetBValue(colorref));
rec->param1 = (long)wxTheBrushList->FindOrCreateBrush(&colour, wxSOLID);
*/
break;
}
case META_CREATEBITMAPINDIRECT:
{
/*
fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
*/
break;
}
case META_CREATEBITMAP:
{
/*
fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle);
*/
break;
}
case META_CREATEREGION:
{
dc->DestroyClippingRegion();
/*
rec->param1 = getshort(handle); // Style: 2 bytes
*/
break;
}
default:
{
break;
}
}
node = node->GetNext();
}
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -