X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c1fa2fda3c72886f62def1e650a7306c82e72f2f..ec75509f94fb11322c1c69056d1ec2af8f041fe2:/contrib/src/ogl/drawn.cpp diff --git a/contrib/src/ogl/drawn.cpp b/contrib/src/ogl/drawn.cpp index 24db4482d9..43588058d5 100644 --- a/contrib/src/ogl/drawn.cpp +++ b/contrib/src/ogl/drawn.cpp @@ -6,7 +6,7 @@ // Created: 12/07/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -25,19 +25,18 @@ #include #endif -#include +#if wxUSE_PROLOGIO +#include +#endif + +#include "wx/ogl/ogl.h" -#include -#include -#include -#include -#include -#include -#include +#if wxUSE_PROLOGIO +static void IntToHex(unsigned int dec, wxChar *buf); +static unsigned long HexToInt(wxChar *buf); +#endif -static void IntToHex(unsigned int dec, char *buf); -static unsigned long HexToInt(char *buf); -extern char *oglBuffer; +extern wxChar *oglBuffer; #define gyTYPE_PEN 40 #define gyTYPE_BRUSH 41 @@ -52,7 +51,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxDrawnShape, wxRectangleShape) wxDrawnShape::wxDrawnShape():wxRectangleShape(100.0, 50.0) { - m_saveToFile = TRUE; + m_saveToFile = true; m_currentAngle = oglDRAWN_ANGLE_0; } @@ -77,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); @@ -90,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); @@ -146,15 +144,15 @@ void wxDrawnShape::Rotate(double x, double y, double theta) // Rotate attachment points double sinTheta = (double)sin(actualTheta); double cosTheta = (double)cos(actualTheta); - wxNode *node = m_attachmentPoints.First(); + wxNode *node = m_attachmentPoints.GetFirst(); while (node) { - wxAttachmentPoint *point = (wxAttachmentPoint *)node->Data(); + wxAttachmentPoint *point = (wxAttachmentPoint *)node->GetData(); double x1 = point->m_x; double y1 = point->m_y; point->m_x = x1*cosTheta - y1*sinTheta + x*(1.0 - cosTheta) + y*sinTheta; point->m_y = x1*sinTheta + y1*cosTheta + y*(1.0 - cosTheta) + x*sinTheta; - node = node->Next(); + node = node->GetNext(); } m_rotation = theta; @@ -167,7 +165,7 @@ void wxDrawnShape::Rotate(double x, double y, double theta) int wxDrawnShape::DetermineMetaFile(double rotation) { double tolerance = 0.0001; - const double pi = 3.1415926535897932384626433832795 ; + const double pi = M_PI ; double angle1 = 0.0; double angle2 = pi/2.0; double angle3 = pi; @@ -202,9 +200,9 @@ void wxDrawnShape::OnDrawOutline(wxDC& dc, double x, double y, double w, double { if (m_metafiles[m_currentAngle].GetOutlineOp() != -1) { - wxNode* node = m_metafiles[m_currentAngle].GetOps().Nth(m_metafiles[m_currentAngle].GetOutlineOp()); + wxNode* node = m_metafiles[m_currentAngle].GetOps().Item(m_metafiles[m_currentAngle].GetOutlineOp()); wxASSERT (node != NULL); - wxDrawOp* op = (wxDrawOp*) node->Data(); + wxDrawOp* op = (wxDrawOp*) node->GetData(); if (op->OnDrawOutline(dc, x, y, w, h, m_width, m_height)) return; @@ -222,29 +220,28 @@ bool wxDrawnShape::GetPerimeterPoint(double x1, double y1, { if (m_metafiles[m_currentAngle].GetOutlineOp() != -1) { - wxNode* node = m_metafiles[m_currentAngle].GetOps().Nth(m_metafiles[m_currentAngle].GetOutlineOp()); + wxNode* node = m_metafiles[m_currentAngle].GetOps().Item(m_metafiles[m_currentAngle].GetOutlineOp()); wxASSERT (node != NULL); - wxDrawOp* op = (wxDrawOp*) node->Data(); + wxDrawOp* op = (wxDrawOp*) node->GetData(); if (op->GetPerimeterPoint(x1, y1, x2, y2, x3, y3, GetX(), GetY(), GetAttachmentMode())) - return TRUE; + return true; } // Default... just use a rectangle return wxRectangleShape::GetPerimeterPoint(x1, y1, x2, y2, x3, y3); } -#ifdef PROLOGIO +#if wxUSE_PROLOGIO 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); @@ -257,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); } @@ -281,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]); } @@ -290,7 +285,7 @@ void wxDrawnShape::Copy(wxShape& copy) drawnCopy.m_currentAngle = m_currentAngle; } -bool wxDrawnShape::LoadFromMetaFile(char *filename) +bool wxDrawnShape::LoadFromMetaFile(const wxString& filename) { return m_metafiles[0].LoadFromMetaFile(filename, &m_width, &m_height); } @@ -420,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) { @@ -435,10 +430,10 @@ void wxOpSetGDI::Do(wxDC& dc, double xoffset, double yoffset) } else { - wxNode *node = m_image->m_gdiObjects.Nth(m_gdiIndex); + wxNode *node = m_image->m_gdiObjects.Item(m_gdiIndex); if (node) { - wxPen *pen = (wxPen *)node->Data(); + wxPen *pen = (wxPen *)node->GetData(); if (pen) dc.SetPen(* pen); } @@ -468,10 +463,10 @@ void wxOpSetGDI::Do(wxDC& dc, double xoffset, double yoffset) } else { - wxNode *node = m_image->m_gdiObjects.Nth(m_gdiIndex); + wxNode *node = m_image->m_gdiObjects.Item(m_gdiIndex); if (node) { - wxBrush *brush = (wxBrush *)node->Data(); + wxBrush *brush = (wxBrush *)node->GetData(); if (brush) dc.SetBrush(* brush); } @@ -480,10 +475,10 @@ void wxOpSetGDI::Do(wxDC& dc, double xoffset, double yoffset) } case DRAWOP_SET_FONT: { - wxNode *node = m_image->m_gdiObjects.Nth(m_gdiIndex); + wxNode *node = m_image->m_gdiObjects.Item(m_gdiIndex); if (node) { - wxFont *font = (wxFont *)node->Data(); + wxFont *font = (wxFont *)node->GetData(); if (font) dc.SetFont(* font); } @@ -520,7 +515,8 @@ wxDrawOp *wxOpSetGDI::Copy(wxPseudoMetaFile *newImage) return newOp; } -wxExpr *wxOpSetGDI::WriteExpr(wxPseudoMetaFile *image) +#if wxUSE_PROLOGIO +wxExpr *wxOpSetGDI::WriteExpr(wxPseudoMetaFile *WXUNUSED(image)) { wxExpr *expr = new wxExpr(wxExprList); expr->Append(new wxExpr((long)m_op)); @@ -552,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) { @@ -580,6 +576,7 @@ void wxOpSetGDI::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) break; } } +#endif /* * Set/destroy clipping @@ -595,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; @@ -634,7 +631,8 @@ void wxOpSetClipping::Translate(double x, double y) m_y1 += y; } -wxExpr *wxOpSetClipping::WriteExpr(wxPseudoMetaFile *image) +#if wxUSE_PROLOGIO +wxExpr *wxOpSetClipping::WriteExpr(wxPseudoMetaFile *WXUNUSED(image)) { wxExpr *expr = new wxExpr(wxExprList); expr->Append(new wxExpr((long)m_op)); @@ -654,7 +652,7 @@ 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) { @@ -670,6 +668,7 @@ void wxOpSetClipping::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) break; } } +#endif /* * Draw line, rectangle, rounded rectangle, ellipse, point, arc, text @@ -677,7 +676,7 @@ void wxOpSetClipping::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) */ wxOpDraw::wxOpDraw(int theOp, double theX1, double theY1, double theX2, double theY2, - double theRadius, wxChar *s) : wxDrawOp(theOp) + double theRadius, const wxString& s) : wxDrawOp(theOp) { m_x1 = theX1; m_y1 = theY1; @@ -686,16 +685,14 @@ wxOpDraw::wxOpDraw(int theOp, double theX1, double theY1, double theX2, double t m_x3 = 0.0; m_y3 = 0.0; m_radius = theRadius; - if (s) m_textString = copystring(s); - else m_textString = NULL; + m_textString = s; } 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; @@ -736,7 +733,7 @@ void wxOpDraw::Do(wxDC& dc, double xoffset, double yoffset) } case DRAWOP_DRAW_ELLIPTIC_ARC: { - const double pi = 3.1415926535897932384626433832795 ; + const double pi = M_PI ; // Convert back to degrees dc.DrawEllipticArc( @@ -818,10 +815,10 @@ void wxOpDraw::Rotate(double x, double y, double theta, double sinTheta, double double newX2 = m_x2*cosTheta - m_y2*sinTheta + x*(1.0 - cosTheta) + y*sinTheta; double newY2 = m_x2*sinTheta + m_y2*cosTheta + y*(1.0 - cosTheta) + x*sinTheta; - m_x1 = newX1; - m_y1 = newY1; - m_x2 = newX2; - m_y2 = newY2; + m_x1 = newX1; + m_y1 = newY1; + m_x2 = newX2; + m_y2 = newY2; break; } case DRAWOP_DRAW_RECT: @@ -864,12 +861,12 @@ void wxOpDraw::Rotate(double x, double y, double theta, double sinTheta, double double newX3 = m_x3*cosTheta - m_y3*sinTheta + x*(1.0 - cosTheta) + y*sinTheta; double newY3 = m_x3*sinTheta + m_y3*cosTheta + y*(1.0 - cosTheta) + x*sinTheta; - m_x1 = newX1; - m_y1 = newY1; - m_x2 = newX2; - m_y2 = newY2; - m_x3 = newX3; - m_y3 = newY3; + m_x1 = newX1; + m_y1 = newY1; + m_x2 = newX2; + m_y2 = newY2; + m_x3 = newX3; + m_y3 = newY3; break; } @@ -878,7 +875,8 @@ void wxOpDraw::Rotate(double x, double y, double theta, double sinTheta, double } } -wxExpr *wxOpDraw::WriteExpr(wxPseudoMetaFile *image) +#if wxUSE_PROLOGIO +wxExpr *wxOpDraw::WriteExpr(wxPseudoMetaFile *WXUNUSED(image)) { wxExpr *expr = new wxExpr(wxExprList); expr->Append(new wxExpr((long)m_op)); @@ -935,7 +933,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) { @@ -968,8 +966,7 @@ void wxOpDraw::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) { m_x1 = expr->Nth(1)->RealValue(); m_y1 = expr->Nth(2)->RealValue(); - wxString str(expr->Nth(3)->StringValue()); - m_textString = copystring(str); + m_textString = wxString(expr->Nth(3)->StringValue()); break; } case DRAWOP_DRAW_ARC: @@ -989,6 +986,7 @@ void wxOpDraw::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) } } } +#endif /* * Draw polygon, polyline, spline @@ -1006,7 +1004,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++) @@ -1066,7 +1064,6 @@ void wxOpPolyDraw::Do(wxDC& dc, double xoffset, double yoffset) delete[] actualPoints; break; - break; } default: break; @@ -1091,7 +1088,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++) { @@ -1102,15 +1099,16 @@ void wxOpPolyDraw::Rotate(double x, double y, double theta, double sinTheta, dou } } -wxExpr *wxOpPolyDraw::WriteExpr(wxPseudoMetaFile *image) +#if wxUSE_PROLOGIO +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; @@ -1126,31 +1124,29 @@ wxExpr *wxOpPolyDraw::WriteExpr(wxPseudoMetaFile *image) long signedY = (long)(m_points[i].y*100.0); // Scale to 0 -> 64K - long unSignedX = (long)(signedX + 32767.0); - long unSignedY = (long)(signedY + 32767.0); + unsigned int unSignedX = (unsigned int)(signedX + 32767.0); + unsigned int unSignedY = (unsigned int)(signedY + 32767.0); -// IntToHex((unsigned int)signedX, buf2); -// IntToHex((unsigned int)signedY, buf3); - IntToHex((int)unSignedX, buf2); - IntToHex((int)unSignedY, buf3); + IntToHex(unSignedX, buf2); + IntToHex(unSignedY, buf3); // 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->Nth(1)->IntegerValue(); - char buf1[5]; - char buf2[5]; + wxChar buf1[5]; + wxChar buf2[5]; m_points = new wxRealPoint[m_noPoints]; int i = 0; @@ -1179,7 +1175,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 @@ -1190,6 +1186,7 @@ void wxOpPolyDraw::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) i ++; } } +#endif // Draw an outline using the current operation. bool wxOpPolyDraw::OnDrawOutline(wxDC& dc, double x, double y, double w, double h, double oldW, double oldH) @@ -1210,7 +1207,7 @@ bool wxOpPolyDraw::OnDrawOutline(wxDC& dc, double x, double y, double w, double } dc.DrawPolygon(n, intPoints, (long) x, (long) y); delete[] intPoints; - return TRUE; + return true; } // Assume (x1, y1) is centre of box (most generally, line end at box) @@ -1240,13 +1237,13 @@ bool wxOpPolyDraw::GetPerimeterPoint(double x1, double y1, { *x3 = point->x + xOffset; *y3 = point->y + yOffset; - return TRUE; + return true; } else if ((y2 < y1) && (point->y < 0.0)) { *x3 = point->x + xOffset; *y3 = point->y + yOffset; - return TRUE; + return true; } } } @@ -1255,8 +1252,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; @@ -1269,7 +1265,7 @@ bool wxOpPolyDraw::GetPerimeterPoint(double x1, double y1, delete[] xpoints; delete[] ypoints; - return TRUE; + return true; } @@ -1278,11 +1274,14 @@ 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' }; +#if wxUSE_PROLOGIO + +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); @@ -1297,50 +1296,49 @@ 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; - default: - return 0; } + 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) ; @@ -1350,6 +1348,8 @@ static unsigned long HexToInt(char *buf) return n; } +#endif // wxUSE_PROLOGIO + /* * wxPseudo meta-file * @@ -1360,7 +1360,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxPseudoMetaFile, wxObject) wxPseudoMetaFile::wxPseudoMetaFile() { m_currentRotation = 0; - m_rotateable = TRUE; + m_rotateable = true; m_width = 0.0; m_height = 0.0; m_outlinePen = NULL; @@ -1368,7 +1368,7 @@ wxPseudoMetaFile::wxPseudoMetaFile() m_outlineOp = -1; } -wxPseudoMetaFile::wxPseudoMetaFile(wxPseudoMetaFile& mf) +wxPseudoMetaFile::wxPseudoMetaFile(wxPseudoMetaFile& mf):wxObject() { mf.Copy(*this); } @@ -1380,12 +1380,12 @@ wxPseudoMetaFile::~wxPseudoMetaFile() void wxPseudoMetaFile::Clear() { - wxNode *node = m_ops.First(); + wxNode *node = m_ops.GetFirst(); while (node) { - wxDrawOp *op = (wxDrawOp *)node->Data(); + wxDrawOp *op = (wxDrawOp *)node->GetData(); delete op; - node = node->Next(); + node = node->GetNext(); } m_ops.Clear(); m_gdiObjects.Clear(); @@ -1396,23 +1396,23 @@ void wxPseudoMetaFile::Clear() void wxPseudoMetaFile::Draw(wxDC& dc, double xoffset, double yoffset) { - wxNode *node = m_ops.First(); + wxNode *node = m_ops.GetFirst(); while (node) { - wxDrawOp *op = (wxDrawOp *)node->Data(); + wxDrawOp *op = (wxDrawOp *)node->GetData(); op->Do(dc, xoffset, yoffset); - node = node->Next(); + node = node->GetNext(); } } void wxPseudoMetaFile::Scale(double sx, double sy) { - wxNode *node = m_ops.First(); + wxNode *node = m_ops.GetFirst(); while (node) { - wxDrawOp *op = (wxDrawOp *)node->Data(); + wxDrawOp *op = (wxDrawOp *)node->GetData(); op->Scale(sx, sy); - node = node->Next(); + node = node->GetNext(); } m_width *= sx; m_height *= sy; @@ -1420,12 +1420,12 @@ void wxPseudoMetaFile::Scale(double sx, double sy) void wxPseudoMetaFile::Translate(double x, double y) { - wxNode *node = m_ops.First(); + wxNode *node = m_ops.GetFirst(); while (node) { - wxDrawOp *op = (wxDrawOp *)node->Data(); + wxDrawOp *op = (wxDrawOp *)node->GetData(); op->Translate(x, y); - node = node->Next(); + node = node->GetNext(); } } @@ -1436,17 +1436,17 @@ void wxPseudoMetaFile::Rotate(double x, double y, double theta) double cosTheta = (double)cos(theta1); double sinTheta = (double)sin(theta1); - wxNode *node = m_ops.First(); + wxNode *node = m_ops.GetFirst(); while (node) { - wxDrawOp *op = (wxDrawOp *)node->Data(); + wxDrawOp *op = (wxDrawOp *)node->GetData(); op->Rotate(x, y, theta, sinTheta, cosTheta); - node = node->Next(); + node = node->GetNext(); } m_currentRotation = theta; } -#ifdef PROLOGIO +#if wxUSE_PROLOGIO void wxPseudoMetaFile::WriteAttributes(wxExpr *clause, int whichAngle) { wxString widthStr; @@ -1468,13 +1468,13 @@ 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.First(); + wxNode *node = m_gdiObjects.GetFirst(); while (node) { - sprintf(buf, "gdi%d_%d", whichAngle, i); - wxObject *obj = (wxObject *)node->Data(); + wxSprintf(buf, _T("gdi%d_%d"), whichAngle, i); + wxObject *obj = (wxObject *)node->GetData(); wxExpr *expr = NULL; if (obj) { @@ -1523,48 +1523,48 @@ void wxPseudoMetaFile::WriteAttributes(wxExpr *clause, int whichAngle) clause->AddAttributeValue(buf, expr); i ++; } - node = node->Next(); + node = node->GetNext(); } // Write drawing operations i = 1; - node = m_ops.First(); + node = m_ops.GetFirst(); while (node) { - sprintf(buf, "op%d_%d", whichAngle, i); - wxDrawOp *op = (wxDrawOp *)node->Data(); + wxSprintf(buf, _T("op%d_%d"), whichAngle, i); + wxDrawOp *op = (wxDrawOp *)node->GetData(); wxExpr *expr = op->WriteExpr(this); if (expr) { clause->AddAttributeValue(buf, expr); i ++; } - node = node->Next(); + node = node->GetNext(); } // Write outline and fill GDI op lists (if any) - if (m_outlineColours.Number() > 0) + if (m_outlineColours.GetCount() > 0) { wxExpr *outlineExpr = new wxExpr(wxExprList); - node = m_outlineColours.First(); + node = m_outlineColours.GetFirst(); while (node) { - outlineExpr->Append(new wxExpr((long)node->Data())); - node = node->Next(); + outlineExpr->Append(new wxExpr((long)node->GetData())); + node = node->GetNext(); } wxString outlineObjectsStr; outlineObjectsStr.Printf(wxT("outline_objects%d"), whichAngle); clause->AddAttributeValue(outlineObjectsStr, outlineExpr); } - if (m_fillColours.Number() > 0) + if (m_fillColours.GetCount() > 0) { wxExpr *fillExpr = new wxExpr(wxExprList); - node = m_fillColours.First(); + node = m_fillColours.GetFirst(); while (node) { - fillExpr->Append(new wxExpr((long)node->Data())); - node = node->Next(); + fillExpr->Append(new wxExpr((long)node->GetData())); + node = node->GetNext(); } wxString fillObjectsStr; fillObjectsStr.Printf(wxT("fill_objects%d"), whichAngle); @@ -1597,17 +1597,17 @@ 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; + 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) { - keepGoing = FALSE; + keepGoing = false; } else { @@ -1618,9 +1618,9 @@ void wxPseudoMetaFile::ReadAttributes(wxExpr *clause, int whichAngle) { 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(); + unsigned char penRed = (unsigned char)expr->Nth(3)->IntegerValue(); + unsigned char penGreen = (unsigned char)expr->Nth(4)->IntegerValue(); + unsigned char penBlue = (unsigned char)expr->Nth(5)->IntegerValue(); wxColour col(penRed, penGreen, penBlue); wxPen *p = wxThePenList->FindOrCreatePen(col, penWidth, penStyle); if (!p) @@ -1631,9 +1631,9 @@ void wxPseudoMetaFile::ReadAttributes(wxExpr *clause, int whichAngle) case gyTYPE_BRUSH: { 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(); + unsigned char brushRed = (unsigned char)expr->Nth(2)->IntegerValue(); + unsigned char brushGreen = (unsigned char)expr->Nth(3)->IntegerValue(); + unsigned char brushBlue = (unsigned char)expr->Nth(4)->IntegerValue(); wxColour col(brushRed, brushGreen, brushBlue); wxBrush *b = wxTheBrushList->FindOrCreateBrush(col, brushStyle); if (!b) @@ -1664,16 +1664,16 @@ void wxPseudoMetaFile::ReadAttributes(wxExpr *clause, int whichAngle) } // Now read in the operations - keepGoing = TRUE; + keepGoing = true; 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) { - keepGoing = FALSE; + keepGoing = false; } else { @@ -1777,35 +1777,35 @@ void wxPseudoMetaFile::Copy(wxPseudoMetaFile& copy) copy.m_outlineOp = m_outlineOp; // Copy the GDI objects - wxNode *node = m_gdiObjects.First(); + wxNode *node = m_gdiObjects.GetFirst(); while (node) { - wxObject *obj = (wxObject *)node->Data(); + wxObject *obj = (wxObject *)node->GetData(); copy.m_gdiObjects.Append(obj); - node = node->Next(); + node = node->GetNext(); } // Copy the operations - node = m_ops.First(); + node = m_ops.GetFirst(); while (node) { - wxDrawOp *op = (wxDrawOp *)node->Data(); + wxDrawOp *op = (wxDrawOp *)node->GetData(); copy.m_ops.Append(op->Copy(©)); - node = node->Next(); + node = node->GetNext(); } // Copy the outline/fill operations - node = m_outlineColours.First(); + node = m_outlineColours.GetFirst(); while (node) { - copy.m_outlineColours.Append((wxObject *)node->Data()); - node = node->Next(); + copy.m_outlineColours.Append((wxObject *)node->GetData()); + node = node->GetNext(); } - node = m_fillColours.First(); + node = m_fillColours.GetFirst(); while (node) { - copy.m_fillColours.Append((wxObject *)node->Data()); - node = node->Next(); + copy.m_fillColours.Append((wxObject *)node->GetData()); + node = node->GetNext(); } } @@ -1815,27 +1815,27 @@ void wxPseudoMetaFile::Copy(wxPseudoMetaFile& copy) * */ -bool wxPseudoMetaFile::LoadFromMetaFile(char *filename, double *rwidth, double *rheight) +bool wxPseudoMetaFile::LoadFromMetaFile(const wxString& filename, double *rwidth, double *rheight) { - if (!FileExists(filename)) - return NULL; + if (!wxFileExists(filename)) + return false; wxXMetaFile *metaFile = new wxXMetaFile; if (!metaFile->ReadFile(filename)) { delete metaFile; - return FALSE; + return false; } double lastX = 0.0; double lastY = 0.0; // Convert from metafile records to wxDrawnShape records - wxNode *node = metaFile->metaRecords.First(); + wxNode *node = metaFile->metaRecords.GetFirst(); while (node) { - wxMetaRecord *record = (wxMetaRecord *)node->Data(); + wxMetaRecord *record = (wxMetaRecord *)node->GetData(); switch (record->metaFunction) { case META_SETBKCOLOR: @@ -2007,10 +2007,10 @@ bool wxPseudoMetaFile::LoadFromMetaFile(char *filename, double *rwidth, double * { // The pen, brush etc. has already been created when the metafile // was read in, so we don't create it - we set it. - wxNode *recNode = metaFile->gdiObjects.Nth((int)record->param2); + wxNode *recNode = metaFile->gdiObjects.Item((int)record->param2); if (recNode) { - wxMetaRecord *gdiRec = (wxMetaRecord *)recNode->Data(); + wxMetaRecord *gdiRec = (wxMetaRecord *)recNode->GetData(); if (gdiRec && (gdiRec->param1 != 0)) { wxObject *obj = (wxObject *)gdiRec->param1; @@ -2125,7 +2125,7 @@ bool wxPseudoMetaFile::LoadFromMetaFile(char *filename, double *rwidth, double * break; } } - node = node->Next(); + node = node->GetNext(); } double actualWidth = (double)fabs(metaFile->right - metaFile->left); double actualHeight = (double)fabs(metaFile->bottom - metaFile->top); @@ -2162,7 +2162,7 @@ bool wxPseudoMetaFile::LoadFromMetaFile(char *filename, double *rwidth, double * m_height = *rheight; delete metaFile; - return TRUE; + return true; } // Scale to fit size @@ -2182,16 +2182,17 @@ void wxPseudoMetaFile::GetBounds(double *boundMinX, double *boundMinY, double *b double minX = (double) 99999.9; double minY = (double) 99999.9; - wxNode *node = m_ops.First(); + wxNode *node = m_ops.GetFirst(); while (node) { - wxDrawOp *op = (wxDrawOp *)node->Data(); + wxDrawOp *op = (wxDrawOp *)node->GetData(); switch (op->GetOp()) { case DRAWOP_DRAW_LINE: case DRAWOP_DRAW_RECT: case DRAWOP_DRAW_ROUNDED_RECT: case DRAWOP_DRAW_ELLIPSE: + case DRAWOP_DRAW_ELLIPTIC_ARC: case DRAWOP_DRAW_POINT: case DRAWOP_DRAW_TEXT: { @@ -2209,7 +2210,8 @@ void wxPseudoMetaFile::GetBounds(double *boundMinX, double *boundMinY, double *b } else if (op->GetOp() == DRAWOP_DRAW_RECT || op->GetOp() == DRAWOP_DRAW_ROUNDED_RECT || - op->GetOp() == DRAWOP_DRAW_ELLIPSE) + op->GetOp() == DRAWOP_DRAW_ELLIPSE || + op->GetOp() == DRAWOP_DRAW_ELLIPTIC_ARC) { if ((opDraw->m_x1 + opDraw->m_x2) < minX) minX = (opDraw->m_x1 + opDraw->m_x2); if ((opDraw->m_x1 + opDraw->m_x2) > maxX) maxX = (opDraw->m_x1 + opDraw->m_x2); @@ -2252,7 +2254,7 @@ void wxPseudoMetaFile::GetBounds(double *boundMinX, double *boundMinY, double *b default: break; } - node = node->Next(); + node = node->GetNext(); } *boundMinX = minX; @@ -2332,7 +2334,7 @@ void wxPseudoMetaFile::DrawArc(const wxPoint& centrePt, const wxPoint& startPt, void wxPseudoMetaFile::DrawEllipticArc(const wxRect& rect, double startAngle, double endAngle) { - const double pi = 3.1415926535897932384626433832795 ; + const double pi = M_PI ; double startAngleRadians = startAngle* (pi*2.0/360.0); double endAngleRadians = endAngle* (pi*2.0/360.0); @@ -2359,7 +2361,7 @@ void wxPseudoMetaFile::DrawText(const wxString& text, const wxPoint& pt) wxOpDraw *theOp = new wxOpDraw(DRAWOP_DRAW_TEXT, (double) pt.x, (double) pt.y, 0.0, 0.0); - theOp->m_textString = copystring(text); + theOp->m_textString = text; m_ops.Append(theOp); } @@ -2390,7 +2392,7 @@ void wxPseudoMetaFile::DrawPolygon(int n, wxPoint pts[], int flags) m_ops.Append(theOp); if (flags & oglMETAFLAGS_OUTLINE) - m_outlineOp = (m_ops.Number() - 1); + m_outlineOp = (m_ops.GetCount() - 1); } void wxPseudoMetaFile::DrawSpline(int n, wxPoint pts[]) @@ -2408,7 +2410,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); } @@ -2423,7 +2425,7 @@ void wxPseudoMetaFile::DestroyClippingRect() void wxPseudoMetaFile::SetPen(wxPen* pen, bool isOutline) { m_gdiObjects.Append(pen); - int n = m_gdiObjects.Number(); + int n = m_gdiObjects.GetCount(); wxOpSetGDI* theOp = new wxOpSetGDI(DRAWOP_SET_PEN, this, n - 1); @@ -2438,7 +2440,7 @@ void wxPseudoMetaFile::SetPen(wxPen* pen, bool isOutline) void wxPseudoMetaFile::SetBrush(wxBrush* brush, bool isFill) { m_gdiObjects.Append(brush); - int n = m_gdiObjects.Number(); + int n = m_gdiObjects.GetCount(); wxOpSetGDI* theOp = new wxOpSetGDI(DRAWOP_SET_BRUSH, this, n - 1); @@ -2453,7 +2455,7 @@ void wxPseudoMetaFile::SetBrush(wxBrush* brush, bool isFill) void wxPseudoMetaFile::SetFont(wxFont* font) { m_gdiObjects.Append(font); - int n = m_gdiObjects.Number(); + int n = m_gdiObjects.GetCount(); wxOpSetGDI* theOp = new wxOpSetGDI(DRAWOP_SET_FONT, this, n - 1);