]>
Commit | Line | Data |
---|---|---|
50581042 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/graphics.h | |
3 | // Purpose: graphics context header | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: | |
7 | // Copyright: (c) Stefan Csomor | |
8 | // RCS-ID: $Id$ | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_GRAPHICS_H_ | |
13 | #define _WX_GRAPHICS_H_ | |
14 | ||
f07d9b97 MR |
15 | #include "wx/defs.h" |
16 | ||
8acd14d1 SC |
17 | #if wxUSE_GRAPHICS_CONTEXT |
18 | ||
50581042 | 19 | #include "wx/geometry.h" |
50581042 | 20 | #include "wx/dynarray.h" |
79bd5e98 | 21 | #include "wx/dc.h" |
08b2d55f | 22 | #include "wx/image.h" |
4ee4c7b9 | 23 | #include "wx/vector.h" |
50581042 | 24 | |
bf02a7f9 SC |
25 | enum wxAntialiasMode |
26 | { | |
27 | wxANTIALIAS_NONE, // should be 0 | |
8b982755 | 28 | wxANTIALIAS_DEFAULT |
bf02a7f9 SC |
29 | }; |
30 | ||
133cb28b SC |
31 | enum wxInterpolationQuality |
32 | { | |
3399af21 SC |
33 | // default interpolation |
34 | wxINTERPOLATION_DEFAULT, | |
133cb28b | 35 | // no interpolation |
3399af21 | 36 | wxINTERPOLATION_NONE, |
133cb28b SC |
37 | // fast interpolation, suited for interactivity |
38 | wxINTERPOLATION_FAST, | |
39 | // better quality | |
40 | wxINTERPOLATION_GOOD, | |
41 | // best quality, not suited for interactivity | |
42 | wxINTERPOLATION_BEST | |
43 | }; | |
44 | ||
bf02a7f9 SC |
45 | enum wxCompositionMode |
46 | { | |
47 | // R = Result, S = Source, D = Destination, premultiplied with alpha | |
48 | // Ra, Sa, Da their alpha components | |
03647350 | 49 | |
bf02a7f9 SC |
50 | // classic Porter-Duff compositions |
51 | // http://keithp.com/~keithp/porterduff/p253-porter.pdf | |
03647350 | 52 | |
fec4e458 | 53 | wxCOMPOSITION_INVALID = -1, /* indicates invalid/unsupported mode */ |
bf02a7f9 SC |
54 | wxCOMPOSITION_CLEAR, /* R = 0 */ |
55 | wxCOMPOSITION_SOURCE, /* R = S */ | |
56 | wxCOMPOSITION_OVER, /* R = S + D*(1 - Sa) */ | |
57 | wxCOMPOSITION_IN, /* R = S*Da */ | |
58 | wxCOMPOSITION_OUT, /* R = S*(1 - Da) */ | |
59 | wxCOMPOSITION_ATOP, /* R = S*Da + D*(1 - Sa) */ | |
60 | ||
61 | wxCOMPOSITION_DEST, /* R = D, essentially a noop */ | |
62 | wxCOMPOSITION_DEST_OVER, /* R = S*(1 - Da) + D */ | |
63 | wxCOMPOSITION_DEST_IN, /* R = D*Sa */ | |
64 | wxCOMPOSITION_DEST_OUT, /* R = D*(1 - Sa) */ | |
65 | wxCOMPOSITION_DEST_ATOP, /* R = S*(1 - Da) + D*Sa */ | |
66 | wxCOMPOSITION_XOR, /* R = S*(1 - Da) + D*(1 - Sa) */ | |
03647350 | 67 | |
bf02a7f9 | 68 | // mathematical compositions |
bbd783e0 | 69 | wxCOMPOSITION_ADD /* R = S + D */ |
bf02a7f9 SC |
70 | }; |
71 | ||
b5dbe15d VS |
72 | class WXDLLIMPEXP_FWD_CORE wxWindowDC; |
73 | class WXDLLIMPEXP_FWD_CORE wxMemoryDC; | |
220d37c8 | 74 | #if wxUSE_PRINTING_ARCHITECTURE |
0b822969 | 75 | class WXDLLIMPEXP_FWD_CORE wxPrinterDC; |
c929ad91 | 76 | #endif |
29188693 | 77 | #ifdef __WXMSW__ |
c929ad91 | 78 | #if wxUSE_ENH_METAFILE |
8371a353 | 79 | class WXDLLIMPEXP_FWD_CORE wxEnhMetaFileDC; |
220d37c8 | 80 | #endif |
29188693 | 81 | #endif |
b5dbe15d VS |
82 | class WXDLLIMPEXP_FWD_CORE wxGraphicsContext; |
83 | class WXDLLIMPEXP_FWD_CORE wxGraphicsPath; | |
84 | class WXDLLIMPEXP_FWD_CORE wxGraphicsMatrix; | |
85 | class WXDLLIMPEXP_FWD_CORE wxGraphicsFigure; | |
86 | class WXDLLIMPEXP_FWD_CORE wxGraphicsRenderer; | |
87 | class WXDLLIMPEXP_FWD_CORE wxGraphicsPen; | |
88 | class WXDLLIMPEXP_FWD_CORE wxGraphicsBrush; | |
89 | class WXDLLIMPEXP_FWD_CORE wxGraphicsFont; | |
1796d384 | 90 | class WXDLLIMPEXP_FWD_CORE wxGraphicsBitmap; |
774f4d12 | 91 | |
50581042 SC |
92 | /* |
93 | * notes about the graphics context apis | |
94 | * | |
0b7dce54 | 95 | * angles : are measured in radians, 0.0 being in direction of positiv x axis, PI/2 being |
50581042 SC |
96 | * in direction of positive y axis. |
97 | */ | |
0b7dce54 | 98 | |
9e605538 | 99 | // Base class of all objects used for drawing in the new graphics API, the always point back to their |
0b7dce54 | 100 | // originating rendering engine, there is no dynamic unloading of a renderer currently allowed, |
9e605538 | 101 | // these references are not counted |
2c820406 SC |
102 | |
103 | // | |
104 | // The data used by objects like graphics pens etc is ref counted, in order to avoid unnecessary expensive | |
105 | // duplication. Any operation on a shared instance that results in a modified state, uncouples this | |
106 | // instance from the other instances that were shared - using copy on write semantics | |
107 | // | |
0b7dce54 | 108 | |
3c419e81 SC |
109 | class WXDLLIMPEXP_FWD_CORE wxGraphicsObjectRefData; |
110 | class WXDLLIMPEXP_FWD_CORE wxGraphicsMatrixData; | |
111 | class WXDLLIMPEXP_FWD_CORE wxGraphicsPathData; | |
2c820406 | 112 | |
9e605538 SC |
113 | class WXDLLIMPEXP_CORE wxGraphicsObject : public wxObject |
114 | { | |
0b7dce54 VZ |
115 | public: |
116 | wxGraphicsObject(); | |
117 | wxGraphicsObject( wxGraphicsRenderer* renderer ); | |
118 | virtual ~wxGraphicsObject(); | |
119 | ||
120 | bool IsNull() const; | |
2c820406 SC |
121 | |
122 | // returns the renderer that was used to create this instance, or NULL if it has not been initialized yet | |
0b7dce54 VZ |
123 | wxGraphicsRenderer* GetRenderer() const; |
124 | wxGraphicsObjectRefData* GetGraphicsData() const; | |
125 | protected: | |
2c820406 SC |
126 | virtual wxObjectRefData* CreateRefData() const; |
127 | virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const; | |
128 | ||
39013ba0 | 129 | DECLARE_DYNAMIC_CLASS(wxGraphicsObject) |
0b7dce54 | 130 | }; |
9e605538 SC |
131 | |
132 | class WXDLLIMPEXP_CORE wxGraphicsPen : public wxGraphicsObject | |
133 | { | |
0b7dce54 | 134 | public: |
2c820406 | 135 | wxGraphicsPen() {} |
9e605538 | 136 | virtual ~wxGraphicsPen() {} |
0b7dce54 | 137 | private: |
2c820406 | 138 | DECLARE_DYNAMIC_CLASS(wxGraphicsPen) |
0b7dce54 | 139 | }; |
9e605538 | 140 | |
53a2db12 | 141 | extern WXDLLIMPEXP_DATA_CORE(wxGraphicsPen) wxNullGraphicsPen; |
2c820406 | 142 | |
9e605538 SC |
143 | class WXDLLIMPEXP_CORE wxGraphicsBrush : public wxGraphicsObject |
144 | { | |
0b7dce54 | 145 | public: |
2c820406 | 146 | wxGraphicsBrush() {} |
9e605538 | 147 | virtual ~wxGraphicsBrush() {} |
0b7dce54 | 148 | private: |
2c820406 | 149 | DECLARE_DYNAMIC_CLASS(wxGraphicsBrush) |
0b7dce54 | 150 | }; |
9e605538 | 151 | |
53a2db12 | 152 | extern WXDLLIMPEXP_DATA_CORE(wxGraphicsBrush) wxNullGraphicsBrush; |
2c820406 | 153 | |
9e605538 | 154 | class WXDLLIMPEXP_CORE wxGraphicsFont : public wxGraphicsObject |
50581042 | 155 | { |
0b7dce54 | 156 | public: |
2c820406 | 157 | wxGraphicsFont() {} |
9e605538 | 158 | virtual ~wxGraphicsFont() {} |
0b7dce54 | 159 | private: |
2c820406 | 160 | DECLARE_DYNAMIC_CLASS(wxGraphicsFont) |
0b7dce54 | 161 | }; |
9e605538 | 162 | |
53a2db12 | 163 | extern WXDLLIMPEXP_DATA_CORE(wxGraphicsFont) wxNullGraphicsFont; |
2c820406 | 164 | |
1796d384 SC |
165 | class WXDLLIMPEXP_CORE wxGraphicsBitmap : public wxGraphicsObject |
166 | { | |
0b7dce54 | 167 | public: |
1796d384 SC |
168 | wxGraphicsBitmap() {} |
169 | virtual ~wxGraphicsBitmap() {} | |
08b2d55f VZ |
170 | |
171 | // Convert bitmap to wxImage: this is more efficient than converting to | |
172 | // wxBitmap first and then to wxImage and also works without X server | |
173 | // connection under Unix that wxBitmap requires. | |
174 | #if wxUSE_IMAGE | |
175 | wxImage ConvertToImage() const; | |
176 | #endif // wxUSE_IMAGE | |
177 | ||
0b7dce54 | 178 | private: |
1796d384 | 179 | DECLARE_DYNAMIC_CLASS(wxGraphicsBitmap) |
0b7dce54 VZ |
180 | }; |
181 | ||
53a2db12 | 182 | extern WXDLLIMPEXP_DATA_CORE(wxGraphicsBitmap) wxNullGraphicsBitmap; |
1796d384 | 183 | |
a4e73390 SC |
184 | class WXDLLIMPEXP_CORE wxGraphicsMatrix : public wxGraphicsObject |
185 | { | |
0b7dce54 | 186 | public: |
a4e73390 SC |
187 | wxGraphicsMatrix() {} |
188 | ||
189 | virtual ~wxGraphicsMatrix() {} | |
190 | ||
191 | // concatenates the matrix | |
192 | virtual void Concat( const wxGraphicsMatrix *t ); | |
193 | void Concat( const wxGraphicsMatrix &t ) { Concat( &t ); } | |
194 | ||
195 | // sets the matrix to the respective values | |
0b7dce54 | 196 | virtual void Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, |
a4e73390 SC |
197 | wxDouble tx=0.0, wxDouble ty=0.0); |
198 | ||
248802d0 RD |
199 | // gets the component valuess of the matrix |
200 | virtual void Get(wxDouble* a=NULL, wxDouble* b=NULL, wxDouble* c=NULL, | |
201 | wxDouble* d=NULL, wxDouble* tx=NULL, wxDouble* ty=NULL) const; | |
0b7dce54 | 202 | |
a4e73390 SC |
203 | // makes this the inverse matrix |
204 | virtual void Invert(); | |
205 | ||
206 | // returns true if the elements of the transformation matrix are equal ? | |
207 | virtual bool IsEqual( const wxGraphicsMatrix* t) const; | |
208 | bool IsEqual( const wxGraphicsMatrix& t) const { return IsEqual( &t ); } | |
209 | ||
210 | // return true if this is the identity matrix | |
211 | virtual bool IsIdentity() const; | |
212 | ||
213 | // | |
214 | // transformation | |
215 | // | |
216 | ||
217 | // add the translation to this matrix | |
218 | virtual void Translate( wxDouble dx , wxDouble dy ); | |
219 | ||
220 | // add the scale to this matrix | |
221 | virtual void Scale( wxDouble xScale , wxDouble yScale ); | |
222 | ||
223 | // add the rotation to this matrix (radians) | |
0b7dce54 | 224 | virtual void Rotate( wxDouble angle ); |
a4e73390 SC |
225 | |
226 | // | |
227 | // apply the transforms | |
228 | // | |
229 | ||
230 | // applies that matrix to the point | |
231 | virtual void TransformPoint( wxDouble *x, wxDouble *y ) const; | |
232 | ||
233 | // applies the matrix except for translations | |
234 | virtual void TransformDistance( wxDouble *dx, wxDouble *dy ) const; | |
235 | ||
236 | // returns the native representation | |
237 | virtual void * GetNativeMatrix() const; | |
238 | ||
0b7dce54 | 239 | const wxGraphicsMatrixData* GetMatrixData() const |
a4e73390 | 240 | { return (const wxGraphicsMatrixData*) GetRefData(); } |
0b7dce54 | 241 | wxGraphicsMatrixData* GetMatrixData() |
a4e73390 SC |
242 | { return (wxGraphicsMatrixData*) GetRefData(); } |
243 | ||
0b7dce54 | 244 | private: |
a4e73390 | 245 | DECLARE_DYNAMIC_CLASS(wxGraphicsMatrix) |
0b7dce54 | 246 | }; |
a4e73390 | 247 | |
53a2db12 | 248 | extern WXDLLIMPEXP_DATA_CORE(wxGraphicsMatrix) wxNullGraphicsMatrix; |
a4e73390 | 249 | |
a4e73390 | 250 | class WXDLLIMPEXP_CORE wxGraphicsPath : public wxGraphicsObject |
774f4d12 | 251 | { |
0b7dce54 | 252 | public: |
a4e73390 SC |
253 | wxGraphicsPath() {} |
254 | virtual ~wxGraphicsPath() {} | |
0b7dce54 | 255 | |
a4e73390 SC |
256 | // |
257 | // These are the path primitives from which everything else can be constructed | |
258 | // | |
9e605538 | 259 | |
a4e73390 SC |
260 | // begins a new subpath at (x,y) |
261 | virtual void MoveToPoint( wxDouble x, wxDouble y ); | |
262 | void MoveToPoint( const wxPoint2DDouble& p); | |
0d3675a6 | 263 | |
0b7dce54 | 264 | // adds a straight line from the current point to (x,y) |
a4e73390 SC |
265 | virtual void AddLineToPoint( wxDouble x, wxDouble y ); |
266 | void AddLineToPoint( const wxPoint2DDouble& p); | |
0d3675a6 | 267 | |
a4e73390 | 268 | // adds a cubic Bezier curve from the current point, using two control points and an end point |
0b7dce54 | 269 | virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1, wxDouble cx2, wxDouble cy2, wxDouble x, wxDouble y ); |
a4e73390 | 270 | void AddCurveToPoint( const wxPoint2DDouble& c1, const wxPoint2DDouble& c2, const wxPoint2DDouble& e); |
0b7dce54 | 271 | |
a4e73390 SC |
272 | // adds another path |
273 | virtual void AddPath( const wxGraphicsPath& path ); | |
274 | ||
275 | // closes the current sub-path | |
0b7dce54 | 276 | virtual void CloseSubpath(); |
a4e73390 SC |
277 | |
278 | // gets the last point of the current path, (0,0) if not yet set | |
279 | virtual void GetCurrentPoint( wxDouble* x, wxDouble* y) const; | |
280 | wxPoint2DDouble GetCurrentPoint() const; | |
281 | ||
282 | // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle | |
0b7dce54 | 283 | virtual void AddArc( wxDouble x, wxDouble y, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise ); |
a4e73390 SC |
284 | void AddArc( const wxPoint2DDouble& c, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise); |
285 | ||
774f4d12 | 286 | // |
0b7dce54 | 287 | // These are convenience functions which - if not available natively will be assembled |
a4e73390 | 288 | // using the primitives from above |
774f4d12 | 289 | // |
a4e73390 SC |
290 | |
291 | // adds a quadratic Bezier curve from the current point, using a control point and an end point | |
292 | virtual void AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y ); | |
293 | ||
0b7dce54 | 294 | // appends a rectangle as a new closed subpath |
a4e73390 SC |
295 | virtual void AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ); |
296 | ||
297 | // appends an ellipsis as a new closed subpath fitting the passed rectangle | |
298 | virtual void AddCircle( wxDouble x, wxDouble y, wxDouble r ); | |
299 | ||
300 | // 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) | |
0b7dce54 VZ |
301 | virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ); |
302 | ||
a4e73390 SC |
303 | // appends an ellipse |
304 | virtual void AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h); | |
774f4d12 | 305 | |
a4e73390 SC |
306 | // appends a rounded rectangle |
307 | virtual void AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius); | |
774f4d12 | 308 | |
a4e73390 SC |
309 | // returns the native path |
310 | virtual void * GetNativePath() const; | |
0b7dce54 | 311 | |
a4e73390 SC |
312 | // give the native path returned by GetNativePath() back (there might be some deallocations necessary) |
313 | virtual void UnGetNativePath(void *p)const; | |
0b7dce54 | 314 | |
a4e73390 SC |
315 | // transforms each point of this path by the matrix |
316 | virtual void Transform( const wxGraphicsMatrix& matrix ); | |
0b7dce54 | 317 | |
a4e73390 SC |
318 | // gets the bounding box enclosing all points (possibly including control points) |
319 | virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h)const; | |
320 | wxRect2DDouble GetBox()const; | |
0b7dce54 | 321 | |
94a007ec FM |
322 | virtual bool Contains( wxDouble x, wxDouble y, wxPolygonFillMode fillStyle = wxODDEVEN_RULE)const; |
323 | bool Contains( const wxPoint2DDouble& c, wxPolygonFillMode fillStyle = wxODDEVEN_RULE)const; | |
0b7dce54 VZ |
324 | |
325 | const wxGraphicsPathData* GetPathData() const | |
a4e73390 | 326 | { return (const wxGraphicsPathData*) GetRefData(); } |
0b7dce54 | 327 | wxGraphicsPathData* GetPathData() |
a4e73390 SC |
328 | { return (wxGraphicsPathData*) GetRefData(); } |
329 | ||
0b7dce54 | 330 | private: |
a4e73390 | 331 | DECLARE_DYNAMIC_CLASS(wxGraphicsPath) |
0b7dce54 | 332 | }; |
774f4d12 | 333 | |
53a2db12 | 334 | extern WXDLLIMPEXP_DATA_CORE(wxGraphicsPath) wxNullGraphicsPath; |
a4e73390 SC |
335 | |
336 | ||
4ee4c7b9 VZ |
337 | // Describes a single gradient stop. |
338 | class wxGraphicsGradientStop | |
339 | { | |
340 | public: | |
2028c33a VZ |
341 | wxGraphicsGradientStop(wxColour col = wxTransparentColour, |
342 | float pos = 0.) | |
4ee4c7b9 VZ |
343 | : m_col(col), |
344 | m_pos(pos) | |
345 | { | |
346 | } | |
347 | ||
348 | // default copy ctor, assignment operator and dtor are ok | |
349 | ||
350 | const wxColour& GetColour() const { return m_col; } | |
351 | void SetColour(const wxColour& col) { m_col = col; } | |
352 | ||
353 | float GetPosition() const { return m_pos; } | |
354 | void SetPosition(float pos) | |
355 | { | |
3784bf30 | 356 | wxASSERT_MSG( pos >= 0 && pos <= 1, "invalid gradient stop position" ); |
4ee4c7b9 VZ |
357 | |
358 | m_pos = pos; | |
359 | } | |
360 | ||
361 | private: | |
362 | // The colour of this gradient band. | |
363 | wxColour m_col; | |
364 | ||
365 | // Its starting position: 0 is the beginning and 1 is the end. | |
366 | float m_pos; | |
367 | }; | |
368 | ||
369 | // A collection of gradient stops ordered by their positions (from lowest to | |
370 | // highest). The first stop (index 0, position 0.0) is always the starting | |
371 | // colour and the last one (index GetCount() - 1, position 1.0) is the end | |
372 | // colour. | |
373 | class WXDLLIMPEXP_CORE wxGraphicsGradientStops | |
374 | { | |
375 | public: | |
376 | wxGraphicsGradientStops(wxColour startCol = wxTransparentColour, | |
377 | wxColour endCol = wxTransparentColour) | |
378 | { | |
379 | // we can't use Add() here as it relies on having start/end stops as | |
380 | // first/last array elements so do it manually | |
7d53220e SC |
381 | m_stops.push_back(wxGraphicsGradientStop(startCol, 0.f)); |
382 | m_stops.push_back(wxGraphicsGradientStop(endCol, 1.f)); | |
4ee4c7b9 VZ |
383 | } |
384 | ||
385 | // default copy ctor, assignment operator and dtor are ok for this class | |
386 | ||
387 | ||
388 | // Add a stop in correct order. | |
389 | void Add(const wxGraphicsGradientStop& stop); | |
390 | void Add(wxColour col, float pos) { Add(wxGraphicsGradientStop(col, pos)); } | |
391 | ||
392 | // Get the number of stops. | |
393 | unsigned GetCount() const { return m_stops.size(); } | |
394 | ||
395 | // Return the stop at the given index (which must be valid). | |
396 | wxGraphicsGradientStop Item(unsigned n) const { return m_stops.at(n); } | |
397 | ||
398 | // Get/set start and end colours. | |
399 | void SetStartColour(wxColour col) | |
400 | { m_stops[0].SetColour(col); } | |
401 | wxColour GetStartColour() const | |
402 | { return m_stops[0].GetColour(); } | |
403 | void SetEndColour(wxColour col) | |
404 | { m_stops[m_stops.size() - 1].SetColour(col); } | |
405 | wxColour GetEndColour() const | |
406 | { return m_stops[m_stops.size() - 1].GetColour(); } | |
407 | ||
408 | private: | |
409 | // All the stops stored in ascending order of positions. | |
410 | wxVector<wxGraphicsGradientStop> m_stops; | |
411 | }; | |
412 | ||
9e605538 | 413 | class WXDLLIMPEXP_CORE wxGraphicsContext : public wxGraphicsObject |
50581042 SC |
414 | { |
415 | public: | |
9e605538 | 416 | wxGraphicsContext(wxGraphicsRenderer* renderer); |
774f4d12 | 417 | |
9e605538 | 418 | virtual ~wxGraphicsContext(); |
0b7dce54 VZ |
419 | |
420 | static wxGraphicsContext* Create( const wxWindowDC& dc); | |
421 | static wxGraphicsContext * Create( const wxMemoryDC& dc); | |
220d37c8 | 422 | #if wxUSE_PRINTING_ARCHITECTURE |
0b7dce54 | 423 | static wxGraphicsContext * Create( const wxPrinterDC& dc); |
c929ad91 | 424 | #endif |
29188693 | 425 | #ifdef __WXMSW__ |
c929ad91 | 426 | #if wxUSE_ENH_METAFILE |
8371a353 | 427 | static wxGraphicsContext * Create( const wxEnhMetaFileDC& dc); |
29188693 | 428 | #endif |
220d37c8 | 429 | #endif |
773ccc31 | 430 | |
0b7dce54 | 431 | static wxGraphicsContext* CreateFromNative( void * context ); |
774f4d12 | 432 | |
0b7dce54 | 433 | static wxGraphicsContext* CreateFromNativeWindow( void * window ); |
9a02779a | 434 | |
0b7dce54 | 435 | static wxGraphicsContext* Create( wxWindow* window ); |
50581042 | 436 | |
0a470e5e VZ |
437 | #if wxUSE_IMAGE |
438 | // Create a context for drawing onto a wxImage. The image life time must be | |
439 | // greater than that of the context itself as when the context is destroyed | |
440 | // it will copy its contents to the specified image. | |
441 | static wxGraphicsContext* Create(wxImage& image); | |
442 | #endif // wxUSE_IMAGE | |
443 | ||
ad667945 SC |
444 | // create a context that can be used for measuring texts only, no drawing allowed |
445 | static wxGraphicsContext * Create(); | |
446 | ||
cc18b1c7 | 447 | // begin a new document (relevant only for printing / pdf etc) if there is a progress dialog, message will be shown |
0b7dce54 VZ |
448 | virtual bool StartDoc( const wxString& message ); |
449 | ||
450 | // done with that document (relevant only for printing / pdf etc) | |
cc18b1c7 SC |
451 | virtual void EndDoc(); |
452 | ||
0b7dce54 | 453 | // opens a new page (relevant only for printing / pdf etc) with the given size in points |
cc18b1c7 SC |
454 | // (if both are null the default page size will be used) |
455 | virtual void StartPage( wxDouble width = 0, wxDouble height = 0 ); | |
0b7dce54 VZ |
456 | |
457 | // ends the current page (relevant only for printing / pdf etc) | |
cc18b1c7 | 458 | virtual void EndPage(); |
0b7dce54 | 459 | |
cc18b1c7 SC |
460 | // make sure that the current content of this context is immediately visible |
461 | virtual void Flush(); | |
462 | ||
a4e73390 | 463 | wxGraphicsPath CreatePath() const; |
0b7dce54 | 464 | |
a4e73390 | 465 | virtual wxGraphicsPen CreatePen(const wxPen& pen) const; |
0b7dce54 | 466 | |
a4e73390 | 467 | virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) const; |
0b7dce54 | 468 | |
4ee4c7b9 VZ |
469 | // sets the brush to a linear gradient, starting at (x1,y1) and ending at |
470 | // (x2,y2) with the given boundary colours or the specified stops | |
471 | wxGraphicsBrush | |
472 | CreateLinearGradientBrush(wxDouble x1, wxDouble y1, | |
473 | wxDouble x2, wxDouble y2, | |
474 | const wxColour& c1, const wxColour& c2) const; | |
475 | wxGraphicsBrush | |
476 | CreateLinearGradientBrush(wxDouble x1, wxDouble y1, | |
477 | wxDouble x2, wxDouble y2, | |
478 | const wxGraphicsGradientStops& stops) const; | |
479 | ||
480 | // sets the brush to a radial gradient originating at (xo,yc) and ending | |
481 | // on a circle around (xc,yc) with the given radius; the colours may be | |
482 | // specified by just the two extremes or the full array of gradient stops | |
483 | wxGraphicsBrush | |
484 | CreateRadialGradientBrush(wxDouble xo, wxDouble yo, | |
485 | wxDouble xc, wxDouble yc, wxDouble radius, | |
486 | const wxColour& oColor, const wxColour& cColor) const; | |
487 | ||
488 | wxGraphicsBrush | |
489 | CreateRadialGradientBrush(wxDouble xo, wxDouble yo, | |
490 | wxDouble xc, wxDouble yc, wxDouble radius, | |
491 | const wxGraphicsGradientStops& stops) const; | |
9e605538 | 492 | |
fa378d36 | 493 | // creates a font |
a4e73390 | 494 | virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) const; |
fa378d36 VZ |
495 | virtual wxGraphicsFont CreateFont(double sizeInPixels, |
496 | const wxString& facename, | |
497 | int flags = wxFONTFLAG_DEFAULT, | |
498 | const wxColour& col = *wxBLACK) const; | |
9e605538 | 499 | |
1796d384 SC |
500 | // create a native bitmap representation |
501 | virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap ) const; | |
0a470e5e VZ |
502 | #if wxUSE_IMAGE |
503 | wxGraphicsBitmap CreateBitmapFromImage(const wxImage& image) const; | |
504 | #endif // wxUSE_IMAGE | |
0b7dce54 | 505 | |
1796d384 SC |
506 | // create a native bitmap representation |
507 | virtual wxGraphicsBitmap CreateSubBitmap( const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) const; | |
508 | ||
0d3675a6 | 509 | // create a 'native' matrix corresponding to these values |
0b7dce54 | 510 | virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, |
a4e73390 | 511 | wxDouble tx=0.0, wxDouble ty=0.0) const; |
0b7dce54 | 512 | |
771563ba VZ |
513 | wxGraphicsMatrix CreateMatrix( const wxAffineMatrix2DBase& mat ) const |
514 | { | |
515 | wxMatrix2D mat2D; | |
516 | wxPoint2DDouble tr; | |
517 | mat.Get(&mat2D, &tr); | |
518 | ||
519 | return CreateMatrix(mat2D.m_11, mat2D.m_12, mat2D.m_21, mat2D.m_22, | |
520 | tr.m_x, tr.m_y); | |
521 | } | |
522 | ||
50581042 SC |
523 | // push the current state of the context, ie the transformation matrix on a stack |
524 | virtual void PushState() = 0; | |
525 | ||
526 | // pops a stored state from the stack | |
527 | virtual void PopState() = 0; | |
528 | ||
cc18b1c7 | 529 | // clips drawings to the region intersected with the current clipping region |
50581042 SC |
530 | virtual void Clip( const wxRegion ®ion ) = 0; |
531 | ||
cc18b1c7 | 532 | // clips drawings to the rect intersected with the current clipping region |
774f4d12 | 533 | virtual void Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; |
0b7dce54 | 534 | |
0d3675a6 | 535 | // resets the clipping to original extent |
0b7dce54 | 536 | virtual void ResetClip() = 0; |
774f4d12 | 537 | |
0d3675a6 RD |
538 | // returns the native context |
539 | virtual void * GetNativeContext() = 0; | |
774f4d12 | 540 | |
bf02a7f9 SC |
541 | // returns the current shape antialiasing mode |
542 | virtual wxAntialiasMode GetAntialiasMode() const { return m_antialias; } | |
03647350 | 543 | |
bf02a7f9 SC |
544 | // sets the antialiasing mode, returns true if it supported |
545 | virtual bool SetAntialiasMode(wxAntialiasMode antialias) = 0; | |
0b7dce54 | 546 | |
a173c813 | 547 | // returns the current interpolation quality |
133cb28b SC |
548 | virtual wxInterpolationQuality GetInterpolationQuality() const { return m_interpolation; } |
549 | ||
a173c813 | 550 | // sets the interpolation quality, returns true if it supported |
133cb28b SC |
551 | virtual bool SetInterpolationQuality(wxInterpolationQuality interpolation) = 0; |
552 | ||
bf02a7f9 SC |
553 | // returns the current compositing operator |
554 | virtual wxCompositionMode GetCompositionMode() const { return m_composition; } | |
03647350 | 555 | |
bf02a7f9 SC |
556 | // sets the compositing operator, returns true if it supported |
557 | virtual bool SetCompositionMode(wxCompositionMode op) = 0; | |
e22cf4b3 | 558 | |
cc18b1c7 | 559 | // returns the size of the graphics context in device coordinates |
b129eaa3 VZ |
560 | void GetSize(wxDouble* width, wxDouble* height) |
561 | { | |
562 | if ( width ) | |
563 | *width = m_width; | |
564 | if ( height ) | |
565 | *height = m_height; | |
566 | } | |
cc18b1c7 SC |
567 | |
568 | // returns the resolution of the graphics context in device points per inch | |
569 | virtual void GetDPI( wxDouble* dpiX, wxDouble* dpiY); | |
0b7dce54 | 570 | |
cc18b1c7 SC |
571 | #if 0 |
572 | // sets the current alpha on this context | |
573 | virtual void SetAlpha( wxDouble alpha ); | |
0b7dce54 | 574 | |
cc18b1c7 SC |
575 | // returns the alpha on this context |
576 | virtual wxDouble GetAlpha() const; | |
577 | #endif | |
bf02a7f9 SC |
578 | |
579 | // all rendering is done into a fully transparent temporary context | |
580 | virtual void BeginLayer(wxDouble opacity) = 0; | |
581 | ||
03647350 | 582 | // composites back the drawings into the context with the opacity given at |
bf02a7f9 SC |
583 | // the BeginLayer call |
584 | virtual void EndLayer() = 0; | |
585 | ||
50581042 | 586 | // |
774f4d12 | 587 | // transformation : changes the current transformation matrix CTM of the context |
50581042 | 588 | // |
0b7dce54 | 589 | |
50581042 SC |
590 | // translate |
591 | virtual void Translate( wxDouble dx , wxDouble dy ) = 0; | |
592 | ||
593 | // scale | |
594 | virtual void Scale( wxDouble xScale , wxDouble yScale ) = 0; | |
595 | ||
596 | // rotate (radians) | |
597 | virtual void Rotate( wxDouble angle ) = 0; | |
0b7dce54 | 598 | |
0d3675a6 | 599 | // concatenates this transform with the current transform of this context |
a4e73390 | 600 | virtual void ConcatTransform( const wxGraphicsMatrix& matrix ) = 0; |
9e605538 | 601 | |
0d3675a6 | 602 | // sets the transform of this context |
a4e73390 | 603 | virtual void SetTransform( const wxGraphicsMatrix& matrix ) = 0; |
50581042 | 604 | |
0d3675a6 | 605 | // gets the matrix of this context |
a4e73390 | 606 | virtual wxGraphicsMatrix GetTransform() const = 0; |
50581042 SC |
607 | // |
608 | // setting the paint | |
609 | // | |
0b7dce54 | 610 | |
9e605538 | 611 | // sets the pen |
2c820406 | 612 | virtual void SetPen( const wxGraphicsPen& pen ); |
0b7dce54 | 613 | |
9e605538 | 614 | void SetPen( const wxPen& pen ); |
50581042 SC |
615 | |
616 | // sets the brush for filling | |
2c820406 | 617 | virtual void SetBrush( const wxGraphicsBrush& brush ); |
0b7dce54 | 618 | |
9e605538 | 619 | void SetBrush( const wxBrush& brush ); |
50581042 SC |
620 | |
621 | // sets the font | |
2c820406 | 622 | virtual void SetFont( const wxGraphicsFont& font ); |
0b7dce54 | 623 | |
9e605538 | 624 | void SetFont( const wxFont& font, const wxColour& colour ); |
0d3675a6 | 625 | |
0b7dce54 | 626 | |
50581042 | 627 | // strokes along a path with the current pen |
a4e73390 | 628 | virtual void StrokePath( const wxGraphicsPath& path ) = 0; |
50581042 SC |
629 | |
630 | // fills a path with the current brush | |
94a007ec | 631 | virtual void FillPath( const wxGraphicsPath& path, wxPolygonFillMode fillStyle = wxODDEVEN_RULE ) = 0; |
50581042 SC |
632 | |
633 | // draws a path by first filling and then stroking | |
94a007ec | 634 | virtual void DrawPath( const wxGraphicsPath& path, wxPolygonFillMode fillStyle = wxODDEVEN_RULE ); |
0b7dce54 | 635 | |
50581042 SC |
636 | // |
637 | // text | |
638 | // | |
50581042 | 639 | |
0b7dce54 VZ |
640 | void DrawText( const wxString &str, wxDouble x, wxDouble y ) |
641 | { DoDrawText(str, x, y); } | |
642 | ||
643 | void DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ) | |
644 | { DoDrawRotatedText(str, x, y, angle); } | |
645 | ||
646 | void DrawText( const wxString &str, wxDouble x, wxDouble y, | |
647 | const wxGraphicsBrush& backgroundBrush ) | |
648 | { DoDrawFilledText(str, x, y, backgroundBrush); } | |
50581042 | 649 | |
0b7dce54 VZ |
650 | void DrawText( const wxString &str, wxDouble x, wxDouble y, |
651 | wxDouble angle, const wxGraphicsBrush& backgroundBrush ) | |
652 | { DoDrawRotatedFilledText(str, x, y, angle, backgroundBrush); } | |
068eb463 | 653 | |
068eb463 | 654 | |
50581042 | 655 | virtual void GetTextExtent( const wxString &text, wxDouble *width, wxDouble *height, |
9bd36c6c | 656 | wxDouble *descent = NULL, wxDouble *externalLeading = NULL ) const = 0; |
50581042 SC |
657 | |
658 | virtual void GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const = 0; | |
659 | ||
660 | // | |
661 | // image support | |
662 | // | |
663 | ||
1796d384 SC |
664 | virtual void DrawBitmap( const wxGraphicsBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; |
665 | ||
50581042 SC |
666 | virtual void DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; |
667 | ||
668 | virtual void DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; | |
669 | ||
670 | // | |
671 | // convenience methods | |
672 | // | |
0b7dce54 | 673 | |
50581042 SC |
674 | // strokes a single line |
675 | virtual void StrokeLine( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2); | |
676 | ||
677 | // stroke lines connecting each of the points | |
678 | virtual void StrokeLines( size_t n, const wxPoint2DDouble *points); | |
679 | ||
680 | // stroke disconnected lines from begin to end points | |
681 | virtual void StrokeLines( size_t n, const wxPoint2DDouble *beginPoints, const wxPoint2DDouble *endPoints); | |
682 | ||
683 | // draws a polygon | |
94a007ec | 684 | virtual void DrawLines( size_t n, const wxPoint2DDouble *points, wxPolygonFillMode fillStyle = wxODDEVEN_RULE ); |
50581042 | 685 | |
bf02a7f9 | 686 | // draws a rectangle |
50581042 SC |
687 | virtual void DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h); |
688 | ||
689 | // draws an ellipse | |
690 | virtual void DrawEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h); | |
691 | ||
692 | // draws a rounded rectangle | |
693 | virtual void DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius); | |
694 | ||
9e605538 | 695 | // wrappers using wxPoint2DDouble TODO |
50581042 | 696 | |
de3cb39f RD |
697 | // helper to determine if a 0.5 offset should be applied for the drawing operation |
698 | virtual bool ShouldOffset() const { return false; } | |
0217cfa5 SC |
699 | |
700 | // indicates whether the context should try to offset for pixel boundaries, this only makes sense on | |
701 | // bitmap devices like screen, by default this is turned off | |
702 | virtual void EnableOffset(bool enable = true); | |
703 | ||
704 | void DisableOffset() { EnableOffset(false); } | |
705 | bool OffsetEnabled() { return m_enableOffset; } | |
706 | ||
0b7dce54 | 707 | protected: |
b129eaa3 VZ |
708 | // These fields must be initialized in the derived class ctors. |
709 | wxDouble m_width, | |
710 | m_height; | |
9da34e21 | 711 | |
2c820406 SC |
712 | wxGraphicsPen m_pen; |
713 | wxGraphicsBrush m_brush; | |
714 | wxGraphicsFont m_font; | |
bf02a7f9 SC |
715 | wxAntialiasMode m_antialias; |
716 | wxCompositionMode m_composition; | |
133cb28b | 717 | wxInterpolationQuality m_interpolation; |
0217cfa5 | 718 | bool m_enableOffset; |
9e605538 | 719 | |
02fd8b9b | 720 | protected: |
0b7dce54 VZ |
721 | // implementations of overloaded public functions: we use different names |
722 | // for them to avoid the virtual function hiding problems in the derived | |
723 | // classes | |
724 | virtual void DoDrawText(const wxString& str, wxDouble x, wxDouble y) = 0; | |
725 | virtual void DoDrawRotatedText(const wxString& str, wxDouble x, wxDouble y, | |
726 | wxDouble angle); | |
727 | virtual void DoDrawFilledText(const wxString& str, wxDouble x, wxDouble y, | |
728 | const wxGraphicsBrush& backgroundBrush); | |
729 | virtual void DoDrawRotatedFilledText(const wxString& str, | |
730 | wxDouble x, wxDouble y, | |
731 | wxDouble angle, | |
732 | const wxGraphicsBrush& backgroundBrush); | |
733 | ||
c0c133e1 | 734 | wxDECLARE_NO_COPY_CLASS(wxGraphicsContext); |
8ddf8e82 | 735 | DECLARE_ABSTRACT_CLASS(wxGraphicsContext) |
50581042 SC |
736 | }; |
737 | ||
0b7dce54 | 738 | #if 0 |
9e605538 SC |
739 | |
740 | // | |
741 | // A graphics figure allows to cache path, pen etc creations, also will be a basis for layering/grouping elements | |
742 | // | |
743 | ||
744 | class WXDLLIMPEXP_CORE wxGraphicsFigure : public wxGraphicsObject | |
745 | { | |
0b7dce54 VZ |
746 | public: |
747 | wxGraphicsFigure(wxGraphicsRenderer* renderer); | |
748 | ||
749 | virtual ~wxGraphicsFigure(); | |
750 | ||
0d3675a6 | 751 | void SetPath( wxGraphicsMatrix* matrix ); |
0b7dce54 | 752 | |
0d3675a6 RD |
753 | void SetMatrix( wxGraphicsPath* path); |
754 | ||
755 | // draws this object on the context | |
756 | virtual void Draw( wxGraphicsContext* cg ); | |
0b7dce54 | 757 | |
0d3675a6 RD |
758 | // returns the path of this object |
759 | wxGraphicsPath* GetPath() { return m_path; } | |
0b7dce54 | 760 | |
0d3675a6 RD |
761 | // returns the transformation matrix of this object, may be null if there is no transformation necessary |
762 | wxGraphicsMatrix* GetMatrix() { return m_matrix; } | |
0b7dce54 VZ |
763 | |
764 | private: | |
0d3675a6 RD |
765 | wxGraphicsMatrix* m_matrix; |
766 | wxGraphicsPath* m_path; | |
0b7dce54 | 767 | |
9e605538 | 768 | DECLARE_DYNAMIC_CLASS(wxGraphicsFigure) |
0b7dce54 VZ |
769 | }; |
770 | ||
771 | #endif | |
9e605538 SC |
772 | |
773 | // | |
774 | // The graphics renderer is the instance corresponding to the rendering engine used, eg there is ONE core graphics renderer | |
775 | // instance on OSX. This instance is pointed back to by all objects created by it. Therefore you can create eg additional | |
776 | // paths at any point from a given matrix etc. | |
777 | // | |
778 | ||
779 | class WXDLLIMPEXP_CORE wxGraphicsRenderer : public wxObject | |
780 | { | |
0b7dce54 | 781 | public: |
9e605538 SC |
782 | wxGraphicsRenderer() {} |
783 | ||
784 | virtual ~wxGraphicsRenderer() {} | |
785 | ||
0d3675a6 | 786 | static wxGraphicsRenderer* GetDefaultRenderer(); |
9e605538 | 787 | |
c0e69d72 | 788 | static wxGraphicsRenderer* GetCairoRenderer(); |
0d3675a6 | 789 | // Context |
9e605538 | 790 | |
0b7dce54 VZ |
791 | virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) = 0; |
792 | virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc) = 0; | |
220d37c8 | 793 | #if wxUSE_PRINTING_ARCHITECTURE |
0b7dce54 | 794 | virtual wxGraphicsContext * CreateContext( const wxPrinterDC& dc) = 0; |
c929ad91 | 795 | #endif |
29188693 | 796 | #ifdef __WXMSW__ |
c929ad91 | 797 | #if wxUSE_ENH_METAFILE |
8371a353 | 798 | virtual wxGraphicsContext * CreateContext( const wxEnhMetaFileDC& dc) = 0; |
29188693 | 799 | #endif |
220d37c8 SC |
800 | #endif |
801 | ||
0d3675a6 | 802 | virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ) = 0; |
9e605538 | 803 | |
0d3675a6 | 804 | virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window ) = 0; |
9e605538 | 805 | |
0d3675a6 | 806 | virtual wxGraphicsContext * CreateContext( wxWindow* window ) = 0; |
9e605538 | 807 | |
0a470e5e VZ |
808 | #if wxUSE_IMAGE |
809 | virtual wxGraphicsContext * CreateContextFromImage(wxImage& image) = 0; | |
810 | #endif // wxUSE_IMAGE | |
811 | ||
ad667945 SC |
812 | // create a context that can be used for measuring texts only, no drawing allowed |
813 | virtual wxGraphicsContext * CreateMeasuringContext() = 0; | |
814 | ||
0d3675a6 | 815 | // Path |
0b7dce54 | 816 | |
a4e73390 | 817 | virtual wxGraphicsPath CreatePath() = 0; |
9e605538 | 818 | |
0d3675a6 | 819 | // Matrix |
0b7dce54 VZ |
820 | |
821 | virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, | |
0d3675a6 | 822 | wxDouble tx=0.0, wxDouble ty=0.0) = 0; |
0b7dce54 | 823 | |
9e605538 | 824 | // Paints |
0b7dce54 VZ |
825 | |
826 | virtual wxGraphicsPen CreatePen(const wxPen& pen) = 0; | |
827 | ||
828 | virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) = 0; | |
829 | ||
4ee4c7b9 VZ |
830 | // Gradient brush creation functions may not honour all the stops specified |
831 | // stops and use just its boundary colours (this is currently the case | |
832 | // under OS X) | |
833 | virtual wxGraphicsBrush | |
834 | CreateLinearGradientBrush(wxDouble x1, wxDouble y1, | |
835 | wxDouble x2, wxDouble y2, | |
836 | const wxGraphicsGradientStops& stops) = 0; | |
9e605538 | 837 | |
4ee4c7b9 VZ |
838 | virtual wxGraphicsBrush |
839 | CreateRadialGradientBrush(wxDouble xo, wxDouble yo, | |
840 | wxDouble xc, wxDouble yc, | |
841 | wxDouble radius, | |
842 | const wxGraphicsGradientStops& stops) = 0; | |
9e605538 | 843 | |
4ee4c7b9 | 844 | // sets the font |
2c820406 | 845 | virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) = 0; |
fa378d36 VZ |
846 | virtual wxGraphicsFont CreateFont(double sizeInPixels, |
847 | const wxString& facename, | |
848 | int flags = wxFONTFLAG_DEFAULT, | |
849 | const wxColour& col = *wxBLACK) = 0; | |
d974a494 | 850 | |
1796d384 SC |
851 | // create a native bitmap representation |
852 | virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap ) = 0; | |
0a470e5e VZ |
853 | #if wxUSE_IMAGE |
854 | virtual wxGraphicsBitmap CreateBitmapFromImage(const wxImage& image) = 0; | |
6e6f074b | 855 | virtual wxImage CreateImageFromBitmap(const wxGraphicsBitmap& bmp) = 0; |
0a470e5e | 856 | #endif // wxUSE_IMAGE |
4ee4c7b9 | 857 | |
2986eb86 SC |
858 | // create a graphics bitmap from a native bitmap |
859 | virtual wxGraphicsBitmap CreateBitmapFromNativeBitmap( void* bitmap ) = 0; | |
0b7dce54 | 860 | |
1796d384 SC |
861 | // create a subimage from a native image representation |
862 | virtual wxGraphicsBitmap CreateSubBitmap( const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; | |
d974a494 | 863 | |
0b7dce54 | 864 | private: |
c0c133e1 | 865 | wxDECLARE_NO_COPY_CLASS(wxGraphicsRenderer); |
9e605538 | 866 | DECLARE_ABSTRACT_CLASS(wxGraphicsRenderer) |
0b7dce54 | 867 | }; |
9e605538 | 868 | |
6e6f074b RD |
869 | |
870 | #if wxUSE_IMAGE | |
871 | inline | |
872 | wxImage wxGraphicsBitmap::ConvertToImage() const | |
873 | { | |
874 | wxGraphicsRenderer* renderer = GetRenderer(); | |
875 | return renderer ? renderer->CreateImageFromBitmap(*this) : wxNullImage; | |
876 | } | |
877 | #endif // wxUSE_IMAGE | |
878 | ||
879 | #endif // wxUSE_GRAPHICS_CONTEXT | |
50581042 | 880 | |
8acd14d1 | 881 | #endif // _WX_GRAPHICS_H_ |