#include <wx/graphics.h>
A wxGraphicsContext instance is the object that is drawn upon.
It is created by a renderer using wxGraphicsRenderer::CreateContext(). This can be either directly using a renderer instance, or indirectly using the static convenience Create() functions of wxGraphicsContext that always delegate the task to the default renderer.
Public Member Functions | |
virtual void | Clip (const wxRegion ®ion)=0 |
Clips drawings to the specified region. More... | |
virtual void | Clip (wxDouble x, wxDouble y, wxDouble w, wxDouble h)=0 |
Clips drawings to the specified rectangle. More... | |
virtual void | ConcatTransform (const wxGraphicsMatrix &matrix)=0 |
Concatenates the passed in transform with the current transform of this context. More... | |
virtual wxGraphicsBitmap | CreateBitmap (const wxBitmap &bitmap)=0 |
Creates wxGraphicsBitmap from an existing wxBitmap. More... | |
virtual wxGraphicsBitmap | CreateBitmapFromImage (const wxImage &image) |
Creates wxGraphicsBitmap from an existing wxImage. More... | |
virtual wxGraphicsBitmap | CreateSubBitmap (const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h)=0 |
Extracts a sub-bitmap from an existing bitmap. More... | |
virtual wxGraphicsBrush | CreateBrush (const wxBrush &brush) const |
Creates a native brush from a wxBrush. More... | |
virtual wxGraphicsFont | CreateFont (const wxFont &font, const wxColour &col=*wxBLACK) const |
Creates a native graphics font from a wxFont and a text colour. More... | |
virtual wxGraphicsFont | CreateFont (double sizeInPixels, const wxString &facename, int flags=wxFONTFLAG_DEFAULT, const wxColour &col=*wxBLACK) const |
Creates a font object with the specified attributes. More... | |
virtual wxGraphicsMatrix | CreateMatrix (wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, wxDouble tx=0.0, wxDouble ty=0.0) const |
Creates a native affine transformation matrix from the passed in values. More... | |
wxGraphicsMatrix | CreateMatrix (const wxAffineMatrix2DBase &mat) const |
Creates a native affine transformation matrix from the passed generic one. More... | |
wxGraphicsPath | CreatePath () const |
Creates a native graphics path which is initially empty. More... | |
virtual wxGraphicsPen | CreatePen (const wxPen &pen) const |
Creates a native pen from a wxPen. More... | |
virtual void | DrawEllipse (wxDouble x, wxDouble y, wxDouble w, wxDouble h) |
Draws an ellipse. More... | |
virtual void | DrawIcon (const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h)=0 |
Draws the icon. More... | |
virtual void | DrawLines (size_t n, const wxPoint2DDouble *points, wxPolygonFillMode fillStyle=wxODDEVEN_RULE) |
Draws a polygon. More... | |
virtual void | DrawPath (const wxGraphicsPath &path, wxPolygonFillMode fillStyle=wxODDEVEN_RULE) |
Draws the path by first filling and then stroking. More... | |
virtual void | DrawRectangle (wxDouble x, wxDouble y, wxDouble w, wxDouble h) |
Draws a rectangle. More... | |
virtual void | DrawRoundedRectangle (wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius) |
Draws a rounded rectangle. More... | |
void | DrawText (const wxString &str, wxDouble x, wxDouble y) |
Draws text at the defined position. More... | |
void | DrawText (const wxString &str, wxDouble x, wxDouble y, wxDouble angle) |
Draws text at the defined position. More... | |
void | DrawText (const wxString &str, wxDouble x, wxDouble y, const wxGraphicsBrush &backgroundBrush) |
Draws text at the defined position. More... | |
void | DrawText (const wxString &str, wxDouble x, wxDouble y, wxDouble angle, const wxGraphicsBrush &backgroundBrush) |
Draws text at the defined position. More... | |
virtual void | FillPath (const wxGraphicsPath &path, wxPolygonFillMode fillStyle=wxODDEVEN_RULE)=0 |
Fills the path with the current brush. More... | |
virtual void * | GetNativeContext ()=0 |
Returns the native context (CGContextRef for Core Graphics, Graphics pointer for GDIPlus and cairo_t pointer for cairo). More... | |
virtual void | GetPartialTextExtents (const wxString &text, wxArrayDouble &widths) const =0 |
Fills the widths array with the widths from the beginning of text to the corresponding character of text. More... | |
virtual void | GetTextExtent (const wxString &text, wxDouble *width, wxDouble *height, wxDouble *descent, wxDouble *externalLeading) const =0 |
Gets the dimensions of the string using the currently selected font. More... | |
virtual wxGraphicsMatrix | GetTransform () const =0 |
Gets the current transformation matrix of this context. More... | |
virtual void | ResetClip ()=0 |
Resets the clipping to original shape. More... | |
virtual void | Rotate (wxDouble angle)=0 |
Rotates the current transformation matrix (in radians). More... | |
virtual void | Scale (wxDouble xScale, wxDouble yScale)=0 |
Scales the current transformation matrix. More... | |
void | SetBrush (const wxBrush &brush) |
Sets the brush for filling paths. More... | |
virtual void | SetBrush (const wxGraphicsBrush &brush) |
Sets the brush for filling paths. More... | |
void | SetFont (const wxFont &font, const wxColour &colour) |
Sets the font for drawing text. More... | |
virtual void | SetFont (const wxGraphicsFont &font) |
Sets the font for drawing text. More... | |
void | SetPen (const wxPen &pen) |
Sets the pen used for stroking. More... | |
virtual void | SetPen (const wxGraphicsPen &pen) |
Sets the pen used for stroking. More... | |
virtual void | SetTransform (const wxGraphicsMatrix &matrix)=0 |
Sets the current transformation matrix of this context. More... | |
virtual void | StrokeLine (wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2) |
Strokes a single line. More... | |
virtual void | StrokeLines (size_t n, const wxPoint2DDouble *beginPoints, const wxPoint2DDouble *endPoints) |
Stroke disconnected lines from begin to end points, fastest method available for this purpose. More... | |
virtual void | StrokeLines (size_t n, const wxPoint2DDouble *points) |
Stroke lines connecting all the points. More... | |
virtual void | StrokePath (const wxGraphicsPath &path)=0 |
Strokes along a path with the current pen. More... | |
virtual void | Translate (wxDouble dx, wxDouble dy)=0 |
Translates the current transformation matrix. More... | |
virtual void | BeginLayer (wxDouble opacity)=0 |
Redirects all rendering is done into a fully transparent temporary context. More... | |
virtual void | EndLayer ()=0 |
Composites back the drawings into the context with the opacity given at the BeginLayer call. More... | |
virtual bool | SetAntialiasMode (wxAntialiasMode antialias)=0 |
Sets the antialiasing mode, returns true if it supported. More... | |
virtual wxAntialiasMode | GetAntialiasMode () const |
Returns the current shape antialiasing mode. More... | |
virtual bool | SetInterpolationQuality (wxInterpolationQuality interpolation)=0 |
Sets the interpolation quality, returns true if it is supported. More... | |
virtual wxInterpolationQuality | GetInterpolationQuality () const |
Returns the current interpolation quality. More... | |
virtual bool | SetCompositionMode (wxCompositionMode op)=0 |
Sets the compositing operator, returns true if it supported. More... | |
virtual wxCompositionMode | GetCompositionMode () const |
Returns the current compositing operator. More... | |
virtual void | PushState ()=0 |
Push the current state of the context's transformation matrix on a stack. More... | |
virtual void | PopState ()=0 |
Pops a stored state from the stack and sets the current transformation matrix to that state. More... | |
virtual bool | ShouldOffset () const |
virtual void | EnableOffset (bool enable=true) |
void | DisableOffset () |
bool | OffsetEnabled () |
virtual bool | StartDoc (const wxString &message) |
Begin a new document (relevant only for printing / pdf etc.) If there is a progress dialog, message will be shown. More... | |
virtual void | EndDoc () |
Done with that document (relevant only for printing / pdf etc.) More... | |
virtual void | StartPage (wxDouble width=0, wxDouble height=0) |
Opens a new page (relevant only for printing / pdf etc.) with the given size in points. More... | |
virtual void | EndPage () |
Ends the current page (relevant only for printing / pdf etc.) More... | |
virtual void | Flush () |
Make sure that the current content of this context is immediately visible. More... | |
void | GetSize (wxDouble *width, wxDouble *height) const |
Returns the size of the graphics context in device coordinates. More... | |
virtual void | GetDPI (wxDouble *dpiX, wxDouble *dpiY) |
Returns the resolution of the graphics context in device points per inch. More... | |
wxGraphicsBrush | CreateLinearGradientBrush (wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, const wxColour &c1, const wxColour &c2) const |
Creates a native brush with a linear gradient. More... | |
wxGraphicsBrush | CreateLinearGradientBrush (wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, const wxGraphicsGradientStops &stops) const |
Creates a native brush with a linear gradient. More... | |
virtual wxGraphicsBrush | CreateRadialGradientBrush (wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, const wxColour &oColor, const wxColour &cColor) const |
Creates a native brush with a radial gradient. More... | |
virtual wxGraphicsBrush | CreateRadialGradientBrush (wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, const wxGraphicsGradientStops &stops)=0 |
Creates a native brush with a radial gradient. More... | |
virtual void | DrawBitmap (const wxGraphicsBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h)=0 |
Draws the bitmap. More... | |
virtual void | DrawBitmap (const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h)=0 |
Draws the bitmap. More... | |
Public Member Functions inherited from wxGraphicsObject | |
wxGraphicsRenderer * | GetRenderer () const |
Returns the renderer that was used to create this instance, or NULL if it has not been initialized yet. More... | |
bool | IsNull () const |
Public Member Functions inherited from wxObject | |
wxObject () | |
Default ctor; initializes to NULL the internal reference data. More... | |
wxObject (const wxObject &other) | |
Copy ctor. More... | |
virtual | ~wxObject () |
Destructor. More... | |
virtual wxClassInfo * | GetClassInfo () const |
This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). More... | |
wxObjectRefData * | GetRefData () const |
Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More... | |
bool | IsKindOf (const wxClassInfo *info) const |
Determines whether this class is a subclass of (or the same class as) the given class. More... | |
bool | IsSameAs (const wxObject &obj) const |
Returns true if this object has the same data pointer as obj. More... | |
void | Ref (const wxObject &clone) |
Makes this object refer to the data in clone. More... | |
void | SetRefData (wxObjectRefData *data) |
Sets the wxObject::m_refData pointer. More... | |
void | UnRef () |
Decrements the reference count in the associated data, and if it is zero, deletes the data. More... | |
void | UnShare () |
This is the same of AllocExclusive() but this method is public. More... | |
void | operator delete (void *buf) |
The delete operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined. More... | |
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0) |
The new operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined. More... | |
Static Public Member Functions | |
static wxGraphicsContext * | Create (wxWindow *window) |
Creates a wxGraphicsContext from a wxWindow. More... | |
static wxGraphicsContext * | Create (const wxWindowDC &windowDC) |
Creates a wxGraphicsContext from a wxWindowDC. More... | |
static wxGraphicsContext * | Create (const wxMemoryDC &memoryDC) |
Creates a wxGraphicsContext from a wxMemoryDC. More... | |
static wxGraphicsContext * | Create (const wxPrinterDC &printerDC) |
Creates a wxGraphicsContext from a wxPrinterDC. More... | |
static wxGraphicsContext * | Create (const wxEnhMetaFileDC &metaFileDC) |
Creates a wxGraphicsContext from a wxEnhMetaFileDC. More... | |
static wxGraphicsContext * | Create (wxImage &image) |
Creates a wxGraphicsContext associated with a wxImage. More... | |
static wxGraphicsContext * | Create () |
Create a lightweight context that can be used only for measuring text. More... | |
static wxGraphicsContext * | CreateFromNative (void *context) |
Creates a wxGraphicsContext from a native context. More... | |
static wxGraphicsContext * | CreateFromNativeWindow (void *window) |
Creates a wxGraphicsContext from a native window. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from wxObject | |
void | AllocExclusive () |
Ensure that this object's data is not shared with any other object. More... | |
virtual wxObjectRefData * | CreateRefData () const |
Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More... | |
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const |
Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data. More... | |
Protected Attributes inherited from wxObject | |
wxObjectRefData * | m_refData |
Pointer to an object which is the object's reference-counted data. More... | |
|
pure virtual |
Redirects all rendering is done into a fully transparent temporary context.
|
pure virtual |
Clips drawings to the specified region.
|
pure virtual |
Clips drawings to the specified rectangle.
|
pure virtual |
Concatenates the passed in transform with the current transform of this context.
|
static |
Creates a wxGraphicsContext from a wxWindow.
|
static |
Creates a wxGraphicsContext from a wxWindowDC.
|
static |
Creates a wxGraphicsContext from a wxMemoryDC.
|
static |
Creates a wxGraphicsContext from a wxPrinterDC.
Under GTK+, this will only work when using the GtkPrint printing backend which is available since GTK+ 2.10.
|
static |
Creates a wxGraphicsContext from a wxEnhMetaFileDC.
This function, as wxEnhMetaFileDC class itself, is only available only under MSW.
|
static |
Creates a wxGraphicsContext associated with a wxImage.
The image specifies the size of the context as well as whether alpha is supported (if wxImage::HasAlpha()) or not and the initial contents of the context. The image object must have a life time greater than that of the new context as the context copies its contents back to the image when it is destroyed.
|
static |
Create a lightweight context that can be used only for measuring text.
|
pure virtual |
Creates wxGraphicsBitmap from an existing wxBitmap.
Returns an invalid wxNullGraphicsBitmap on failure.
|
virtual |
Creates wxGraphicsBitmap from an existing wxImage.
This method is more efficient than converting wxImage to wxBitmap first and then calling CreateBitmap() but otherwise has the same effect.
Returns an invalid wxNullGraphicsBitmap on failure.
|
virtual |
Creates a native brush from a wxBrush.
|
virtual |
Creates a native graphics font from a wxFont and a text colour.
|
virtual |
Creates a font object with the specified attributes.
The use of overload taking wxFont is preferred, see wxGraphicsRenderer::CreateFont() for more details.
|
static |
Creates a wxGraphicsContext from a native context.
This native context must be a CGContextRef for Core Graphics, a Graphics pointer for GDIPlus, or a cairo_t pointer for cairo.
|
static |
Creates a wxGraphicsContext from a native window.
wxGraphicsBrush wxGraphicsContext::CreateLinearGradientBrush | ( | wxDouble | x1, |
wxDouble | y1, | ||
wxDouble | x2, | ||
wxDouble | y2, | ||
const wxColour & | c1, | ||
const wxColour & | c2 | ||
) | const |
Creates a native brush with a linear gradient.
The brush starts at (x1, y1) and ends at (x2, y2). Either just the start and end gradient colours (c1 and c2) or full set of gradient stops can be specified.
The version taking wxGraphicsGradientStops is new in wxWidgets 2.9.1.
wxGraphicsBrush wxGraphicsContext::CreateLinearGradientBrush | ( | wxDouble | x1, |
wxDouble | y1, | ||
wxDouble | x2, | ||
wxDouble | y2, | ||
const wxGraphicsGradientStops & | stops | ||
) | const |
Creates a native brush with a linear gradient.
The brush starts at (x1, y1) and ends at (x2, y2). Either just the start and end gradient colours (c1 and c2) or full set of gradient stops can be specified.
The version taking wxGraphicsGradientStops is new in wxWidgets 2.9.1.
|
virtual |
Creates a native affine transformation matrix from the passed in values.
The default parameters result in an identity matrix.
wxGraphicsMatrix wxGraphicsContext::CreateMatrix | ( | const wxAffineMatrix2DBase & | mat | ) | const |
Creates a native affine transformation matrix from the passed generic one.
wxGraphicsPath wxGraphicsContext::CreatePath | ( | ) | const |
Creates a native graphics path which is initially empty.
|
virtual |
Creates a native pen from a wxPen.
|
virtual |
Creates a native brush with a radial gradient.
The brush originates at (xo, yc) and ends on a circle around (xc, yc) with the given radius.
The gradient may be specified either by its start and end colours oColor and cColor or by a full set of gradient stops.
The version taking wxGraphicsGradientStops is new in wxWidgets 2.9.1.
|
pure virtual |
Creates a native brush with a radial gradient.
The brush originates at (xo, yc) and ends on a circle around (xc, yc) with the given radius.
The gradient may be specified either by its start and end colours oColor and cColor or by a full set of gradient stops.
The version taking wxGraphicsGradientStops is new in wxWidgets 2.9.1.
|
pure virtual |
Extracts a sub-bitmap from an existing bitmap.
Currently this function is implemented in the native MSW and OS X versions but not when using Cairo.
void wxGraphicsContext::DisableOffset | ( | ) |
|
pure virtual |
Draws the bitmap.
In case of a mono bitmap, this is treated as a mask and the current brushed is used for filling.
|
pure virtual |
Draws the bitmap.
In case of a mono bitmap, this is treated as a mask and the current brushed is used for filling.
|
virtual |
Draws an ellipse.
|
pure virtual |
Draws the icon.
|
virtual |
Draws a polygon.
|
virtual |
Draws the path by first filling and then stroking.
|
virtual |
Draws a rectangle.
|
virtual |
Draws a rounded rectangle.
Draws text at the defined position.
Draws text at the defined position.
str | The text to draw. |
x | The x coordinate position to draw the text at. |
y | The y coordinate position to draw the text at. |
angle | The angle relative to the (default) horizontal direction to draw the string. |
void wxGraphicsContext::DrawText | ( | const wxString & | str, |
wxDouble | x, | ||
wxDouble | y, | ||
const wxGraphicsBrush & | backgroundBrush | ||
) |
Draws text at the defined position.
str | The text to draw. |
x | The x coordinate position to draw the text at. |
y | The y coordinate position to draw the text at. |
backgroundBrush | Brush to fill the text with. |
void wxGraphicsContext::DrawText | ( | const wxString & | str, |
wxDouble | x, | ||
wxDouble | y, | ||
wxDouble | angle, | ||
const wxGraphicsBrush & | backgroundBrush | ||
) |
Draws text at the defined position.
str | The text to draw. |
x | The x coordinate position to draw the text at. |
y | The y coordinate position to draw the text at. |
angle | The angle relative to the (default) horizontal direction to draw the string. |
backgroundBrush | Brush to fill the text with. |
|
virtual |
|
virtual |
Done with that document (relevant only for printing / pdf etc.)
|
pure virtual |
Composites back the drawings into the context with the opacity given at the BeginLayer call.
|
virtual |
Ends the current page (relevant only for printing / pdf etc.)
|
pure virtual |
Fills the path with the current brush.
|
virtual |
Make sure that the current content of this context is immediately visible.
|
virtual |
Returns the current shape antialiasing mode.
|
virtual |
Returns the current compositing operator.
Returns the resolution of the graphics context in device points per inch.
|
virtual |
Returns the current interpolation quality.
|
pure virtual |
Returns the native context (CGContextRef for Core Graphics, Graphics pointer for GDIPlus and cairo_t pointer for cairo).
|
pure virtual |
Fills the widths array with the widths from the beginning of text to the corresponding character of text.
Returns the size of the graphics context in device coordinates.
|
pure virtual |
Gets the dimensions of the string using the currently selected font.
text | The text string to measure. |
width | Variable to store the total calculated width of the text. |
height | Variable to store the total calculated height of the text. |
descent | Variable to store the dimension from the baseline of the font to the bottom of the descender. |
externalLeading | Any extra vertical space added to the font by the font designer (usually is zero). |
|
pure virtual |
Gets the current transformation matrix of this context.
bool wxGraphicsContext::OffsetEnabled | ( | ) |
|
pure virtual |
Pops a stored state from the stack and sets the current transformation matrix to that state.
|
pure virtual |
Push the current state of the context's transformation matrix on a stack.
|
pure virtual |
Resets the clipping to original shape.
|
pure virtual |
Rotates the current transformation matrix (in radians).
Scales the current transformation matrix.
|
pure virtual |
Sets the antialiasing mode, returns true if it supported.
void wxGraphicsContext::SetBrush | ( | const wxBrush & | brush | ) |
Sets the brush for filling paths.
|
virtual |
Sets the brush for filling paths.
|
pure virtual |
Sets the compositing operator, returns true if it supported.
Sets the font for drawing text.
|
virtual |
Sets the font for drawing text.
|
pure virtual |
Sets the interpolation quality, returns true if it is supported.
Not implemented in Cairo backend currently.
Notice that in wxWidgets 3.0 the default interpolation quality for GDI+-based implementation is wxINTERPOLATION_GOOD and not wxINTERPOLATION_DEFAULT (unlike under OS X with CoreGraphics-based implementation). This will be changed in wxWidgets 3.1 and later version, call this method explicitly instead of relying on the default value to ensure consistent behaviour across different platforms and versions.
void wxGraphicsContext::SetPen | ( | const wxPen & | pen | ) |
Sets the pen used for stroking.
|
virtual |
Sets the pen used for stroking.
|
pure virtual |
Sets the current transformation matrix of this context.
|
virtual |
|
virtual |
Begin a new document (relevant only for printing / pdf etc.) If there is a progress dialog, message will be shown.
Opens a new page (relevant only for printing / pdf etc.) with the given size in points.
(If both are null the default page size will be used.)
|
virtual |
Strokes a single line.
|
virtual |
Stroke disconnected lines from begin to end points, fastest method available for this purpose.
|
virtual |
Stroke lines connecting all the points.
Unlike the other overload of this function, this method draws a single polyline and not a number of disconnected lines.
|
pure virtual |
Strokes along a path with the current pen.