X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1fc25a89ac1e6c5208db24bfc0abc8666b791dc6..3527f29c8769e09d796c547c0c309f8b86407012:/contrib/src/ogl/mfutils.cpp diff --git a/contrib/src/ogl/mfutils.cpp b/contrib/src/ogl/mfutils.cpp index b2684836a1..17111d481e 100644 --- a/contrib/src/ogl/mfutils.cpp +++ b/contrib/src/ogl/mfutils.cpp @@ -14,7 +14,7 @@ #endif // For compilers that support precompilation, includes "wx.h". -#include +#include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop @@ -27,9 +27,12 @@ #include #include -#include +#include "wx/ogl/ogl.h" + #include +static char _buf[1024]; // a temp buffer to use inplace of wxBuffer, which is deprecated. + static char hexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; @@ -41,7 +44,7 @@ static void DecToHex(int dec, char *buf) buf[1] = hexArray[secondDigit]; buf[2] = 0; } - + // 16-bit unsigned integer static unsigned int getshort(FILE *fp) { @@ -56,7 +59,10 @@ static int getsignedshort(FILE *fp) { int c, c1; c = getc(fp); c1 = getc(fp); +#if 0 + // this is not used value, no need to execute it int testRes = ((unsigned int) c) + (((unsigned int) c1) << 8); +#endif unsigned long res1 = ((unsigned int) c) + (((unsigned int) c1) << 8); int res = 0; if (res1 > 32767) @@ -72,7 +78,7 @@ static long getint(FILE *fp) int c, c1, c2, c3; c = getc(fp); c1 = getc(fp); c2 = getc(fp); c3 = getc(fp); long res = (long)((long) c) + - (((long) c1) << 8) + + (((long) c1) << 8) + (((long) c2) << 16) + (((long) c3) << 24); return res; @@ -96,14 +102,14 @@ wxMetaRecord::~wxMetaRecord(void) if (stringParam) delete[] stringParam; } -wxXMetaFile::wxXMetaFile(char *file) +wxXMetaFile::wxXMetaFile(const wxChar *file) { ok = FALSE; top = 0.0; bottom = 0.0; left = 0.0; right = 0.0; - + if (file) ok = ReadFile(file); } @@ -115,7 +121,7 @@ wxXMetaFile::wxXMetaFile(char *file) [1]----param2--- wxBrush [2] | wxFont [3] | -> wxPen - + The handle table works as follows. When a GDI object is created whilst reading in the metafile, the (e.g.) createpen record is added to the @@ -123,7 +129,7 @@ wxXMetaFile::wxXMetaFile(char *file) record's param1 is a pointer to the actual wxPen, and its param2 is the index into the gdiObjects list, which only grows and never shrinks (unlike the handle table.) - + When SelectObject(index) is found, the index in the file refers to the position in the handle table. BUT we then set param2 to be the position of the wxPen in gdiObjects, @@ -135,7 +141,7 @@ wxXMetaFile::wxXMetaFile(char *file) allows us to create all GDI objects in advance of playing the metafile). */ - + static wxMetaRecord *HandleTable[100]; static int HandleTableSize = 0; @@ -154,25 +160,25 @@ int AddMetaRecordHandle(wxMetaRecord *record) return i; } // No free spaces in table, so append. - + HandleTable[HandleTableSize] = record; HandleTableSize ++; return (HandleTableSize - 1); } -bool wxXMetaFile::ReadFile(char *file) +bool wxXMetaFile::ReadFile(const wxChar *file) { HandleTableSize = 0; - - FILE *handle = fopen(file, "rb"); + + FILE *handle = wxFopen(file, wxT("rb")); if (!handle) return FALSE; // Read placeable metafile header, if any long key = getint(handle); - + if (key == (long) 0x9AC6CDD7) { - long hmf = getshort(handle); + /* long hmf = */ getshort(handle); int iLeft, iTop, iRight, iBottom; iLeft = getsignedshort(handle); iTop = getsignedshort(handle); @@ -184,9 +190,9 @@ bool wxXMetaFile::ReadFile(char *file) right = (double)iRight; bottom = (double)iBottom; - int inch = getshort(handle); - long reserved = getint(handle); - int checksum = getshort(handle); + /* int inch = */ getshort(handle); + /* long reserved = */ getint(handle); + /* int checksum = */ getshort(handle); /* double widthInUnits = (double)right - left; double heightInUnits = (double)bottom - top; @@ -205,7 +211,7 @@ bool wxXMetaFile::ReadFile(char *file) return FALSE; } - int mtHeaderSize = getshort(handle); + /* int mtHeaderSize = */ getshort(handle); int mtVersion = getshort(handle); if (mtVersion != 0x0300 && mtVersion != 0x0100) @@ -213,11 +219,11 @@ bool wxXMetaFile::ReadFile(char *file) fclose(handle); return FALSE; } - - long mtSize = getint(handle); - int mtNoObjects = getshort(handle); - long mtMaxRecord = getint(handle); - int mtNoParameters = getshort(handle); + + /* long mtSize = */ getint(handle); + /* int mtNoObjects = */ getshort(handle); + /* long mtMaxRecord = */ getint(handle); + /* int mtNoParameters = */ getshort(handle); while (!feof(handle)) { @@ -379,8 +385,8 @@ bool wxXMetaFile::ReadFile(char *file) { wxMetaRecord *rec = new wxMetaRecord(META_TEXTOUT); int count = getshort(handle); - rec->stringParam = new char[count+1]; - fread((void *)rec->stringParam, sizeof(char), count, handle); + rec->stringParam = new wxChar[count+1]; + fread((void *)rec->stringParam, sizeof(wxChar), count, handle); rec->stringParam[count] = 0; rec->param2 = getshort(handle); // Y rec->param1 = getshort(handle); // X @@ -420,7 +426,7 @@ bool wxXMetaFile::ReadFile(char *file) rec->points[i].x = getshort(handle); rec->points[i].y = getshort(handle); } - + metaRecords.Append(rec); break; } @@ -434,7 +440,7 @@ bool wxXMetaFile::ReadFile(char *file) rec->points[i].x = getshort(handle); rec->points[i].y = getshort(handle); } - + metaRecords.Append(rec); break; } @@ -472,12 +478,12 @@ bool wxXMetaFile::ReadFile(char *file) case META_DIBCREATEPATTERNBRUSH: { wxMetaRecord *rec = new wxMetaRecord(META_DIBCREATEPATTERNBRUSH); - fread((void *)wxBuffer, sizeof(char), (int)((2*rdSize) - 6), handle); - + fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle); + metaRecords.Append(rec); gdiObjects.Append(rec); AddMetaRecordHandle(rec); - rec->param2 = (long)(gdiObjects.Number() - 1); + rec->param2 = (long)(gdiObjects.GetCount() - 1); break; } // case META_STRETCHDIB: @@ -497,32 +503,32 @@ bool wxXMetaFile::ReadFile(char *file) case META_CREATEPALETTE: { wxMetaRecord *rec = new wxMetaRecord(META_CREATEPALETTE); - fread((void *)wxBuffer, sizeof(char), (int)((2*rdSize) - 6), handle); - + fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle); + metaRecords.Append(rec); gdiObjects.Append(rec); AddMetaRecordHandle(rec); - rec->param2 = (long)(gdiObjects.Number() - 1); + rec->param2 = (long)(gdiObjects.GetCount() - 1); break; } case META_CREATEBRUSH: { wxMetaRecord *rec = new wxMetaRecord(META_CREATEBRUSH); - fread((void *)wxBuffer, sizeof(char), (int)((2*rdSize) - 6), handle); + fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle); metaRecords.Append(rec); gdiObjects.Append(rec); AddMetaRecordHandle(rec); - rec->param2 = (long)(gdiObjects.Number() - 1); + rec->param2 = (long)(gdiObjects.GetCount() - 1); break; } case META_CREATEPATTERNBRUSH: { wxMetaRecord *rec = new wxMetaRecord(META_CREATEPATTERNBRUSH); - fread((void *)wxBuffer, sizeof(char), (int)((2*rdSize) - 6), handle); + fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle); metaRecords.Append(rec); gdiObjects.Append(rec); AddMetaRecordHandle(rec); - rec->param2 = (long)(gdiObjects.Number() - 1); + rec->param2 = (long)(gdiObjects.GetCount() - 1); break; } case META_CREATEPENINDIRECT: @@ -530,7 +536,7 @@ bool wxXMetaFile::ReadFile(char *file) wxMetaRecord *rec = new wxMetaRecord(META_CREATEPENINDIRECT); int msStyle = getshort(handle); // Style: 2 bytes int x = getshort(handle); // X: 2 bytes - int y = getshort(handle); // Y: 2 bytes + /* int y = */ getshort(handle); // Y: 2 bytes long colorref = getint(handle); // COLORREF 4 bytes int style; @@ -548,8 +554,8 @@ bool wxXMetaFile::ReadFile(char *file) gdiObjects.Append(rec); AddMetaRecordHandle(rec); - rec->param2 = (long)(gdiObjects.Number() - 1); - + rec->param2 = (long)(gdiObjects.GetCount() - 1); + // For some reason, the size of this record is sometimes 9 words!!! // instead of the usual 8. So read 2 characters extra. if (rdSize == 9) @@ -562,17 +568,17 @@ bool wxXMetaFile::ReadFile(char *file) { wxMetaRecord *rec = new wxMetaRecord(META_CREATEFONTINDIRECT); int lfHeight = getshort(handle); // 2 bytes - int lfWidth = getshort(handle); // 2 bytes - int lfEsc = getshort(handle); // 2 bytes - int lfOrient = getshort(handle); // 2 bytes + /* int lfWidth = */ getshort(handle); // 2 bytes + /* int lfEsc = */ getshort(handle); // 2 bytes + /* int lfOrient = */ getshort(handle); // 2 bytes int lfWeight = getshort(handle); // 2 bytes char lfItalic = getc(handle); // 1 byte char lfUnderline = getc(handle); // 1 byte - char lfStrikeout = getc(handle); // 1 byte - char lfCharSet = getc(handle); // 1 byte - char lfOutPrecision = getc(handle); // 1 byte - char lfClipPrecision = getc(handle); // 1 byte - char lfQuality = getc(handle); // 1 byte + /* char lfStrikeout = */ getc(handle); // 1 byte + /* char lfCharSet = */ getc(handle); // 1 byte + /* char lfOutPrecision = */ getc(handle); // 1 byte + /* char lfClipPrecision = */ getc(handle); // 1 byte + /* char lfQuality = */ getc(handle); // 1 byte char lfPitchAndFamily = getc(handle); // 1 byte (18th) char lfFacename[32]; // Read the rest of the record, which is total record size @@ -620,7 +626,7 @@ bool wxXMetaFile::ReadFile(char *file) metaRecords.Append(rec); gdiObjects.Append(rec); AddMetaRecordHandle(rec); - rec->param2 = (long)(gdiObjects.Number() - 1); + rec->param2 = (long)(gdiObjects.GetCount() - 1); break; } case META_CREATEBRUSHINDIRECT: @@ -677,45 +683,45 @@ bool wxXMetaFile::ReadFile(char *file) metaRecords.Append(rec); gdiObjects.Append(rec); AddMetaRecordHandle(rec); - rec->param2 = (long)(gdiObjects.Number() - 1); + rec->param2 = (long)(gdiObjects.GetCount() - 1); break; } case META_CREATEBITMAPINDIRECT: { wxMetaRecord *rec = new wxMetaRecord(META_CREATEBITMAPINDIRECT); - fread((void *)wxBuffer, sizeof(char), (int)((2*rdSize) - 6), handle); - + fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle); + metaRecords.Append(rec); gdiObjects.Append(rec); AddMetaRecordHandle(rec); - rec->param2 = (long)(gdiObjects.Number() - 1); + rec->param2 = (long)(gdiObjects.GetCount() - 1); break; } case META_CREATEBITMAP: { wxMetaRecord *rec = new wxMetaRecord(META_CREATEBITMAP); - fread((void *)wxBuffer, sizeof(char), (int)((2*rdSize) - 6), handle); - + fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle); + metaRecords.Append(rec); gdiObjects.Append(rec); AddMetaRecordHandle(rec); - rec->param2 = (long)(gdiObjects.Number() - 1); + rec->param2 = (long)(gdiObjects.GetCount() - 1); break; } case META_CREATEREGION: { wxMetaRecord *rec = new wxMetaRecord(META_CREATEREGION); - fread((void *)wxBuffer, sizeof(char), (int)((2*rdSize) - 6), handle); + fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle); metaRecords.Append(rec); gdiObjects.Append(rec); AddMetaRecordHandle(rec); - rec->param2 = (long)(gdiObjects.Number() - 1); + rec->param2 = (long)(gdiObjects.GetCount() - 1); break; } default: { - fread((void *)wxBuffer, sizeof(char), (int)((2*rdSize) - 6), handle); + fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle); break; } } @@ -726,28 +732,28 @@ bool wxXMetaFile::ReadFile(char *file) wxXMetaFile::~wxXMetaFile(void) { - wxNode *node = metaRecords.First(); + wxNode *node = metaRecords.GetFirst(); while (node) { - wxMetaRecord *rec = (wxMetaRecord *)node->Data(); + wxMetaRecord *rec = (wxMetaRecord *)node->GetData(); delete rec; - wxNode *next = node->Next(); + wxNode *next = node->GetNext(); delete node; node = next; } } -bool wxXMetaFile::SetClipboard(int width, int height) +bool wxXMetaFile::SetClipboard(int WXUNUSED(width), int WXUNUSED(height)) { return FALSE; } bool wxXMetaFile::Play(wxDC *dc) { - wxNode *node = metaRecords.First(); + wxNode *node = metaRecords.GetFirst(); while (node) { - wxMetaRecord *rec = (wxMetaRecord *)node->Data(); + wxMetaRecord *rec = (wxMetaRecord *)node->GetData(); int rdFunction = rec->metaFunction; switch (rdFunction) @@ -865,7 +871,7 @@ bool wxXMetaFile::Play(wxDC *dc) rec->points[i].x = getshort(handle); rec->points[i].y = getshort(handle); } -*/ +*/ break; } case META_POLYLINE: @@ -879,7 +885,7 @@ bool wxXMetaFile::Play(wxDC *dc) rec->points[i].x = getshort(handle); rec->points[i].y = getshort(handle); } -*/ +*/ break; } // case META_ESCAPE: @@ -915,7 +921,7 @@ bool wxXMetaFile::Play(wxDC *dc) { /* fread((void *)wxBuffer, sizeof(char), (int)(rdSize - 3), handle); -*/ +*/ break; } // case META_STRETCHDIB: @@ -1055,14 +1061,14 @@ bool wxXMetaFile::Play(wxDC *dc) { /* 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: @@ -1078,7 +1084,7 @@ bool wxXMetaFile::Play(wxDC *dc) break; } } - node = node->Next(); + node = node->GetNext(); } return TRUE; }