// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include <wx/wx.h>
#endif
-#if wxUSE_DEPRECATED
+#if wxUSE_PROLOGIO
#include <wx/deprecated/wxexpr.h>
#endif
-#include <wx/ogl/basic.h>
-#include <wx/ogl/basicp.h>
-#include <wx/ogl/canvas.h>
-#include <wx/ogl/mfutils.h>
-#include <wx/ogl/drawn.h>
-#include <wx/ogl/drawnp.h>
-#include <wx/ogl/misc.h>
-
-#include <math.h>
+#include "wx/ogl/ogl.h"
-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
wxDrawnShape::wxDrawnShape():wxRectangleShape(100.0, 50.0)
{
- m_saveToFile = TRUE;
+ m_saveToFile = true;
m_currentAngle = oglDRAWN_ANGLE_0;
}
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);
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);
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;
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
{
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);
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);
}
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]);
}
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)
{
}
#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));
return expr;
}
-void wxOpSetGDI::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr)
+void wxOpSetGDI::ReadExpr(wxPseudoMetaFile *WXUNUSED(image), wxExpr *expr)
{
switch (m_op)
{
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;
}
#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));
return expr;
}
-void wxOpSetClipping::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr)
+void wxOpSetClipping::ReadExpr(wxPseudoMetaFile *WXUNUSED(image), wxExpr *expr)
{
switch (m_op)
{
*/
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;
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;
}
case DRAWOP_DRAW_ELLIPTIC_ARC:
{
- const double pi = 3.1415926535897932384626433832795 ;
+ const double pi = M_PI ;
// Convert back to degrees
dc.DrawEllipticArc(
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:
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;
}
}
#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));
return expr;
}
-void wxOpDraw::ReadExpr(wxPseudoMetaFile *image, wxExpr *expr)
+void wxOpDraw::ReadExpr(wxPseudoMetaFile *WXUNUSED(image), wxExpr *expr)
{
switch (m_op)
{
{
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:
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++)
delete[] actualPoints;
break;
- break;
}
default:
break;
}
}
-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++)
{
}
#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;
// 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;
// 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
}
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)
{
*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;
}
}
}
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;
delete[] xpoints;
delete[] ypoints;
- return TRUE;
+ return true;
}
*
*/
-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);
}
// 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) ;
wxPseudoMetaFile::wxPseudoMetaFile()
{
m_currentRotation = 0;
- m_rotateable = TRUE;
+ m_rotateable = true;
m_width = 0.0;
m_height = 0.0;
m_outlinePen = NULL;
m_outlineOp = -1;
}
-wxPseudoMetaFile::wxPseudoMetaFile(wxPseudoMetaFile& mf)
+wxPseudoMetaFile::wxPseudoMetaFile(wxPseudoMetaFile& mf):wxObject()
{
mf.Copy(*this);
}
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)
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)
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
{
}
// 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
{
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;
m_height = *rheight;
delete metaFile;
- return TRUE;
+ return true;
}
// Scale to fit size
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);
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);
}
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);
}