1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/private/graphics.h
3 // Purpose: private graphics context header
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
8 // RCS-ID: $Id: graphics.h 50348 2007-11-30 13:48:22Z RR $
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GRAPHICS_PRIVATE_H_
13 #define _WX_GRAPHICS_PRIVATE_H_
15 #if wxUSE_GRAPHICS_CONTEXT
17 #include "wx/graphics.h"
19 class WXDLLIMPEXP_CORE wxGraphicsObjectRefData
: public wxObjectRefData
22 wxGraphicsObjectRefData( wxGraphicsRenderer
* renderer
);
23 wxGraphicsObjectRefData( const wxGraphicsObjectRefData
* data
);
24 wxGraphicsRenderer
* GetRenderer() const ;
25 virtual wxGraphicsObjectRefData
* Clone() const ;
28 wxGraphicsRenderer
* m_renderer
;
31 class WXDLLIMPEXP_CORE wxGraphicsMatrixData
: public wxGraphicsObjectRefData
34 wxGraphicsMatrixData( wxGraphicsRenderer
* renderer
) :
35 wxGraphicsObjectRefData(renderer
) {}
37 virtual ~wxGraphicsMatrixData() {}
39 // concatenates the matrix
40 virtual void Concat( const wxGraphicsMatrixData
*t
) = 0;
42 // sets the matrix to the respective values
43 virtual void Set(wxDouble a
=1.0, wxDouble b
=0.0, wxDouble c
=0.0, wxDouble d
=1.0,
44 wxDouble tx
=0.0, wxDouble ty
=0.0) = 0;
46 // gets the component valuess of the matrix
47 virtual void Get(wxDouble
* a
=NULL
, wxDouble
* b
=NULL
, wxDouble
* c
=NULL
,
48 wxDouble
* d
=NULL
, wxDouble
* tx
=NULL
, wxDouble
* ty
=NULL
) const = 0;
50 // makes this the inverse matrix
51 virtual void Invert() = 0;
53 // returns true if the elements of the transformation matrix are equal ?
54 virtual bool IsEqual( const wxGraphicsMatrixData
* t
) const = 0;
56 // return true if this is the identity matrix
57 virtual bool IsIdentity() const = 0;
63 // add the translation to this matrix
64 virtual void Translate( wxDouble dx
, wxDouble dy
) = 0;
66 // add the scale to this matrix
67 virtual void Scale( wxDouble xScale
, wxDouble yScale
) = 0;
69 // add the rotation to this matrix (radians)
70 virtual void Rotate( wxDouble angle
) = 0;
73 // apply the transforms
76 // applies that matrix to the point
77 virtual void TransformPoint( wxDouble
*x
, wxDouble
*y
) const = 0;
79 // applies the matrix except for translations
80 virtual void TransformDistance( wxDouble
*dx
, wxDouble
*dy
) const =0;
82 // returns the native representation
83 virtual void * GetNativeMatrix() const = 0;
86 class WXDLLIMPEXP_CORE wxGraphicsPathData
: public wxGraphicsObjectRefData
89 wxGraphicsPathData(wxGraphicsRenderer
* renderer
) : wxGraphicsObjectRefData(renderer
) {}
90 virtual ~wxGraphicsPathData() {}
93 // These are the path primitives from which everything else can be constructed
96 // begins a new subpath at (x,y)
97 virtual void MoveToPoint( wxDouble x
, wxDouble y
) = 0;
99 // adds a straight line from the current point to (x,y)
100 virtual void AddLineToPoint( wxDouble x
, wxDouble y
) = 0;
102 // adds a cubic Bezier curve from the current point, using two control points and an end point
103 virtual void AddCurveToPoint( wxDouble cx1
, wxDouble cy1
, wxDouble cx2
, wxDouble cy2
, wxDouble x
, wxDouble y
) = 0;
106 virtual void AddPath( const wxGraphicsPathData
* path
) =0;
108 // closes the current sub-path
109 virtual void CloseSubpath() = 0;
111 // gets the last point of the current path, (0,0) if not yet set
112 virtual void GetCurrentPoint( wxDouble
* x
, wxDouble
* y
) const = 0;
114 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
115 virtual void AddArc( wxDouble x
, wxDouble y
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
) = 0;
118 // These are convenience functions which - if not available natively will be assembled
119 // using the primitives from above
122 // adds a quadratic Bezier curve from the current point, using a control point and an end point
123 virtual void AddQuadCurveToPoint( wxDouble cx
, wxDouble cy
, wxDouble x
, wxDouble y
);
125 // appends a rectangle as a new closed subpath
126 virtual void AddRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
128 // appends an ellipsis as a new closed subpath fitting the passed rectangle
129 virtual void AddCircle( wxDouble x
, wxDouble y
, wxDouble r
);
131 // appends a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1)
132 virtual void AddArcToPoint( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
, wxDouble r
) ;
134 // appends an ellipse
135 virtual void AddEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
137 // appends a rounded rectangle
138 virtual void AddRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
);
140 // returns the native path
141 virtual void * GetNativePath() const = 0;
143 // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
144 virtual void UnGetNativePath(void *p
) const= 0;
146 // transforms each point of this path by the matrix
147 virtual void Transform( const wxGraphicsMatrixData
* matrix
) =0;
149 // gets the bounding box enclosing all points (possibly including control points)
150 virtual void GetBox(wxDouble
*x
, wxDouble
*y
, wxDouble
*w
, wxDouble
*h
) const=0;
152 virtual bool Contains( wxDouble x
, wxDouble y
, wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) const=0;
157 #endif // _WX_GRAPHICS_PRIVATE_H_