1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of various wxGraphics* classes
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
12 A wxGraphicsPath is a native representation of a geometric path. The
13 contents are specific an private to the respective renderer. Instances are
14 reference counted and can therefore be assigned as usual. The only way to
15 get a valid instance is by using wxGraphicsContext::CreatePath() or
16 wxGraphicsRenderer::CreatePath().
21 class wxGraphicsPath
: public wxGraphicsObject
25 Adds an arc of a circle.
27 The circle is defined by the coordinates of its centre (@a x, @a y) or
28 @a c and its radius @a r. The arc goes from the starting angle @a
29 startAngle to @a endAngle either clockwise or counter-clockwise
30 depending on the value of @a clockwise argument.
32 The angles are measured in radians but, contrary to the usual
33 mathematical convention, are always @e clockwise from the horizontal
37 virtual void AddArc(wxDouble x
, wxDouble y
, wxDouble r
,
38 wxDouble startAngle
, wxDouble endAngle
,
40 void AddArc(const wxPoint2DDouble
& c
, wxDouble r
,
41 wxDouble startAngle
, wxDouble endAngle
, bool clockwise
);
45 Appends a an arc to two tangents connecting (current) to (@a x1,@a y1)
46 and (@a x1,@a y1) to (@a x2,@a y2), also a straight line from (current)
49 virtual void AddArcToPoint(wxDouble x1
, wxDouble y1
, wxDouble x2
,
50 wxDouble y2
, wxDouble r
);
53 Appends a circle around (@a x,@a y) with radius @a r as a new closed
56 virtual void AddCircle(wxDouble x
, wxDouble y
, wxDouble r
);
59 Adds a cubic bezier curve from the current point, using two control
60 points and an end point.
62 virtual void AddCurveToPoint(wxDouble cx1
, wxDouble cy1
,
63 wxDouble cx2
, wxDouble cy2
,
64 wxDouble x
, wxDouble y
);
66 Adds a cubic bezier curve from the current point, using two control
67 points and an end point.
69 void AddCurveToPoint(const wxPoint2DDouble
& c1
,
70 const wxPoint2DDouble
& c2
,
71 const wxPoint2DDouble
& e
);
74 Appends an ellipse fitting into the passed in rectangle.
76 virtual void AddEllipse(wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
79 Adds a straight line from the current point to (@a x,@a y).
81 virtual void AddLineToPoint(wxDouble x
, wxDouble y
);
83 Adds a straight line from the current point to @a p.
85 void AddLineToPoint(const wxPoint2DDouble
& p
);
90 virtual void AddPath(const wxGraphicsPath
& path
);
93 Adds a quadratic bezier curve from the current point, using a control
94 point and an end point.
96 virtual void AddQuadCurveToPoint(wxDouble cx
, wxDouble cy
,
97 wxDouble x
, wxDouble y
);
100 Appends a rectangle as a new closed subpath.
102 virtual void AddRectangle(wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
105 Appends a rounded rectangle as a new closed subpath.
107 virtual void AddRoundedRectangle(wxDouble x
, wxDouble y
, wxDouble w
,
108 wxDouble h
, wxDouble radius
);
111 Closes the current sub-path.
113 virtual void CloseSubpath();
116 @return @true if the point is within the path.
118 bool Contains(const wxPoint2DDouble
& c
,
119 int fillStyle
= wxODDEVEN_RULE
) const;
121 @return @true if the point is within the path.
123 virtual bool Contains(wxDouble x
, wxDouble y
,
124 int fillStyle
= wxODDEVEN_RULE
) const;
127 Gets the bounding box enclosing all points (possibly including control
130 wxRect2DDouble
GetBox() const;
132 Gets the bounding box enclosing all points (possibly including control
135 virtual void GetBox(wxDouble
* x
, wxDouble
* y
,
136 wxDouble
* w
, wxDouble
* h
) const;
139 Gets the last point of the current path, (0,0) if not yet set.
141 virtual void GetCurrentPoint(wxDouble
* x
, wxDouble
* y
) const;
143 Gets the last point of the current path, (0,0) if not yet set.
145 wxPoint2DDouble
GetCurrentPoint() const;
148 Returns the native path (CGPathRef for Core Graphics, Path pointer for
149 GDIPlus and a cairo_path_t pointer for cairo).
151 virtual void* GetNativePath() const;
154 Begins a new subpath at (@a x,@a y).
156 virtual void MoveToPoint(wxDouble x
, wxDouble y
);
158 Begins a new subpath at @a p.
160 void MoveToPoint(const wxPoint2DDouble
& p
);
163 Transforms each point of this path by the matrix.
165 virtual void Transform(const wxGraphicsMatrix
& matrix
);
168 Gives back the native path returned by GetNativePath() because there
169 might be some deallocations necessary (e.g. on cairo the native path
170 returned by GetNativePath() is newly allocated each time).
172 virtual void UnGetNativePath(void* p
) const;
178 @class wxGraphicsObject
180 This class is the superclass of native graphics objects like pens etc. It
181 allows reference counting. Not instantiated by user code.
186 @see wxGraphicsBrush, wxGraphicsPen, wxGraphicsMatrix, wxGraphicsPath
188 class wxGraphicsObject
: public wxObject
192 Returns the renderer that was used to create this instance, or @NULL
193 if it has not been initialized yet.
195 wxGraphicsRenderer
* GetRenderer() const;
198 @return @false if this object is valid, otherwise returns @true.
204 Anti-aliasing modes used by wxGraphicsContext::SetAntialiasMode().
208 /** No anti-aliasing */
211 /** The default anti-aliasing */
216 Interpolation quality used by wxGraphicsContext::SetInterpolationQuality().
218 enum wxInterpolationQuality
220 /** default interpolation, based on type of context, in general medium quality */
221 wxINTERPOLATION_DEFAULT
,
222 /** no interpolation */
223 wxINTERPOLATION_NONE
,
224 /** fast interpolation, suited for interactivity */
225 wxINTERPOLATION_FAST
,
226 /** better quality */
227 wxINTERPOLATION_GOOD
,
228 /** best quality, not suited for interactivity */
233 Compositing is done using Porter-Duff compositions
234 (see http://keithp.com/~keithp/porterduff/p253-porter.pdf) with
235 wxGraphicsContext::SetCompositionMode().
237 The description give a short equation on how the values of a resulting
238 pixel are calculated.
239 @e R = Result, @e S = Source, @e D = Destination, colors premultiplied with alpha
240 @e Ra, @e Sa, @e Da their alpha components
242 enum wxCompositionMode
245 Indicates invalid or unsupported composition mode.
247 This value can't be passed to wxGraphicsContext::SetCompositionMode().
251 wxCOMPOSITION_INVALID
= -1,
252 wxCOMPOSITION_CLEAR
, /**< @e R = 0 */
253 wxCOMPOSITION_SOURCE
, /**< @e R = S */
254 wxCOMPOSITION_OVER
, /**< @e R = @e S + @e D*(1 - @e Sa) */
255 wxCOMPOSITION_IN
, /**< @e R = @e S*@e Da */
256 wxCOMPOSITION_OUT
, /**< @e R = @e S*(1 - @e Da) */
257 wxCOMPOSITION_ATOP
, /**< @e R = @e S*@e Da + @e D*(1 - @e Sa) */
259 wxCOMPOSITION_DEST
, /**< @e R = @e D, essentially a noop */
260 wxCOMPOSITION_DEST_OVER
, /**< @e R = @e S*(1 - @e Da) + @e D */
261 wxCOMPOSITION_DEST_IN
, /**< @e R = @e D*@e Sa */
262 wxCOMPOSITION_DEST_OUT
, /**< @e R = @e D*(1 - @e Sa) */
263 wxCOMPOSITION_DEST_ATOP
, /**< @e R = @e S*(1 - @e Da) + @e D*@e Sa */
264 wxCOMPOSITION_XOR
, /**< @e R = @e S*(1 - @e Da) + @e D*(1 - @e Sa) */
265 wxCOMPOSITION_ADD
/**< @e R = @e S + @e D */
270 @class wxGraphicsContext
272 A wxGraphicsContext instance is the object that is drawn upon. It is
273 created by a renderer using wxGraphicsRenderer::CreateContext(). This can
274 be either directly using a renderer instance, or indirectly using the
275 static convenience Create() functions of wxGraphicsContext that always
276 delegate the task to the default renderer.
279 void MyCanvas::OnPaint(wxPaintEvent &event)
284 // Create graphics context from it
285 wxGraphicsContext *gc = wxGraphicsContext::Create( dc );
289 // make a path that contains a circle and some lines
290 gc->SetPen( *wxRED_PEN );
291 wxGraphicsPath path = gc->CreatePath();
292 path.AddCircle( 50.0, 50.0, 50.0 );
293 path.MoveToPoint(0.0, 50.0);
294 path.AddLineToPoint(100.0, 50.0);
295 path.MoveToPoint(50.0, 0.0);
296 path.AddLineToPoint(50.0, 100.0 );
298 path.AddRectangle(25.0, 25.0, 50.0, 50.0);
300 gc->StrokePath(path);
310 @see wxGraphicsRenderer::CreateContext(), wxGCDC, wxDC
312 class wxGraphicsContext
: public wxGraphicsObject
316 Creates a wxGraphicsContext from a wxWindow.
318 @see wxGraphicsRenderer::CreateContext()
320 static wxGraphicsContext
* Create(wxWindow
* window
);
323 Creates a wxGraphicsContext from a wxWindowDC
325 @see wxGraphicsRenderer::CreateContext()
327 static wxGraphicsContext
* Create(const wxWindowDC
& dc
);
330 Creates a wxGraphicsContext from a wxMemoryDC
332 @see wxGraphicsRenderer::CreateContext()
334 static wxGraphicsContext
* Create(const wxMemoryDC
& dc
);
337 Creates a wxGraphicsContext from a wxPrinterDC. Under GTK+, this will
338 only work when using the GtkPrint printing backend which is available
341 @see wxGraphicsRenderer::CreateContext(), @ref overview_unixprinting
343 static wxGraphicsContext
* Create(const wxPrinterDC
& dc
);
346 Creates a wxGraphicsContext from a wxEnhMetaFileDC.
348 This function, as wxEnhMetaFileDC class itself, is only available only
351 @see wxGraphicsRenderer::CreateContext()
353 static wxGraphicsContext
* Create(const wxEnhMetaFileDC
& dc
);
356 Clips drawings to the specified region.
358 virtual void Clip(const wxRegion
& region
) = 0;
361 Clips drawings to the specified rectangle.
363 virtual void Clip(wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
) = 0;
366 Concatenates the passed in transform with the current transform of this
369 virtual void ConcatTransform(const wxGraphicsMatrix
& matrix
) = 0;
372 Creates a native brush from a wxBrush.
374 virtual wxGraphicsBrush
CreateBrush(const wxBrush
& brush
) const;
377 Creates a native graphics font from a wxFont and a text colour.
379 virtual wxGraphicsFont
CreateFont(const wxFont
& font
,
380 const wxColour
& col
= *wxBLACK
) const;
383 Creates a wxGraphicsContext from a native context. This native context
384 must be a CGContextRef for Core Graphics, a Graphics pointer for
385 GDIPlus, or a cairo_t pointer for cairo.
387 @see wxGraphicsRenderer::CreateContextFromNativeContext()
389 static wxGraphicsContext
* CreateFromNative(void* context
);
392 Creates a wxGraphicsContext from a native window.
394 @see wxGraphicsRenderer::CreateContextFromNativeWindow()
396 static wxGraphicsContext
* CreateFromNativeWindow(void* window
);
399 Creates a native brush with a linear gradient.
401 The brush starts at (@a x1, @a y1) and ends at (@a x2, @a y2). Either
402 just the start and end gradient colours (@a c1 and @a c2) or full set
403 of gradient @a stops can be specified.
405 The version taking wxGraphicsGradientStops is new in wxWidgets 2.9.1.
409 CreateLinearGradientBrush(wxDouble x1
, wxDouble y1
,
410 wxDouble x2
, wxDouble y2
,
411 const wxColour
& c1
, const wxColour
& c2
) const;
414 CreateLinearGradientBrush(wxDouble x1
, wxDouble y1
,
415 wxDouble x2
, wxDouble y2
,
416 const wxGraphicsGradientStops
& stops
) const;
420 Creates a native affine transformation matrix from the passed in
421 values. The default parameters result in an identity matrix.
423 virtual wxGraphicsMatrix
CreateMatrix(wxDouble a
= 1.0, wxDouble b
= 0.0,
424 wxDouble c
= 0.0, wxDouble d
= 1.0,
426 wxDouble ty
= 0.0) const;
429 Creates a native graphics path which is initially empty.
431 wxGraphicsPath
CreatePath() const;
434 Creates a native pen from a wxPen.
436 virtual wxGraphicsPen
CreatePen(const wxPen
& pen
) const;
439 Creates a native brush with a radial gradient.
441 The brush originates at (@a xo, @a yc) and ends on a circle around
442 (@a xc, @a yc) with the given @a radius.
444 The gradient may be specified either by its start and end colours @a
445 oColor and @a cColor or by a full set of gradient @a stops.
447 The version taking wxGraphicsGradientStops is new in wxWidgets 2.9.1.
450 virtual wxGraphicsBrush
451 CreateRadialGradientBrush(wxDouble xo
, wxDouble yo
,
452 wxDouble xc
, wxDouble yc
,
454 const wxColour
& oColor
,
455 const wxColour
& cColor
) const;
457 virtual wxGraphicsBrush
458 CreateRadialGradientBrush(wxDouble xo
, wxDouble yo
,
459 wxDouble xc
, wxDouble yc
,
461 const wxGraphicsGradientStops
& stops
) = 0;
465 Draws the bitmap. In case of a mono bitmap, this is treated as a mask
466 and the current brushed is used for filling.
468 virtual void DrawBitmap(const wxBitmap
& bmp
, wxDouble x
, wxDouble y
,
469 wxDouble w
, wxDouble h
) = 0;
474 virtual void DrawEllipse(wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
479 virtual void DrawIcon(const wxIcon
& icon
, wxDouble x
, wxDouble y
,
480 wxDouble w
, wxDouble h
) = 0;
485 virtual void DrawLines(size_t n
, const wxPoint2DDouble
* points
,
486 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
);
489 Draws the path by first filling and then stroking.
491 virtual void DrawPath(const wxGraphicsPath
& path
,
492 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
);
497 virtual void DrawRectangle(wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
500 Draws a rounded rectangle.
502 virtual void DrawRoundedRectangle(wxDouble x
, wxDouble y
, wxDouble w
,
503 wxDouble h
, wxDouble radius
);
506 Draws text at the defined position.
508 void DrawText(const wxString
& str
, wxDouble x
, wxDouble y
);
510 Draws text at the defined position.
515 The x coordinate position to draw the text at.
517 The y coordinate position to draw the text at.
519 The angle relative to the (default) horizontal direction to draw
522 void DrawText(const wxString
& str
, wxDouble x
, wxDouble y
, wxDouble angle
);
524 Draws text at the defined position.
529 The x coordinate position to draw the text at.
531 The y coordinate position to draw the text at.
532 @param backgroundBrush
533 Brush to fill the text with.
535 void DrawText(const wxString
& str
, wxDouble x
, wxDouble y
,
536 const wxGraphicsBrush
& backgroundBrush
);
538 Draws text at the defined position.
543 The x coordinate position to draw the text at.
545 The y coordinate position to draw the text at.
547 The angle relative to the (default) horizontal direction to draw
549 @param backgroundBrush
550 Brush to fill the text with.
552 void DrawText(const wxString
& str
, wxDouble x
, wxDouble y
,
553 wxDouble angle
, const wxGraphicsBrush
& backgroundBrush
);
556 Fills the path with the current brush.
558 virtual void FillPath(const wxGraphicsPath
& path
,
559 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) = 0;
562 Returns the native context (CGContextRef for Core Graphics, Graphics
563 pointer for GDIPlus and cairo_t pointer for cairo).
565 virtual void* GetNativeContext() = 0;
568 Fills the @a widths array with the widths from the beginning of
569 @a text to the corresponding character of @a text.
571 virtual void GetPartialTextExtents(const wxString
& text
,
572 wxArrayDouble
& widths
) const = 0;
575 Gets the dimensions of the string using the currently selected font.
578 The text string to measure.
580 Variable to store the total calculated width of the text.
582 Variable to store the total calculated height of the text.
584 Variable to store the dimension from the baseline of the font to
585 the bottom of the descender.
586 @param externalLeading
587 Any extra vertical space added to the font by the font designer
590 virtual void GetTextExtent(const wxString
& text
, wxDouble
* width
,
591 wxDouble
* height
, wxDouble
* descent
,
592 wxDouble
* externalLeading
) const = 0;
595 Gets the current transformation matrix of this context.
597 virtual wxGraphicsMatrix
GetTransform() const = 0;
600 Resets the clipping to original shape.
602 virtual void ResetClip() = 0;
605 Rotates the current transformation matrix (in radians).
607 virtual void Rotate(wxDouble angle
) = 0;
610 Scales the current transformation matrix.
612 virtual void Scale(wxDouble xScale
, wxDouble yScale
) = 0;
615 Sets the brush for filling paths.
617 void SetBrush(const wxBrush
& brush
);
619 Sets the brush for filling paths.
621 virtual void SetBrush(const wxGraphicsBrush
& brush
);
624 Sets the font for drawing text.
626 void SetFont(const wxFont
& font
, const wxColour
& colour
);
628 Sets the font for drawing text.
630 virtual void SetFont(const wxGraphicsFont
& font
);
633 Sets the pen used for stroking.
635 void SetPen(const wxPen
& pen
);
637 Sets the pen used for stroking.
639 virtual void SetPen(const wxGraphicsPen
& pen
);
642 Sets the current transformation matrix of this context
644 virtual void SetTransform(const wxGraphicsMatrix
& matrix
) = 0;
647 Strokes a single line.
649 virtual void StrokeLine(wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
);
652 Stroke disconnected lines from begin to end points, fastest method
653 available for this purpose.
655 virtual void StrokeLines(size_t n
, const wxPoint2DDouble
* beginPoints
,
656 const wxPoint2DDouble
* endPoints
);
658 Stroke lines connecting all the points.
660 Unlike the other overload of this function, this method draws a single
661 polyline and not a number of disconnected lines.
663 virtual void StrokeLines(size_t n
, const wxPoint2DDouble
* points
);
666 Strokes along a path with the current pen.
668 virtual void StrokePath(const wxGraphicsPath
& path
) = 0;
671 Translates the current transformation matrix.
673 virtual void Translate(wxDouble dx
, wxDouble dy
) = 0;
676 Redirects all rendering is done into a fully transparent temporary context
678 virtual void BeginLayer(wxDouble opacity
) = 0;
681 Composites back the drawings into the context with the opacity given at
684 virtual void EndLayer() = 0;
687 Sets the antialiasing mode, returns true if it supported
689 virtual bool SetAntialiasMode(wxAntialiasMode antialias
) = 0;
692 Returns the current shape antialiasing mode
694 virtual wxAntialiasMode
GetAntialiasMode() const ;
697 Sets the interpolation quality, returns true if it supported
699 virtual bool SetInterpolationQuality(wxInterpolationQuality interpolation
) = 0;
702 Returns the current interpolation quality
704 virtual wxInterpolationQuality
GetInterpolationQuality() const;
707 Sets the compositing operator, returns true if it supported
709 virtual bool SetCompositionMode(wxCompositionMode op
) = 0;
712 Returns the current compositing operator
714 virtual wxCompositionMode
GetCompositionMode() const;
719 Represents a single gradient stop in a collection of gradient stops as
720 represented by wxGraphicsGradientStops.
727 class wxGraphicsGradientStop
731 Creates a stop with the given colour and position.
733 @param col The colour of this stop. Note that the alpha component of
734 the colour is honoured thus allowing the background colours to
735 partially show through the gradient.
736 @param pos The stop position, must be in [0, 1] range with 0 being the
737 beginning and 1 the end of the gradient.
739 wxGraphicsGradientStop(wxColour col
= wxTransparentColour
, float pos
= 0.);
741 /// Return the stop colour.
742 const wxColour
& GetColour() const;
745 Change the stop colour.
747 @param col The new colour.
749 void SetColour(const wxColour
& col
);
751 /// Return the stop position.
752 float GetPosition() const;
755 Change the stop position.
757 @param pos The new position, must always be in [0, 1] range.
759 void SetPosition(float pos
);
763 Represents a collection of wxGraphicGradientStop values for use with
764 CreateLinearGradientBrush and CreateRadialGradientBrush.
766 The stops are maintained in order of position. If two or more stops are
767 added with the same position then the one(s) added later come later.
768 This can be useful for producing discontinuities in the colour gradient.
770 Notice that this class is write-once, you can't modify the stops once they
778 class wxGraphicsGradientStops
782 Initializes the gradient stops with the given boundary colours.
784 Creates a wxGraphicsGradientStops instance with start colour given
785 by @a startCol and end colour given by @a endCol.
787 wxGraphicsGradientStops(wxColour startCol
= wxTransparentColour
,
788 wxColour endCol
= wxTransparentColour
);
794 void Add(const wxGraphicsGradientStop
& stop
);
795 void Add(wxColour col
, float pos
);
799 Returns the stop at the given index.
801 @param n The index, must be in [0, GetCount()) range.
803 wxGraphicsGradientStop
Item(unsigned n
) const;
806 Returns the number of stops.
808 unsigned GetCount() const;
811 Set the start colour to @a col
813 void SetStartColour(wxColour col
);
816 Returns the start colour.
818 wxColour
GetStartColour() const;
821 Set the end colour to @a col
823 void SetEndColour(wxColour col
);
826 Returns the end colour.
828 wxColour
GetEndColour() const;
832 @class wxGraphicsRenderer
834 A wxGraphicsRenderer is the instance corresponding to the rendering engine
835 used. There may be multiple instances on a system, if there are different
836 rendering engines present, but there is always only one instance per
837 engine. This instance is pointed back to by all objects created by it
838 (wxGraphicsContext, wxGraphicsPath etc) and can be retrieved through their
839 wxGraphicsObject::GetRenderer() method. Therefore you can create an
840 additional instance of a path etc. by calling
841 wxGraphicsObject::GetRenderer() and then using the appropriate CreateXXX()
842 function of that renderer.
845 wxGraphicsPath *path = // from somewhere
846 wxGraphicsBrush *brush = path->GetRenderer()->CreateBrush( *wxBLACK_BRUSH );
852 class wxGraphicsRenderer
: public wxObject
856 Creates a wxGraphicsContext from a wxWindow.
858 virtual wxGraphicsContext
* CreateContext(wxWindow
* window
) = 0;
861 Creates a wxGraphicsContext from a wxWindowDC
863 virtual wxGraphicsContext
* CreateContext(const wxWindowDC
& dc
) = 0 ;
866 Creates a wxGraphicsContext from a wxMemoryDC
868 virtual wxGraphicsContext
* CreateContext(const wxMemoryDC
& dc
) = 0 ;
871 Creates a wxGraphicsContext from a wxPrinterDC
873 virtual wxGraphicsContext
* CreateContext(const wxPrinterDC
& dc
) = 0 ;
876 Creates a wxGraphicsContext from a wxEnhMetaFileDC.
878 This function, as wxEnhMetaFileDC class itself, is only available only
881 virtual wxGraphicsContext
* CreateContext(const wxEnhMetaFileDC
& dc
) = 0;
884 Creates a native brush from a wxBrush.
886 virtual wxGraphicsBrush
CreateBrush(const wxBrush
& brush
) = 0;
889 Creates a wxGraphicsContext from a native context. This native context
890 must be a CGContextRef for Core Graphics, a Graphics pointer for
891 GDIPlus, or a cairo_t pointer for cairo.
893 virtual wxGraphicsContext
* CreateContextFromNativeContext(void* context
) = 0;
896 Creates a wxGraphicsContext from a native window.
898 virtual wxGraphicsContext
* CreateContextFromNativeWindow(void* window
) = 0;
901 Creates a wxGraphicsContext that can be used for measuring texts only.
902 No drawing commands are allowed.
904 virtual wxGraphicsContext
* CreateMeasuringContext() = 0;
907 Creates a native graphics font from a wxFont and a text colour.
909 virtual wxGraphicsFont
CreateFont(const wxFont
& font
,
910 const wxColour
& col
= *wxBLACK
) = 0;
914 Creates a native brush with a linear gradient.
916 Stops support is new since wxWidgets 2.9.1, previously only the start
917 and end colours could be specified.
919 virtual wxGraphicsBrush
CreateLinearGradientBrush(wxDouble x1
,
923 const wxGraphicsGradientStops
& stops
) = 0;
926 Creates a native affine transformation matrix from the passed in
927 values. The defaults result in an identity matrix.
929 virtual wxGraphicsMatrix
CreateMatrix(wxDouble a
= 1.0, wxDouble b
= 0.0,
930 wxDouble c
= 0.0, wxDouble d
= 1.0,
932 wxDouble ty
= 0.0) = 0;
935 Creates a native graphics path which is initially empty.
937 virtual wxGraphicsPath
CreatePath() = 0;
940 Creates a native pen from a wxPen.
942 virtual wxGraphicsPen
CreatePen(const wxPen
& pen
) = 0;
945 Creates a native brush with a radial gradient.
947 Stops support is new since wxWidgets 2.9.1, previously only the start
948 and end colours could be specified.
950 virtual wxGraphicsBrush
CreateRadialGradientBrush(wxDouble xo
, wxDouble yo
,
951 wxDouble xc
, wxDouble yc
,
953 const wxGraphicsGradientStops
& stops
) = 0;
956 Returns the default renderer on this platform. On OS X this is the Core
957 Graphics (a.k.a. Quartz 2D) renderer, on MSW the GDIPlus renderer, and
958 on GTK we currently default to the cairo renderer.
960 static wxGraphicsRenderer
* GetDefaultRenderer();
966 @class wxGraphicsBrush
968 A wxGraphicsBrush is a native representation of a brush. The contents are
969 specific and private to the respective renderer. Instances are ref counted
970 and can therefore be assigned as usual. The only way to get a valid
971 instance is via wxGraphicsContext::CreateBrush() or
972 wxGraphicsRenderer::CreateBrush().
977 class wxGraphicsBrush
: public wxGraphicsObject
986 @class wxGraphicsFont
988 A wxGraphicsFont is a native representation of a font. The contents are
989 specific and private to the respective renderer. Instances are ref counted
990 and can therefore be assigned as usual. The only way to get a valid
991 instance is via wxGraphicsContext::CreateFont() or
992 wxGraphicsRenderer::CreateFont().
997 class wxGraphicsFont
: public wxGraphicsObject
1006 @class wxGraphicsPen
1008 A wxGraphicsPen is a native representation of a pen. The contents are
1009 specific and private to the respective renderer. Instances are ref counted
1010 and can therefore be assigned as usual. The only way to get a valid
1011 instance is via wxGraphicsContext::CreatePen() or
1012 wxGraphicsRenderer::CreatePen().
1017 class wxGraphicsPen
: public wxGraphicsObject
1026 @class wxGraphicsMatrix
1028 A wxGraphicsMatrix is a native representation of an affine matrix. The
1029 contents are specific and private to the respective renderer. Instances are
1030 ref counted and can therefore be assigned as usual. The only way to get a
1031 valid instance is via wxGraphicsContext::CreateMatrix() or
1032 wxGraphicsRenderer::CreateMatrix().
1037 class wxGraphicsMatrix
: public wxGraphicsObject
1041 Concatenates the matrix passed with the current matrix.
1043 virtual void Concat(const wxGraphicsMatrix
* t
);
1045 Concatenates the matrix passed with the current matrix.
1047 void Concat(const wxGraphicsMatrix
& t
);
1050 Returns the component values of the matrix via the argument pointers.
1052 virtual void Get(wxDouble
* a
= NULL
, wxDouble
* b
= NULL
,
1053 wxDouble
* c
= NULL
, wxDouble
* d
= NULL
,
1054 wxDouble
* tx
= NULL
, wxDouble
* ty
= NULL
) const;
1057 Returns the native representation of the matrix. For CoreGraphics this
1058 is a CFAffineMatrix pointer, for GDIPlus a Matrix Pointer, and for
1059 Cairo a cairo_matrix_t pointer.
1061 virtual void* GetNativeMatrix() const;
1066 virtual void Invert();
1069 Returns @true if the elements of the transformation matrix are equal.
1071 virtual bool IsEqual(const wxGraphicsMatrix
* t
) const;
1073 Returns @true if the elements of the transformation matrix are equal.
1075 bool IsEqual(const wxGraphicsMatrix
& t
) const;
1078 Return @true if this is the identity matrix.
1080 virtual bool IsIdentity() const;
1083 Rotates this matrix (in radians).
1085 virtual void Rotate(wxDouble angle
);
1090 virtual void Scale(wxDouble xScale
, wxDouble yScale
);
1093 Sets the matrix to the respective values (default values are the
1096 virtual void Set(wxDouble a
= 1.0, wxDouble b
= 0.0, wxDouble c
= 0.0,
1097 wxDouble d
= 1.0, wxDouble tx
= 0.0, wxDouble ty
= 0.0);
1100 Applies this matrix to a distance (ie. performs all transforms except
1103 virtual void TransformDistance(wxDouble
* dx
, wxDouble
* dy
) const;
1106 Applies this matrix to a point.
1108 virtual void TransformPoint(wxDouble
* x
, wxDouble
* y
) const;
1111 Translates this matrix.
1113 virtual void Translate(wxDouble dx
, wxDouble dy
);