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.