// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include <wx/metafile.h>
#include <wx/utils.h>
-#include <wx/ogl/mfutils.h>
+#include "wx/ogl/ogl.h"
+
#include <stdio.h>
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)
{
{
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;
+ int res;
if (res1 > 32767)
res = (int)(res1 - 65536);
else
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
};
*/
if (stringParam) delete[] stringParam;
}
-wxXMetaFile::wxXMetaFile(char *file)
+wxXMetaFile::wxXMetaFile(const wxChar *file)
{
- ok = FALSE;
+ ok = false;
top = 0.0;
bottom = 0.0;
left = 0.0;
return (HandleTableSize - 1);
}
-bool wxXMetaFile::ReadFile(char *file)
+bool wxXMetaFile::ReadFile(const wxChar *file)
{
HandleTableSize = 0;
- FILE *handle = fopen(file, "rb");
- if (!handle) return FALSE;
+ 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);
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;
if (mtType != 1 && mtType != 2)
{
fclose(handle);
- return FALSE;
+ return false;
}
- int mtHeaderSize = getshort(handle);
+ /* int mtHeaderSize = */ getshort(handle);
int mtVersion = getshort(handle);
if (mtVersion != 0x0300 && mtVersion != 0x0100)
{
fclose(handle);
- return FALSE;
+ 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))
{
{
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
metaRecords.Append(rec);
gdiObjects.Append(rec);
AddMetaRecordHandle(rec);
- rec->param2 = (long)(gdiObjects.Number() - 1);
+ rec->param2 = (long)(gdiObjects.GetCount() - 1);
break;
}
// case META_STRETCHDIB:
metaRecords.Append(rec);
gdiObjects.Append(rec);
AddMetaRecordHandle(rec);
- rec->param2 = (long)(gdiObjects.Number() - 1);
+ rec->param2 = (long)(gdiObjects.GetCount() - 1);
break;
}
case META_CREATEBRUSH:
metaRecords.Append(rec);
gdiObjects.Append(rec);
AddMetaRecordHandle(rec);
- rec->param2 = (long)(gdiObjects.Number() - 1);
+ rec->param2 = (long)(gdiObjects.GetCount() - 1);
break;
}
case META_CREATEPATTERNBRUSH:
metaRecords.Append(rec);
gdiObjects.Append(rec);
AddMetaRecordHandle(rec);
- rec->param2 = (long)(gdiObjects.Number() - 1);
+ rec->param2 = (long)(gdiObjects.GetCount() - 1);
break;
}
case META_CREATEPENINDIRECT:
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;
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.
{
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
metaRecords.Append(rec);
gdiObjects.Append(rec);
AddMetaRecordHandle(rec);
- rec->param2 = (long)(gdiObjects.Number() - 1);
+ rec->param2 = (long)(gdiObjects.GetCount() - 1);
break;
}
case META_CREATEBRUSHINDIRECT:
}
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);
metaRecords.Append(rec);
gdiObjects.Append(rec);
AddMetaRecordHandle(rec);
- rec->param2 = (long)(gdiObjects.Number() - 1);
+ rec->param2 = (long)(gdiObjects.GetCount() - 1);
break;
}
case META_CREATEBITMAPINDIRECT:
metaRecords.Append(rec);
gdiObjects.Append(rec);
AddMetaRecordHandle(rec);
- rec->param2 = (long)(gdiObjects.Number() - 1);
+ rec->param2 = (long)(gdiObjects.GetCount() - 1);
break;
}
case META_CREATEBITMAP:
metaRecords.Append(rec);
gdiObjects.Append(rec);
AddMetaRecordHandle(rec);
- rec->param2 = (long)(gdiObjects.Number() - 1);
+ rec->param2 = (long)(gdiObjects.GetCount() - 1);
break;
}
case META_CREATEREGION:
metaRecords.Append(rec);
gdiObjects.Append(rec);
AddMetaRecordHandle(rec);
- rec->param2 = (long)(gdiObjects.Number() - 1);
+ rec->param2 = (long)(gdiObjects.GetCount() - 1);
break;
}
default:
}
}
fclose(handle);
- return TRUE;
+ return true;
}
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;
+ 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)
break;
}
}
- node = node->Next();
+ node = node->GetNext();
}
- return TRUE;
+ return true;
}