Contents Up Previous Next

wxGraphicsContext

A wxGraphicsContext instance is the object that is drawn upon. It is created by a renderer using the CreateContext calls.., this can be either directly using a renderer instance, or indirectly using the static convenience CreateXXX functions of wxGraphicsContext that always delegate the task to the default renderer.

Derived from

wxGraphicsObject

Include files

<wx/graphics.h>

Members

wxGraphicsContext::Create
wxGraphicsContext::CreateFromNative
wxGraphicsContext::CreateFromNativeWindow
wxGraphicsContext::CreatePen
wxGraphicsContext::CreateBrush
wxGraphicsContext::CreateRadialGradientBrush
wxGraphicsContext::CreateLinearGradientBrush
wxGraphicsContext::CreateFont
wxGraphicsContext::CreateMatrix
wxGraphicsContext::CreatePath
wxGraphicsContext::Clip
wxGraphicsContext::ResetClip
wxGraphicsContext::DrawBitmap
wxGraphicsContext::DrawEllipse
wxGraphicsContext::DrawIcon
wxGraphicsContext::DrawLines
wxGraphicsContext::DrawPath
wxGraphicsContext::DrawRectangle
wxGraphicsContext::DrawRoundedRectangle
wxGraphicsContext::DrawText
wxGraphicsContext::FillPath
wxGraphicsContext::StrokePath
wxGraphicsContext::GetNativeContext
wxGraphicsContext::GetPartialTextExtents
wxGraphicsContext::GetTextExtent
wxGraphicsContext::Rotate
wxGraphicsContext::Scale
wxGraphicsContext::Translate
wxGraphicsContext::GetTransform
wxGraphicsContext::SetTransform
wxGraphicsContext::ConcatTransform
wxGraphicsContext::SetBrush
wxGraphicsContext::SetFont
wxGraphicsContext::SetPen
wxGraphicsContext::StrokeLine
wxGraphicsContext::StrokeLines


wxGraphicsContext::Create

wxGraphicsContext* Create(const wxWindowDC& dc)

Creates a wxGraphicsContext from a wxWindowDC (eg a wxPaintDC).

wxGraphicsContext* Create(wxWindow* window)

Creates a wxGraphicsContext from a wxWindow.

See also

wxGraphicsRenderer:: CreateContext


wxGraphicsContext::CreateFromNative

Creates a wxGraphicsContext from a native context. This native context must be eg a CGContextRef for Core Graphics, a Graphics pointer for GDIPlus or a cairo_t pointer for cairo.

wxGraphicsContext* CreateFromNative(void * context)

Creates a wxGraphicsContext from a native window.

See also

wxGraphicsRenderer:: CreateContextFromNativeContext


wxGraphicsContext::CreateFromNativeWindow

wxGraphicsContext* CreateFromNativeWindow(void * window)

See also

wxGraphicsRenderer:: CreateContextFromNativeWindow


wxGraphicsContext::CreatePen

wxGraphicsPen CreatePen(const wxPen& pen) const

Creates a native pen from a wxPen.


wxGraphicsContext::CreateBrush

wxGraphicsBrush CreateBrush(const wxBrush& brush) const

Creates a native brush from a wxBrush.


wxGraphicsContext::CreateRadialGradientBrush

wxGraphicsBrush CreateRadialGradientBrush(wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, const wxColour& oColor, const wxColour& cColor) const

Creates a native brush, having a radial gradient originating at (xo,yc) with color oColour and ends on a circle around (xc,yc) with radius r and color cColour


wxGraphicsContext::CreateLinearGradientBrush

wxGraphicsBrush CreateLinearGradientBrush(wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, const wxColour&c1, const wxColour&c2) const

Creates a native brush, having a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2


wxGraphicsContext::CreateFont

wxGraphicsFont CreateFont(const wxFont& font, const wxColour& col = *wxBLACK) const

Creates a native graphics font from a wxFont and a text colour.


wxGraphicsContext::CreateMatrix

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. The defaults result in an identity matrix.


wxGraphicsContext::CreatePath

wxGraphicsPath CreatePath() const

Creates a native graphics path which is initially empty.


wxGraphicsContext::Clip

void Clip(const wxRegion& region)

Clips drawings to the region, combined to current clipping region

void Clip(wxDouble x, wxDouble y, wxDouble w, wxDouble h)

Clips drawings to the rectangle.


wxGraphicsContext::ResetClip

void ResetClip()

Resets the clipping to original shape.


wxGraphicsContext::DrawBitmap

void DrawBitmap(const wxBitmap& bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h)

Draws the bitmap. In case of a mono bitmap, this is treated as a mask and the current brushed is used for filling.


wxGraphicsContext::DrawEllipse

void DrawEllipse(wxDouble x, wxDouble y, wxDouble w, wxDouble h)

Draws an ellipse.


wxGraphicsContext::DrawIcon

void DrawIcon(const wxIcon& icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h)

Draws the icon.


wxGraphicsContext::DrawLines

void DrawLines(size_t n, const wxPoint2DDouble* points, int fillStyle = wxODDEVEN_RULE)

Draws a polygon.


wxGraphicsContext::DrawPath

void DrawPath(const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE)

Draws the path by first filling and then stroking.


wxGraphicsContext::DrawRectangle

void DrawRectangle(wxDouble x, wxDouble y, wxDouble w, wxDouble h)

Draws a rectangle.


wxGraphicsContext::DrawRoundedRectangle

void DrawRoundedRectangle(wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius)

Draws a rounded rectangle.


wxGraphicsContext::DrawText

void DrawText(const wxString& str, wxDouble x, wxDouble y, wxDouble angle)

void DrawText(const wxString& str, wxDouble x, wxDouble y)

Draws a text at the defined position, at the given angle.


wxGraphicsContext::FillPath

void FillPath(const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE)

Fills the path with the current brush.


wxGraphicsContext::StrokePath

void StrokePath(const wxGraphicsPath& path)

Strokes along a path with the current pen.


wxGraphicsContext::GetNativeContext

void * GetNativeContext()

Returns the native context (CGContextRef for Core Graphics, Graphics pointer for GDIPlus and cairo_t pointer for cairo).


wxGraphicsContext::GetPartialTextExtents

void GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const

Fills the widths array with the widths from the beginning of text to the corresponding character of text.


wxGraphicsContext::GetTextExtent

void GetTextExtent(const wxString& text, wxDouble* width, wxDouble* height, wxDouble* descent, wxDouble* externalLeading) const

Gets the dimensions of the string using the currently selected font. string is the text string to measure, w and h are the total width and height respectively, descent is the dimension from the baseline of the font to the bottom of the descender, and externalLeading is any extra vertical space added to the font by the font designer (usually is zero).


wxGraphicsContext::Rotate

void Rotate(wxDouble angle)

Rotates the current transformation matrix (radians),


wxGraphicsContext::Scale

void Scale(wxDouble xScale, wxDouble yScale)

Scales the current transformation matrix.


wxGraphicsContext::Translate

void Translate(wxDouble dx, wxDouble dy)

Translates the current transformation matrix.


wxGraphicsContext::GetTransform

wxGraphicsMatrix GetTransform() const

Gets the current transformation matrix of this context.


wxGraphicsContext::SetTransform

void SetTransform(const wxGraphicsMatrix& matrix)

Sets the current transformation matrix of this context


wxGraphicsContext::ConcatTransform

void ConcatTransform(const wxGraphicsMatrix& matrix)

Concatenates the passed in transform with the current transform of this context


wxGraphicsContext::SetBrush

void SetBrush(const wxBrush& brush)

void SetBrush(const wxGraphicsBrush& brush)

Sets the brush for filling paths.


wxGraphicsContext::SetFont

void SetFont(const wxFont& font, const wxColour& colour)

void SetFont(const wxGraphicsFont& font)

Sets the font for drawing text.


wxGraphicsContext::SetPen

void SetPen(const wxGraphicsPen& pen)

void SetPen(const wxPen& pen)

Sets the pen used for stroking.


wxGraphicsContext::StrokeLine

void StrokeLine(wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2)

Strokes a single line.


wxGraphicsContext::StrokeLines

void StrokeLines(size_t n, const wxPoint2DDouble* beginPoints, const wxPoint2DDouble* endPoints)

void StrokeLines(size_t n, const wxPoint2DDouble* points)

Stroke disconnected lines from begin to end points, fastest method available for this purpose.