X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b9ac87bc5cbe46227195e32c44e25831f8206e3c..d1a6e2b7a103d761fbc15e0e9c1c20ab53a849d9:/contrib/src/ogl/drawn.cpp diff --git a/contrib/src/ogl/drawn.cpp b/contrib/src/ogl/drawn.cpp index bb5c79e463..20bea6a216 100644 --- a/contrib/src/ogl/drawn.cpp +++ b/contrib/src/ogl/drawn.cpp @@ -25,21 +25,18 @@ #include #endif -#include +#if wxUSE_PROLOGIO +#include +#endif + +#include "wx/ogl/ogl.h" -#include -#include -#include -#include -#include -#include -#include #include -static void IntToHex(unsigned int dec, char *buf); -static unsigned long HexToInt(char *buf); -extern char *oglBuffer; +static void IntToHex(unsigned int dec, wxChar *buf); +static unsigned long HexToInt(wxChar *buf); +extern wxChar *oglBuffer; #define gyTYPE_PEN 40 #define gyTYPE_BRUSH 41 @@ -79,7 +76,7 @@ void wxDrawnShape::OnDraw(wxDC& dc) m_metafiles[m_currentAngle].Draw(dc, m_xpos, m_ypos); } -void wxDrawnShape::SetSize(double w, double h, bool recursive) +void wxDrawnShape::SetSize(double w, double h, bool WXUNUSED(recursive)) { SetAttachmentSize(w, h); @@ -92,8 +89,7 @@ void wxDrawnShape::SetSize(double w, double h, bool recursive) scaleY = 1.0; else scaleY = h/GetHeight(); - int i = 0; - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { if (m_metafiles[i].IsValid()) m_metafiles[i].Scale(scaleX, scaleY); @@ -241,12 +237,11 @@ void wxDrawnShape::WriteAttributes(wxExpr *clause) { wxRectangleShape::WriteAttributes(clause); - clause->AddAttributeValue("current_angle", (long)m_currentAngle); - clause->AddAttributeValue("save_metafile", (long)m_saveToFile); + clause->AddAttributeValue(_T("current_angle"), (long)m_currentAngle); + clause->AddAttributeValue(_T("save_metafile"), (long)m_saveToFile); if (m_saveToFile) { - int i = 0; - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { if (m_metafiles[i].IsValid()) m_metafiles[i].WriteAttributes(clause, i); @@ -259,14 +254,13 @@ void wxDrawnShape::ReadAttributes(wxExpr *clause) wxRectangleShape::ReadAttributes(clause); int iVal = (int) m_saveToFile; - clause->GetAttributeValue("save_metafile", iVal); - clause->GetAttributeValue("current_angle", m_currentAngle); + clause->GetAttributeValue(_T("save_metafile"), iVal); + clause->GetAttributeValue(_T("current_angle"), m_currentAngle); m_saveToFile = (iVal != 0); if (m_saveToFile) { - int i = 0; - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { m_metafiles[i].ReadAttributes(clause, i); } @@ -283,8 +277,7 @@ void wxDrawnShape::Copy(wxShape& copy) wxDrawnShape& drawnCopy = (wxDrawnShape&) copy; - int i = 0; - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { m_metafiles[i].Copy(drawnCopy.m_metafiles[i]); } @@ -422,7 +415,7 @@ wxOpSetGDI::wxOpSetGDI(int theOp, wxPseudoMetaFile *theImage, int theGdiIndex, i m_mode = theMode; } -void wxOpSetGDI::Do(wxDC& dc, double xoffset, double yoffset) +void wxOpSetGDI::Do(wxDC& dc, double WXUNUSED(xoffset), double WXUNUSED(yoffset)) { switch (m_op) { @@ -523,7 +516,7 @@ wxDrawOp *wxOpSetGDI::Copy(wxPseudoMetaFile *newImage) } #if wxUSE_PROLOGIO -wxExpr *wxOpSetGDI::WriteExpr(wxPseudoMetaFile *image) +wxExpr *wxOpSetGDI::WriteExpr(wxPseudoMetaFile *WXUNUSED(image)) { wxExpr *expr = new wxExpr(wxExprList); expr->Append(new wxExpr((long)m_op)); @@ -555,7 +548,7 @@ wxExpr *wxOpSetGDI::WriteExpr(wxPseudoMetaFile *image) return expr; } -void wxOpSetGDI::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) +void wxOpSetGDI::ReadExpr(wxPseudoMetaFile *WXUNUSED(image), wxExpr *expr) { switch (m_op) { @@ -563,20 +556,20 @@ void wxOpSetGDI::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) case DRAWOP_SET_BRUSH: case DRAWOP_SET_FONT: { - m_gdiIndex = (int)expr->Item(1)->IntegerValue(); + m_gdiIndex = (int)expr->Nth(1)->IntegerValue(); break; } case DRAWOP_SET_TEXT_COLOUR: case DRAWOP_SET_BK_COLOUR: { - m_r = (unsigned char)expr->Item(1)->IntegerValue(); - m_g = (unsigned char)expr->Item(2)->IntegerValue(); - m_b = (unsigned char)expr->Item(3)->IntegerValue(); + m_r = (unsigned char)expr->Nth(1)->IntegerValue(); + m_g = (unsigned char)expr->Nth(2)->IntegerValue(); + m_b = (unsigned char)expr->Nth(3)->IntegerValue(); break; } case DRAWOP_SET_BK_MODE: { - m_mode = (int)expr->Item(1)->IntegerValue(); + m_mode = (int)expr->Nth(1)->IntegerValue(); break; } default: @@ -599,7 +592,7 @@ wxOpSetClipping::wxOpSetClipping(int theOp, double theX1, double theY1, m_y2 = theY2; } -wxDrawOp *wxOpSetClipping::Copy(wxPseudoMetaFile *newImage) +wxDrawOp *wxOpSetClipping::Copy(wxPseudoMetaFile *WXUNUSED(newImage)) { wxOpSetClipping *newOp = new wxOpSetClipping(m_op, m_x1, m_y1, m_x2, m_y2); return newOp; @@ -639,7 +632,7 @@ void wxOpSetClipping::Translate(double x, double y) } #if wxUSE_PROLOGIO -wxExpr *wxOpSetClipping::WriteExpr(wxPseudoMetaFile *image) +wxExpr *wxOpSetClipping::WriteExpr(wxPseudoMetaFile *WXUNUSED(image)) { wxExpr *expr = new wxExpr(wxExprList); expr->Append(new wxExpr((long)m_op)); @@ -659,16 +652,16 @@ wxExpr *wxOpSetClipping::WriteExpr(wxPseudoMetaFile *image) return expr; } -void wxOpSetClipping::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) +void wxOpSetClipping::ReadExpr(wxPseudoMetaFile *WXUNUSED(image), wxExpr *expr) { switch (m_op) { case DRAWOP_SET_CLIPPING_RECT: { - m_x1 = expr->Item(1)->RealValue(); - m_y1 = expr->Item(2)->RealValue(); - m_x2 = expr->Item(3)->RealValue(); - m_y2 = expr->Item(4)->RealValue(); + m_x1 = expr->Nth(1)->RealValue(); + m_y1 = expr->Nth(2)->RealValue(); + m_x2 = expr->Nth(3)->RealValue(); + m_y2 = expr->Nth(4)->RealValue(); break; } default: @@ -701,7 +694,7 @@ wxOpDraw::~wxOpDraw() if (m_textString) delete[] m_textString; } -wxDrawOp *wxOpDraw::Copy(wxPseudoMetaFile *newImage) +wxDrawOp *wxOpDraw::Copy(wxPseudoMetaFile *WXUNUSED(newImage)) { wxOpDraw *newOp = new wxOpDraw(m_op, m_x1, m_y1, m_x2, m_y2, m_radius, m_textString); newOp->m_x3 = m_x3; @@ -885,7 +878,7 @@ void wxOpDraw::Rotate(double x, double y, double theta, double sinTheta, double } #if wxUSE_PROLOGIO -wxExpr *wxOpDraw::WriteExpr(wxPseudoMetaFile *image) +wxExpr *wxOpDraw::WriteExpr(wxPseudoMetaFile *WXUNUSED(image)) { wxExpr *expr = new wxExpr(wxExprList); expr->Append(new wxExpr((long)m_op)); @@ -942,7 +935,7 @@ wxExpr *wxOpDraw::WriteExpr(wxPseudoMetaFile *image) return expr; } -void wxOpDraw::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) +void wxOpDraw::ReadExpr(wxPseudoMetaFile *WXUNUSED(image), wxExpr *expr) { switch (m_op) { @@ -950,44 +943,44 @@ void wxOpDraw::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) case DRAWOP_DRAW_RECT: case DRAWOP_DRAW_ELLIPSE: { - m_x1 = expr->Item(1)->RealValue(); - m_y1 = expr->Item(2)->RealValue(); - m_x2 = expr->Item(3)->RealValue(); - m_y2 = expr->Item(4)->RealValue(); + m_x1 = expr->Nth(1)->RealValue(); + m_y1 = expr->Nth(2)->RealValue(); + m_x2 = expr->Nth(3)->RealValue(); + m_y2 = expr->Nth(4)->RealValue(); break; } case DRAWOP_DRAW_ROUNDED_RECT: { - m_x1 = expr->Item(1)->RealValue(); - m_y1 = expr->Item(2)->RealValue(); - m_x2 = expr->Item(3)->RealValue(); - m_y2 = expr->Item(4)->RealValue(); - m_radius = expr->Item(5)->RealValue(); + m_x1 = expr->Nth(1)->RealValue(); + m_y1 = expr->Nth(2)->RealValue(); + m_x2 = expr->Nth(3)->RealValue(); + m_y2 = expr->Nth(4)->RealValue(); + m_radius = expr->Nth(5)->RealValue(); break; } case DRAWOP_DRAW_POINT: { - m_x1 = expr->Item(1)->RealValue(); - m_y1 = expr->Item(2)->RealValue(); + m_x1 = expr->Nth(1)->RealValue(); + m_y1 = expr->Nth(2)->RealValue(); break; } case DRAWOP_DRAW_TEXT: { - m_x1 = expr->Item(1)->RealValue(); - m_y1 = expr->Item(2)->RealValue(); - wxString str(expr->Item(3)->StringValue()); + m_x1 = expr->Nth(1)->RealValue(); + m_y1 = expr->Nth(2)->RealValue(); + wxString str(expr->Nth(3)->StringValue()); m_textString = copystring(str); break; } case DRAWOP_DRAW_ARC: case DRAWOP_DRAW_ELLIPTIC_ARC: { - m_x1 = expr->Item(1)->RealValue(); - m_y1 = expr->Item(2)->RealValue(); - m_x2 = expr->Item(3)->RealValue(); - m_y2 = expr->Item(4)->RealValue(); - m_x3 = expr->Item(5)->RealValue(); - m_y3 = expr->Item(6)->RealValue(); + m_x1 = expr->Nth(1)->RealValue(); + m_y1 = expr->Nth(2)->RealValue(); + m_x2 = expr->Nth(3)->RealValue(); + m_y2 = expr->Nth(4)->RealValue(); + m_x3 = expr->Nth(5)->RealValue(); + m_y3 = expr->Nth(6)->RealValue(); break; } default: @@ -1014,7 +1007,7 @@ wxOpPolyDraw::~wxOpPolyDraw() delete[] m_points; } -wxDrawOp *wxOpPolyDraw::Copy(wxPseudoMetaFile *newImage) +wxDrawOp *wxOpPolyDraw::Copy(wxPseudoMetaFile *WXUNUSED(newImage)) { wxRealPoint *newPoints = new wxRealPoint[m_noPoints]; for (int i = 0; i < m_noPoints; i++) @@ -1074,7 +1067,6 @@ void wxOpPolyDraw::Do(wxDC& dc, double xoffset, double yoffset) delete[] actualPoints; break; - break; } default: break; @@ -1099,7 +1091,7 @@ void wxOpPolyDraw::Translate(double x, double y) } } -void wxOpPolyDraw::Rotate(double x, double y, double theta, double sinTheta, double cosTheta) +void wxOpPolyDraw::Rotate(double x, double y, double WXUNUSED(theta), double sinTheta, double cosTheta) { for (int i = 0; i < m_noPoints; i++) { @@ -1111,15 +1103,15 @@ void wxOpPolyDraw::Rotate(double x, double y, double theta, double sinTheta, dou } #if wxUSE_PROLOGIO -wxExpr *wxOpPolyDraw::WriteExpr(wxPseudoMetaFile *image) +wxExpr *wxOpPolyDraw::WriteExpr(wxPseudoMetaFile *WXUNUSED(image)) { wxExpr *expr = new wxExpr(wxExprList); expr->Append(new wxExpr((long)m_op)); expr->Append(new wxExpr((long)m_noPoints)); // char buf1[9]; - char buf2[5]; - char buf3[5]; + wxChar buf2[5]; + wxChar buf3[5]; oglBuffer[0] = 0; @@ -1146,25 +1138,25 @@ wxExpr *wxOpPolyDraw::WriteExpr(wxPseudoMetaFile *image) // Don't overrun the buffer if ((i*8) < 3000) { - strcat(oglBuffer, buf2); - strcat(oglBuffer, buf3); + wxStrcat(oglBuffer, buf2); + wxStrcat(oglBuffer, buf3); } } expr->Append(new wxExpr(wxExprString, oglBuffer)); return expr; } -void wxOpPolyDraw::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) +void wxOpPolyDraw::ReadExpr(wxPseudoMetaFile *WXUNUSED(image), wxExpr *expr) { - m_noPoints = (int)expr->Item(1)->IntegerValue(); + m_noPoints = (int)expr->Nth(1)->IntegerValue(); - char buf1[5]; - char buf2[5]; + wxChar buf1[5]; + wxChar buf2[5]; m_points = new wxRealPoint[m_noPoints]; int i = 0; int bufPtr = 0; - wxString hexString = expr->Item(2)->StringValue(); + wxString hexString = expr->Nth(2)->StringValue(); while (i < m_noPoints) { buf1[0] = hexString[(size_t)bufPtr]; @@ -1188,7 +1180,7 @@ void wxOpPolyDraw::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) // Scale -32K -> +32K long signedX = unSignedX - 32767; long signedY = unSignedY - 32767; -#ifdef __WXMSW__ +#if defined(__WXMSW__) && 0 int testX = (signed int)unSignedX; int testY = (signed int)unSignedY; #endif @@ -1265,8 +1257,7 @@ bool wxOpPolyDraw::GetPerimeterPoint(double x1, double y1, double *xpoints = new double[n]; double *ypoints = new double[n]; - int i = 0; - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) { wxRealPoint *point = & (m_points[i]); xpoints[i] = point->x + xOffset; @@ -1288,11 +1279,12 @@ bool wxOpPolyDraw::GetPerimeterPoint(double x1, double y1, * */ -static char hexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', - 'C', 'D', 'E', 'F' }; +static char hexArray[] = { + _T('0'), _T('1'), _T('2'), _T('3'), _T('4'), _T('5'), _T('6'), _T('7'), + _T('8'), _T('9'), _T('A'), _T('B'), _T('C'), _T('D'), _T('E'), _T('F') }; // Convert unsigned 16-bit integer to 4-character hex string -static void IntToHex(unsigned int dec, char *buf) +static void IntToHex(unsigned int dec, wxChar *buf) { int digit1 = (int)(dec/4096); int digit2 = (int)((dec - (digit1*4096))/256); @@ -1307,50 +1299,54 @@ static void IntToHex(unsigned int dec, char *buf) } // One hex digit to decimal number -static int HexToInt1(char hex) +static int HexToInt1(wxChar hex) { switch (hex) { - case '0': + case _T('0'): return 0; - case '1': + case _T('1'): return 1; - case '2': + case _T('2'): return 2; - case '3': + case _T('3'): return 3; - case '4': + case _T('4'): return 4; - case '5': + case _T('5'): return 5; - case '6': + case _T('6'): return 6; - case '7': + case _T('7'): return 7; - case '8': + case _T('8'): return 8; - case '9': + case _T('9'): return 9; - case 'A': + case _T('A'): return 10; - case 'B': + case _T('B'): return 11; - case 'C': + case _T('C'): return 12; - case 'D': + case _T('D'): return 13; - case 'E': + case _T('E'): return 14; - case 'F': + case _T('F'): return 15; + #if 0 + // handling this default outside switch removes warning under Borland default: return 0; + #endif } + return 0; } // 4-digit hex string to unsigned integer -static unsigned long HexToInt(char *buf) +static unsigned long HexToInt(wxChar *buf) { long d1 = (long)(HexToInt1(buf[0])*4096.0) ; long d2 = (long)(HexToInt1(buf[1])*256.0) ; @@ -1478,12 +1474,12 @@ void wxPseudoMetaFile::WriteAttributes(wxExpr *clause, int whichAngle) clause->AddAttributeValue(outlineStr, (long)m_outlineOp); // Write GDI objects - char buf[50]; + wxChar buf[50]; int i = 1; wxNode *node = m_gdiObjects.GetFirst(); while (node) { - sprintf(buf, "gdi%d_%d", whichAngle, i); + wxSprintf(buf, _T("gdi%d_%d"), whichAngle, i); wxObject *obj = (wxObject *)node->GetData(); wxExpr *expr = NULL; if (obj) @@ -1541,7 +1537,7 @@ void wxPseudoMetaFile::WriteAttributes(wxExpr *clause, int whichAngle) node = m_ops.GetFirst(); while (node) { - sprintf(buf, "op%d_%d", whichAngle, i); + wxSprintf(buf, _T("op%d_%d"), whichAngle, i); wxDrawOp *op = (wxDrawOp *)node->GetData(); wxExpr *expr = op->WriteExpr(this); if (expr) @@ -1607,12 +1603,12 @@ void wxPseudoMetaFile::ReadAttributes(wxExpr *clause, int whichAngle) m_rotateable = (iVal != 0); // Read GDI objects - char buf[50]; + wxChar buf[50]; int i = 1; bool keepGoing = TRUE; while (keepGoing) { - sprintf(buf, "gdi%d_%d", whichAngle, i); + wxSprintf(buf, _T("gdi%d_%d"), whichAngle, i); wxExpr *expr = NULL; clause->GetAttributeValue(buf, &expr); if (!expr) @@ -1621,16 +1617,16 @@ void wxPseudoMetaFile::ReadAttributes(wxExpr *clause, int whichAngle) } else { - wxExpr *idExpr = expr->Item(0); + wxExpr *idExpr = expr->Nth(0); switch (idExpr->IntegerValue()) { case gyTYPE_PEN: { - int penWidth = (int)expr->Item(1)->IntegerValue(); - int penStyle = (int)expr->Item(2)->IntegerValue(); - int penRed = (int)expr->Item(3)->IntegerValue(); - int penGreen = (int)expr->Item(4)->IntegerValue(); - int penBlue = (int)expr->Item(5)->IntegerValue(); + int penWidth = (int)expr->Nth(1)->IntegerValue(); + int penStyle = (int)expr->Nth(2)->IntegerValue(); + int penRed = (int)expr->Nth(3)->IntegerValue(); + int penGreen = (int)expr->Nth(4)->IntegerValue(); + int penBlue = (int)expr->Nth(5)->IntegerValue(); wxColour col(penRed, penGreen, penBlue); wxPen *p = wxThePenList->FindOrCreatePen(col, penWidth, penStyle); if (!p) @@ -1640,10 +1636,10 @@ void wxPseudoMetaFile::ReadAttributes(wxExpr *clause, int whichAngle) } case gyTYPE_BRUSH: { - int brushStyle = (int)expr->Item(1)->IntegerValue(); - int brushRed = (int)expr->Item(2)->IntegerValue(); - int brushGreen = (int)expr->Item(3)->IntegerValue(); - int brushBlue = (int)expr->Item(4)->IntegerValue(); + int brushStyle = (int)expr->Nth(1)->IntegerValue(); + int brushRed = (int)expr->Nth(2)->IntegerValue(); + int brushGreen = (int)expr->Nth(3)->IntegerValue(); + int brushBlue = (int)expr->Nth(4)->IntegerValue(); wxColour col(brushRed, brushGreen, brushBlue); wxBrush *b = wxTheBrushList->FindOrCreateBrush(col, brushStyle); if (!b) @@ -1653,11 +1649,11 @@ void wxPseudoMetaFile::ReadAttributes(wxExpr *clause, int whichAngle) } case gyTYPE_FONT: { - int fontPointSize = (int)expr->Item(1)->IntegerValue(); - int fontFamily = (int)expr->Item(2)->IntegerValue(); - int fontStyle = (int)expr->Item(3)->IntegerValue(); - int fontWeight = (int)expr->Item(4)->IntegerValue(); - int fontUnderlined = (int)expr->Item(5)->IntegerValue(); + int fontPointSize = (int)expr->Nth(1)->IntegerValue(); + int fontFamily = (int)expr->Nth(2)->IntegerValue(); + int fontStyle = (int)expr->Nth(3)->IntegerValue(); + int fontWeight = (int)expr->Nth(4)->IntegerValue(); + int fontUnderlined = (int)expr->Nth(5)->IntegerValue(); m_gdiObjects.Append(wxTheFontList->FindOrCreateFont(fontPointSize, fontFamily, fontStyle, fontWeight, (fontUnderlined != 0))); break; @@ -1678,7 +1674,7 @@ void wxPseudoMetaFile::ReadAttributes(wxExpr *clause, int whichAngle) i = 1; while (keepGoing) { - sprintf(buf, "op%d_%d", whichAngle, i); + wxSprintf(buf, _T("op%d_%d"), whichAngle, i); wxExpr *expr = NULL; clause->GetAttributeValue(buf, &expr); if (!expr) @@ -1687,7 +1683,7 @@ void wxPseudoMetaFile::ReadAttributes(wxExpr *clause, int whichAngle) } else { - wxExpr *idExpr = expr->Item(0); + wxExpr *idExpr = expr->Nth(0); int opId = (int)idExpr->IntegerValue(); switch (opId) { @@ -2418,7 +2414,7 @@ void wxPseudoMetaFile::DrawSpline(int n, wxPoint pts[]) void wxPseudoMetaFile::SetClippingRect(const wxRect& rect) { - wxOpSetClipping* theOp = new wxOpSetClipping(DRAWOP_SET_CLIPPING_RECT, + /* wxOpSetClipping* theOp = */ new wxOpSetClipping(DRAWOP_SET_CLIPPING_RECT, (double) rect.x, (double) rect.y, (double) rect.width, (double) rect.height); }