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 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) const;
121 @return @true if the point is within the path.
123 virtual bool Contains(wxDouble x
, wxDouble y
,
124 wxPolygonFillMode 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 */
271 The objects of this class are not created directly but only via
272 wxGraphicsContext or wxGraphicsRenderer CreateBitmap() and
273 CreateSubBitmap() methods. They can subsequently be used with
274 wxGraphicsContext::DrawBitmap(). The only other operation is testing for
275 the bitmap validity which can be performed using IsNull() method inherited
278 class wxGraphicsBitmap
: public wxGraphicsObject
282 Default constructor creates an invalid bitmap.
284 wxGraphicsBitmap() {}
287 Return the contents of this bitmap as wxImage.
289 Using this method is more efficient than converting wxGraphicsBitmap to
290 wxBitmap first and then to wxImage and can be useful if, for example,
291 you want to save wxGraphicsBitmap as a disk file in a format not
292 directly supported by wxBitmap.
294 Invalid image is returned if the bitmap is invalid.
298 wxImage
ConvertToImage() const;
302 @class wxGraphicsContext
304 A wxGraphicsContext instance is the object that is drawn upon. It is
305 created by a renderer using wxGraphicsRenderer::CreateContext(). This can
306 be either directly using a renderer instance, or indirectly using the
307 static convenience Create() functions of wxGraphicsContext that always
308 delegate the task to the default renderer.
311 void MyCanvas::OnPaint(wxPaintEvent &event)
316 // Create graphics context from it
317 wxGraphicsContext *gc = wxGraphicsContext::Create( dc );
321 // make a path that contains a circle and some lines
322 gc->SetPen( *wxRED_PEN );
323 wxGraphicsPath path = gc->CreatePath();
324 path.AddCircle( 50.0, 50.0, 50.0 );
325 path.MoveToPoint(0.0, 50.0);
326 path.AddLineToPoint(100.0, 50.0);
327 path.MoveToPoint(50.0, 0.0);
328 path.AddLineToPoint(50.0, 100.0 );
330 path.AddRectangle(25.0, 25.0, 50.0, 50.0);
332 gc->StrokePath(path);
342 @see wxGraphicsRenderer::CreateContext(), wxGCDC, wxDC
344 class wxGraphicsContext
: public wxGraphicsObject
348 Creates a wxGraphicsContext from a wxWindow.
350 @see wxGraphicsRenderer::CreateContext()
352 static wxGraphicsContext
* Create(wxWindow
* window
);
355 Creates a wxGraphicsContext from a wxWindowDC
357 @see wxGraphicsRenderer::CreateContext()
359 static wxGraphicsContext
* Create(const wxWindowDC
& dc
);
362 Creates a wxGraphicsContext from a wxMemoryDC
364 @see wxGraphicsRenderer::CreateContext()
366 static wxGraphicsContext
* Create(const wxMemoryDC
& dc
);
369 Creates a wxGraphicsContext from a wxPrinterDC. Under GTK+, this will
370 only work when using the GtkPrint printing backend which is available
373 @see wxGraphicsRenderer::CreateContext(), @ref overview_unixprinting
375 static wxGraphicsContext
* Create(const wxPrinterDC
& dc
);
378 Creates a wxGraphicsContext from a wxEnhMetaFileDC.
380 This function, as wxEnhMetaFileDC class itself, is only available only
383 @see wxGraphicsRenderer::CreateContext()
385 static wxGraphicsContext
* Create(const wxEnhMetaFileDC
& dc
);
388 Clips drawings to the specified region.
390 virtual void Clip(const wxRegion
& region
) = 0;
393 Clips drawings to the specified rectangle.
395 virtual void Clip(wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
) = 0;
398 Concatenates the passed in transform with the current transform of this
401 virtual void ConcatTransform(const wxGraphicsMatrix
& matrix
) = 0;
404 Creates wxGraphicsBitmap from an existing wxBitmap.
406 Returns an invalid wxNullGraphicsBitmap on failure.
408 virtual wxGraphicsBitmap
CreateBitmap( const wxBitmap
&bitmap
) = 0;
411 Extracts a sub-bitmap from an existing bitmap.
413 Currently this function is implemented in the native MSW and OS X
414 versions but not when using Cairo.
416 virtual wxGraphicsBitmap
CreateSubBitmap(const wxGraphicsBitmap
& bitmap
,
417 wxDouble x
, wxDouble y
,
418 wxDouble w
, wxDouble h
) = 0;
421 Creates a native brush from a wxBrush.
423 virtual wxGraphicsBrush
CreateBrush(const wxBrush
& brush
) const;
426 Creates a native graphics font from a wxFont and a text colour.
428 virtual wxGraphicsFont
CreateFont(const wxFont
& font
,
429 const wxColour
& col
= *wxBLACK
) const;
432 Creates a wxGraphicsContext from a native context. This native context
433 must be a CGContextRef for Core Graphics, a Graphics pointer for
434 GDIPlus, or a cairo_t pointer for cairo.
436 @see wxGraphicsRenderer::CreateContextFromNativeContext()
438 static wxGraphicsContext
* CreateFromNative(void* context
);
441 Creates a wxGraphicsContext from a native window.
443 @see wxGraphicsRenderer::CreateContextFromNativeWindow()
445 static wxGraphicsContext
* CreateFromNativeWindow(void* window
);
448 Creates a native brush with a linear gradient.
450 The brush starts at (@a x1, @a y1) and ends at (@a x2, @a y2). Either
451 just the start and end gradient colours (@a c1 and @a c2) or full set
452 of gradient @a stops can be specified.
454 The version taking wxGraphicsGradientStops is new in wxWidgets 2.9.1.
458 CreateLinearGradientBrush(wxDouble x1
, wxDouble y1
,
459 wxDouble x2
, wxDouble y2
,
460 const wxColour
& c1
, const wxColour
& c2
) const;
463 CreateLinearGradientBrush(wxDouble x1
, wxDouble y1
,
464 wxDouble x2
, wxDouble y2
,
465 const wxGraphicsGradientStops
& stops
) const;
469 Creates a native affine transformation matrix from the passed in
470 values. The default parameters result in an identity matrix.
472 virtual wxGraphicsMatrix
CreateMatrix(wxDouble a
= 1.0, wxDouble b
= 0.0,
473 wxDouble c
= 0.0, wxDouble d
= 1.0,
475 wxDouble ty
= 0.0) const;
478 Creates a native graphics path which is initially empty.
480 wxGraphicsPath
CreatePath() const;
483 Creates a native pen from a wxPen.
485 virtual wxGraphicsPen
CreatePen(const wxPen
& pen
) const;
488 Creates a native brush with a radial gradient.
490 The brush originates at (@a xo, @a yc) and ends on a circle around
491 (@a xc, @a yc) with the given @a radius.
493 The gradient may be specified either by its start and end colours @a
494 oColor and @a cColor or by a full set of gradient @a stops.
496 The version taking wxGraphicsGradientStops is new in wxWidgets 2.9.1.
499 virtual wxGraphicsBrush
500 CreateRadialGradientBrush(wxDouble xo
, wxDouble yo
,
501 wxDouble xc
, wxDouble yc
,
503 const wxColour
& oColor
,
504 const wxColour
& cColor
) const;
506 virtual wxGraphicsBrush
507 CreateRadialGradientBrush(wxDouble xo
, wxDouble yo
,
508 wxDouble xc
, wxDouble yc
,
510 const wxGraphicsGradientStops
& stops
) = 0;
514 Draws the bitmap. In case of a mono bitmap, this is treated as a mask
515 and the current brushed is used for filling.
518 virtual void DrawBitmap(const wxGraphicsBitmap
& bmp
,
519 wxDouble x
, wxDouble y
,
520 wxDouble w
, wxDouble h
) = 0;
521 virtual void DrawBitmap(const wxBitmap
& bmp
,
522 wxDouble x
, wxDouble y
,
523 wxDouble w
, wxDouble h
) = 0;
529 virtual void DrawEllipse(wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
534 virtual void DrawIcon(const wxIcon
& icon
, wxDouble x
, wxDouble y
,
535 wxDouble w
, wxDouble h
) = 0;
540 virtual void DrawLines(size_t n
, const wxPoint2DDouble
* points
,
541 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
);
544 Draws the path by first filling and then stroking.
546 virtual void DrawPath(const wxGraphicsPath
& path
,
547 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
);
552 virtual void DrawRectangle(wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
555 Draws a rounded rectangle.
557 virtual void DrawRoundedRectangle(wxDouble x
, wxDouble y
, wxDouble w
,
558 wxDouble h
, wxDouble radius
);
561 Draws text at the defined position.
563 void DrawText(const wxString
& str
, wxDouble x
, wxDouble y
);
565 Draws text at the defined position.
570 The x coordinate position to draw the text at.
572 The y coordinate position to draw the text at.
574 The angle relative to the (default) horizontal direction to draw
577 void DrawText(const wxString
& str
, wxDouble x
, wxDouble y
, wxDouble angle
);
579 Draws text at the defined position.
584 The x coordinate position to draw the text at.
586 The y coordinate position to draw the text at.
587 @param backgroundBrush
588 Brush to fill the text with.
590 void DrawText(const wxString
& str
, wxDouble x
, wxDouble y
,
591 const wxGraphicsBrush
& backgroundBrush
);
593 Draws text at the defined position.
598 The x coordinate position to draw the text at.
600 The y coordinate position to draw the text at.
602 The angle relative to the (default) horizontal direction to draw
604 @param backgroundBrush
605 Brush to fill the text with.
607 void DrawText(const wxString
& str
, wxDouble x
, wxDouble y
,
608 wxDouble angle
, const wxGraphicsBrush
& backgroundBrush
);
611 Fills the path with the current brush.
613 virtual void FillPath(const wxGraphicsPath
& path
,
614 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) = 0;
617 Returns the native context (CGContextRef for Core Graphics, Graphics
618 pointer for GDIPlus and cairo_t pointer for cairo).
620 virtual void* GetNativeContext() = 0;
623 Fills the @a widths array with the widths from the beginning of
624 @a text to the corresponding character of @a text.
626 virtual void GetPartialTextExtents(const wxString
& text
,
627 wxArrayDouble
& widths
) const = 0;
630 Gets the dimensions of the string using the currently selected font.
633 The text string to measure.
635 Variable to store the total calculated width of the text.
637 Variable to store the total calculated height of the text.
639 Variable to store the dimension from the baseline of the font to
640 the bottom of the descender.
641 @param externalLeading
642 Any extra vertical space added to the font by the font designer
645 virtual void GetTextExtent(const wxString
& text
, wxDouble
* width
,
646 wxDouble
* height
, wxDouble
* descent
,
647 wxDouble
* externalLeading
) const = 0;
650 Gets the current transformation matrix of this context.
652 virtual wxGraphicsMatrix
GetTransform() const = 0;
655 Resets the clipping to original shape.
657 virtual void ResetClip() = 0;
660 Rotates the current transformation matrix (in radians).
662 virtual void Rotate(wxDouble angle
) = 0;
665 Scales the current transformation matrix.
667 virtual void Scale(wxDouble xScale
, wxDouble yScale
) = 0;
670 Sets the brush for filling paths.
672 void SetBrush(const wxBrush
& brush
);
674 Sets the brush for filling paths.
676 virtual void SetBrush(const wxGraphicsBrush
& brush
);
679 Sets the font for drawing text.
681 void SetFont(const wxFont
& font
, const wxColour
& colour
);
683 Sets the font for drawing text.
685 virtual void SetFont(const wxGraphicsFont
& font
);
688 Sets the pen used for stroking.
690 void SetPen(const wxPen
& pen
);
692 Sets the pen used for stroking.
694 virtual void SetPen(const wxGraphicsPen
& pen
);
697 Sets the current transformation matrix of this context
699 virtual void SetTransform(const wxGraphicsMatrix
& matrix
) = 0;
702 Strokes a single line.
704 virtual void StrokeLine(wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
);
707 Stroke disconnected lines from begin to end points, fastest method
708 available for this purpose.
710 virtual void StrokeLines(size_t n
, const wxPoint2DDouble
* beginPoints
,
711 const wxPoint2DDouble
* endPoints
);
713 Stroke lines connecting all the points.
715 Unlike the other overload of this function, this method draws a single
716 polyline and not a number of disconnected lines.
718 virtual void StrokeLines(size_t n
, const wxPoint2DDouble
* points
);
721 Strokes along a path with the current pen.
723 virtual void StrokePath(const wxGraphicsPath
& path
) = 0;
726 Translates the current transformation matrix.
728 virtual void Translate(wxDouble dx
, wxDouble dy
) = 0;
731 Redirects all rendering is done into a fully transparent temporary context
733 virtual void BeginLayer(wxDouble opacity
) = 0;
736 Composites back the drawings into the context with the opacity given at
739 virtual void EndLayer() = 0;
742 Sets the antialiasing mode, returns true if it supported
744 virtual bool SetAntialiasMode(wxAntialiasMode antialias
) = 0;
747 Returns the current shape antialiasing mode
749 virtual wxAntialiasMode
GetAntialiasMode() const ;
752 Sets the interpolation quality, returns true if it supported
754 virtual bool SetInterpolationQuality(wxInterpolationQuality interpolation
) = 0;
757 Returns the current interpolation quality
759 virtual wxInterpolationQuality
GetInterpolationQuality() const;
762 Sets the compositing operator, returns true if it supported
764 virtual bool SetCompositionMode(wxCompositionMode op
) = 0;
767 Returns the current compositing operator
769 virtual wxCompositionMode
GetCompositionMode() const;
774 Represents a single gradient stop in a collection of gradient stops as
775 represented by wxGraphicsGradientStops.
782 class wxGraphicsGradientStop
786 Creates a stop with the given colour and position.
788 @param col The colour of this stop. Note that the alpha component of
789 the colour is honoured thus allowing the background colours to
790 partially show through the gradient.
791 @param pos The stop position, must be in [0, 1] range with 0 being the
792 beginning and 1 the end of the gradient.
794 wxGraphicsGradientStop(wxColour col
= wxTransparentColour
, float pos
= 0.);
796 /// Return the stop colour.
797 const wxColour
& GetColour() const;
800 Change the stop colour.
802 @param col The new colour.
804 void SetColour(const wxColour
& col
);
806 /// Return the stop position.
807 float GetPosition() const;
810 Change the stop position.
812 @param pos The new position, must always be in [0, 1] range.
814 void SetPosition(float pos
);
818 Represents a collection of wxGraphicGradientStop values for use with
819 CreateLinearGradientBrush and CreateRadialGradientBrush.
821 The stops are maintained in order of position. If two or more stops are
822 added with the same position then the one(s) added later come later.
823 This can be useful for producing discontinuities in the colour gradient.
825 Notice that this class is write-once, you can't modify the stops once they
833 class wxGraphicsGradientStops
837 Initializes the gradient stops with the given boundary colours.
839 Creates a wxGraphicsGradientStops instance with start colour given
840 by @a startCol and end colour given by @a endCol.
842 wxGraphicsGradientStops(wxColour startCol
= wxTransparentColour
,
843 wxColour endCol
= wxTransparentColour
);
849 void Add(const wxGraphicsGradientStop
& stop
);
850 void Add(wxColour col
, float pos
);
854 Returns the stop at the given index.
856 @param n The index, must be in [0, GetCount()) range.
858 wxGraphicsGradientStop
Item(unsigned n
) const;
861 Returns the number of stops.
863 unsigned GetCount() const;
866 Set the start colour to @a col
868 void SetStartColour(wxColour col
);
871 Returns the start colour.
873 wxColour
GetStartColour() const;
876 Set the end colour to @a col
878 void SetEndColour(wxColour col
);
881 Returns the end colour.
883 wxColour
GetEndColour() const;
887 @class wxGraphicsRenderer
889 A wxGraphicsRenderer is the instance corresponding to the rendering engine
890 used. There may be multiple instances on a system, if there are different
891 rendering engines present, but there is always only one instance per
892 engine. This instance is pointed back to by all objects created by it
893 (wxGraphicsContext, wxGraphicsPath etc) and can be retrieved through their
894 wxGraphicsObject::GetRenderer() method. Therefore you can create an
895 additional instance of a path etc. by calling
896 wxGraphicsObject::GetRenderer() and then using the appropriate CreateXXX()
897 function of that renderer.
900 wxGraphicsPath *path = // from somewhere
901 wxGraphicsBrush *brush = path->GetRenderer()->CreateBrush( *wxBLACK_BRUSH );
907 class wxGraphicsRenderer
: public wxObject
911 Creates wxGraphicsBitmap from an existing wxBitmap.
913 Returns an invalid wxNullGraphicsBitmap on failure.
915 virtual wxGraphicsBitmap
CreateBitmap( const wxBitmap
&bitmap
) = 0;
918 Creates wxGraphicsBitmap from a native bitmap handle.
920 @a bitmap meaning is platform-dependent. Currently it's a GDI+ @c
921 Bitmap pointer under MSW, @c CGImage pointer under OS X or a @c
922 cairo_surface_t pointer when using Cairo under any platform.
924 virtual wxGraphicsBitmap
CreateBitmapFromNativeBitmap( void* bitmap
) = 0;
927 Creates a wxGraphicsContext from a wxWindow.
929 virtual wxGraphicsContext
* CreateContext(wxWindow
* window
) = 0;
932 Creates a wxGraphicsContext from a wxWindowDC
934 virtual wxGraphicsContext
* CreateContext(const wxWindowDC
& dc
) = 0 ;
937 Creates a wxGraphicsContext from a wxMemoryDC
939 virtual wxGraphicsContext
* CreateContext(const wxMemoryDC
& dc
) = 0 ;
942 Creates a wxGraphicsContext from a wxPrinterDC
944 virtual wxGraphicsContext
* CreateContext(const wxPrinterDC
& dc
) = 0 ;
947 Creates a wxGraphicsContext from a wxEnhMetaFileDC.
949 This function, as wxEnhMetaFileDC class itself, is only available only
952 virtual wxGraphicsContext
* CreateContext(const wxEnhMetaFileDC
& dc
) = 0;
955 Creates a native brush from a wxBrush.
957 virtual wxGraphicsBrush
CreateBrush(const wxBrush
& brush
) = 0;
960 Creates a wxGraphicsContext from a native context. This native context
961 must be a CGContextRef for Core Graphics, a Graphics pointer for
962 GDIPlus, or a cairo_t pointer for cairo.
964 virtual wxGraphicsContext
* CreateContextFromNativeContext(void* context
) = 0;
967 Creates a wxGraphicsContext from a native window.
969 virtual wxGraphicsContext
* CreateContextFromNativeWindow(void* window
) = 0;
972 Creates a wxGraphicsContext that can be used for measuring texts only.
973 No drawing commands are allowed.
975 virtual wxGraphicsContext
* CreateMeasuringContext() = 0;
978 Creates a native graphics font from a wxFont and a text colour.
980 virtual wxGraphicsFont
CreateFont(const wxFont
& font
,
981 const wxColour
& col
= *wxBLACK
) = 0;
985 Creates a native brush with a linear gradient.
987 Stops support is new since wxWidgets 2.9.1, previously only the start
988 and end colours could be specified.
990 virtual wxGraphicsBrush
CreateLinearGradientBrush(wxDouble x1
,
994 const wxGraphicsGradientStops
& stops
) = 0;
997 Creates a native affine transformation matrix from the passed in
998 values. The defaults result in an identity matrix.
1000 virtual wxGraphicsMatrix
CreateMatrix(wxDouble a
= 1.0, wxDouble b
= 0.0,
1001 wxDouble c
= 0.0, wxDouble d
= 1.0,
1003 wxDouble ty
= 0.0) = 0;
1006 Creates a native graphics path which is initially empty.
1008 virtual wxGraphicsPath
CreatePath() = 0;
1011 Creates a native pen from a wxPen.
1013 virtual wxGraphicsPen
CreatePen(const wxPen
& pen
) = 0;
1016 Creates a native brush with a radial gradient.
1018 Stops support is new since wxWidgets 2.9.1, previously only the start
1019 and end colours could be specified.
1021 virtual wxGraphicsBrush
CreateRadialGradientBrush(wxDouble xo
, wxDouble yo
,
1022 wxDouble xc
, wxDouble yc
,
1024 const wxGraphicsGradientStops
& stops
) = 0;
1027 Extracts a sub-bitmap from an existing bitmap.
1029 Currently this function is implemented in the native MSW and OS X
1030 versions but not when using Cairo.
1032 virtual wxGraphicsBitmap
CreateSubBitmap(const wxGraphicsBitmap
& bitmap
,
1033 wxDouble x
, wxDouble y
,
1034 wxDouble w
, wxDouble h
) = 0;
1037 Returns the default renderer on this platform. On OS X this is the Core
1038 Graphics (a.k.a. Quartz 2D) renderer, on MSW the GDIPlus renderer, and
1039 on GTK we currently default to the cairo renderer.
1041 static wxGraphicsRenderer
* GetDefaultRenderer();
1047 @class wxGraphicsBrush
1049 A wxGraphicsBrush is a native representation of a brush. The contents are
1050 specific and private to the respective renderer. Instances are ref counted
1051 and can therefore be assigned as usual. The only way to get a valid
1052 instance is via wxGraphicsContext::CreateBrush() or
1053 wxGraphicsRenderer::CreateBrush().
1058 class wxGraphicsBrush
: public wxGraphicsObject
1067 @class wxGraphicsFont
1069 A wxGraphicsFont is a native representation of a font. The contents are
1070 specific and private to the respective renderer. Instances are ref counted
1071 and can therefore be assigned as usual. The only way to get a valid
1072 instance is via wxGraphicsContext::CreateFont() or
1073 wxGraphicsRenderer::CreateFont().
1078 class wxGraphicsFont
: public wxGraphicsObject
1087 @class wxGraphicsPen
1089 A wxGraphicsPen is a native representation of a pen. The contents are
1090 specific and private to the respective renderer. Instances are ref counted
1091 and can therefore be assigned as usual. The only way to get a valid
1092 instance is via wxGraphicsContext::CreatePen() or
1093 wxGraphicsRenderer::CreatePen().
1098 class wxGraphicsPen
: public wxGraphicsObject
1107 @class wxGraphicsMatrix
1109 A wxGraphicsMatrix is a native representation of an affine matrix. The
1110 contents are specific and private to the respective renderer. Instances are
1111 ref counted and can therefore be assigned as usual. The only way to get a
1112 valid instance is via wxGraphicsContext::CreateMatrix() or
1113 wxGraphicsRenderer::CreateMatrix().
1118 class wxGraphicsMatrix
: public wxGraphicsObject
1122 Concatenates the matrix passed with the current matrix.
1124 virtual void Concat(const wxGraphicsMatrix
* t
);
1126 Concatenates the matrix passed with the current matrix.
1128 void Concat(const wxGraphicsMatrix
& t
);
1131 Returns the component values of the matrix via the argument pointers.
1133 virtual void Get(wxDouble
* a
= NULL
, wxDouble
* b
= NULL
,
1134 wxDouble
* c
= NULL
, wxDouble
* d
= NULL
,
1135 wxDouble
* tx
= NULL
, wxDouble
* ty
= NULL
) const;
1138 Returns the native representation of the matrix. For CoreGraphics this
1139 is a CFAffineMatrix pointer, for GDIPlus a Matrix Pointer, and for
1140 Cairo a cairo_matrix_t pointer.
1142 virtual void* GetNativeMatrix() const;
1147 virtual void Invert();
1150 Returns @true if the elements of the transformation matrix are equal.
1152 virtual bool IsEqual(const wxGraphicsMatrix
* t
) const;
1154 Returns @true if the elements of the transformation matrix are equal.
1156 bool IsEqual(const wxGraphicsMatrix
& t
) const;
1159 Return @true if this is the identity matrix.
1161 virtual bool IsIdentity() const;
1164 Rotates this matrix (in radians).
1166 virtual void Rotate(wxDouble angle
);
1171 virtual void Scale(wxDouble xScale
, wxDouble yScale
);
1174 Sets the matrix to the respective values (default values are the
1177 virtual void Set(wxDouble a
= 1.0, wxDouble b
= 0.0, wxDouble c
= 0.0,
1178 wxDouble d
= 1.0, wxDouble tx
= 0.0, wxDouble ty
= 0.0);
1181 Applies this matrix to a distance (ie. performs all transforms except
1184 virtual void TransformDistance(wxDouble
* dx
, wxDouble
* dy
) const;
1187 Applies this matrix to a point.
1189 virtual void TransformPoint(wxDouble
* x
, wxDouble
* y
) const;
1192 Translates this matrix.
1194 virtual void Translate(wxDouble dx
, wxDouble dy
);