1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/private/graphics.h
3 // Purpose: private graphics context header
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_GRAPHICS_PRIVATE_H_
12 #define _WX_GRAPHICS_PRIVATE_H_
14 #if wxUSE_GRAPHICS_CONTEXT
16 #include "wx/graphics.h"
18 class WXDLLIMPEXP_CORE wxGraphicsObjectRefData
: public wxObjectRefData
21 wxGraphicsObjectRefData( wxGraphicsRenderer
* renderer
);
22 wxGraphicsObjectRefData( const wxGraphicsObjectRefData
* data
);
23 wxGraphicsRenderer
* GetRenderer() const ;
24 virtual wxGraphicsObjectRefData
* Clone() const ;
27 wxGraphicsRenderer
* m_renderer
;
30 class WXDLLIMPEXP_CORE wxGraphicsBitmapData
: public wxGraphicsObjectRefData
33 wxGraphicsBitmapData( wxGraphicsRenderer
* renderer
) :
34 wxGraphicsObjectRefData(renderer
) {}
36 virtual ~wxGraphicsBitmapData() {}
38 // returns the native representation
39 virtual void * GetNativeBitmap() const = 0;
42 class WXDLLIMPEXP_CORE wxGraphicsMatrixData
: public wxGraphicsObjectRefData
45 wxGraphicsMatrixData( wxGraphicsRenderer
* renderer
) :
46 wxGraphicsObjectRefData(renderer
) {}
48 virtual ~wxGraphicsMatrixData() {}
50 // concatenates the matrix
51 virtual void Concat( const wxGraphicsMatrixData
*t
) = 0;
53 // sets the matrix to the respective values
54 virtual void Set(wxDouble a
=1.0, wxDouble b
=0.0, wxDouble c
=0.0, wxDouble d
=1.0,
55 wxDouble tx
=0.0, wxDouble ty
=0.0) = 0;
57 // gets the component valuess of the matrix
58 virtual void Get(wxDouble
* a
=NULL
, wxDouble
* b
=NULL
, wxDouble
* c
=NULL
,
59 wxDouble
* d
=NULL
, wxDouble
* tx
=NULL
, wxDouble
* ty
=NULL
) const = 0;
61 // makes this the inverse matrix
62 virtual void Invert() = 0;
64 // returns true if the elements of the transformation matrix are equal ?
65 virtual bool IsEqual( const wxGraphicsMatrixData
* t
) const = 0;
67 // return true if this is the identity matrix
68 virtual bool IsIdentity() const = 0;
74 // add the translation to this matrix
75 virtual void Translate( wxDouble dx
, wxDouble dy
) = 0;
77 // add the scale to this matrix
78 virtual void Scale( wxDouble xScale
, wxDouble yScale
) = 0;
80 // add the rotation to this matrix (radians)
81 virtual void Rotate( wxDouble angle
) = 0;
84 // apply the transforms
87 // applies that matrix to the point
88 virtual void TransformPoint( wxDouble
*x
, wxDouble
*y
) const = 0;
90 // applies the matrix except for translations
91 virtual void TransformDistance( wxDouble
*dx
, wxDouble
*dy
) const =0;
93 // returns the native representation
94 virtual void * GetNativeMatrix() const = 0;
97 class WXDLLIMPEXP_CORE wxGraphicsPathData
: public wxGraphicsObjectRefData
100 wxGraphicsPathData(wxGraphicsRenderer
* renderer
) : wxGraphicsObjectRefData(renderer
) {}
101 virtual ~wxGraphicsPathData() {}
104 // These are the path primitives from which everything else can be constructed
107 // begins a new subpath at (x,y)
108 virtual void MoveToPoint( wxDouble x
, wxDouble y
) = 0;
110 // adds a straight line from the current point to (x,y)
111 virtual void AddLineToPoint( wxDouble x
, wxDouble y
) = 0;
113 // adds a cubic Bezier curve from the current point, using two control points and an end point
114 virtual void AddCurveToPoint( wxDouble cx1
, wxDouble cy1
, wxDouble cx2
, wxDouble cy2
, wxDouble x
, wxDouble y
) = 0;
117 virtual void AddPath( const wxGraphicsPathData
* path
) =0;
119 // closes the current sub-path
120 virtual void CloseSubpath() = 0;
122 // gets the last point of the current path, (0,0) if not yet set
123 virtual void GetCurrentPoint( wxDouble
* x
, wxDouble
* y
) const = 0;
125 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
126 virtual void AddArc( wxDouble x
, wxDouble y
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
) = 0;
129 // These are convenience functions which - if not available natively will be assembled
130 // using the primitives from above
133 // adds a quadratic Bezier curve from the current point, using a control point and an end point
134 virtual void AddQuadCurveToPoint( wxDouble cx
, wxDouble cy
, wxDouble x
, wxDouble y
);
136 // appends a rectangle as a new closed subpath
137 virtual void AddRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
139 // appends an ellipsis as a new closed subpath fitting the passed rectangle
140 virtual void AddCircle( wxDouble x
, wxDouble y
, wxDouble r
);
142 // 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)
143 virtual void AddArcToPoint( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
, wxDouble r
) ;
145 // appends an ellipse
146 virtual void AddEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
148 // appends a rounded rectangle
149 virtual void AddRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
);
151 // returns the native path
152 virtual void * GetNativePath() const = 0;
154 // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
155 virtual void UnGetNativePath(void *p
) const= 0;
157 // transforms each point of this path by the matrix
158 virtual void Transform( const wxGraphicsMatrixData
* matrix
) =0;
160 // gets the bounding box enclosing all points (possibly including control points)
161 virtual void GetBox(wxDouble
*x
, wxDouble
*y
, wxDouble
*w
, wxDouble
*h
) const=0;
163 virtual bool Contains( wxDouble x
, wxDouble y
, wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) const=0;
168 #endif // _WX_GRAPHICS_PRIVATE_H_