1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: graphics context header
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GRAPHICS_H_
13 #define _WX_GRAPHICS_H_
15 #if wxUSE_GRAPHICS_CONTEXT
17 #include "wx/geometry.h"
18 #include "wx/dynarray.h"
20 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
21 class WXDLLIMPEXP_FWD_CORE wxMemoryDC
;
22 class WXDLLIMPEXP_FWD_CORE wxGraphicsContext
;
23 class WXDLLIMPEXP_FWD_CORE wxGraphicsPath
;
24 class WXDLLIMPEXP_FWD_CORE wxGraphicsMatrix
;
25 class WXDLLIMPEXP_FWD_CORE wxGraphicsFigure
;
26 class WXDLLIMPEXP_FWD_CORE wxGraphicsRenderer
;
27 class WXDLLIMPEXP_FWD_CORE wxGraphicsPen
;
28 class WXDLLIMPEXP_FWD_CORE wxGraphicsBrush
;
29 class WXDLLIMPEXP_FWD_CORE wxGraphicsFont
;
32 * notes about the graphics context apis
34 * angles : are measured in radians, 0.0 being in direction of positiv x axis, PI/2 being
35 * in direction of positive y axis.
38 // Base class of all objects used for drawing in the new graphics API, the always point back to their
39 // originating rendering engine, there is no dynamic unloading of a renderer currently allowed,
40 // these references are not counted
43 // The data used by objects like graphics pens etc is ref counted, in order to avoid unnecessary expensive
44 // duplication. Any operation on a shared instance that results in a modified state, uncouples this
45 // instance from the other instances that were shared - using copy on write semantics
48 class WXDLLIMPEXP_CORE wxGraphicsObjectRefData
: public wxObjectRefData
51 wxGraphicsObjectRefData( wxGraphicsRenderer
* renderer
);
52 wxGraphicsObjectRefData( const wxGraphicsObjectRefData
* data
);
53 wxGraphicsRenderer
* GetRenderer() const ;
54 virtual wxGraphicsObjectRefData
* Clone() const ;
57 wxGraphicsRenderer
* m_renderer
;
60 class WXDLLIMPEXP_CORE wxGraphicsObject
: public wxObject
64 wxGraphicsObject( wxGraphicsRenderer
* renderer
) ;
65 virtual ~wxGraphicsObject() ;
69 // returns the renderer that was used to create this instance, or NULL if it has not been initialized yet
70 wxGraphicsRenderer
* GetRenderer() const ;
71 wxGraphicsObjectRefData
* GetGraphicsData() const ;
73 virtual wxObjectRefData
* CreateRefData() const;
74 virtual wxObjectRefData
* CloneRefData(const wxObjectRefData
* data
) const;
76 DECLARE_DYNAMIC_CLASS(wxGraphicsObject
)
79 class WXDLLIMPEXP_CORE wxGraphicsPen
: public wxGraphicsObject
83 virtual ~wxGraphicsPen() {}
85 DECLARE_DYNAMIC_CLASS(wxGraphicsPen
)
88 extern WXDLLEXPORT_DATA(wxGraphicsPen
) wxNullGraphicsPen
;
90 class WXDLLIMPEXP_CORE wxGraphicsBrush
: public wxGraphicsObject
94 virtual ~wxGraphicsBrush() {}
96 DECLARE_DYNAMIC_CLASS(wxGraphicsBrush
)
99 extern WXDLLEXPORT_DATA(wxGraphicsBrush
) wxNullGraphicsBrush
;
101 class WXDLLIMPEXP_CORE wxGraphicsFont
: public wxGraphicsObject
105 virtual ~wxGraphicsFont() {}
107 DECLARE_DYNAMIC_CLASS(wxGraphicsFont
)
110 extern WXDLLEXPORT_DATA(wxGraphicsFont
) wxNullGraphicsFont
;
113 class WXDLLIMPEXP_CORE wxGraphicsMatrixData
: public wxGraphicsObjectRefData
116 wxGraphicsMatrixData( wxGraphicsRenderer
* renderer
) :
117 wxGraphicsObjectRefData(renderer
) {}
119 virtual ~wxGraphicsMatrixData() {}
121 // concatenates the matrix
122 virtual void Concat( const wxGraphicsMatrixData
*t
) = 0;
124 // sets the matrix to the respective values
125 virtual void Set(wxDouble a
=1.0, wxDouble b
=0.0, wxDouble c
=0.0, wxDouble d
=1.0,
126 wxDouble tx
=0.0, wxDouble ty
=0.0) = 0;
128 // gets the component valuess of the matrix
129 virtual void Get(wxDouble
* a
=NULL
, wxDouble
* b
=NULL
, wxDouble
* c
=NULL
,
130 wxDouble
* d
=NULL
, wxDouble
* tx
=NULL
, wxDouble
* ty
=NULL
) const = 0;
132 // makes this the inverse matrix
133 virtual void Invert() = 0;
135 // returns true if the elements of the transformation matrix are equal ?
136 virtual bool IsEqual( const wxGraphicsMatrixData
* t
) const = 0;
138 // return true if this is the identity matrix
139 virtual bool IsIdentity() const = 0;
145 // add the translation to this matrix
146 virtual void Translate( wxDouble dx
, wxDouble dy
) = 0;
148 // add the scale to this matrix
149 virtual void Scale( wxDouble xScale
, wxDouble yScale
) = 0;
151 // add the rotation to this matrix (radians)
152 virtual void Rotate( wxDouble angle
) = 0;
155 // apply the transforms
158 // applies that matrix to the point
159 virtual void TransformPoint( wxDouble
*x
, wxDouble
*y
) const = 0;
161 // applies the matrix except for translations
162 virtual void TransformDistance( wxDouble
*dx
, wxDouble
*dy
) const =0;
164 // returns the native representation
165 virtual void * GetNativeMatrix() const = 0;
168 class WXDLLIMPEXP_CORE wxGraphicsMatrix
: public wxGraphicsObject
171 wxGraphicsMatrix() {}
173 virtual ~wxGraphicsMatrix() {}
175 // concatenates the matrix
176 virtual void Concat( const wxGraphicsMatrix
*t
);
177 void Concat( const wxGraphicsMatrix
&t
) { Concat( &t
); }
179 // sets the matrix to the respective values
180 virtual void Set(wxDouble a
=1.0, wxDouble b
=0.0, wxDouble c
=0.0, wxDouble d
=1.0,
181 wxDouble tx
=0.0, wxDouble ty
=0.0);
183 // gets the component valuess of the matrix
184 virtual void Get(wxDouble
* a
=NULL
, wxDouble
* b
=NULL
, wxDouble
* c
=NULL
,
185 wxDouble
* d
=NULL
, wxDouble
* tx
=NULL
, wxDouble
* ty
=NULL
) const;
187 // makes this the inverse matrix
188 virtual void Invert();
190 // returns true if the elements of the transformation matrix are equal ?
191 virtual bool IsEqual( const wxGraphicsMatrix
* t
) const;
192 bool IsEqual( const wxGraphicsMatrix
& t
) const { return IsEqual( &t
); }
194 // return true if this is the identity matrix
195 virtual bool IsIdentity() const;
201 // add the translation to this matrix
202 virtual void Translate( wxDouble dx
, wxDouble dy
);
204 // add the scale to this matrix
205 virtual void Scale( wxDouble xScale
, wxDouble yScale
);
207 // add the rotation to this matrix (radians)
208 virtual void Rotate( wxDouble angle
);
211 // apply the transforms
214 // applies that matrix to the point
215 virtual void TransformPoint( wxDouble
*x
, wxDouble
*y
) const;
217 // applies the matrix except for translations
218 virtual void TransformDistance( wxDouble
*dx
, wxDouble
*dy
) const;
220 // returns the native representation
221 virtual void * GetNativeMatrix() const;
223 const wxGraphicsMatrixData
* GetMatrixData() const
224 { return (const wxGraphicsMatrixData
*) GetRefData(); }
225 wxGraphicsMatrixData
* GetMatrixData()
226 { return (wxGraphicsMatrixData
*) GetRefData(); }
229 DECLARE_DYNAMIC_CLASS(wxGraphicsMatrix
)
232 extern WXDLLEXPORT_DATA(wxGraphicsMatrix
) wxNullGraphicsMatrix
;
234 class WXDLLIMPEXP_CORE wxGraphicsPathData
: public wxGraphicsObjectRefData
237 wxGraphicsPathData(wxGraphicsRenderer
* renderer
) : wxGraphicsObjectRefData(renderer
) {}
238 virtual ~wxGraphicsPathData() {}
241 // These are the path primitives from which everything else can be constructed
244 // begins a new subpath at (x,y)
245 virtual void MoveToPoint( wxDouble x
, wxDouble y
) = 0;
247 // adds a straight line from the current point to (x,y)
248 virtual void AddLineToPoint( wxDouble x
, wxDouble y
) = 0;
250 // adds a cubic Bezier curve from the current point, using two control points and an end point
251 virtual void AddCurveToPoint( wxDouble cx1
, wxDouble cy1
, wxDouble cx2
, wxDouble cy2
, wxDouble x
, wxDouble y
) = 0;
254 virtual void AddPath( const wxGraphicsPathData
* path
) =0;
256 // closes the current sub-path
257 virtual void CloseSubpath() = 0;
259 // gets the last point of the current path, (0,0) if not yet set
260 virtual void GetCurrentPoint( wxDouble
* x
, wxDouble
* y
) const = 0;
262 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
263 virtual void AddArc( wxDouble x
, wxDouble y
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
) = 0;
266 // These are convenience functions which - if not available natively will be assembled
267 // using the primitives from above
270 // adds a quadratic Bezier curve from the current point, using a control point and an end point
271 virtual void AddQuadCurveToPoint( wxDouble cx
, wxDouble cy
, wxDouble x
, wxDouble y
);
273 // appends a rectangle as a new closed subpath
274 virtual void AddRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
276 // appends an ellipsis as a new closed subpath fitting the passed rectangle
277 virtual void AddCircle( wxDouble x
, wxDouble y
, wxDouble r
);
279 // 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)
280 virtual void AddArcToPoint( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
, wxDouble r
) ;
282 // appends an ellipse
283 virtual void AddEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
285 // appends a rounded rectangle
286 virtual void AddRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
);
288 // returns the native path
289 virtual void * GetNativePath() const = 0;
291 // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
292 virtual void UnGetNativePath(void *p
) const= 0;
294 // transforms each point of this path by the matrix
295 virtual void Transform( const wxGraphicsMatrixData
* matrix
) =0;
297 // gets the bounding box enclosing all points (possibly including control points)
298 virtual void GetBox(wxDouble
*x
, wxDouble
*y
, wxDouble
*w
, wxDouble
*h
) const=0;
300 virtual bool Contains( wxDouble x
, wxDouble y
, int fillStyle
= wxODDEVEN_RULE
) const=0;
303 class WXDLLIMPEXP_CORE wxGraphicsPath
: public wxGraphicsObject
307 virtual ~wxGraphicsPath() {}
310 // These are the path primitives from which everything else can be constructed
313 // begins a new subpath at (x,y)
314 virtual void MoveToPoint( wxDouble x
, wxDouble y
);
315 void MoveToPoint( const wxPoint2DDouble
& p
);
317 // adds a straight line from the current point to (x,y)
318 virtual void AddLineToPoint( wxDouble x
, wxDouble y
);
319 void AddLineToPoint( const wxPoint2DDouble
& p
);
321 // adds a cubic Bezier curve from the current point, using two control points and an end point
322 virtual void AddCurveToPoint( wxDouble cx1
, wxDouble cy1
, wxDouble cx2
, wxDouble cy2
, wxDouble x
, wxDouble y
) ;
323 void AddCurveToPoint( const wxPoint2DDouble
& c1
, const wxPoint2DDouble
& c2
, const wxPoint2DDouble
& e
);
326 virtual void AddPath( const wxGraphicsPath
& path
);
328 // closes the current sub-path
329 virtual void CloseSubpath() ;
331 // gets the last point of the current path, (0,0) if not yet set
332 virtual void GetCurrentPoint( wxDouble
* x
, wxDouble
* y
) const;
333 wxPoint2DDouble
GetCurrentPoint() const;
335 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
336 virtual void AddArc( wxDouble x
, wxDouble y
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
) ;
337 void AddArc( const wxPoint2DDouble
& c
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
);
340 // These are convenience functions which - if not available natively will be assembled
341 // using the primitives from above
344 // adds a quadratic Bezier curve from the current point, using a control point and an end point
345 virtual void AddQuadCurveToPoint( wxDouble cx
, wxDouble cy
, wxDouble x
, wxDouble y
);
347 // appends a rectangle as a new closed subpath
348 virtual void AddRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
350 // appends an ellipsis as a new closed subpath fitting the passed rectangle
351 virtual void AddCircle( wxDouble x
, wxDouble y
, wxDouble r
);
353 // 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)
354 virtual void AddArcToPoint( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
, wxDouble r
) ;
356 // appends an ellipse
357 virtual void AddEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
359 // appends a rounded rectangle
360 virtual void AddRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
);
362 // returns the native path
363 virtual void * GetNativePath() const;
365 // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
366 virtual void UnGetNativePath(void *p
)const;
368 // transforms each point of this path by the matrix
369 virtual void Transform( const wxGraphicsMatrix
& matrix
);
371 // gets the bounding box enclosing all points (possibly including control points)
372 virtual void GetBox(wxDouble
*x
, wxDouble
*y
, wxDouble
*w
, wxDouble
*h
)const;
373 wxRect2DDouble
GetBox()const;
375 virtual bool Contains( wxDouble x
, wxDouble y
, int fillStyle
= wxODDEVEN_RULE
)const;
376 bool Contains( const wxPoint2DDouble
& c
, int fillStyle
= wxODDEVEN_RULE
)const;
378 const wxGraphicsPathData
* GetPathData() const
379 { return (const wxGraphicsPathData
*) GetRefData(); }
380 wxGraphicsPathData
* GetPathData()
381 { return (wxGraphicsPathData
*) GetRefData(); }
384 DECLARE_DYNAMIC_CLASS(wxGraphicsPath
)
387 extern WXDLLEXPORT_DATA(wxGraphicsPath
) wxNullGraphicsPath
;
390 class WXDLLIMPEXP_CORE wxGraphicsContext
: public wxGraphicsObject
393 wxGraphicsContext(wxGraphicsRenderer
* renderer
);
395 virtual ~wxGraphicsContext();
397 static wxGraphicsContext
* Create( const wxWindowDC
& dc
) ;
400 static wxGraphicsContext
* Create( const wxMemoryDC
& dc
) ;
403 static wxGraphicsContext
* CreateFromNative( void * context
) ;
405 static wxGraphicsContext
* CreateFromNativeWindow( void * window
) ;
407 static wxGraphicsContext
* Create( wxWindow
* window
) ;
409 // create a context that can be used for measuring texts only, no drawing allowed
410 static wxGraphicsContext
* Create();
412 // begin a new document (relevant only for printing / pdf etc) if there is a progress dialog, message will be shown
413 virtual bool StartDoc( const wxString
& message
) ;
415 // done with that document (relevant only for printing / pdf etc)
416 virtual void EndDoc();
418 // opens a new page (relevant only for printing / pdf etc) with the given size in points
419 // (if both are null the default page size will be used)
420 virtual void StartPage( wxDouble width
= 0, wxDouble height
= 0 );
422 // ends the current page (relevant only for printing / pdf etc)
423 virtual void EndPage();
425 // make sure that the current content of this context is immediately visible
426 virtual void Flush();
428 wxGraphicsPath
CreatePath() const;
430 virtual wxGraphicsPen
CreatePen(const wxPen
& pen
) const;
432 virtual wxGraphicsBrush
CreateBrush(const wxBrush
& brush
) const;
434 // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
435 virtual wxGraphicsBrush
CreateLinearGradientBrush( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
,
436 const wxColour
&c1
, const wxColour
&c2
) const;
438 // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
439 // with radius r and color cColor
440 virtual wxGraphicsBrush
CreateRadialGradientBrush( wxDouble xo
, wxDouble yo
, wxDouble xc
, wxDouble yc
, wxDouble radius
,
441 const wxColour
&oColor
, const wxColour
&cColor
) const;
444 virtual wxGraphicsFont
CreateFont( const wxFont
&font
, const wxColour
&col
= *wxBLACK
) const;
446 // create a 'native' matrix corresponding to these values
447 virtual wxGraphicsMatrix
CreateMatrix( wxDouble a
=1.0, wxDouble b
=0.0, wxDouble c
=0.0, wxDouble d
=1.0,
448 wxDouble tx
=0.0, wxDouble ty
=0.0) const;
450 // push the current state of the context, ie the transformation matrix on a stack
451 virtual void PushState() = 0;
453 // pops a stored state from the stack
454 virtual void PopState() = 0;
456 // clips drawings to the region intersected with the current clipping region
457 virtual void Clip( const wxRegion
®ion
) = 0;
459 // clips drawings to the rect intersected with the current clipping region
460 virtual void Clip( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
) = 0;
462 // resets the clipping to original extent
463 virtual void ResetClip() = 0 ;
465 // returns the native context
466 virtual void * GetNativeContext() = 0;
468 // returns the current logical function
469 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
471 // sets the current logical function, returns true if it supported
472 virtual bool SetLogicalFunction(int function
) ;
474 // returns the size of the graphics context in device coordinates
475 virtual void GetSize( wxDouble
* width
, wxDouble
* height
);
477 // returns the resolution of the graphics context in device points per inch
478 virtual void GetDPI( wxDouble
* dpiX
, wxDouble
* dpiY
);
481 // sets the current alpha on this context
482 virtual void SetAlpha( wxDouble alpha
);
484 // returns the alpha on this context
485 virtual wxDouble
GetAlpha() const;
488 // transformation : changes the current transformation matrix CTM of the context
492 virtual void Translate( wxDouble dx
, wxDouble dy
) = 0;
495 virtual void Scale( wxDouble xScale
, wxDouble yScale
) = 0;
498 virtual void Rotate( wxDouble angle
) = 0;
500 // concatenates this transform with the current transform of this context
501 virtual void ConcatTransform( const wxGraphicsMatrix
& matrix
) = 0;
503 // sets the transform of this context
504 virtual void SetTransform( const wxGraphicsMatrix
& matrix
) = 0;
506 // gets the matrix of this context
507 virtual wxGraphicsMatrix
GetTransform() const = 0;
513 virtual void SetPen( const wxGraphicsPen
& pen
);
515 void SetPen( const wxPen
& pen
);
517 // sets the brush for filling
518 virtual void SetBrush( const wxGraphicsBrush
& brush
);
520 void SetBrush( const wxBrush
& brush
);
523 virtual void SetFont( const wxGraphicsFont
& font
);
525 void SetFont( const wxFont
& font
, const wxColour
& colour
);
528 // strokes along a path with the current pen
529 virtual void StrokePath( const wxGraphicsPath
& path
) = 0;
531 // fills a path with the current brush
532 virtual void FillPath( const wxGraphicsPath
& path
, int fillStyle
= wxODDEVEN_RULE
) = 0;
534 // draws a path by first filling and then stroking
535 virtual void DrawPath( const wxGraphicsPath
& path
, int fillStyle
= wxODDEVEN_RULE
);
541 virtual void DrawText( const wxString
&str
, wxDouble x
, wxDouble y
) = 0;
543 virtual void DrawText( const wxString
&str
, wxDouble x
, wxDouble y
, wxDouble angle
);
545 virtual void DrawText( const wxString
&str
, wxDouble x
, wxDouble y
, const wxGraphicsBrush
& backgroundBrush
) ;
547 virtual void DrawText( const wxString
&str
, wxDouble x
, wxDouble y
, wxDouble angle
, const wxGraphicsBrush
& backgroundBrush
);
549 virtual void GetTextExtent( const wxString
&text
, wxDouble
*width
, wxDouble
*height
,
550 wxDouble
*descent
, wxDouble
*externalLeading
) const = 0;
552 virtual void GetPartialTextExtents(const wxString
& text
, wxArrayDouble
& widths
) const = 0;
558 virtual void DrawBitmap( const wxBitmap
&bmp
, wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
) = 0;
560 virtual void DrawIcon( const wxIcon
&icon
, wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
) = 0;
563 // convenience methods
566 // strokes a single line
567 virtual void StrokeLine( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
);
569 // stroke lines connecting each of the points
570 virtual void StrokeLines( size_t n
, const wxPoint2DDouble
*points
);
572 // stroke disconnected lines from begin to end points
573 virtual void StrokeLines( size_t n
, const wxPoint2DDouble
*beginPoints
, const wxPoint2DDouble
*endPoints
);
576 virtual void DrawLines( size_t n
, const wxPoint2DDouble
*points
, int fillStyle
= wxODDEVEN_RULE
);
579 virtual void DrawRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
582 virtual void DrawEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
584 // draws a rounded rectangle
585 virtual void DrawRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
);
587 // wrappers using wxPoint2DDouble TODO
589 // helper to determine if a 0.5 offset should be applied for the drawing operation
590 virtual bool ShouldOffset() const { return false; }
595 wxGraphicsBrush m_brush
;
596 wxGraphicsFont m_font
;
597 int m_logicalFunction
;
600 DECLARE_NO_COPY_CLASS(wxGraphicsContext
)
601 DECLARE_ABSTRACT_CLASS(wxGraphicsContext
)
607 // A graphics figure allows to cache path, pen etc creations, also will be a basis for layering/grouping elements
610 class WXDLLIMPEXP_CORE wxGraphicsFigure
: public wxGraphicsObject
613 wxGraphicsFigure(wxGraphicsRenderer
* renderer
) ;
615 virtual ~wxGraphicsFigure() ;
617 void SetPath( wxGraphicsMatrix
* matrix
);
619 void SetMatrix( wxGraphicsPath
* path
);
621 // draws this object on the context
622 virtual void Draw( wxGraphicsContext
* cg
);
624 // returns the path of this object
625 wxGraphicsPath
* GetPath() { return m_path
; }
627 // returns the transformation matrix of this object, may be null if there is no transformation necessary
628 wxGraphicsMatrix
* GetMatrix() { return m_matrix
; }
631 wxGraphicsMatrix
* m_matrix
;
632 wxGraphicsPath
* m_path
;
634 DECLARE_DYNAMIC_CLASS(wxGraphicsFigure
)
640 // The graphics renderer is the instance corresponding to the rendering engine used, eg there is ONE core graphics renderer
641 // instance on OSX. This instance is pointed back to by all objects created by it. Therefore you can create eg additional
642 // paths at any point from a given matrix etc.
645 class WXDLLIMPEXP_CORE wxGraphicsRenderer
: public wxObject
648 wxGraphicsRenderer() {}
650 virtual ~wxGraphicsRenderer() {}
652 static wxGraphicsRenderer
* GetDefaultRenderer();
656 virtual wxGraphicsContext
* CreateContext( const wxWindowDC
& dc
) = 0 ;
658 virtual wxGraphicsContext
* CreateContext( const wxMemoryDC
& dc
) = 0 ;
660 virtual wxGraphicsContext
* CreateContextFromNativeContext( void * context
) = 0;
662 virtual wxGraphicsContext
* CreateContextFromNativeWindow( void * window
) = 0;
664 virtual wxGraphicsContext
* CreateContext( wxWindow
* window
) = 0;
666 // create a context that can be used for measuring texts only, no drawing allowed
667 virtual wxGraphicsContext
* CreateMeasuringContext() = 0;
671 virtual wxGraphicsPath
CreatePath() = 0;
675 virtual wxGraphicsMatrix
CreateMatrix( wxDouble a
=1.0, wxDouble b
=0.0, wxDouble c
=0.0, wxDouble d
=1.0,
676 wxDouble tx
=0.0, wxDouble ty
=0.0) = 0;
680 virtual wxGraphicsPen
CreatePen(const wxPen
& pen
) = 0 ;
682 virtual wxGraphicsBrush
CreateBrush(const wxBrush
& brush
) = 0 ;
684 // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
685 virtual wxGraphicsBrush
CreateLinearGradientBrush( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
,
686 const wxColour
&c1
, const wxColour
&c2
) = 0;
688 // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
689 // with radius r and color cColor
690 virtual wxGraphicsBrush
CreateRadialGradientBrush( wxDouble xo
, wxDouble yo
, wxDouble xc
, wxDouble yc
, wxDouble radius
,
691 const wxColour
&oColor
, const wxColour
&cColor
) = 0;
694 virtual wxGraphicsFont
CreateFont( const wxFont
&font
, const wxColour
&col
= *wxBLACK
) = 0;
697 DECLARE_NO_COPY_CLASS(wxGraphicsRenderer
)
698 DECLARE_ABSTRACT_CLASS(wxGraphicsRenderer
)
703 #endif // _WX_GRAPHICS_H_