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_
17 #if wxUSE_GRAPHICS_CONTEXT
19 #include "wx/geometry.h"
20 #include "wx/dynarray.h"
22 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
23 class WXDLLIMPEXP_FWD_CORE wxMemoryDC
;
24 class WXDLLIMPEXP_FWD_CORE wxGraphicsContext
;
25 class WXDLLIMPEXP_FWD_CORE wxGraphicsPath
;
26 class WXDLLIMPEXP_FWD_CORE wxGraphicsMatrix
;
27 class WXDLLIMPEXP_FWD_CORE wxGraphicsFigure
;
28 class WXDLLIMPEXP_FWD_CORE wxGraphicsRenderer
;
29 class WXDLLIMPEXP_FWD_CORE wxGraphicsPen
;
30 class WXDLLIMPEXP_FWD_CORE wxGraphicsBrush
;
31 class WXDLLIMPEXP_FWD_CORE wxGraphicsFont
;
34 * notes about the graphics context apis
36 * angles : are measured in radians, 0.0 being in direction of positiv x axis, PI/2 being
37 * in direction of positive y axis.
40 // Base class of all objects used for drawing in the new graphics API, the always point back to their
41 // originating rendering engine, there is no dynamic unloading of a renderer currently allowed,
42 // these references are not counted
45 // The data used by objects like graphics pens etc is ref counted, in order to avoid unnecessary expensive
46 // duplication. Any operation on a shared instance that results in a modified state, uncouples this
47 // instance from the other instances that were shared - using copy on write semantics
50 class WXDLLIMPEXP_CORE wxGraphicsObjectRefData
: public wxObjectRefData
53 wxGraphicsObjectRefData( wxGraphicsRenderer
* renderer
);
54 wxGraphicsObjectRefData( const wxGraphicsObjectRefData
* data
);
55 wxGraphicsRenderer
* GetRenderer() const ;
56 virtual wxGraphicsObjectRefData
* Clone() const ;
59 wxGraphicsRenderer
* m_renderer
;
62 class WXDLLIMPEXP_CORE wxGraphicsObject
: public wxObject
66 wxGraphicsObject( wxGraphicsRenderer
* renderer
) ;
67 virtual ~wxGraphicsObject() ;
71 // returns the renderer that was used to create this instance, or NULL if it has not been initialized yet
72 wxGraphicsRenderer
* GetRenderer() const ;
73 wxGraphicsObjectRefData
* GetGraphicsData() const ;
75 virtual wxObjectRefData
* CreateRefData() const;
76 virtual wxObjectRefData
* CloneRefData(const wxObjectRefData
* data
) const;
78 DECLARE_DYNAMIC_CLASS(wxGraphicsObject
)
81 class WXDLLIMPEXP_CORE wxGraphicsPen
: public wxGraphicsObject
85 virtual ~wxGraphicsPen() {}
87 DECLARE_DYNAMIC_CLASS(wxGraphicsPen
)
90 extern WXDLLEXPORT_DATA(wxGraphicsPen
) wxNullGraphicsPen
;
92 class WXDLLIMPEXP_CORE wxGraphicsBrush
: public wxGraphicsObject
96 virtual ~wxGraphicsBrush() {}
98 DECLARE_DYNAMIC_CLASS(wxGraphicsBrush
)
101 extern WXDLLEXPORT_DATA(wxGraphicsBrush
) wxNullGraphicsBrush
;
103 class WXDLLIMPEXP_CORE wxGraphicsFont
: public wxGraphicsObject
107 virtual ~wxGraphicsFont() {}
109 DECLARE_DYNAMIC_CLASS(wxGraphicsFont
)
112 extern WXDLLEXPORT_DATA(wxGraphicsFont
) wxNullGraphicsFont
;
115 class WXDLLIMPEXP_CORE wxGraphicsMatrixData
: public wxGraphicsObjectRefData
118 wxGraphicsMatrixData( wxGraphicsRenderer
* renderer
) :
119 wxGraphicsObjectRefData(renderer
) {}
121 virtual ~wxGraphicsMatrixData() {}
123 // concatenates the matrix
124 virtual void Concat( const wxGraphicsMatrixData
*t
) = 0;
126 // sets the matrix to the respective values
127 virtual void Set(wxDouble a
=1.0, wxDouble b
=0.0, wxDouble c
=0.0, wxDouble d
=1.0,
128 wxDouble tx
=0.0, wxDouble ty
=0.0) = 0;
130 // gets the component valuess of the matrix
131 virtual void Get(wxDouble
* a
=NULL
, wxDouble
* b
=NULL
, wxDouble
* c
=NULL
,
132 wxDouble
* d
=NULL
, wxDouble
* tx
=NULL
, wxDouble
* ty
=NULL
) const = 0;
134 // makes this the inverse matrix
135 virtual void Invert() = 0;
137 // returns true if the elements of the transformation matrix are equal ?
138 virtual bool IsEqual( const wxGraphicsMatrixData
* t
) const = 0;
140 // return true if this is the identity matrix
141 virtual bool IsIdentity() const = 0;
147 // add the translation to this matrix
148 virtual void Translate( wxDouble dx
, wxDouble dy
) = 0;
150 // add the scale to this matrix
151 virtual void Scale( wxDouble xScale
, wxDouble yScale
) = 0;
153 // add the rotation to this matrix (radians)
154 virtual void Rotate( wxDouble angle
) = 0;
157 // apply the transforms
160 // applies that matrix to the point
161 virtual void TransformPoint( wxDouble
*x
, wxDouble
*y
) const = 0;
163 // applies the matrix except for translations
164 virtual void TransformDistance( wxDouble
*dx
, wxDouble
*dy
) const =0;
166 // returns the native representation
167 virtual void * GetNativeMatrix() const = 0;
170 class WXDLLIMPEXP_CORE wxGraphicsMatrix
: public wxGraphicsObject
173 wxGraphicsMatrix() {}
175 virtual ~wxGraphicsMatrix() {}
177 // concatenates the matrix
178 virtual void Concat( const wxGraphicsMatrix
*t
);
179 void Concat( const wxGraphicsMatrix
&t
) { Concat( &t
); }
181 // sets the matrix to the respective values
182 virtual void Set(wxDouble a
=1.0, wxDouble b
=0.0, wxDouble c
=0.0, wxDouble d
=1.0,
183 wxDouble tx
=0.0, wxDouble ty
=0.0);
185 // gets the component valuess of the matrix
186 virtual void Get(wxDouble
* a
=NULL
, wxDouble
* b
=NULL
, wxDouble
* c
=NULL
,
187 wxDouble
* d
=NULL
, wxDouble
* tx
=NULL
, wxDouble
* ty
=NULL
) const;
189 // makes this the inverse matrix
190 virtual void Invert();
192 // returns true if the elements of the transformation matrix are equal ?
193 virtual bool IsEqual( const wxGraphicsMatrix
* t
) const;
194 bool IsEqual( const wxGraphicsMatrix
& t
) const { return IsEqual( &t
); }
196 // return true if this is the identity matrix
197 virtual bool IsIdentity() const;
203 // add the translation to this matrix
204 virtual void Translate( wxDouble dx
, wxDouble dy
);
206 // add the scale to this matrix
207 virtual void Scale( wxDouble xScale
, wxDouble yScale
);
209 // add the rotation to this matrix (radians)
210 virtual void Rotate( wxDouble angle
);
213 // apply the transforms
216 // applies that matrix to the point
217 virtual void TransformPoint( wxDouble
*x
, wxDouble
*y
) const;
219 // applies the matrix except for translations
220 virtual void TransformDistance( wxDouble
*dx
, wxDouble
*dy
) const;
222 // returns the native representation
223 virtual void * GetNativeMatrix() const;
225 const wxGraphicsMatrixData
* GetMatrixData() const
226 { return (const wxGraphicsMatrixData
*) GetRefData(); }
227 wxGraphicsMatrixData
* GetMatrixData()
228 { return (wxGraphicsMatrixData
*) GetRefData(); }
231 DECLARE_DYNAMIC_CLASS(wxGraphicsMatrix
)
234 extern WXDLLEXPORT_DATA(wxGraphicsMatrix
) wxNullGraphicsMatrix
;
236 class WXDLLIMPEXP_CORE wxGraphicsPathData
: public wxGraphicsObjectRefData
239 wxGraphicsPathData(wxGraphicsRenderer
* renderer
) : wxGraphicsObjectRefData(renderer
) {}
240 virtual ~wxGraphicsPathData() {}
243 // These are the path primitives from which everything else can be constructed
246 // begins a new subpath at (x,y)
247 virtual void MoveToPoint( wxDouble x
, wxDouble y
) = 0;
249 // adds a straight line from the current point to (x,y)
250 virtual void AddLineToPoint( wxDouble x
, wxDouble y
) = 0;
252 // adds a cubic Bezier curve from the current point, using two control points and an end point
253 virtual void AddCurveToPoint( wxDouble cx1
, wxDouble cy1
, wxDouble cx2
, wxDouble cy2
, wxDouble x
, wxDouble y
) = 0;
256 virtual void AddPath( const wxGraphicsPathData
* path
) =0;
258 // closes the current sub-path
259 virtual void CloseSubpath() = 0;
261 // gets the last point of the current path, (0,0) if not yet set
262 virtual void GetCurrentPoint( wxDouble
* x
, wxDouble
* y
) const = 0;
264 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
265 virtual void AddArc( wxDouble x
, wxDouble y
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
) = 0;
268 // These are convenience functions which - if not available natively will be assembled
269 // using the primitives from above
272 // adds a quadratic Bezier curve from the current point, using a control point and an end point
273 virtual void AddQuadCurveToPoint( wxDouble cx
, wxDouble cy
, wxDouble x
, wxDouble y
);
275 // appends a rectangle as a new closed subpath
276 virtual void AddRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
278 // appends an ellipsis as a new closed subpath fitting the passed rectangle
279 virtual void AddCircle( wxDouble x
, wxDouble y
, wxDouble r
);
281 // 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)
282 virtual void AddArcToPoint( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
, wxDouble r
) ;
284 // appends an ellipse
285 virtual void AddEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
287 // appends a rounded rectangle
288 virtual void AddRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
);
290 // returns the native path
291 virtual void * GetNativePath() const = 0;
293 // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
294 virtual void UnGetNativePath(void *p
) const= 0;
296 // transforms each point of this path by the matrix
297 virtual void Transform( const wxGraphicsMatrixData
* matrix
) =0;
299 // gets the bounding box enclosing all points (possibly including control points)
300 virtual void GetBox(wxDouble
*x
, wxDouble
*y
, wxDouble
*w
, wxDouble
*h
) const=0;
302 virtual bool Contains( wxDouble x
, wxDouble y
, int fillStyle
= wxODDEVEN_RULE
) const=0;
305 class WXDLLIMPEXP_CORE wxGraphicsPath
: public wxGraphicsObject
309 virtual ~wxGraphicsPath() {}
312 // These are the path primitives from which everything else can be constructed
315 // begins a new subpath at (x,y)
316 virtual void MoveToPoint( wxDouble x
, wxDouble y
);
317 void MoveToPoint( const wxPoint2DDouble
& p
);
319 // adds a straight line from the current point to (x,y)
320 virtual void AddLineToPoint( wxDouble x
, wxDouble y
);
321 void AddLineToPoint( const wxPoint2DDouble
& p
);
323 // adds a cubic Bezier curve from the current point, using two control points and an end point
324 virtual void AddCurveToPoint( wxDouble cx1
, wxDouble cy1
, wxDouble cx2
, wxDouble cy2
, wxDouble x
, wxDouble y
) ;
325 void AddCurveToPoint( const wxPoint2DDouble
& c1
, const wxPoint2DDouble
& c2
, const wxPoint2DDouble
& e
);
328 virtual void AddPath( const wxGraphicsPath
& path
);
330 // closes the current sub-path
331 virtual void CloseSubpath() ;
333 // gets the last point of the current path, (0,0) if not yet set
334 virtual void GetCurrentPoint( wxDouble
* x
, wxDouble
* y
) const;
335 wxPoint2DDouble
GetCurrentPoint() const;
337 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
338 virtual void AddArc( wxDouble x
, wxDouble y
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
) ;
339 void AddArc( const wxPoint2DDouble
& c
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
);
342 // These are convenience functions which - if not available natively will be assembled
343 // using the primitives from above
346 // adds a quadratic Bezier curve from the current point, using a control point and an end point
347 virtual void AddQuadCurveToPoint( wxDouble cx
, wxDouble cy
, wxDouble x
, wxDouble y
);
349 // appends a rectangle as a new closed subpath
350 virtual void AddRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
352 // appends an ellipsis as a new closed subpath fitting the passed rectangle
353 virtual void AddCircle( wxDouble x
, wxDouble y
, wxDouble r
);
355 // 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)
356 virtual void AddArcToPoint( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
, wxDouble r
) ;
358 // appends an ellipse
359 virtual void AddEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
361 // appends a rounded rectangle
362 virtual void AddRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
);
364 // returns the native path
365 virtual void * GetNativePath() const;
367 // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
368 virtual void UnGetNativePath(void *p
)const;
370 // transforms each point of this path by the matrix
371 virtual void Transform( const wxGraphicsMatrix
& matrix
);
373 // gets the bounding box enclosing all points (possibly including control points)
374 virtual void GetBox(wxDouble
*x
, wxDouble
*y
, wxDouble
*w
, wxDouble
*h
)const;
375 wxRect2DDouble
GetBox()const;
377 virtual bool Contains( wxDouble x
, wxDouble y
, int fillStyle
= wxODDEVEN_RULE
)const;
378 bool Contains( const wxPoint2DDouble
& c
, int fillStyle
= wxODDEVEN_RULE
)const;
380 const wxGraphicsPathData
* GetPathData() const
381 { return (const wxGraphicsPathData
*) GetRefData(); }
382 wxGraphicsPathData
* GetPathData()
383 { return (wxGraphicsPathData
*) GetRefData(); }
386 DECLARE_DYNAMIC_CLASS(wxGraphicsPath
)
389 extern WXDLLEXPORT_DATA(wxGraphicsPath
) wxNullGraphicsPath
;
392 class WXDLLIMPEXP_CORE wxGraphicsContext
: public wxGraphicsObject
395 wxGraphicsContext(wxGraphicsRenderer
* renderer
);
397 virtual ~wxGraphicsContext();
399 static wxGraphicsContext
* Create( const wxWindowDC
& dc
) ;
400 static wxGraphicsContext
* Create( const wxMemoryDC
& dc
) ;
402 static wxGraphicsContext
* CreateFromNative( void * context
) ;
404 static wxGraphicsContext
* CreateFromNativeWindow( void * window
) ;
406 static wxGraphicsContext
* Create( wxWindow
* window
) ;
408 // create a context that can be used for measuring texts only, no drawing allowed
409 static wxGraphicsContext
* Create();
411 // begin a new document (relevant only for printing / pdf etc) if there is a progress dialog, message will be shown
412 virtual bool StartDoc( const wxString
& message
) ;
414 // done with that document (relevant only for printing / pdf etc)
415 virtual void EndDoc();
417 // opens a new page (relevant only for printing / pdf etc) with the given size in points
418 // (if both are null the default page size will be used)
419 virtual void StartPage( wxDouble width
= 0, wxDouble height
= 0 );
421 // ends the current page (relevant only for printing / pdf etc)
422 virtual void EndPage();
424 // make sure that the current content of this context is immediately visible
425 virtual void Flush();
427 wxGraphicsPath
CreatePath() const;
429 virtual wxGraphicsPen
CreatePen(const wxPen
& pen
) const;
431 virtual wxGraphicsBrush
CreateBrush(const wxBrush
& brush
) const;
433 // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
434 virtual wxGraphicsBrush
CreateLinearGradientBrush( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
,
435 const wxColour
&c1
, const wxColour
&c2
) const;
437 // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
438 // with radius r and color cColor
439 virtual wxGraphicsBrush
CreateRadialGradientBrush( wxDouble xo
, wxDouble yo
, wxDouble xc
, wxDouble yc
, wxDouble radius
,
440 const wxColour
&oColor
, const wxColour
&cColor
) const;
443 virtual wxGraphicsFont
CreateFont( const wxFont
&font
, const wxColour
&col
= *wxBLACK
) const;
445 // create a 'native' matrix corresponding to these values
446 virtual wxGraphicsMatrix
CreateMatrix( wxDouble a
=1.0, wxDouble b
=0.0, wxDouble c
=0.0, wxDouble d
=1.0,
447 wxDouble tx
=0.0, wxDouble ty
=0.0) const;
449 // push the current state of the context, ie the transformation matrix on a stack
450 virtual void PushState() = 0;
452 // pops a stored state from the stack
453 virtual void PopState() = 0;
455 // clips drawings to the region intersected with the current clipping region
456 virtual void Clip( const wxRegion
®ion
) = 0;
458 // clips drawings to the rect intersected with the current clipping region
459 virtual void Clip( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
) = 0;
461 // resets the clipping to original extent
462 virtual void ResetClip() = 0 ;
464 // returns the native context
465 virtual void * GetNativeContext() = 0;
467 // returns the current logical function
468 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
470 // sets the current logical function, returns true if it supported
471 virtual bool SetLogicalFunction(int function
) ;
473 // returns the size of the graphics context in device coordinates
474 virtual void GetSize( wxDouble
* width
, wxDouble
* height
);
476 // returns the resolution of the graphics context in device points per inch
477 virtual void GetDPI( wxDouble
* dpiX
, wxDouble
* dpiY
);
480 // sets the current alpha on this context
481 virtual void SetAlpha( wxDouble alpha
);
483 // returns the alpha on this context
484 virtual wxDouble
GetAlpha() const;
487 // transformation : changes the current transformation matrix CTM of the context
491 virtual void Translate( wxDouble dx
, wxDouble dy
) = 0;
494 virtual void Scale( wxDouble xScale
, wxDouble yScale
) = 0;
497 virtual void Rotate( wxDouble angle
) = 0;
499 // concatenates this transform with the current transform of this context
500 virtual void ConcatTransform( const wxGraphicsMatrix
& matrix
) = 0;
502 // sets the transform of this context
503 virtual void SetTransform( const wxGraphicsMatrix
& matrix
) = 0;
505 // gets the matrix of this context
506 virtual wxGraphicsMatrix
GetTransform() const = 0;
512 virtual void SetPen( const wxGraphicsPen
& pen
);
514 void SetPen( const wxPen
& pen
);
516 // sets the brush for filling
517 virtual void SetBrush( const wxGraphicsBrush
& brush
);
519 void SetBrush( const wxBrush
& brush
);
522 virtual void SetFont( const wxGraphicsFont
& font
);
524 void SetFont( const wxFont
& font
, const wxColour
& colour
);
527 // strokes along a path with the current pen
528 virtual void StrokePath( const wxGraphicsPath
& path
) = 0;
530 // fills a path with the current brush
531 virtual void FillPath( const wxGraphicsPath
& path
, int fillStyle
= wxODDEVEN_RULE
) = 0;
533 // draws a path by first filling and then stroking
534 virtual void DrawPath( const wxGraphicsPath
& path
, int fillStyle
= wxODDEVEN_RULE
);
540 virtual void DrawText( const wxString
&str
, wxDouble x
, wxDouble y
) = 0;
542 virtual void DrawText( const wxString
&str
, wxDouble x
, wxDouble y
, wxDouble angle
);
544 virtual void DrawText( const wxString
&str
, wxDouble x
, wxDouble y
, const wxGraphicsBrush
& backgroundBrush
) ;
546 virtual void DrawText( const wxString
&str
, wxDouble x
, wxDouble y
, wxDouble angle
, const wxGraphicsBrush
& backgroundBrush
);
548 virtual void GetTextExtent( const wxString
&text
, wxDouble
*width
, wxDouble
*height
,
549 wxDouble
*descent
, wxDouble
*externalLeading
) const = 0;
551 virtual void GetPartialTextExtents(const wxString
& text
, wxArrayDouble
& widths
) const = 0;
557 virtual void DrawBitmap( const wxBitmap
&bmp
, wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
) = 0;
559 virtual void DrawIcon( const wxIcon
&icon
, wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
) = 0;
562 // convenience methods
565 // strokes a single line
566 virtual void StrokeLine( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
);
568 // stroke lines connecting each of the points
569 virtual void StrokeLines( size_t n
, const wxPoint2DDouble
*points
);
571 // stroke disconnected lines from begin to end points
572 virtual void StrokeLines( size_t n
, const wxPoint2DDouble
*beginPoints
, const wxPoint2DDouble
*endPoints
);
575 virtual void DrawLines( size_t n
, const wxPoint2DDouble
*points
, int fillStyle
= wxODDEVEN_RULE
);
578 virtual void DrawRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
581 virtual void DrawEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
583 // draws a rounded rectangle
584 virtual void DrawRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
);
586 // wrappers using wxPoint2DDouble TODO
588 // helper to determine if a 0.5 offset should be applied for the drawing operation
589 virtual bool ShouldOffset() const { return false; }
594 wxGraphicsBrush m_brush
;
595 wxGraphicsFont m_font
;
596 int m_logicalFunction
;
599 DECLARE_NO_COPY_CLASS(wxGraphicsContext
)
600 DECLARE_ABSTRACT_CLASS(wxGraphicsContext
)
606 // A graphics figure allows to cache path, pen etc creations, also will be a basis for layering/grouping elements
609 class WXDLLIMPEXP_CORE wxGraphicsFigure
: public wxGraphicsObject
612 wxGraphicsFigure(wxGraphicsRenderer
* renderer
) ;
614 virtual ~wxGraphicsFigure() ;
616 void SetPath( wxGraphicsMatrix
* matrix
);
618 void SetMatrix( wxGraphicsPath
* path
);
620 // draws this object on the context
621 virtual void Draw( wxGraphicsContext
* cg
);
623 // returns the path of this object
624 wxGraphicsPath
* GetPath() { return m_path
; }
626 // returns the transformation matrix of this object, may be null if there is no transformation necessary
627 wxGraphicsMatrix
* GetMatrix() { return m_matrix
; }
630 wxGraphicsMatrix
* m_matrix
;
631 wxGraphicsPath
* m_path
;
633 DECLARE_DYNAMIC_CLASS(wxGraphicsFigure
)
639 // The graphics renderer is the instance corresponding to the rendering engine used, eg there is ONE core graphics renderer
640 // instance on OSX. This instance is pointed back to by all objects created by it. Therefore you can create eg additional
641 // paths at any point from a given matrix etc.
644 class WXDLLIMPEXP_CORE wxGraphicsRenderer
: public wxObject
647 wxGraphicsRenderer() {}
649 virtual ~wxGraphicsRenderer() {}
651 static wxGraphicsRenderer
* GetDefaultRenderer();
655 virtual wxGraphicsContext
* CreateContext( const wxWindowDC
& dc
) = 0 ;
656 virtual wxGraphicsContext
* CreateContext( const wxMemoryDC
& dc
) = 0 ;
658 virtual wxGraphicsContext
* CreateContextFromNativeContext( void * context
) = 0;
660 virtual wxGraphicsContext
* CreateContextFromNativeWindow( void * window
) = 0;
662 virtual wxGraphicsContext
* CreateContext( wxWindow
* window
) = 0;
664 // create a context that can be used for measuring texts only, no drawing allowed
665 virtual wxGraphicsContext
* CreateMeasuringContext() = 0;
669 virtual wxGraphicsPath
CreatePath() = 0;
673 virtual wxGraphicsMatrix
CreateMatrix( wxDouble a
=1.0, wxDouble b
=0.0, wxDouble c
=0.0, wxDouble d
=1.0,
674 wxDouble tx
=0.0, wxDouble ty
=0.0) = 0;
678 virtual wxGraphicsPen
CreatePen(const wxPen
& pen
) = 0 ;
680 virtual wxGraphicsBrush
CreateBrush(const wxBrush
& brush
) = 0 ;
682 // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
683 virtual wxGraphicsBrush
CreateLinearGradientBrush( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
,
684 const wxColour
&c1
, const wxColour
&c2
) = 0;
686 // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
687 // with radius r and color cColor
688 virtual wxGraphicsBrush
CreateRadialGradientBrush( wxDouble xo
, wxDouble yo
, wxDouble xc
, wxDouble yc
, wxDouble radius
,
689 const wxColour
&oColor
, const wxColour
&cColor
) = 0;
692 virtual wxGraphicsFont
CreateFont( const wxFont
&font
, const wxColour
&col
= *wxBLACK
) = 0;
695 DECLARE_NO_COPY_CLASS(wxGraphicsRenderer
)
696 DECLARE_ABSTRACT_CLASS(wxGraphicsRenderer
)
701 #endif // _WX_GRAPHICS_H_