wx.GraphicsContext

Inheritance diagram for wx.GraphicsContext:



Description

A wx.GraphicsContext 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 wx.GraphicsContext that always delegate the task to the default renderer.

Derived From

Class API

Methods

__init__()
No docstrings available for this method.

Clip(x, y, w, h)

Clips drawings to the specified rectangle.

Parameters:

  • x (double)
  • y (double)
  • w (double)
  • h (double)

ClipRegion(region)

Clips drawings to the region intersected with the current clipping region.

Parameters:


ConcatTransform(matrix)

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

Parameters:


Create()

Creates a wx.GraphicsContext from a wx.Window.


Returns:

wx.GraphicsContext


CreateBrush(brush)

Creates a native brush from a wx.Brush.

Parameters:


Returns:

wx.GraphicsBrush


CreateFont(font, col=wx.BLACK)

Creates a native graphics font from a wx.Font and a text colour.

Parameters:


Returns:

wx.GraphicsFont


CreateFromNative(context)

Creates a wx.GraphicsContext 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.

Parameters:

  • context ()

Returns:

wx.GraphicsContext

Note

For wxPython we still need a way to make this value usable.


CreateFromNativeWindow(window)

Parameters:

  • window ()

Returns:

wx.GraphicsContext

Note

For wxPython we still need a way to make this value usable.


CreateLinearGradientBrush(x1, y1, x2, y2, c1, c2)

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

Parameters:


Returns:

wx.GraphicsBrush


CreateMatrix(a=1.0, b=0.0, c=0.0, d=1.0, tx=0.0, ty=0.0)

Creates a native affine transformation matrix from the passed in values. The defaults result in an identity matrix.

Parameters:

  • a (double)
  • b (double)
  • c (double)
  • d (double)
  • tx (double)
  • ty (double)

Returns:

wx.GraphicsMatrix


CreateMeasuringContext()

Create a lightweight context that can be used for measuring text only.


Returns:

wx.GraphicsContext


CreatePath()

Creates a native graphics path which is initially empty.


Returns:

wx.GraphicsPath


CreatePen(pen)

Creates a native pen from a wx.Pen.

Parameters:


Returns:

wx.GraphicsPen


CreateRadialGradientBrush(xo, yo, xc, yc, radius, oColor, cColor)

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

Parameters:

  • xo (double)
  • yo (double)
  • xc (double)
  • yc (double)
  • radius (double)
  • oColor (wx.Colour)
  • cColor (wx.Colour)

Returns:

wx.GraphicsBrush


DrawBitmap(bmp, x, y, w, h)

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

Parameters:

  • bmp (wx.Bitmap)
  • x (double)
  • y (double)
  • w (double)
  • h (double)

DrawEllipse(x, y, w, h)

Draws an ellipse.

Parameters:

  • x (double)
  • y (double)
  • w (double)
  • h (double)

DrawIcon(icon, x, y, w, h)

Draws the icon.

Parameters:

  • icon (wx.Icon)
  • x (double)
  • y (double)
  • w (double)
  • h (double)

DrawLines(points, fiilStyle=wx.ODDEVEN_RULE)

Draws a polygon.

Parameters:


DrawPath(path, fillStyle=wx.ODDEVEN_RULE)

Draws the path by first filling and then stroking.

Parameters:


DrawRectangle(x, y, w, h)

Draws a rectangle.

Parameters:

  • x (double)
  • y (double)
  • w (double)
  • h (double)

DrawRotatedText(str, x, y, angle, backgroundBrush=wx.NullGraphicsBrush)

Draws a text string at the defined position, at the specified angle, which is given in radians.

Parameters:

  • str (string)
  • x (double)
  • y (double)
  • angle (double)
  • backgroundBrush (wx.GraphicsBrush)

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

Draws a rounded rectangle.

Parameters:

  • x (double)
  • y (double)
  • w (double)
  • h (double)
  • radius (double)

DrawText(str, x, y, angle)

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

Parameters:

  • str (string)
  • x (double)
  • y (double)
  • angle (double)

FillPath(path, fillStyle=wx.ODDEVEN_RULE)

Fills the path with the current brush.

Parameters:


GetFullTextExtent(text)

Gets the dimensions of the string using the currently selected font. text is the 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).

Parameters:

  • text (string): the text to measure

Returns:

(w, h, descent, externalLeading)


GetLogicalFunction()

Returns the current logical function.


Returns:

int


GetNativeContext()

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


Returns:

void


GetPartialTextExtents(text)

Returns a list of widths from the beginning of text to the coresponding character in text.

Parameters:

  • text (string)

Returns:

(list of doubles)


GetTextExtent(text)

Gets the dimensions of the string using the currently selected font. text is the text string to measure, w and h are the total width and height respectively.


Returns:

(w, h)


GetTransform()

Gets the current transformation matrix of this context.


Returns:

wx.GraphicsMatrix


PopState()
Pops a stored state from the stack.

PushState()
Push the current state of the context, (ie the transformation matrix) on a stack.

ResetClip()
Resets the clipping to original shape.

Rotate(angle)

Rotate the current transformation matrix of the context. angle is specified in radians.

Parameters:

  • angle (double)

Scale(xScale, yScale)

Scales the current transformation matrix.

Parameters:

  • xScale (double)
  • yScale (double)

SetBrush(brush)

Sets the brush for filling paths.

Parameters:


SetFont(font)

Sets the font for drawing text.

Parameters:


SetLogicalFunction(function)

Sets the current logical function, returns True if it supported

Parameters:

  • function (int)

Returns:

bool


SetPen(pen)

Sets the pen used for stroking.

Parameters:


SetTransform(matrix)

Sets the current transformation matrix of this context

Parameters:


ShouldOffset()

helper to determine if a 0.5 offset should be applied for the drawing operation


Returns:

bool


StrokeLine(x1, y1, x2, y2)

Strokes a single line.

Parameters:

  • x1 (double)
  • x2 (double)
  • y1 (double)
  • y2 (double)

StrokeLineSegments(beginPoints, endPoints)

Stroke disconnected lines from begin to end points.

Parameters:


StrokeLines(points)

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

Parameters:


StrokePath(path)

Strokes along a path with the current pen.

Parameters:


Translate(dx, dy)

Translates the current transformation matrix.

Parameters:

  • dx (double)
  • dy (double)