1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDrawnShape
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "drawn.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include <wx/wxprec.h>
28 #include <wx/wxexpr.h>
39 static void IntToHex(unsigned int dec
, char *buf
);
40 static unsigned long HexToInt(char *buf
);
41 extern char *oglBuffer
;
44 #define gyTYPE_BRUSH 41
45 #define gyTYPE_FONT 42
52 IMPLEMENT_DYNAMIC_CLASS(wxDrawnShape
, wxRectangleShape
)
54 wxDrawnShape::wxDrawnShape():wxRectangleShape(100.0, 50.0)
57 m_currentAngle
= oglDRAWN_ANGLE_0
;
60 wxDrawnShape::~wxDrawnShape()
64 void wxDrawnShape::OnDraw(wxDC
& dc
)
66 // Pass pen and brush in case we have force outline
68 if (m_shadowMode
!= SHADOW_NONE
)
71 m_metafiles
[m_currentAngle
].m_fillBrush
= m_shadowBrush
;
72 m_metafiles
[m_currentAngle
].m_outlinePen
= g_oglTransparentPen
;
73 m_metafiles
[m_currentAngle
].Draw(dc
, m_xpos
+ m_shadowOffsetX
, m_ypos
+ m_shadowOffsetY
);
76 m_metafiles
[m_currentAngle
].m_outlinePen
= m_pen
;
77 m_metafiles
[m_currentAngle
].m_fillBrush
= m_brush
;
78 m_metafiles
[m_currentAngle
].Draw(dc
, m_xpos
, m_ypos
);
81 void wxDrawnShape::SetSize(double w
, double h
, bool recursive
)
83 SetAttachmentSize(w
, h
);
87 if (GetWidth() == 0.0)
89 else scaleX
= w
/GetWidth();
90 if (GetHeight() == 0.0)
92 else scaleY
= h
/GetHeight();
95 for (i
= 0; i
< 4; i
++)
97 if (m_metafiles
[i
].IsValid())
98 m_metafiles
[i
].Scale(scaleX
, scaleY
);
102 SetDefaultRegionSize();
105 void wxDrawnShape::Scale(double sx
, double sy
)
108 for (i
= 0; i
< 4; i
++)
110 if (m_metafiles
[i
].IsValid())
112 m_metafiles
[i
].Scale(sx
, sy
);
113 m_metafiles
[i
].CalculateSize(this);
118 void wxDrawnShape::Translate(double x
, double y
)
121 for (i
= 0; i
< 4; i
++)
123 if (m_metafiles
[i
].IsValid())
125 m_metafiles
[i
].Translate(x
, y
);
126 m_metafiles
[i
].CalculateSize(this);
131 // theta is absolute rotation from the zero position
132 void wxDrawnShape::Rotate(double x
, double y
, double theta
)
134 m_currentAngle
= DetermineMetaFile(theta
);
136 if (m_currentAngle
== 0)
139 if (!m_metafiles
[0].GetRotateable())
142 m_metafiles
[0].Rotate(x
, y
, theta
);
145 double actualTheta
= theta
-m_rotation
;
147 // Rotate attachment points
148 double sinTheta
= (double)sin(actualTheta
);
149 double cosTheta
= (double)cos(actualTheta
);
150 wxNode
*node
= m_attachmentPoints
.First();
153 wxAttachmentPoint
*point
= (wxAttachmentPoint
*)node
->Data();
154 double x1
= point
->m_x
;
155 double y1
= point
->m_y
;
156 point
->m_x
= x1
*cosTheta
- y1
*sinTheta
+ x
*(1.0 - cosTheta
) + y
*sinTheta
;
157 point
->m_y
= x1
*sinTheta
+ y1
*cosTheta
+ y
*(1.0 - cosTheta
) + x
*sinTheta
;
162 m_metafiles
[m_currentAngle
].CalculateSize(this);
165 // Which metafile do we use now? Based on current rotation and validity
168 int wxDrawnShape::DetermineMetaFile(double rotation
)
170 double tolerance
= 0.0001;
171 const double pi
= 3.1415926535897932384626433832795 ;
173 double angle2
= pi
/2.0;
175 double angle4
= 3.0*pi
/2.0;
177 int whichMetafile
= 0;
179 if (oglRoughlyEqual(rotation
, angle1
, tolerance
))
183 else if (oglRoughlyEqual(rotation
, angle2
, tolerance
))
187 else if (oglRoughlyEqual(rotation
, angle3
, tolerance
))
191 else if (oglRoughlyEqual(rotation
, angle4
, tolerance
))
196 if ((whichMetafile
> 0) && !m_metafiles
[whichMetafile
].IsValid())
199 return whichMetafile
;
202 void wxDrawnShape::OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
)
204 if (m_metafiles
[m_currentAngle
].GetOutlineOp() != -1)
206 wxNode
* node
= m_metafiles
[m_currentAngle
].GetOps().Nth(m_metafiles
[m_currentAngle
].GetOutlineOp());
207 wxASSERT (node
!= NULL
);
208 wxDrawOp
* op
= (wxDrawOp
*) node
->Data();
210 if (op
->OnDrawOutline(dc
, x
, y
, w
, h
, m_width
, m_height
))
214 // Default... just use a rectangle
215 wxRectangleShape::OnDrawOutline(dc
, x
, y
, w
, h
);
218 // Get the perimeter point using the special outline op, if there is one,
219 // otherwise use default wxRectangleShape scheme
220 bool wxDrawnShape::GetPerimeterPoint(double x1
, double y1
,
221 double x2
, double y2
,
222 double *x3
, double *y3
)
224 if (m_metafiles
[m_currentAngle
].GetOutlineOp() != -1)
226 wxNode
* node
= m_metafiles
[m_currentAngle
].GetOps().Nth(m_metafiles
[m_currentAngle
].GetOutlineOp());
227 wxASSERT (node
!= NULL
);
228 wxDrawOp
* op
= (wxDrawOp
*) node
->Data();
230 if (op
->GetPerimeterPoint(x1
, y1
, x2
, y2
, x3
, y3
, GetX(), GetY(), GetAttachmentMode()))
234 // Default... just use a rectangle
235 return wxRectangleShape::GetPerimeterPoint(x1
, y1
, x2
, y2
, x3
, y3
);
239 void wxDrawnShape::WriteAttributes(wxExpr
*clause
)
241 wxRectangleShape::WriteAttributes(clause
);
243 clause
->AddAttributeValue("current_angle", (long)m_currentAngle
);
244 clause
->AddAttributeValue("save_metafile", (long)m_saveToFile
);
248 for (i
= 0; i
< 4; i
++)
250 if (m_metafiles
[i
].IsValid())
251 m_metafiles
[i
].WriteAttributes(clause
, i
);
256 void wxDrawnShape::ReadAttributes(wxExpr
*clause
)
258 wxRectangleShape::ReadAttributes(clause
);
260 int iVal
= (int) m_saveToFile
;
261 clause
->GetAttributeValue("save_metafile", iVal
);
262 clause
->GetAttributeValue("current_angle", m_currentAngle
);
263 m_saveToFile
= (iVal
!= 0);
268 for (i
= 0; i
< 4; i
++)
270 m_metafiles
[i
].ReadAttributes(clause
, i
);
276 // Does the copying for this object
277 void wxDrawnShape::Copy(wxShape
& copy
)
279 wxRectangleShape::Copy(copy
);
281 wxASSERT( copy
.IsKindOf(CLASSINFO(wxDrawnShape
)) ) ;
283 wxDrawnShape
& drawnCopy
= (wxDrawnShape
&) copy
;
286 for (i
= 0; i
< 4; i
++)
288 m_metafiles
[i
].Copy(drawnCopy
.m_metafiles
[i
]);
290 drawnCopy
.m_saveToFile
= m_saveToFile
;
291 drawnCopy
.m_currentAngle
= m_currentAngle
;
294 bool wxDrawnShape::LoadFromMetaFile(char *filename
)
296 return m_metafiles
[0].LoadFromMetaFile(filename
, &m_width
, &m_height
);
299 // Set of functions for drawing into a pseudo metafile.
300 // They use integers, but doubles are used internally for accuracy
303 void wxDrawnShape::DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
305 m_metafiles
[m_currentAngle
].DrawLine(pt1
, pt2
);
308 void wxDrawnShape::DrawRectangle(const wxRect
& rect
)
310 m_metafiles
[m_currentAngle
].DrawRectangle(rect
);
313 void wxDrawnShape::DrawRoundedRectangle(const wxRect
& rect
, double radius
)
315 m_metafiles
[m_currentAngle
].DrawRoundedRectangle(rect
, radius
);
318 void wxDrawnShape::DrawEllipse(const wxRect
& rect
)
320 m_metafiles
[m_currentAngle
].DrawEllipse(rect
);
323 void wxDrawnShape::DrawArc(const wxPoint
& centrePt
, const wxPoint
& startPt
, const wxPoint
& endPt
)
325 m_metafiles
[m_currentAngle
].DrawArc(centrePt
, startPt
, endPt
);
328 void wxDrawnShape::DrawEllipticArc(const wxRect
& rect
, double startAngle
, double endAngle
)
330 m_metafiles
[m_currentAngle
].DrawEllipticArc(rect
, startAngle
, endAngle
);
333 void wxDrawnShape::DrawPoint(const wxPoint
& pt
)
335 m_metafiles
[m_currentAngle
].DrawPoint(pt
);
338 void wxDrawnShape::DrawText(const wxString
& text
, const wxPoint
& pt
)
340 m_metafiles
[m_currentAngle
].DrawText(text
, pt
);
343 void wxDrawnShape::DrawLines(int n
, wxPoint pts
[])
345 m_metafiles
[m_currentAngle
].DrawLines(n
, pts
);
348 void wxDrawnShape::DrawPolygon(int n
, wxPoint pts
[], int flags
)
350 if (flags
& oglMETAFLAGS_ATTACHMENTS
)
354 for (i
= 0; i
< n
; i
++)
355 m_attachmentPoints
.Append(new wxAttachmentPoint(i
, pts
[i
].x
, pts
[i
].y
));
357 m_metafiles
[m_currentAngle
].DrawPolygon(n
, pts
, flags
);
360 void wxDrawnShape::DrawSpline(int n
, wxPoint pts
[])
362 m_metafiles
[m_currentAngle
].DrawSpline(n
, pts
);
365 void wxDrawnShape::SetClippingRect(const wxRect
& rect
)
367 m_metafiles
[m_currentAngle
].SetClippingRect(rect
);
370 void wxDrawnShape::DestroyClippingRect()
372 m_metafiles
[m_currentAngle
].DestroyClippingRect();
375 void wxDrawnShape::SetDrawnPen(wxPen
* pen
, bool isOutline
)
377 m_metafiles
[m_currentAngle
].SetPen(pen
, isOutline
);
380 void wxDrawnShape::SetDrawnBrush(wxBrush
* brush
, bool isFill
)
382 m_metafiles
[m_currentAngle
].SetBrush(brush
, isFill
);
385 void wxDrawnShape::SetDrawnFont(wxFont
* font
)
387 m_metafiles
[m_currentAngle
].SetFont(font
);
390 void wxDrawnShape::SetDrawnTextColour(const wxColour
& colour
)
392 m_metafiles
[m_currentAngle
].SetTextColour(colour
);
395 void wxDrawnShape::SetDrawnBackgroundColour(const wxColour
& colour
)
397 m_metafiles
[m_currentAngle
].SetBackgroundColour(colour
);
400 void wxDrawnShape::SetDrawnBackgroundMode(int mode
)
402 m_metafiles
[m_currentAngle
].SetBackgroundMode(mode
);
407 * Individual operations
412 * Set font, brush, text colour
416 wxOpSetGDI::wxOpSetGDI(int theOp
, wxPseudoMetaFile
*theImage
, int theGdiIndex
, int theMode
):
419 m_gdiIndex
= theGdiIndex
;
424 void wxOpSetGDI::Do(wxDC
& dc
, double xoffset
, double yoffset
)
430 // Check for overriding this operation for outline
432 if (m_image
->m_outlineColours
.Member((wxObject
*)m_gdiIndex
))
434 if (m_image
->m_outlinePen
)
435 dc
.SetPen(m_image
->m_outlinePen
);
439 wxNode
*node
= m_image
->m_gdiObjects
.Nth(m_gdiIndex
);
442 wxPen
*pen
= (wxPen
*)node
->Data();
449 case DRAWOP_SET_BRUSH
:
451 // Check for overriding this operation for outline or fill
453 if (m_image
->m_outlineColours
.Member((wxObject
*)m_gdiIndex
))
455 // Need to construct a brush to match the outline pen's colour
456 if (m_image
->m_outlinePen
)
458 wxBrush
*br
= wxTheBrushList
->FindOrCreateBrush(m_image
->m_outlinePen
->GetColour(), wxSOLID
);
463 else if (m_image
->m_fillColours
.Member((wxObject
*)m_gdiIndex
))
465 if (m_image
->m_fillBrush
)
467 dc
.SetBrush(m_image
->m_fillBrush
);
472 wxNode
*node
= m_image
->m_gdiObjects
.Nth(m_gdiIndex
);
475 wxBrush
*brush
= (wxBrush
*)node
->Data();
482 case DRAWOP_SET_FONT
:
484 wxNode
*node
= m_image
->m_gdiObjects
.Nth(m_gdiIndex
);
487 wxFont
*font
= (wxFont
*)node
->Data();
493 case DRAWOP_SET_TEXT_COLOUR
:
495 wxColour
col(m_r
,m_g
,m_b
);
496 dc
.SetTextForeground(col
);
499 case DRAWOP_SET_BK_COLOUR
:
501 wxColour
col(m_r
,m_g
,m_b
);
502 dc
.SetTextBackground(col
);
505 case DRAWOP_SET_BK_MODE
:
507 dc
.SetBackgroundMode(m_mode
);
515 wxDrawOp
*wxOpSetGDI::Copy(wxPseudoMetaFile
*newImage
)
517 wxOpSetGDI
*newOp
= new wxOpSetGDI(m_op
, newImage
, m_gdiIndex
, m_mode
);
524 wxExpr
*wxOpSetGDI::WriteExpr(wxPseudoMetaFile
*image
)
526 wxExpr
*expr
= new wxExpr(wxExprList
);
527 expr
->Append(new wxExpr((long)m_op
));
531 case DRAWOP_SET_BRUSH
:
532 case DRAWOP_SET_FONT
:
534 expr
->Append(new wxExpr((long)m_gdiIndex
));
537 case DRAWOP_SET_TEXT_COLOUR
:
538 case DRAWOP_SET_BK_COLOUR
:
540 expr
->Append(new wxExpr((long)m_r
));
541 expr
->Append(new wxExpr((long)m_g
));
542 expr
->Append(new wxExpr((long)m_b
));
545 case DRAWOP_SET_BK_MODE
:
547 expr
->Append(new wxExpr((long)m_mode
));
556 void wxOpSetGDI::ReadExpr(wxPseudoMetaFile
*image
, wxExpr
*expr
)
561 case DRAWOP_SET_BRUSH
:
562 case DRAWOP_SET_FONT
:
564 m_gdiIndex
= (int)expr
->Nth(1)->IntegerValue();
567 case DRAWOP_SET_TEXT_COLOUR
:
568 case DRAWOP_SET_BK_COLOUR
:
570 m_r
= (unsigned char)expr
->Nth(1)->IntegerValue();
571 m_g
= (unsigned char)expr
->Nth(2)->IntegerValue();
572 m_b
= (unsigned char)expr
->Nth(3)->IntegerValue();
575 case DRAWOP_SET_BK_MODE
:
577 m_mode
= (int)expr
->Nth(1)->IntegerValue();
586 * Set/destroy clipping
590 wxOpSetClipping::wxOpSetClipping(int theOp
, double theX1
, double theY1
,
591 double theX2
, double theY2
):wxDrawOp(theOp
)
599 wxDrawOp
*wxOpSetClipping::Copy(wxPseudoMetaFile
*newImage
)
601 wxOpSetClipping
*newOp
= new wxOpSetClipping(m_op
, m_x1
, m_y1
, m_x2
, m_y2
);
605 void wxOpSetClipping::Do(wxDC
& dc
, double xoffset
, double yoffset
)
609 case DRAWOP_SET_CLIPPING_RECT
:
611 dc
.SetClippingRegion(m_x1
+ xoffset
, m_y1
+ yoffset
, m_x2
+ xoffset
, m_y2
+ yoffset
);
614 case DRAWOP_DESTROY_CLIPPING_RECT
:
616 dc
.DestroyClippingRegion();
624 void wxOpSetClipping::Scale(double xScale
, double yScale
)
632 void wxOpSetClipping::Translate(double x
, double y
)
638 wxExpr
*wxOpSetClipping::WriteExpr(wxPseudoMetaFile
*image
)
640 wxExpr
*expr
= new wxExpr(wxExprList
);
641 expr
->Append(new wxExpr((long)m_op
));
644 case DRAWOP_SET_CLIPPING_RECT
:
646 expr
->Append(new wxExpr(m_x1
));
647 expr
->Append(new wxExpr(m_y1
));
648 expr
->Append(new wxExpr(m_x2
));
649 expr
->Append(new wxExpr(m_y2
));
658 void wxOpSetClipping::ReadExpr(wxPseudoMetaFile
*image
, wxExpr
*expr
)
662 case DRAWOP_SET_CLIPPING_RECT
:
664 m_x1
= expr
->Nth(1)->RealValue();
665 m_y1
= expr
->Nth(2)->RealValue();
666 m_x2
= expr
->Nth(3)->RealValue();
667 m_y2
= expr
->Nth(4)->RealValue();
676 * Draw line, rectangle, rounded rectangle, ellipse, point, arc, text
680 wxOpDraw::wxOpDraw(int theOp
, double theX1
, double theY1
, double theX2
, double theY2
,
681 double theRadius
, char *s
):wxDrawOp(theOp
)
689 m_radius
= theRadius
;
690 if (s
) m_textString
= copystring(s
);
691 else m_textString
= NULL
;
694 wxOpDraw::~wxOpDraw()
696 if (m_textString
) delete[] m_textString
;
699 wxDrawOp
*wxOpDraw::Copy(wxPseudoMetaFile
*newImage
)
701 wxOpDraw
*newOp
= new wxOpDraw(m_op
, m_x1
, m_y1
, m_x2
, m_y2
, m_radius
, m_textString
);
707 void wxOpDraw::Do(wxDC
& dc
, double xoffset
, double yoffset
)
711 case DRAWOP_DRAW_LINE
:
713 dc
.DrawLine(WXROUND(m_x1
+xoffset
), WXROUND(m_y1
+yoffset
), WXROUND(m_x2
+xoffset
), WXROUND(m_y2
+yoffset
));
716 case DRAWOP_DRAW_RECT
:
718 dc
.DrawRectangle(WXROUND(m_x1
+xoffset
), WXROUND(m_y1
+yoffset
), WXROUND(m_x2
), WXROUND(m_y2
));
721 case DRAWOP_DRAW_ROUNDED_RECT
:
723 dc
.DrawRoundedRectangle(WXROUND(m_x1
+xoffset
), WXROUND(m_y1
+yoffset
), WXROUND(m_x2
), WXROUND(m_y2
), m_radius
);
726 case DRAWOP_DRAW_ELLIPSE
:
728 dc
.DrawEllipse(WXROUND(m_x1
+xoffset
), WXROUND(m_y1
+yoffset
), WXROUND(m_x2
), WXROUND(m_y2
));
731 case DRAWOP_DRAW_ARC
:
733 dc
.DrawArc(WXROUND(m_x2
+xoffset
), WXROUND(m_y2
+yoffset
),
734 WXROUND(m_x3
+xoffset
), WXROUND(m_y3
+yoffset
),
735 WXROUND(m_x1
+xoffset
), WXROUND(m_y1
+yoffset
));
738 case DRAWOP_DRAW_ELLIPTIC_ARC
:
740 const double pi
= 3.1415926535897932384626433832795 ;
742 // Convert back to degrees
744 WXROUND(m_x1
+xoffset
), WXROUND(m_y1
+yoffset
),
745 WXROUND(m_x2
), WXROUND(m_y2
),
746 WXROUND(m_x3
*(360.0/(2.0*pi
))), WXROUND(m_y3
*(360.0/(2.0*pi
))));
749 case DRAWOP_DRAW_POINT
:
751 dc
.DrawPoint(WXROUND(m_x1
+xoffset
), WXROUND(m_y1
+yoffset
));
754 case DRAWOP_DRAW_TEXT
:
756 dc
.DrawText(m_textString
, WXROUND(m_x1
+xoffset
), WXROUND(m_y1
+yoffset
));
764 void wxOpDraw::Scale(double scaleX
, double scaleY
)
771 if (m_op
!= DRAWOP_DRAW_ELLIPTIC_ARC
)
780 void wxOpDraw::Translate(double x
, double y
)
787 case DRAWOP_DRAW_LINE
:
793 case DRAWOP_DRAW_ARC
:
801 case DRAWOP_DRAW_ELLIPTIC_ARC
:
810 void wxOpDraw::Rotate(double x
, double y
, double theta
, double sinTheta
, double cosTheta
)
812 double newX1
= m_x1
*cosTheta
- m_y1
*sinTheta
+ x
*(1.0 - cosTheta
) + y
*sinTheta
;
813 double newY1
= m_x1
*sinTheta
+ m_y1
*cosTheta
+ y
*(1.0 - cosTheta
) + x
*sinTheta
;
817 case DRAWOP_DRAW_LINE
:
819 double newX2
= m_x2
*cosTheta
- m_y2
*sinTheta
+ x
*(1.0 - cosTheta
) + y
*sinTheta
;
820 double newY2
= m_x2
*sinTheta
+ m_y2
*cosTheta
+ y
*(1.0 - cosTheta
) + x
*sinTheta
;
828 case DRAWOP_DRAW_RECT
:
829 case DRAWOP_DRAW_ROUNDED_RECT
:
830 case DRAWOP_DRAW_ELLIPTIC_ARC
:
832 // Assume only 0, 90, 180, 270 degree rotations.
833 // oldX1, oldY1 represents the top left corner. Find the
834 // bottom right, and rotate that. Then the width/height is the difference
835 // between x/y values.
836 double oldBottomRightX
= m_x1
+ m_x2
;
837 double oldBottomRightY
= m_y1
+ m_y2
;
838 double newBottomRightX
= oldBottomRightX
*cosTheta
- oldBottomRightY
*sinTheta
+ x
*(1.0 - cosTheta
) + y
*sinTheta
;
839 double newBottomRightY
= oldBottomRightX
*sinTheta
+ oldBottomRightY
*cosTheta
+ y
*(1.0 - cosTheta
) + x
*sinTheta
;
841 // Now find the new top-left, bottom-right coordinates.
842 double minX
= wxMin(newX1
, newBottomRightX
);
843 double minY
= wxMin(newY1
, newBottomRightY
);
844 double maxX
= wxMax(newX1
, newBottomRightX
);
845 double maxY
= wxMax(newY1
, newBottomRightY
);
849 m_x2
= maxX
- minX
; // width
850 m_y2
= maxY
- minY
; // height
852 if (m_op
== DRAWOP_DRAW_ELLIPTIC_ARC
)
854 // Add rotation to angles
861 case DRAWOP_DRAW_ARC
:
863 double newX2
= m_x2
*cosTheta
- m_y2
*sinTheta
+ x
*(1.0 - cosTheta
) + y
*sinTheta
;
864 double newY2
= m_x2
*sinTheta
+ m_y2
*cosTheta
+ y
*(1.0 - cosTheta
) + x
*sinTheta
;
865 double newX3
= m_x3
*cosTheta
- m_y3
*sinTheta
+ x
*(1.0 - cosTheta
) + y
*sinTheta
;
866 double newY3
= m_x3
*sinTheta
+ m_y3
*cosTheta
+ y
*(1.0 - cosTheta
) + x
*sinTheta
;
882 wxExpr
*wxOpDraw::WriteExpr(wxPseudoMetaFile
*image
)
884 wxExpr
*expr
= new wxExpr(wxExprList
);
885 expr
->Append(new wxExpr((long)m_op
));
888 case DRAWOP_DRAW_LINE
:
889 case DRAWOP_DRAW_RECT
:
890 case DRAWOP_DRAW_ELLIPSE
:
892 expr
->Append(new wxExpr(m_x1
));
893 expr
->Append(new wxExpr(m_y1
));
894 expr
->Append(new wxExpr(m_x2
));
895 expr
->Append(new wxExpr(m_y2
));
898 case DRAWOP_DRAW_ROUNDED_RECT
:
900 expr
->Append(new wxExpr(m_x1
));
901 expr
->Append(new wxExpr(m_y1
));
902 expr
->Append(new wxExpr(m_x2
));
903 expr
->Append(new wxExpr(m_y2
));
904 expr
->Append(new wxExpr(m_radius
));
907 case DRAWOP_DRAW_POINT
:
909 expr
->Append(new wxExpr(m_x1
));
910 expr
->Append(new wxExpr(m_y1
));
913 case DRAWOP_DRAW_TEXT
:
915 expr
->Append(new wxExpr(m_x1
));
916 expr
->Append(new wxExpr(m_y1
));
917 expr
->Append(new wxExpr(wxExprString
, m_textString
));
920 case DRAWOP_DRAW_ARC
:
921 case DRAWOP_DRAW_ELLIPTIC_ARC
:
923 expr
->Append(new wxExpr(m_x1
));
924 expr
->Append(new wxExpr(m_y1
));
925 expr
->Append(new wxExpr(m_x2
));
926 expr
->Append(new wxExpr(m_y2
));
927 expr
->Append(new wxExpr(m_x3
));
928 expr
->Append(new wxExpr(m_y3
));
939 void wxOpDraw::ReadExpr(wxPseudoMetaFile
*image
, wxExpr
*expr
)
943 case DRAWOP_DRAW_LINE
:
944 case DRAWOP_DRAW_RECT
:
945 case DRAWOP_DRAW_ELLIPSE
:
947 m_x1
= expr
->Nth(1)->RealValue();
948 m_y1
= expr
->Nth(2)->RealValue();
949 m_x2
= expr
->Nth(3)->RealValue();
950 m_y2
= expr
->Nth(4)->RealValue();
953 case DRAWOP_DRAW_ROUNDED_RECT
:
955 m_x1
= expr
->Nth(1)->RealValue();
956 m_y1
= expr
->Nth(2)->RealValue();
957 m_x2
= expr
->Nth(3)->RealValue();
958 m_y2
= expr
->Nth(4)->RealValue();
959 m_radius
= expr
->Nth(5)->RealValue();
962 case DRAWOP_DRAW_POINT
:
964 m_x1
= expr
->Nth(1)->RealValue();
965 m_y1
= expr
->Nth(2)->RealValue();
968 case DRAWOP_DRAW_TEXT
:
970 m_x1
= expr
->Nth(1)->RealValue();
971 m_y1
= expr
->Nth(2)->RealValue();
972 wxString
str(expr
->Nth(3)->StringValue());
973 m_textString
= copystring((const char*) str
);
976 case DRAWOP_DRAW_ARC
:
977 case DRAWOP_DRAW_ELLIPTIC_ARC
:
979 m_x1
= expr
->Nth(1)->RealValue();
980 m_y1
= expr
->Nth(2)->RealValue();
981 m_x2
= expr
->Nth(3)->RealValue();
982 m_y2
= expr
->Nth(4)->RealValue();
983 m_x3
= expr
->Nth(5)->RealValue();
984 m_y3
= expr
->Nth(6)->RealValue();
995 * Draw polygon, polyline, spline
999 wxOpPolyDraw::wxOpPolyDraw(int theOp
, int n
, wxRealPoint
*thePoints
):wxDrawOp(theOp
)
1002 m_points
= thePoints
;
1005 wxOpPolyDraw::~wxOpPolyDraw()
1010 wxDrawOp
*wxOpPolyDraw::Copy(wxPseudoMetaFile
*newImage
)
1012 wxRealPoint
*newPoints
= new wxRealPoint
[m_noPoints
];
1013 for (int i
= 0; i
< m_noPoints
; i
++)
1015 newPoints
[i
].x
= m_points
[i
].x
;
1016 newPoints
[i
].y
= m_points
[i
].y
;
1018 wxOpPolyDraw
*newOp
= new wxOpPolyDraw(m_op
, m_noPoints
, newPoints
);
1022 void wxOpPolyDraw::Do(wxDC
& dc
, double xoffset
, double yoffset
)
1026 case DRAWOP_DRAW_POLYLINE
:
1028 wxPoint
*actualPoints
= new wxPoint
[m_noPoints
];
1030 for (i
= 0; i
< m_noPoints
; i
++)
1032 actualPoints
[i
].x
= WXROUND(m_points
[i
].x
);
1033 actualPoints
[i
].y
= WXROUND(m_points
[i
].y
);
1036 dc
.DrawLines(m_noPoints
, actualPoints
, WXROUND(xoffset
), WXROUND(yoffset
));
1038 delete[] actualPoints
;
1041 case DRAWOP_DRAW_POLYGON
:
1043 wxPoint
*actualPoints
= new wxPoint
[m_noPoints
];
1045 for (i
= 0; i
< m_noPoints
; i
++)
1047 actualPoints
[i
].x
= WXROUND(m_points
[i
].x
);
1048 actualPoints
[i
].y
= WXROUND(m_points
[i
].y
);
1051 dc
.DrawPolygon(m_noPoints
, actualPoints
, WXROUND(xoffset
), WXROUND(yoffset
));
1053 delete[] actualPoints
;
1056 case DRAWOP_DRAW_SPLINE
:
1058 wxPoint
*actualPoints
= new wxPoint
[m_noPoints
];
1060 for (i
= 0; i
< m_noPoints
; i
++)
1062 actualPoints
[i
].x
= WXROUND(m_points
[i
].x
);
1063 actualPoints
[i
].y
= WXROUND(m_points
[i
].y
);
1066 dc
.DrawSpline(m_noPoints
, actualPoints
); // no offsets in DrawSpline // , xoffset, yoffset);
1068 delete[] actualPoints
;
1077 void wxOpPolyDraw::Scale(double scaleX
, double scaleY
)
1079 for (int i
= 0; i
< m_noPoints
; i
++)
1081 m_points
[i
].x
*= scaleX
;
1082 m_points
[i
].y
*= scaleY
;
1086 void wxOpPolyDraw::Translate(double x
, double y
)
1088 for (int i
= 0; i
< m_noPoints
; i
++)
1095 void wxOpPolyDraw::Rotate(double x
, double y
, double theta
, double sinTheta
, double cosTheta
)
1097 for (int i
= 0; i
< m_noPoints
; i
++)
1099 double x1
= m_points
[i
].x
;
1100 double y1
= m_points
[i
].y
;
1101 m_points
[i
].x
= x1
*cosTheta
- y1
*sinTheta
+ x
*(1.0 - cosTheta
) + y
*sinTheta
;
1102 m_points
[i
].y
= x1
*sinTheta
+ y1
*cosTheta
+ y
*(1.0 - cosTheta
) + x
*sinTheta
;
1106 wxExpr
*wxOpPolyDraw::WriteExpr(wxPseudoMetaFile
*image
)
1108 wxExpr
*expr
= new wxExpr(wxExprList
);
1109 expr
->Append(new wxExpr((long)m_op
));
1110 expr
->Append(new wxExpr((long)m_noPoints
));
1119 * Store each coordinate pair in a hex string to save space.
1120 * E.g. "1B9080CD". 4 hex digits per coordinate pair.
1124 for (int i
= 0; i
< m_noPoints
; i
++)
1126 long signedX
= (long)(m_points
[i
].x
*100.0);
1127 long signedY
= (long)(m_points
[i
].y
*100.0);
1129 // Scale to 0 -> 64K
1130 long unSignedX
= (long)(signedX
+ 32767.0);
1131 long unSignedY
= (long)(signedY
+ 32767.0);
1133 // IntToHex((unsigned int)signedX, buf2);
1134 // IntToHex((unsigned int)signedY, buf3);
1135 IntToHex((int)unSignedX
, buf2
);
1136 IntToHex((int)unSignedY
, buf3
);
1138 // Don't overrun the buffer
1141 strcat(oglBuffer
, buf2
);
1142 strcat(oglBuffer
, buf3
);
1145 expr
->Append(new wxExpr(wxExprString
, oglBuffer
));
1149 void wxOpPolyDraw::ReadExpr(wxPseudoMetaFile
*image
, wxExpr
*expr
)
1151 m_noPoints
= (int)expr
->Nth(1)->IntegerValue();
1156 m_points
= new wxRealPoint
[m_noPoints
];
1159 wxString hexString
= expr
->Nth(2)->StringValue();
1160 while (i
< m_noPoints
)
1162 buf1
[0] = hexString
[bufPtr
];
1163 buf1
[1] = hexString
[bufPtr
+ 1];
1164 buf1
[2] = hexString
[bufPtr
+ 2];
1165 buf1
[3] = hexString
[bufPtr
+ 3];
1168 buf2
[0] = hexString
[bufPtr
+ 4];
1169 buf2
[1] = hexString
[bufPtr
+ 5];
1170 buf2
[2] = hexString
[bufPtr
+ 6];
1171 buf2
[3] = hexString
[bufPtr
+ 7];
1176 // int signedX = (signed int)HexToInt(buf1);
1177 // int signedY = (signed int)HexToInt(buf2);
1178 long unSignedX
= HexToInt(buf1
);
1179 long unSignedY
= HexToInt(buf2
);
1180 // Scale -32K -> +32K
1181 long signedX
= unSignedX
- 32767;
1182 long signedY
= unSignedY
- 32767;
1184 int testX
= (signed int)unSignedX
;
1185 int testY
= (signed int)unSignedY
;
1188 m_points
[i
].x
= (double)(signedX
/ 100.0);
1189 m_points
[i
].y
= (double)(signedY
/ 100.0);
1195 // Draw an outline using the current operation.
1196 bool wxOpPolyDraw::OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
, double oldW
, double oldH
)
1198 dc
.SetBrush(wxTRANSPARENT_BRUSH
);
1200 // Multiply all points by proportion of new size to old size
1201 double x_proportion
= (double)(fabs(w
/oldW
));
1202 double y_proportion
= (double)(fabs(h
/oldH
));
1205 wxPoint
*intPoints
= new wxPoint
[n
];
1207 for (i
= 0; i
< n
; i
++)
1209 intPoints
[i
].x
= WXROUND (x_proportion
* m_points
[i
].x
);
1210 intPoints
[i
].y
= WXROUND (y_proportion
* m_points
[i
].y
);
1212 dc
.DrawPolygon(n
, intPoints
, x
, y
);
1217 // Assume (x1, y1) is centre of box (most generally, line end at box)
1218 bool wxOpPolyDraw::GetPerimeterPoint(double x1
, double y1
,
1219 double x2
, double y2
,
1220 double *x3
, double *y3
,
1221 double xOffset
, double yOffset
,
1226 // First check for situation where the line is vertical,
1227 // and we would want to connect to a point on that vertical --
1228 // oglFindEndForPolyline can't cope with this (the arrow
1229 // gets drawn to the wrong place).
1230 if ((attachmentMode
== ATTACHMENT_MODE_NONE
) && (x1
== x2
))
1232 // Look for the point we'd be connecting to. This is
1235 for (i
= 0; i
< n
; i
++)
1237 wxRealPoint
*point
= & (m_points
[i
]);
1238 if (point
->x
== 0.0)
1240 if ((y2
> y1
) && (point
->y
> 0.0))
1242 *x3
= point
->x
+ xOffset
;
1243 *y3
= point
->y
+ yOffset
;
1246 else if ((y2
< y1
) && (point
->y
< 0.0))
1248 *x3
= point
->x
+ xOffset
;
1249 *y3
= point
->y
+ yOffset
;
1256 double *xpoints
= new double[n
];
1257 double *ypoints
= new double[n
];
1260 for (i
= 0; i
< n
; i
++)
1262 wxRealPoint
*point
= & (m_points
[i
]);
1263 xpoints
[i
] = point
->x
+ xOffset
;
1264 ypoints
[i
] = point
->y
+ yOffset
;
1267 oglFindEndForPolyline(n
, xpoints
, ypoints
,
1268 x1
, y1
, x2
, y2
, x3
, y3
);
1282 static char hexArray
[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
1283 'C', 'D', 'E', 'F' };
1285 // Convert unsigned 16-bit integer to 4-character hex string
1286 static void IntToHex(unsigned int dec
, char *buf
)
1288 int digit1
= (int)(dec
/4096);
1289 int digit2
= (int)((dec
- (digit1
*4096))/256);
1290 int digit3
= (int)((dec
- (digit1
*4096) - (digit2
*256))/16);
1291 int digit4
= dec
- (digit1
*4096 + digit2
*256 + digit3
*16);
1293 buf
[0] = hexArray
[digit1
];
1294 buf
[1] = hexArray
[digit2
];
1295 buf
[2] = hexArray
[digit3
];
1296 buf
[3] = hexArray
[digit4
];
1300 // One hex digit to decimal number
1301 static int HexToInt1(char hex
)
1343 // 4-digit hex string to unsigned integer
1344 static unsigned long HexToInt(char *buf
)
1346 long d1
= (long)(HexToInt1(buf
[0])*4096.0) ;
1347 long d2
= (long)(HexToInt1(buf
[1])*256.0) ;
1348 long d3
= (long)(HexToInt1(buf
[2])*16.0) ;
1349 long d4
= (long)(HexToInt1(buf
[3])) ;
1350 unsigned long n
= (long)(d1
+ d2
+ d3
+ d4
) ;
1355 * wxPseudo meta-file
1359 IMPLEMENT_DYNAMIC_CLASS(wxPseudoMetaFile
, wxObject
)
1361 wxPseudoMetaFile::wxPseudoMetaFile()
1363 m_currentRotation
= 0;
1364 m_rotateable
= TRUE
;
1367 m_outlinePen
= NULL
;
1372 wxPseudoMetaFile::wxPseudoMetaFile(wxPseudoMetaFile
& mf
)
1377 wxPseudoMetaFile::~wxPseudoMetaFile()
1382 void wxPseudoMetaFile::Clear()
1384 wxNode
*node
= m_ops
.First();
1387 wxDrawOp
*op
= (wxDrawOp
*)node
->Data();
1389 node
= node
->Next();
1392 m_gdiObjects
.Clear();
1393 m_outlineColours
.Clear();
1394 m_fillColours
.Clear();
1398 void wxPseudoMetaFile::Draw(wxDC
& dc
, double xoffset
, double yoffset
)
1400 wxNode
*node
= m_ops
.First();
1403 wxDrawOp
*op
= (wxDrawOp
*)node
->Data();
1404 op
->Do(dc
, xoffset
, yoffset
);
1405 node
= node
->Next();
1409 void wxPseudoMetaFile::Scale(double sx
, double sy
)
1411 wxNode
*node
= m_ops
.First();
1414 wxDrawOp
*op
= (wxDrawOp
*)node
->Data();
1416 node
= node
->Next();
1422 void wxPseudoMetaFile::Translate(double x
, double y
)
1424 wxNode
*node
= m_ops
.First();
1427 wxDrawOp
*op
= (wxDrawOp
*)node
->Data();
1428 op
->Translate(x
, y
);
1429 node
= node
->Next();
1433 void wxPseudoMetaFile::Rotate(double x
, double y
, double theta
)
1435 double theta1
= theta
-m_currentRotation
;
1436 if (theta1
== 0.0) return;
1437 double cosTheta
= (double)cos(theta1
);
1438 double sinTheta
= (double)sin(theta1
);
1440 wxNode
*node
= m_ops
.First();
1443 wxDrawOp
*op
= (wxDrawOp
*)node
->Data();
1444 op
->Rotate(x
, y
, theta
, sinTheta
, cosTheta
);
1445 node
= node
->Next();
1447 m_currentRotation
= theta
;
1451 void wxPseudoMetaFile::WriteAttributes(wxExpr
*clause
, int whichAngle
)
1454 widthStr
.Printf("meta_width%d", whichAngle
);
1457 heightStr
.Printf("meta_height%d", whichAngle
);
1459 wxString outlineStr
;
1460 outlineStr
.Printf("outline_op%d", whichAngle
);
1462 wxString rotateableStr
;
1463 rotateableStr
.Printf("meta_rotateable%d", whichAngle
);
1465 // Write width and height
1466 clause
->AddAttributeValue(widthStr
, m_width
);
1467 clause
->AddAttributeValue(heightStr
, m_height
);
1468 clause
->AddAttributeValue(rotateableStr
, (long)m_rotateable
);
1469 clause
->AddAttributeValue(outlineStr
, (long)m_outlineOp
);
1471 // Write GDI objects
1474 wxNode
*node
= m_gdiObjects
.First();
1477 sprintf(buf
, "gdi%d_%d", whichAngle
, i
);
1478 wxObject
*obj
= (wxObject
*)node
->Data();
1479 wxExpr
*expr
= NULL
;
1482 if (obj
->IsKindOf(CLASSINFO(wxPen
)))
1484 wxPen
*thePen
= (wxPen
*)obj
;
1485 expr
= new wxExpr(wxExprList
);
1486 expr
->Append(new wxExpr((long)gyTYPE_PEN
));
1487 expr
->Append(new wxExpr((long)thePen
->GetWidth()));
1488 expr
->Append(new wxExpr((long)thePen
->GetStyle()));
1489 expr
->Append(new wxExpr((long)thePen
->GetColour().Red()));
1490 expr
->Append(new wxExpr((long)thePen
->GetColour().Green()));
1491 expr
->Append(new wxExpr((long)thePen
->GetColour().Blue()));
1493 else if (obj
->IsKindOf(CLASSINFO(wxBrush
)))
1495 wxBrush
*theBrush
= (wxBrush
*)obj
;
1496 expr
= new wxExpr(wxExprList
);
1497 expr
->Append(new wxExpr((long)gyTYPE_BRUSH
));
1498 expr
->Append(new wxExpr((long)theBrush
->GetStyle()));
1499 expr
->Append(new wxExpr((long)theBrush
->GetColour().Red()));
1500 expr
->Append(new wxExpr((long)theBrush
->GetColour().Green()));
1501 expr
->Append(new wxExpr((long)theBrush
->GetColour().Blue()));
1503 else if (obj
->IsKindOf(CLASSINFO(wxFont
)))
1505 wxFont
*theFont
= (wxFont
*)obj
;
1506 expr
= new wxExpr(wxExprList
);
1507 expr
->Append(new wxExpr((long)gyTYPE_FONT
));
1508 expr
->Append(new wxExpr((long)theFont
->GetPointSize()));
1509 expr
->Append(new wxExpr((long)theFont
->GetFamily()));
1510 expr
->Append(new wxExpr((long)theFont
->GetStyle()));
1511 expr
->Append(new wxExpr((long)theFont
->GetWeight()));
1512 expr
->Append(new wxExpr((long)theFont
->GetUnderlined()));
1517 // If no recognised GDI object, append a place holder anyway.
1518 expr
= new wxExpr(wxExprList
);
1519 expr
->Append(new wxExpr((long)0));
1524 clause
->AddAttributeValue(buf
, expr
);
1527 node
= node
->Next();
1530 // Write drawing operations
1532 node
= m_ops
.First();
1535 sprintf(buf
, "op%d_%d", whichAngle
, i
);
1536 wxDrawOp
*op
= (wxDrawOp
*)node
->Data();
1537 wxExpr
*expr
= op
->WriteExpr(this);
1540 clause
->AddAttributeValue(buf
, expr
);
1543 node
= node
->Next();
1546 // Write outline and fill GDI op lists (if any)
1547 if (m_outlineColours
.Number() > 0)
1549 wxExpr
*outlineExpr
= new wxExpr(wxExprList
);
1550 node
= m_outlineColours
.First();
1553 outlineExpr
->Append(new wxExpr((long)node
->Data()));
1554 node
= node
->Next();
1556 wxString outlineObjectsStr
;
1557 outlineObjectsStr
.Printf("outline_objects%d", whichAngle
);
1559 clause
->AddAttributeValue(outlineObjectsStr
, outlineExpr
);
1561 if (m_fillColours
.Number() > 0)
1563 wxExpr
*fillExpr
= new wxExpr(wxExprList
);
1564 node
= m_fillColours
.First();
1567 fillExpr
->Append(new wxExpr((long)node
->Data()));
1568 node
= node
->Next();
1570 wxString fillObjectsStr
;
1571 fillObjectsStr
.Printf("fill_objects%d", whichAngle
);
1573 clause
->AddAttributeValue(fillObjectsStr
, fillExpr
);
1578 void wxPseudoMetaFile::ReadAttributes(wxExpr
*clause
, int whichAngle
)
1581 widthStr
.Printf("meta_width%d", whichAngle
);
1584 heightStr
.Printf("meta_height%d", whichAngle
);
1586 wxString outlineStr
;
1587 outlineStr
.Printf("outline_op%d", whichAngle
);
1589 wxString rotateableStr
;
1590 rotateableStr
.Printf("meta_rotateable%d", whichAngle
);
1592 clause
->GetAttributeValue(widthStr
, m_width
);
1593 clause
->GetAttributeValue(heightStr
, m_height
);
1594 clause
->GetAttributeValue(outlineStr
, m_outlineOp
);
1596 int iVal
= (int) m_rotateable
;
1597 clause
->GetAttributeValue(rotateableStr
, iVal
);
1598 m_rotateable
= (iVal
!= 0);
1603 bool keepGoing
= TRUE
;
1606 sprintf(buf
, "gdi%d_%d", whichAngle
, i
);
1607 wxExpr
*expr
= NULL
;
1608 clause
->GetAttributeValue(buf
, &expr
);
1615 wxExpr
*idExpr
= expr
->Nth(0);
1616 switch (idExpr
->IntegerValue())
1620 int penWidth
= (int)expr
->Nth(1)->IntegerValue();
1621 int penStyle
= (int)expr
->Nth(2)->IntegerValue();
1622 int penRed
= (int)expr
->Nth(3)->IntegerValue();
1623 int penGreen
= (int)expr
->Nth(4)->IntegerValue();
1624 int penBlue
= (int)expr
->Nth(5)->IntegerValue();
1625 wxColour
col(penRed
, penGreen
, penBlue
);
1626 wxPen
*p
= wxThePenList
->FindOrCreatePen(col
, penWidth
, penStyle
);
1629 m_gdiObjects
.Append(p
);
1634 int brushStyle
= (int)expr
->Nth(1)->IntegerValue();
1635 int brushRed
= (int)expr
->Nth(2)->IntegerValue();
1636 int brushGreen
= (int)expr
->Nth(3)->IntegerValue();
1637 int brushBlue
= (int)expr
->Nth(4)->IntegerValue();
1638 wxColour
col(brushRed
, brushGreen
, brushBlue
);
1639 wxBrush
*b
= wxTheBrushList
->FindOrCreateBrush(col
, brushStyle
);
1642 m_gdiObjects
.Append(b
);
1647 int fontPointSize
= (int)expr
->Nth(1)->IntegerValue();
1648 int fontFamily
= (int)expr
->Nth(2)->IntegerValue();
1649 int fontStyle
= (int)expr
->Nth(3)->IntegerValue();
1650 int fontWeight
= (int)expr
->Nth(4)->IntegerValue();
1651 int fontUnderlined
= (int)expr
->Nth(5)->IntegerValue();
1652 m_gdiObjects
.Append(wxTheFontList
->FindOrCreateFont(fontPointSize
,
1653 fontFamily
, fontStyle
, fontWeight
, (fontUnderlined
!= 0)));
1659 m_gdiObjects
.Append(NULL
);
1667 // Now read in the operations
1672 sprintf(buf
, "op%d_%d", whichAngle
, i
);
1673 wxExpr
*expr
= NULL
;
1674 clause
->GetAttributeValue(buf
, &expr
);
1681 wxExpr
*idExpr
= expr
->Nth(0);
1682 int opId
= (int)idExpr
->IntegerValue();
1685 case DRAWOP_SET_PEN
:
1686 case DRAWOP_SET_BRUSH
:
1687 case DRAWOP_SET_FONT
:
1688 case DRAWOP_SET_TEXT_COLOUR
:
1689 case DRAWOP_SET_BK_COLOUR
:
1690 case DRAWOP_SET_BK_MODE
:
1692 wxOpSetGDI
*theOp
= new wxOpSetGDI(opId
, this, 0);
1693 theOp
->ReadExpr(this, expr
);
1694 m_ops
.Append(theOp
);
1698 case DRAWOP_SET_CLIPPING_RECT
:
1699 case DRAWOP_DESTROY_CLIPPING_RECT
:
1701 wxOpSetClipping
*theOp
= new wxOpSetClipping(opId
, 0.0, 0.0, 0.0, 0.0);
1702 theOp
->ReadExpr(this, expr
);
1703 m_ops
.Append(theOp
);
1707 case DRAWOP_DRAW_LINE
:
1708 case DRAWOP_DRAW_RECT
:
1709 case DRAWOP_DRAW_ROUNDED_RECT
:
1710 case DRAWOP_DRAW_ELLIPSE
:
1711 case DRAWOP_DRAW_POINT
:
1712 case DRAWOP_DRAW_ARC
:
1713 case DRAWOP_DRAW_TEXT
:
1715 wxOpDraw
*theOp
= new wxOpDraw(opId
, 0.0, 0.0, 0.0, 0.0);
1716 theOp
->ReadExpr(this, expr
);
1717 m_ops
.Append(theOp
);
1720 case DRAWOP_DRAW_SPLINE
:
1721 case DRAWOP_DRAW_POLYLINE
:
1722 case DRAWOP_DRAW_POLYGON
:
1724 wxOpPolyDraw
*theOp
= new wxOpPolyDraw(opId
, 0, NULL
);
1725 theOp
->ReadExpr(this, expr
);
1726 m_ops
.Append(theOp
);
1736 wxString outlineObjectsStr
;
1737 outlineObjectsStr
.Printf("outline_objects%d", whichAngle
);
1739 // Now read in the list of outline and fill operations, if any
1740 wxExpr
*expr1
= clause
->AttributeValue(outlineObjectsStr
);
1743 wxExpr
*eachExpr
= expr1
->GetFirst();
1746 m_outlineColours
.Append((wxObject
*)eachExpr
->IntegerValue());
1747 eachExpr
= eachExpr
->GetNext();
1751 wxString fillObjectsStr
;
1752 fillObjectsStr
.Printf("fill_objects%d", whichAngle
);
1754 expr1
= clause
->AttributeValue(fillObjectsStr
);
1757 wxExpr
*eachExpr
= expr1
->GetFirst();
1760 m_fillColours
.Append((wxObject
*)eachExpr
->IntegerValue());
1761 eachExpr
= eachExpr
->GetNext();
1767 // Does the copying for this object
1768 void wxPseudoMetaFile::Copy(wxPseudoMetaFile
& copy
)
1772 copy
.m_currentRotation
= m_currentRotation
;
1773 copy
.m_width
= m_width
;
1774 copy
.m_height
= m_height
;
1775 copy
.m_rotateable
= m_rotateable
;
1776 copy
.m_fillBrush
= m_fillBrush
;
1777 copy
.m_outlinePen
= m_outlinePen
;
1778 copy
.m_outlineOp
= m_outlineOp
;
1780 // Copy the GDI objects
1781 wxNode
*node
= m_gdiObjects
.First();
1784 wxObject
*obj
= (wxObject
*)node
->Data();
1785 copy
.m_gdiObjects
.Append(obj
);
1786 node
= node
->Next();
1789 // Copy the operations
1790 node
= m_ops
.First();
1793 wxDrawOp
*op
= (wxDrawOp
*)node
->Data();
1794 copy
.m_ops
.Append(op
->Copy(©
));
1795 node
= node
->Next();
1798 // Copy the outline/fill operations
1799 node
= m_outlineColours
.First();
1802 copy
.m_outlineColours
.Append((wxObject
*)node
->Data());
1803 node
= node
->Next();
1805 node
= m_fillColours
.First();
1808 copy
.m_fillColours
.Append((wxObject
*)node
->Data());
1809 node
= node
->Next();
1814 * Pass size of existing image; scale height to
1815 * fit width and return new width and height.
1819 bool wxPseudoMetaFile::LoadFromMetaFile(char *filename
, double *rwidth
, double *rheight
)
1821 if (!FileExists(filename
))
1824 wxXMetaFile
*metaFile
= new wxXMetaFile
;
1826 if (!metaFile
->ReadFile(filename
))
1835 // Convert from metafile records to wxDrawnShape records
1836 wxNode
*node
= metaFile
->metaRecords
.First();
1839 wxMetaRecord
*record
= (wxMetaRecord
*)node
->Data();
1840 switch (record
->metaFunction
)
1842 case META_SETBKCOLOR
:
1844 wxOpSetGDI
*op
= new wxOpSetGDI(DRAWOP_SET_BK_COLOUR
, this, 0);
1845 op
->m_r
= (unsigned char)record
->param1
;
1846 op
->m_g
= (unsigned char)record
->param2
;
1847 op
->m_b
= (unsigned char)record
->param3
;
1851 case META_SETBKMODE
:
1853 wxOpSetGDI
*op
= new wxOpSetGDI(DRAWOP_SET_BK_MODE
, this, 0, (int)record
->param1
);
1857 case META_SETMAPMODE
:
1861 // case META_SETROP2:
1862 // case META_SETRELABS:
1863 // case META_SETPOLYFILLMODE:
1864 // case META_SETSTRETCHBLTMODE:
1865 // case META_SETTEXTCHAREXTRA:
1866 case META_SETTEXTCOLOR
:
1868 wxOpSetGDI
*op
= new wxOpSetGDI(DRAWOP_SET_TEXT_COLOUR
, this, 0);
1869 op
->m_r
= (unsigned char)record
->param1
;
1870 op
->m_g
= (unsigned char)record
->param2
;
1871 op
->m_b
= (unsigned char)record
->param3
;
1875 // case META_SETTEXTJUSTIFICATION:
1876 // case META_SETWINDOWORG:
1877 // case META_SETWINDOWEXT:
1878 // case META_SETVIEWPORTORG:
1879 // case META_SETVIEWPORTEXT:
1880 // case META_OFFSETWINDOWORG:
1881 // case META_SCALEWINDOWEXT:
1882 // case META_OFFSETVIEWPORTORG:
1883 // case META_SCALEVIEWPORTEXT:
1886 wxOpDraw
*op
= new wxOpDraw(DRAWOP_DRAW_LINE
, (double)lastX
, (double)lastY
,
1887 (double)record
->param1
, (double)record
->param2
);
1893 lastX
= (double)record
->param1
;
1894 lastY
= (double)record
->param2
;
1897 case META_EXCLUDECLIPRECT
:
1900 wxMetaRecord *rec = new wxMetaRecord(META_EXCLUDECLIPRECT);
1901 rec->param4 = getshort(handle); // m_y2
1902 rec->param3 = getshort(handle); // x2
1903 rec->param2 = getshort(handle); // y1
1904 rec->param1 = getshort(handle); // x1
1908 case META_INTERSECTCLIPRECT
:
1911 rec->param4 = getshort(handle); // m_y2
1912 rec->param3 = getshort(handle); // x2
1913 rec->param2 = getshort(handle); // y1
1914 rec->param1 = getshort(handle); // x1
1918 // case META_ARC: // DO!!!
1921 wxOpDraw
*op
= new wxOpDraw(DRAWOP_DRAW_ELLIPSE
,
1922 (double)record
->param1
, (double)record
->param2
,
1923 (double)(record
->param3
- record
->param1
),
1924 (double)(record
->param4
- record
->param2
));
1928 // case META_FLOODFILL:
1929 // case META_PIE: // DO!!!
1930 case META_RECTANGLE
:
1932 wxOpDraw
*op
= new wxOpDraw(DRAWOP_DRAW_RECT
,
1933 (double)record
->param1
, (double)record
->param2
,
1934 (double)(record
->param3
- record
->param1
),
1935 (double)(record
->param4
- record
->param2
));
1939 case META_ROUNDRECT
:
1941 wxOpDraw
*op
= new wxOpDraw(DRAWOP_DRAW_ROUNDED_RECT
,
1942 (double)record
->param1
, (double)record
->param2
,
1943 (double)(record
->param3
- record
->param1
),
1944 (double)(record
->param4
- record
->param2
), (double)record
->param5
);
1948 // case META_PATBLT:
1949 // case META_SAVEDC:
1952 wxOpDraw
*op
= new wxOpDraw(DRAWOP_DRAW_POINT
,
1953 (double)record
->param1
, (double)record
->param2
,
1956 // SHOULD SET THE COLOUR - SET PEN?
1957 // rec->param3 = getint(handle); // COLORREF
1961 // case META_OFFSETCLIPRGN:
1964 wxOpDraw
*op
= new wxOpDraw(DRAWOP_DRAW_TEXT
,
1965 (double)record
->param1
, (double)record
->param2
,
1966 0.0, 0.0, 0.0, record
->stringParam
);
1970 // case META_BITBLT:
1971 // case META_STRETCHBLT:
1974 int n
= (int)record
->param1
;
1975 wxRealPoint
*newPoints
= new wxRealPoint
[n
];
1976 for (int i
= 0; i
< n
; i
++)
1978 newPoints
[i
].x
= record
->points
[i
].x
;
1979 newPoints
[i
].y
= record
->points
[i
].y
;
1982 wxOpPolyDraw
*op
= new wxOpPolyDraw(DRAWOP_DRAW_POLYGON
, n
, newPoints
);
1988 int n
= (int)record
->param1
;
1989 wxRealPoint
*newPoints
= new wxRealPoint
[n
];
1990 for (int i
= 0; i
< n
; i
++)
1992 newPoints
[i
].x
= record
->points
[i
].x
;
1993 newPoints
[i
].y
= record
->points
[i
].y
;
1996 wxOpPolyDraw
*op
= new wxOpPolyDraw(DRAWOP_DRAW_POLYLINE
, n
, newPoints
);
2000 // case META_ESCAPE:
2001 // case META_RESTOREDC:
2002 // case META_FILLREGION:
2003 // case META_FRAMEREGION:
2004 // case META_INVERTREGION:
2005 // case META_PAINTREGION:
2006 // case META_SELECTCLIPREGION: // DO THIS!
2007 case META_SELECTOBJECT
:
2009 // The pen, brush etc. has already been created when the metafile
2010 // was read in, so we don't create it - we set it.
2011 wxNode
*recNode
= metaFile
->gdiObjects
.Nth((int)record
->param2
);
2014 wxMetaRecord
*gdiRec
= (wxMetaRecord
*)recNode
->Data();
2015 if (gdiRec
&& (gdiRec
->param1
!= 0))
2017 wxObject
*obj
= (wxObject
*)gdiRec
->param1
;
2018 if (obj
->IsKindOf(CLASSINFO(wxPen
)))
2020 wxOpSetGDI
*op
= new wxOpSetGDI(DRAWOP_SET_PEN
, this, (int)record
->param2
);
2023 else if (obj
->IsKindOf(CLASSINFO(wxBrush
)))
2025 wxOpSetGDI
*op
= new wxOpSetGDI(DRAWOP_SET_BRUSH
, this, (int)record
->param2
);
2028 else if (obj
->IsKindOf(CLASSINFO(wxFont
)))
2030 wxOpSetGDI
*op
= new wxOpSetGDI(DRAWOP_SET_FONT
, this, (int)record
->param2
);
2037 // case META_SETTEXTALIGN:
2038 // case META_DRAWTEXT:
2040 // case META_SETMAPPERFLAGS:
2041 // case META_EXTTEXTOUT:
2042 // case META_SETDIBTODEV:
2043 // case META_SELECTPALETTE:
2044 // case META_REALIZEPALETTE:
2045 // case META_ANIMATEPALETTE:
2046 // case META_SETPALENTRIES:
2047 // case META_POLYPOLYGON:
2048 // case META_RESIZEPALETTE:
2049 // case META_DIBBITBLT:
2050 // case META_DIBSTRETCHBLT:
2051 case META_DIBCREATEPATTERNBRUSH
:
2054 m_gdiObjects
.Append(NULL
);
2057 // case META_STRETCHDIB:
2058 // case META_EXTFLOODFILL:
2059 // case META_RESETDC:
2060 // case META_STARTDOC:
2061 // case META_STARTPAGE:
2062 // case META_ENDPAGE:
2063 // case META_ABORTDOC:
2064 // case META_ENDDOC:
2065 // case META_DELETEOBJECT: // DO!!
2066 case META_CREATEPALETTE
:
2069 m_gdiObjects
.Append(NULL
);
2072 case META_CREATEBRUSH
:
2075 m_gdiObjects
.Append(NULL
);
2078 case META_CREATEPATTERNBRUSH
:
2081 m_gdiObjects
.Append(NULL
);
2084 case META_CREATEPENINDIRECT
:
2086 // The pen is created when the metafile is read in.
2087 // We keep track of all the GDI objects needed for this
2088 // image so when reading the wxDrawnShape from file,
2089 // we can read in all the GDI objects, then refer
2090 // to them by an index starting from zero thereafter.
2091 m_gdiObjects
.Append((wxObject
*)record
->param1
);
2094 case META_CREATEFONTINDIRECT
:
2096 m_gdiObjects
.Append((wxObject
*)record
->param1
);
2099 case META_CREATEBRUSHINDIRECT
:
2101 // Don't have to do anything here: the pen is created
2102 // when the metafile is read in.
2103 m_gdiObjects
.Append((wxObject
*)record
->param1
);
2106 case META_CREATEBITMAPINDIRECT
:
2109 m_gdiObjects
.Append(NULL
);
2112 case META_CREATEBITMAP
:
2115 m_gdiObjects
.Append(NULL
);
2118 case META_CREATEREGION
:
2121 m_gdiObjects
.Append(NULL
);
2129 node
= node
->Next();
2131 double actualWidth
= (double)fabs(metaFile
->right
- metaFile
->left
);
2132 double actualHeight
= (double)fabs(metaFile
->bottom
- metaFile
->top
);
2134 double initialScaleX
= 1.0;
2135 double initialScaleY
= 1.0;
2137 double xoffset
, yoffset
;
2139 // Translate so origin is at centre of rectangle
2140 if (metaFile
->bottom
> metaFile
->top
)
2141 yoffset
= - (double)((metaFile
->bottom
- metaFile
->top
)/2.0);
2143 yoffset
= - (double)((metaFile
->top
- metaFile
->bottom
)/2.0);
2145 if (metaFile
->right
> metaFile
->left
)
2146 xoffset
= - (double)((metaFile
->right
- metaFile
->left
)/2.0);
2148 xoffset
= - (double)((metaFile
->left
- metaFile
->right
)/2.0);
2150 Translate(xoffset
, yoffset
);
2152 // Scale to a reasonable size (take the width of this wxDrawnShape
2154 if (actualWidth
!= 0.0)
2156 initialScaleX
= (double)((*rwidth
) / actualWidth
);
2157 initialScaleY
= initialScaleX
;
2158 (*rheight
) = initialScaleY
*actualHeight
;
2160 Scale(initialScaleX
, initialScaleY
);
2162 m_width
= (actualWidth
*initialScaleX
);
2163 m_height
= *rheight
;
2169 // Scale to fit size
2170 void wxPseudoMetaFile::ScaleTo(double w
, double h
)
2172 double scaleX
= (double)(w
/m_width
);
2173 double scaleY
= (double)(h
/m_height
);
2176 Scale(scaleX
, scaleY
);
2179 void wxPseudoMetaFile::GetBounds(double *boundMinX
, double *boundMinY
, double *boundMaxX
, double *boundMaxY
)
2181 double maxX
= (double) -99999.9;
2182 double maxY
= (double) -99999.9;
2183 double minX
= (double) 99999.9;
2184 double minY
= (double) 99999.9;
2186 wxNode
*node
= m_ops
.First();
2189 wxDrawOp
*op
= (wxDrawOp
*)node
->Data();
2190 switch (op
->GetOp())
2192 case DRAWOP_DRAW_LINE
:
2193 case DRAWOP_DRAW_RECT
:
2194 case DRAWOP_DRAW_ROUNDED_RECT
:
2195 case DRAWOP_DRAW_ELLIPSE
:
2196 case DRAWOP_DRAW_POINT
:
2197 case DRAWOP_DRAW_TEXT
:
2199 wxOpDraw
*opDraw
= (wxOpDraw
*)op
;
2200 if (opDraw
->m_x1
< minX
) minX
= opDraw
->m_x1
;
2201 if (opDraw
->m_x1
> maxX
) maxX
= opDraw
->m_x1
;
2202 if (opDraw
->m_y1
< minY
) minY
= opDraw
->m_y1
;
2203 if (opDraw
->m_y1
> maxY
) maxY
= opDraw
->m_y1
;
2204 if (op
->GetOp() == DRAWOP_DRAW_LINE
)
2206 if (opDraw
->m_x2
< minX
) minX
= opDraw
->m_x2
;
2207 if (opDraw
->m_x2
> maxX
) maxX
= opDraw
->m_x2
;
2208 if (opDraw
->m_y2
< minY
) minY
= opDraw
->m_y2
;
2209 if (opDraw
->m_y2
> maxY
) maxY
= opDraw
->m_y2
;
2211 else if (op
->GetOp() == DRAWOP_DRAW_RECT
||
2212 op
->GetOp() == DRAWOP_DRAW_ROUNDED_RECT
||
2213 op
->GetOp() == DRAWOP_DRAW_ELLIPSE
)
2215 if ((opDraw
->m_x1
+ opDraw
->m_x2
) < minX
) minX
= (opDraw
->m_x1
+ opDraw
->m_x2
);
2216 if ((opDraw
->m_x1
+ opDraw
->m_x2
) > maxX
) maxX
= (opDraw
->m_x1
+ opDraw
->m_x2
);
2217 if ((opDraw
->m_y1
+ opDraw
->m_y2
) < minY
) minY
= (opDraw
->m_y1
+ opDraw
->m_y2
);
2218 if ((opDraw
->m_y1
+ opDraw
->m_y2
) > maxY
) maxY
= (opDraw
->m_y1
+ opDraw
->m_y2
);
2222 case DRAWOP_DRAW_ARC
:
2224 // TODO: don't yet know how to calculate the bounding box
2225 // for an arc. So pretend it's a line; to get a correct
2226 // bounding box, draw a blank rectangle first, of the correct
2228 wxOpDraw
*opDraw
= (wxOpDraw
*)op
;
2229 if (opDraw
->m_x1
< minX
) minX
= opDraw
->m_x1
;
2230 if (opDraw
->m_x1
> maxX
) maxX
= opDraw
->m_x1
;
2231 if (opDraw
->m_y1
< minY
) minY
= opDraw
->m_y1
;
2232 if (opDraw
->m_y1
> maxY
) maxY
= opDraw
->m_y1
;
2233 if (opDraw
->m_x2
< minX
) minX
= opDraw
->m_x2
;
2234 if (opDraw
->m_x2
> maxX
) maxX
= opDraw
->m_x2
;
2235 if (opDraw
->m_y2
< minY
) minY
= opDraw
->m_y2
;
2236 if (opDraw
->m_y2
> maxY
) maxY
= opDraw
->m_y2
;
2239 case DRAWOP_DRAW_POLYLINE
:
2240 case DRAWOP_DRAW_POLYGON
:
2241 case DRAWOP_DRAW_SPLINE
:
2243 wxOpPolyDraw
*poly
= (wxOpPolyDraw
*)op
;
2244 for (int i
= 0; i
< poly
->m_noPoints
; i
++)
2246 if (poly
->m_points
[i
].x
< minX
) minX
= poly
->m_points
[i
].x
;
2247 if (poly
->m_points
[i
].x
> maxX
) maxX
= poly
->m_points
[i
].x
;
2248 if (poly
->m_points
[i
].y
< minY
) minY
= poly
->m_points
[i
].y
;
2249 if (poly
->m_points
[i
].y
> maxY
) maxY
= poly
->m_points
[i
].y
;
2256 node
= node
->Next();
2264 *w = (double)fabs(maxX - minX);
2265 *h = (double)fabs(maxY - minY);
2269 // Calculate size from current operations
2270 void wxPseudoMetaFile::CalculateSize(wxDrawnShape
* shape
)
2272 double boundMinX
, boundMinY
, boundMaxX
, boundMaxY
;
2274 GetBounds(& boundMinX
, & boundMinY
, & boundMaxX
, & boundMaxY
);
2276 SetSize(boundMaxX
- boundMinX
, boundMaxY
- boundMinY
);
2280 shape
->SetWidth(m_width
);
2281 shape
->SetHeight(m_height
);
2285 // Set of functions for drawing into a pseudo metafile.
2286 // They use integers, but doubles are used internally for accuracy
2289 void wxPseudoMetaFile::DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
2291 wxOpDraw
*theOp
= new wxOpDraw(DRAWOP_DRAW_LINE
,
2292 (double) pt1
.x
, (double) pt1
.y
, (double) pt2
.x
, (double) pt2
.y
);
2294 m_ops
.Append(theOp
);
2297 void wxPseudoMetaFile::DrawRectangle(const wxRect
& rect
)
2299 wxOpDraw
*theOp
= new wxOpDraw(DRAWOP_DRAW_RECT
,
2300 (double) rect
.x
, (double) rect
.y
, (double) rect
.width
, (double) rect
.height
);
2302 m_ops
.Append(theOp
);
2305 void wxPseudoMetaFile::DrawRoundedRectangle(const wxRect
& rect
, double radius
)
2307 wxOpDraw
*theOp
= new wxOpDraw(DRAWOP_DRAW_ROUNDED_RECT
,
2308 (double) rect
.x
, (double) rect
.y
, (double) rect
.width
, (double) rect
.height
);
2310 theOp
->m_radius
= radius
;
2312 m_ops
.Append(theOp
);
2315 void wxPseudoMetaFile::DrawEllipse(const wxRect
& rect
)
2317 wxOpDraw
*theOp
= new wxOpDraw(DRAWOP_DRAW_ELLIPSE
,
2318 (double) rect
.x
, (double) rect
.y
, (double) rect
.width
, (double) rect
.height
);
2320 m_ops
.Append(theOp
);
2323 void wxPseudoMetaFile::DrawArc(const wxPoint
& centrePt
, const wxPoint
& startPt
, const wxPoint
& endPt
)
2325 wxOpDraw
*theOp
= new wxOpDraw(DRAWOP_DRAW_ARC
,
2326 (double) centrePt
.x
, (double) centrePt
.y
, (double) startPt
.x
, (double) startPt
.y
);
2328 theOp
->m_x3
= (double) endPt
.x
;
2329 theOp
->m_y3
= (double) endPt
.y
;
2331 m_ops
.Append(theOp
);
2334 void wxPseudoMetaFile::DrawEllipticArc(const wxRect
& rect
, double startAngle
, double endAngle
)
2336 const double pi
= 3.1415926535897932384626433832795 ;
2338 double startAngleRadians
= startAngle
* (pi
*2.0/360.0);
2339 double endAngleRadians
= endAngle
* (pi
*2.0/360.0);
2341 wxOpDraw
*theOp
= new wxOpDraw(DRAWOP_DRAW_ELLIPTIC_ARC
,
2342 (double) rect
.x
, (double) rect
.y
, (double) rect
.width
, (double) rect
.height
);
2344 theOp
->m_x3
= startAngleRadians
;
2345 theOp
->m_y3
= endAngleRadians
;
2347 m_ops
.Append(theOp
);
2350 void wxPseudoMetaFile::DrawPoint(const wxPoint
& pt
)
2352 wxOpDraw
*theOp
= new wxOpDraw(DRAWOP_DRAW_POINT
,
2353 (double) pt
.x
, (double) pt
.y
, 0.0, 0.0);
2355 m_ops
.Append(theOp
);
2358 void wxPseudoMetaFile::DrawText(const wxString
& text
, const wxPoint
& pt
)
2360 wxOpDraw
*theOp
= new wxOpDraw(DRAWOP_DRAW_TEXT
,
2361 (double) pt
.x
, (double) pt
.y
, 0.0, 0.0);
2363 theOp
->m_textString
= copystring(text
);
2365 m_ops
.Append(theOp
);
2368 void wxPseudoMetaFile::DrawLines(int n
, wxPoint pts
[])
2370 wxRealPoint
* realPoints
= new wxRealPoint
[n
];
2372 for (i
= 0; i
< n
; i
++)
2374 realPoints
[i
].x
= pts
[i
].x
;
2375 realPoints
[i
].y
= pts
[i
].y
;
2377 wxOpPolyDraw
* theOp
= new wxOpPolyDraw(DRAWOP_DRAW_POLYLINE
, n
, realPoints
);
2378 m_ops
.Append(theOp
);
2381 void wxPseudoMetaFile::DrawPolygon(int n
, wxPoint pts
[], int flags
)
2383 wxRealPoint
* realPoints
= new wxRealPoint
[n
];
2385 for (i
= 0; i
< n
; i
++)
2387 realPoints
[i
].x
= pts
[i
].x
;
2388 realPoints
[i
].y
= pts
[i
].y
;
2390 wxOpPolyDraw
* theOp
= new wxOpPolyDraw(DRAWOP_DRAW_POLYGON
, n
, realPoints
);
2391 m_ops
.Append(theOp
);
2393 if (flags
& oglMETAFLAGS_OUTLINE
)
2394 m_outlineOp
= (m_ops
.Number() - 1);
2397 void wxPseudoMetaFile::DrawSpline(int n
, wxPoint pts
[])
2399 wxRealPoint
* realPoints
= new wxRealPoint
[n
];
2401 for (i
= 0; i
< n
; i
++)
2403 realPoints
[i
].x
= pts
[i
].x
;
2404 realPoints
[i
].y
= pts
[i
].y
;
2406 wxOpPolyDraw
* theOp
= new wxOpPolyDraw(DRAWOP_DRAW_SPLINE
, n
, realPoints
);
2407 m_ops
.Append(theOp
);
2410 void wxPseudoMetaFile::SetClippingRect(const wxRect
& rect
)
2412 wxOpSetClipping
* theOp
= new wxOpSetClipping(DRAWOP_SET_CLIPPING_RECT
,
2413 (double) rect
.x
, (double) rect
.y
, (double) rect
.width
, (double) rect
.height
);
2416 void wxPseudoMetaFile::DestroyClippingRect()
2418 wxOpSetClipping
* theOp
= new wxOpSetClipping(DRAWOP_DESTROY_CLIPPING_RECT
,
2419 0.0, 0.0, 0.0, 0.0);
2421 m_ops
.Append(theOp
);
2424 void wxPseudoMetaFile::SetPen(wxPen
* pen
, bool isOutline
)
2426 m_gdiObjects
.Append(pen
);
2427 int n
= m_gdiObjects
.Number();
2429 wxOpSetGDI
* theOp
= new wxOpSetGDI(DRAWOP_SET_PEN
, this, n
- 1);
2431 m_ops
.Append(theOp
);
2435 m_outlineColours
.Append((wxObject
*) (n
- 1));
2439 void wxPseudoMetaFile::SetBrush(wxBrush
* brush
, bool isFill
)
2441 m_gdiObjects
.Append(brush
);
2442 int n
= m_gdiObjects
.Number();
2444 wxOpSetGDI
* theOp
= new wxOpSetGDI(DRAWOP_SET_BRUSH
, this, n
- 1);
2446 m_ops
.Append(theOp
);
2450 m_fillColours
.Append((wxObject
*) (n
- 1));
2454 void wxPseudoMetaFile::SetFont(wxFont
* font
)
2456 m_gdiObjects
.Append(font
);
2457 int n
= m_gdiObjects
.Number();
2459 wxOpSetGDI
* theOp
= new wxOpSetGDI(DRAWOP_SET_FONT
, this, n
- 1);
2461 m_ops
.Append(theOp
);
2464 void wxPseudoMetaFile::SetTextColour(const wxColour
& colour
)
2466 wxOpSetGDI
* theOp
= new wxOpSetGDI(DRAWOP_SET_TEXT_COLOUR
, this, 0);
2467 theOp
->m_r
= colour
.Red();
2468 theOp
->m_g
= colour
.Green();
2469 theOp
->m_b
= colour
.Blue();
2471 m_ops
.Append(theOp
);
2474 void wxPseudoMetaFile::SetBackgroundColour(const wxColour
& colour
)
2476 wxOpSetGDI
* theOp
= new wxOpSetGDI(DRAWOP_SET_BK_COLOUR
, this, 0);
2477 theOp
->m_r
= colour
.Red();
2478 theOp
->m_g
= colour
.Green();
2479 theOp
->m_b
= colour
.Blue();
2481 m_ops
.Append(theOp
);
2484 void wxPseudoMetaFile::SetBackgroundMode(int mode
)
2486 wxOpSetGDI
* theOp
= new wxOpSetGDI(DRAWOP_SET_BK_MODE
, this, 0, mode
);
2488 m_ops
.Append(theOp
);