X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/17401ab1cd48e293a9f9d8a41cb8851abb2f5f1f..ec75509f94fb11322c1c69056d1ec2af8f041fe2:/contrib/src/ogl/drawn.cpp?ds=sidebyside diff --git a/contrib/src/ogl/drawn.cpp b/contrib/src/ogl/drawn.cpp index 3733cdacd0..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__ @@ -31,11 +31,11 @@ #include "wx/ogl/ogl.h" - -#include - +#if wxUSE_PROLOGIO static void IntToHex(unsigned int dec, wxChar *buf); static unsigned long HexToInt(wxChar *buf); +#endif + extern wxChar *oglBuffer; #define gyTYPE_PEN 40 @@ -51,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; } @@ -165,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; @@ -225,7 +225,7 @@ bool wxDrawnShape::GetPerimeterPoint(double x1, double y1, 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 @@ -733,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( @@ -815,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: @@ -861,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; } @@ -1124,13 +1124,11 @@ wxExpr *wxOpPolyDraw::WriteExpr(wxPseudoMetaFile *WXUNUSED(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) @@ -1209,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) @@ -1239,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; } } } @@ -1267,7 +1265,7 @@ bool wxOpPolyDraw::GetPerimeterPoint(double x1, double y1, delete[] xpoints; delete[] ypoints; - return TRUE; + return true; } @@ -1276,8 +1274,10 @@ bool wxOpPolyDraw::GetPerimeterPoint(double x1, double y1, * */ -static char hexArray[] = { - _T('0'), _T('1'), _T('2'), _T('3'), _T('4'), _T('5'), _T('6'), _T('7'), +#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 @@ -1332,11 +1332,6 @@ static int HexToInt1(wxChar hex) return 14; case _T('F'): return 15; - #if 0 - // handling this default outside switch removes warning under Borland - default: - return 0; - #endif } return 0; @@ -1353,6 +1348,8 @@ static unsigned long HexToInt(wxChar *buf) return n; } +#endif // wxUSE_PROLOGIO + /* * wxPseudo meta-file * @@ -1363,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; @@ -1371,7 +1368,7 @@ wxPseudoMetaFile::wxPseudoMetaFile() m_outlineOp = -1; } -wxPseudoMetaFile::wxPseudoMetaFile(wxPseudoMetaFile& mf) +wxPseudoMetaFile::wxPseudoMetaFile(wxPseudoMetaFile& mf):wxObject() { mf.Copy(*this); } @@ -1602,7 +1599,7 @@ void wxPseudoMetaFile::ReadAttributes(wxExpr *clause, int whichAngle) // Read GDI objects wxChar buf[50]; int i = 1; - bool keepGoing = TRUE; + bool keepGoing = true; while (keepGoing) { wxSprintf(buf, _T("gdi%d_%d"), whichAngle, i); @@ -1610,7 +1607,7 @@ void wxPseudoMetaFile::ReadAttributes(wxExpr *clause, int whichAngle) clause->GetAttributeValue(buf, &expr); if (!expr) { - keepGoing = FALSE; + keepGoing = false; } else { @@ -1621,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) @@ -1634,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) @@ -1667,7 +1664,7 @@ void wxPseudoMetaFile::ReadAttributes(wxExpr *clause, int whichAngle) } // Now read in the operations - keepGoing = TRUE; + keepGoing = true; i = 1; while (keepGoing) { @@ -1676,7 +1673,7 @@ void wxPseudoMetaFile::ReadAttributes(wxExpr *clause, int whichAngle) clause->GetAttributeValue(buf, &expr); if (!expr) { - keepGoing = FALSE; + keepGoing = false; } else { @@ -1821,14 +1818,14 @@ void wxPseudoMetaFile::Copy(wxPseudoMetaFile& copy) bool wxPseudoMetaFile::LoadFromMetaFile(const wxString& filename, double *rwidth, double *rheight) { if (!wxFileExists(filename)) - return FALSE; + return false; wxXMetaFile *metaFile = new wxXMetaFile; if (!metaFile->ReadFile(filename)) { delete metaFile; - return FALSE; + return false; } double lastX = 0.0; @@ -2165,7 +2162,7 @@ bool wxPseudoMetaFile::LoadFromMetaFile(const wxString& filename, double *rwidth m_height = *rheight; delete metaFile; - return TRUE; + return true; } // Scale to fit size @@ -2195,6 +2192,7 @@ void wxPseudoMetaFile::GetBounds(double *boundMinX, double *boundMinY, double *b 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: { @@ -2212,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); @@ -2335,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);