+// Calculate size from current operations
+void wxPseudoMetaFile::CalculateSize(wxDrawnShape* shape)
+{
+ double boundMinX, boundMinY, boundMaxX, boundMaxY;
+
+ GetBounds(& boundMinX, & boundMinY, & boundMaxX, & boundMaxY);
+
+ SetSize(boundMaxX - boundMinX, boundMaxY - boundMinY);
+
+ if (shape)
+ {
+ shape->SetWidth(m_width);
+ shape->SetHeight(m_height);
+ }
+}
+
+// Set of functions for drawing into a pseudo metafile.
+// They use integers, but doubles are used internally for accuracy
+// when scaling.
+
+void wxPseudoMetaFile::DrawLine(const wxPoint& pt1, const wxPoint& pt2)
+{
+ wxOpDraw *theOp = new wxOpDraw(DRAWOP_DRAW_LINE,
+ (double) pt1.x, (double) pt1.y, (double) pt2.x, (double) pt2.y);
+
+ m_ops.Append(theOp);
+}
+
+void wxPseudoMetaFile::DrawRectangle(const wxRect& rect)
+{
+ wxOpDraw *theOp = new wxOpDraw(DRAWOP_DRAW_RECT,
+ (double) rect.x, (double) rect.y, (double) rect.width, (double) rect.height);
+
+ m_ops.Append(theOp);
+}
+
+void wxPseudoMetaFile::DrawRoundedRectangle(const wxRect& rect, double radius)
+{
+ wxOpDraw *theOp = new wxOpDraw(DRAWOP_DRAW_ROUNDED_RECT,
+ (double) rect.x, (double) rect.y, (double) rect.width, (double) rect.height);
+
+ theOp->m_radius = radius;
+
+ m_ops.Append(theOp);
+}
+
+void wxPseudoMetaFile::DrawEllipse(const wxRect& rect)
+{
+ wxOpDraw *theOp = new wxOpDraw(DRAWOP_DRAW_ELLIPSE,
+ (double) rect.x, (double) rect.y, (double) rect.width, (double) rect.height);
+
+ m_ops.Append(theOp);
+}
+
+void wxPseudoMetaFile::DrawArc(const wxPoint& centrePt, const wxPoint& startPt, const wxPoint& endPt)
+{
+ wxOpDraw *theOp = new wxOpDraw(DRAWOP_DRAW_ARC,
+ (double) centrePt.x, (double) centrePt.y, (double) startPt.x, (double) startPt.y);
+
+ theOp->m_x3 = (double) endPt.x;
+ theOp->m_y3 = (double) endPt.y;
+
+ m_ops.Append(theOp);
+}
+
+void wxPseudoMetaFile::DrawEllipticArc(const wxRect& rect, double startAngle, double endAngle)
+{
+ const double pi = 3.1415926535897932384626433832795 ;
+
+ double startAngleRadians = startAngle* (pi*2.0/360.0);
+ double endAngleRadians = endAngle* (pi*2.0/360.0);
+
+ wxOpDraw *theOp = new wxOpDraw(DRAWOP_DRAW_ELLIPTIC_ARC,
+ (double) rect.x, (double) rect.y, (double) rect.width, (double) rect.height);
+
+ theOp->m_x3 = startAngleRadians;
+ theOp->m_y3 = endAngleRadians;
+
+ m_ops.Append(theOp);
+}
+
+void wxPseudoMetaFile::DrawPoint(const wxPoint& pt)
+{
+ wxOpDraw *theOp = new wxOpDraw(DRAWOP_DRAW_POINT,
+ (double) pt.x, (double) pt.y, 0.0, 0.0);
+
+ m_ops.Append(theOp);
+}
+
+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);
+
+ m_ops.Append(theOp);
+}
+
+void wxPseudoMetaFile::DrawLines(int n, wxPoint pts[])
+{
+ wxRealPoint* realPoints = new wxRealPoint[n];
+ int i;
+ for (i = 0; i < n; i++)
+ {
+ realPoints[i].x = pts[i].x;
+ realPoints[i].y = pts[i].y;
+ }
+ wxOpPolyDraw* theOp = new wxOpPolyDraw(DRAWOP_DRAW_POLYLINE, n, realPoints);
+ m_ops.Append(theOp);
+}
+
+void wxPseudoMetaFile::DrawPolygon(int n, wxPoint pts[], int flags)
+{
+ wxRealPoint* realPoints = new wxRealPoint[n];
+ int i;
+ for (i = 0; i < n; i++)
+ {
+ realPoints[i].x = pts[i].x;
+ realPoints[i].y = pts[i].y;
+ }
+ wxOpPolyDraw* theOp = new wxOpPolyDraw(DRAWOP_DRAW_POLYGON, n, realPoints);
+ m_ops.Append(theOp);
+
+ if (flags & oglMETAFLAGS_OUTLINE)
+ m_outlineOp = (m_ops.Number() - 1);
+}
+
+void wxPseudoMetaFile::DrawSpline(int n, wxPoint pts[])
+{
+ wxRealPoint* realPoints = new wxRealPoint[n];
+ int i;
+ for (i = 0; i < n; i++)
+ {
+ realPoints[i].x = pts[i].x;
+ realPoints[i].y = pts[i].y;
+ }
+ wxOpPolyDraw* theOp = new wxOpPolyDraw(DRAWOP_DRAW_SPLINE, n, realPoints);
+ m_ops.Append(theOp);
+}
+
+void wxPseudoMetaFile::SetClippingRect(const wxRect& rect)
+{
+ wxOpSetClipping* theOp = new wxOpSetClipping(DRAWOP_SET_CLIPPING_RECT,
+ (double) rect.x, (double) rect.y, (double) rect.width, (double) rect.height);
+}
+
+void wxPseudoMetaFile::DestroyClippingRect()
+{
+ wxOpSetClipping* theOp = new wxOpSetClipping(DRAWOP_DESTROY_CLIPPING_RECT,
+ 0.0, 0.0, 0.0, 0.0);
+
+ m_ops.Append(theOp);
+}
+
+void wxPseudoMetaFile::SetPen(wxPen* pen, bool isOutline)
+{
+ m_gdiObjects.Append(pen);
+ int n = m_gdiObjects.Number();
+
+ wxOpSetGDI* theOp = new wxOpSetGDI(DRAWOP_SET_PEN, this, n - 1);
+
+ m_ops.Append(theOp);
+
+ if (isOutline)
+ {
+ m_outlineColours.Append((wxObject*) (n - 1));
+ }
+}
+
+void wxPseudoMetaFile::SetBrush(wxBrush* brush, bool isFill)
+{
+ m_gdiObjects.Append(brush);
+ int n = m_gdiObjects.Number();
+
+ wxOpSetGDI* theOp = new wxOpSetGDI(DRAWOP_SET_BRUSH, this, n - 1);
+
+ m_ops.Append(theOp);
+
+ if (isFill)
+ {
+ m_fillColours.Append((wxObject*) (n - 1));
+ }
+}
+
+void wxPseudoMetaFile::SetFont(wxFont* font)
+{
+ m_gdiObjects.Append(font);
+ int n = m_gdiObjects.Number();
+
+ wxOpSetGDI* theOp = new wxOpSetGDI(DRAWOP_SET_FONT, this, n - 1);
+
+ m_ops.Append(theOp);
+}
+
+void wxPseudoMetaFile::SetTextColour(const wxColour& colour)
+{
+ wxOpSetGDI* theOp = new wxOpSetGDI(DRAWOP_SET_TEXT_COLOUR, this, 0);
+ theOp->m_r = colour.Red();
+ theOp->m_g = colour.Green();
+ theOp->m_b = colour.Blue();
+
+ m_ops.Append(theOp);
+}
+
+void wxPseudoMetaFile::SetBackgroundColour(const wxColour& colour)
+{
+ wxOpSetGDI* theOp = new wxOpSetGDI(DRAWOP_SET_BK_COLOUR, this, 0);
+ theOp->m_r = colour.Red();
+ theOp->m_g = colour.Green();
+ theOp->m_b = colour.Blue();
+
+ m_ops.Append(theOp);
+}
+
+void wxPseudoMetaFile::SetBackgroundMode(int mode)
+{
+ wxOpSetGDI* theOp = new wxOpSetGDI(DRAWOP_SET_BK_MODE, this, 0, mode);
+
+ m_ops.Append(theOp);
+}