X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1484b5cc701329c54bbe70f2a155119fd86945c7..55c91e8a3faff8a1f4e758bbb64c28d1743c66c8:/contrib/src/ogl/mfutils.cpp diff --git a/contrib/src/ogl/mfutils.cpp b/contrib/src/ogl/mfutils.cpp index 17111d481e..ae084590fe 100644 --- a/contrib/src/ogl/mfutils.cpp +++ b/contrib/src/ogl/mfutils.cpp @@ -6,7 +6,7 @@ // Created: 12/07/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -33,18 +33,6 @@ 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' }; - -static void DecToHex(int dec, char *buf) -{ - int firstDigit = (int)(dec/16.0); - int secondDigit = (int)(dec - (firstDigit*16.0)); - buf[0] = hexArray[firstDigit]; - buf[1] = hexArray[secondDigit]; - buf[2] = 0; -} - // 16-bit unsigned integer static unsigned int getshort(FILE *fp) { @@ -64,7 +52,7 @@ static int getsignedshort(FILE *fp) int testRes = ((unsigned int) c) + (((unsigned int) c1) << 8); #endif unsigned long res1 = ((unsigned int) c) + (((unsigned int) c1) << 8); - int res = 0; + int res; if (res1 > 32767) res = (int)(res1 - 65536); else @@ -79,20 +67,20 @@ static long getint(FILE *fp) c = getc(fp); c1 = getc(fp); c2 = getc(fp); c3 = getc(fp); long res = (long)((long) c) + (((long) c1) << 8) + - (((long) c2) << 16) + - (((long) c3) << 24); + (((long) c2) << 16) + + (((long) c3) << 24); return res; } /* Placeable metafile header struct mfPLACEABLEHEADER { - DWORD key; // 32-bit - HANDLE hmf; // 16-bit - RECT bbox; // 4x16 bit - WORD inch; // 16-bit - DWORD reserved; // 32-bit - WORD checksum; // 16-bit + DWORD key; // 32-bit + HANDLE hmf; // 16-bit + RECT bbox; // 4x16 bit + WORD inch; // 16-bit + DWORD reserved; // 32-bit + WORD checksum; // 16-bit }; */ @@ -104,7 +92,7 @@ wxMetaRecord::~wxMetaRecord(void) wxXMetaFile::wxXMetaFile(const wxChar *file) { - ok = FALSE; + ok = false; top = 0.0; bottom = 0.0; left = 0.0; @@ -123,7 +111,7 @@ wxXMetaFile::wxXMetaFile(const wxChar *file) [3] | -> wxPen The handle table works as follows. - When a GDI object is created whilst reading in the + When a GDI object is created while reading in the metafile, the (e.g.) createpen record is added to the first free entry in the handle table. The createpen record's param1 is a pointer to the actual wxPen, and @@ -171,7 +159,7 @@ bool wxXMetaFile::ReadFile(const wxChar *file) HandleTableSize = 0; FILE *handle = wxFopen(file, wxT("rb")); - if (!handle) return FALSE; + if (!handle) return false; // Read placeable metafile header, if any long key = getint(handle); @@ -208,7 +196,7 @@ bool wxXMetaFile::ReadFile(const wxChar *file) if (mtType != 1 && mtType != 2) { fclose(handle); - return FALSE; + return false; } /* int mtHeaderSize = */ getshort(handle); @@ -217,7 +205,7 @@ bool wxXMetaFile::ReadFile(const wxChar *file) if (mtVersion != 0x0300 && mtVersion != 0x0100) { fclose(handle); - return FALSE; + return false; } /* long mtSize = */ getint(handle); @@ -572,14 +560,14 @@ bool wxXMetaFile::ReadFile(const wxChar *file) /* 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 lfItalic = (char)getc(handle); // 1 byte + char lfUnderline = (char)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 lfPitchAndFamily = (char)getc(handle); // 1 byte (18th) char lfFacename[32]; // Read the rest of the record, which is total record size // minus the number of bytes already read (18 record, 6 metarecord @@ -665,18 +653,26 @@ bool wxXMetaFile::ReadFile(const wxChar *file) } break; } +#if PS_DOT != BS_HATCHED + /* ABX 30.12.2003 */ + /* in microsoft/include/wingdi.h both are the same */ + /* in fact I'm not sure why pen related PS_XXX and */ + /* BS_XXX constants are all mixed into single style */ + case PS_DOT: + style = wxDOT; + break; +#endif + case PS_DASH: + style = wxSHORT_DASH; + break; + case PS_NULL: + style = wxTRANSPARENT; + break; case BS_SOLID: default: style = wxSOLID; break; } - 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, style); @@ -727,30 +723,30 @@ bool wxXMetaFile::ReadFile(const wxChar *file) } } fclose(handle); - return TRUE; + return true; } wxXMetaFile::~wxXMetaFile(void) { - wxNode *node = metaRecords.GetFirst(); + wxObjectList::compatibility_iterator node = metaRecords.GetFirst(); while (node) { wxMetaRecord *rec = (wxMetaRecord *)node->GetData(); delete rec; - wxNode *next = node->GetNext(); - delete node; + wxObjectList::compatibility_iterator next = node->GetNext(); + metaRecords.Erase(node); node = next; } } bool wxXMetaFile::SetClipboard(int WXUNUSED(width), int WXUNUSED(height)) { - return FALSE; + return false; } bool wxXMetaFile::Play(wxDC *dc) { - wxNode *node = metaRecords.GetFirst(); + wxObjectList::compatibility_iterator node = metaRecords.GetFirst(); while (node) { wxMetaRecord *rec = (wxMetaRecord *)node->GetData(); @@ -1086,6 +1082,6 @@ bool wxXMetaFile::Play(wxDC *dc) } node = node->GetNext(); } - return TRUE; + return true; }