1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/private/graphics.h
3 // Purpose: private graphics context header
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
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 wxGraphicsBitmapData
: public wxGraphicsObjectRefData
34 wxGraphicsBitmapData( wxGraphicsRenderer
* renderer
) :
35 wxGraphicsObjectRefData(renderer
) {}
37 virtual ~wxGraphicsBitmapData() {}
39 // returns the native representation
40 virtual void * GetNativeBitmap() const = 0;
43 class WXDLLIMPEXP_CORE wxGraphicsMatrixData
: public wxGraphicsObjectRefData
46 wxGraphicsMatrixData( wxGraphicsRenderer
* renderer
) :
47 wxGraphicsObjectRefData(renderer
) {}
49 virtual ~wxGraphicsMatrixData() {}
51 // concatenates the matrix
52 virtual void Concat( const wxGraphicsMatrixData
*t
) = 0;
54 // sets the matrix to the respective values
55 virtual void Set(wxDouble a
=1.0, wxDouble b
=0.0, wxDouble c
=0.0, wxDouble d
=1.0,
56 wxDouble tx
=0.0, wxDouble ty
=0.0) = 0;
58 // gets the component valuess of the matrix
59 virtual void Get(wxDouble
* a
=NULL
, wxDouble
* b
=NULL
, wxDouble
* c
=NULL
,
60 wxDouble
* d
=NULL
, wxDouble
* tx
=NULL
, wxDouble
* ty
=NULL
) const = 0;
62 // makes this the inverse matrix
63 virtual void Invert() = 0;
65 // returns true if the elements of the transformation matrix are equal ?
66 virtual bool IsEqual( const wxGraphicsMatrixData
* t
) const = 0;
68 // return true if this is the identity matrix
69 virtual bool IsIdentity() const = 0;
75 // add the translation to this matrix
76 virtual void Translate( wxDouble dx
, wxDouble dy
) = 0;
78 // add the scale to this matrix
79 virtual void Scale( wxDouble xScale
, wxDouble yScale
) = 0;
81 // add the rotation to this matrix (radians)
82 virtual void Rotate( wxDouble angle
) = 0;
85 // apply the transforms
88 // applies that matrix to the point
89 virtual void TransformPoint( wxDouble
*x
, wxDouble
*y
) const = 0;
91 // applies the matrix except for translations
92 virtual void TransformDistance( wxDouble
*dx
, wxDouble
*dy
) const =0;
94 // returns the native representation
95 virtual void * GetNativeMatrix() const = 0;
98 class WXDLLIMPEXP_CORE wxGraphicsPathData
: public wxGraphicsObjectRefData
101 wxGraphicsPathData(wxGraphicsRenderer
* renderer
) : wxGraphicsObjectRefData(renderer
) {}
102 virtual ~wxGraphicsPathData() {}
105 // These are the path primitives from which everything else can be constructed
108 // begins a new subpath at (x,y)
109 virtual void MoveToPoint( wxDouble x
, wxDouble y
) = 0;
111 // adds a straight line from the current point to (x,y)
112 virtual void AddLineToPoint( wxDouble x
, wxDouble y
) = 0;
114 // adds a cubic Bezier curve from the current point, using two control points and an end point
115 virtual void AddCurveToPoint( wxDouble cx1
, wxDouble cy1
, wxDouble cx2
, wxDouble cy2
, wxDouble x
, wxDouble y
) = 0;
118 virtual void AddPath( const wxGraphicsPathData
* path
) =0;
120 // closes the current sub-path
121 virtual void CloseSubpath() = 0;
123 // gets the last point of the current path, (0,0) if not yet set
124 virtual void GetCurrentPoint( wxDouble
* x
, wxDouble
* y
) const = 0;
126 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
127 virtual void AddArc( wxDouble x
, wxDouble y
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
) = 0;
130 // These are convenience functions which - if not available natively will be assembled
131 // using the primitives from above
134 // adds a quadratic Bezier curve from the current point, using a control point and an end point
135 virtual void AddQuadCurveToPoint( wxDouble cx
, wxDouble cy
, wxDouble x
, wxDouble y
);
137 // appends a rectangle as a new closed subpath
138 virtual void AddRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
140 // appends an ellipsis as a new closed subpath fitting the passed rectangle
141 virtual void AddCircle( wxDouble x
, wxDouble y
, wxDouble r
);
143 // 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)
144 virtual void AddArcToPoint( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
, wxDouble r
) ;
146 // appends an ellipse
147 virtual void AddEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
149 // appends a rounded rectangle
150 virtual void AddRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
);
152 // returns the native path
153 virtual void * GetNativePath() const = 0;
155 // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
156 virtual void UnGetNativePath(void *p
) const= 0;
158 // transforms each point of this path by the matrix
159 virtual void Transform( const wxGraphicsMatrixData
* matrix
) =0;
161 // gets the bounding box enclosing all points (possibly including control points)
162 virtual void GetBox(wxDouble
*x
, wxDouble
*y
, wxDouble
*w
, wxDouble
*h
) const=0;
164 virtual bool Contains( wxDouble x
, wxDouble y
, wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) const=0;
169 #endif // _WX_GRAPHICS_PRIVATE_H_