wxMaxima
Loading...
Searching...
No Matches
private_graphics.h
1
2// Name: wx/private/graphics.h
3// Purpose: private graphics context header
4// Author: Stefan Csomor
5// Created:
6// Copyright: (c) Stefan Csomor
7// Licence: wxWindows licence
9
10#ifndef _WX_GRAPHICS_PRIVATE_H_
11#define _WX_GRAPHICS_PRIVATE_H_
12
13#if wxUSE_GRAPHICS_CONTEXT
14
15#include "wx/graphics.h"
16
17class WXDLLIMPEXP_CORE wxGraphicsObjectRefData : public wxObjectRefData
18{
19 public :
20 wxGraphicsObjectRefData( wxGraphicsRenderer* renderer );
21 wxGraphicsObjectRefData( const wxGraphicsObjectRefData* data );
22 wxGraphicsRenderer* GetRenderer() const ;
23 virtual wxGraphicsObjectRefData* Clone() const ;
24
25 protected :
26 wxGraphicsRenderer* m_renderer;
27} ;
28
29class WXDLLIMPEXP_CORE wxGraphicsBitmapData : public wxGraphicsObjectRefData
30{
31public :
32 wxGraphicsBitmapData( wxGraphicsRenderer* renderer) :
33 wxGraphicsObjectRefData(renderer) {}
34
35 virtual ~wxGraphicsBitmapData() = default;
36
37 // returns the native representation
38 virtual void * GetNativeBitmap() const = 0;
39} ;
40
41class WXDLLIMPEXP_CORE wxGraphicsMatrixData : public wxGraphicsObjectRefData
42{
43public :
44 wxGraphicsMatrixData( wxGraphicsRenderer* renderer) :
45 wxGraphicsObjectRefData(renderer) {}
46
47 virtual ~wxGraphicsMatrixData() = default;
48
49 // concatenates the matrix
50 virtual void Concat( const wxGraphicsMatrixData *t ) = 0;
51
52 // sets the matrix to the respective values
53 virtual void Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
54 wxDouble tx=0.0, wxDouble ty=0.0) = 0;
55
56 // gets the component values of the matrix
57 virtual void Get(wxDouble* a=nullptr, wxDouble* b=nullptr, wxDouble* c=nullptr,
58 wxDouble* d=nullptr, wxDouble* tx=nullptr, wxDouble* ty=nullptr) const = 0;
59
60 // makes this the inverse matrix
61 virtual void Invert() = 0;
62
63 // returns true if the elements of the transformation matrix are equal ?
64 virtual bool IsEqual( const wxGraphicsMatrixData* t) const = 0;
65
66 // return true if this is the identity matrix
67 virtual bool IsIdentity() const = 0;
68
69 //
70 // transformation
71 //
72
73 // add the translation to this matrix
74 virtual void Translate( wxDouble dx , wxDouble dy ) = 0;
75
76 // add the scale to this matrix
77 virtual void Scale( wxDouble xScale , wxDouble yScale ) = 0;
78
79 // add the rotation to this matrix (radians)
80 virtual void Rotate( wxDouble angle ) = 0;
81
82 //
83 // apply the transforms
84 //
85
86 // applies that matrix to the point
87 virtual void TransformPoint( wxDouble *x, wxDouble *y ) const = 0;
88
89 // applies the matrix except for translations
90 virtual void TransformDistance( wxDouble *dx, wxDouble *dy ) const =0;
91
92 // returns the native representation
93 virtual void * GetNativeMatrix() const = 0;
94} ;
95
96class WXDLLIMPEXP_CORE wxGraphicsPathData : public wxGraphicsObjectRefData
97{
98public :
99 wxGraphicsPathData(wxGraphicsRenderer* renderer) : wxGraphicsObjectRefData(renderer) {}
100 virtual ~wxGraphicsPathData() = default;
101
102 //
103 // These are the path primitives from which everything else can be constructed
104 //
105
106 // begins a new subpath at (x,y)
107 virtual void MoveToPoint( wxDouble x, wxDouble y ) = 0;
108
109 // adds a straight line from the current point to (x,y)
110 virtual void AddLineToPoint( wxDouble x, wxDouble y ) = 0;
111
112 // adds a cubic Bezier curve from the current point, using two control points and an end point
113 virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1, wxDouble cx2, wxDouble cy2, wxDouble x, wxDouble y ) = 0;
114
115 // adds another path
116 virtual void AddPath( const wxGraphicsPathData* path ) =0;
117
118 // closes the current sub-path
119 virtual void CloseSubpath() = 0;
120
121 // gets the last point of the current path, (0,0) if not yet set
122 virtual void GetCurrentPoint( wxDouble* x, wxDouble* y) const = 0;
123
124 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
125 virtual void AddArc( wxDouble x, wxDouble y, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise ) = 0;
126
127 //
128 // These are convenience functions which - if not available natively will be assembled
129 // using the primitives from above
130 //
131
132 // adds a quadratic Bezier curve from the current point, using a control point and an end point
133 virtual void AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y );
134
135 // appends a rectangle as a new closed subpath
136 virtual void AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
137
138 // appends an ellipsis as a new closed subpath fitting the passed rectangle
139 virtual void AddCircle( wxDouble x, wxDouble y, wxDouble r );
140
141 // 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)
142 virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ;
143
144 // appends an ellipse
145 virtual void AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h);
146
147 // appends a rounded rectangle
148 virtual void AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius);
149
150 // returns the native path
151 virtual void * GetNativePath() const = 0;
152
153 // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
154 virtual void UnGetNativePath(void *p) const= 0;
155
156 // transforms each point of this path by the matrix
157 virtual void Transform( const wxGraphicsMatrixData* matrix ) =0;
158
159 // gets the bounding box enclosing all points (possibly including control points)
160 virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) const=0;
161
162 virtual bool Contains( wxDouble x, wxDouble y, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) const=0;
163};
164
165#endif
166
167#endif // _WX_GRAPHICS_PRIVATE_H_