wx.PseudoDC

Inheritance diagram for wx.PseudoDC:



Class API

Methods

__init__()

Constructs a new wx.Pseudo device context for recording dc operations.


Returns:

wx.PseudoDC


BeginDrawing()

Allows for optimization of drawing code on platforms that need it. On other platforms this is just an empty function and is harmless.

To take advantage of this postential optimization simply enclose each group of calls to the drawing primitives within calls to BeginDrawing and EndDrawing.


Clear()
Clears the device context using the current background brush.

ClearId(id)

Removes all operations associated with id so the object can be redrawn.

Parameters:

  • id (int)

CrossHair(x, y)

Displays a cross hair using the current pen.

This is a vertical and horizontal line the height and width of the window, centred on the given point.

Parameters:

  • x (int)
  • y (int)

CrossHairPoint(pt)

Displays a cross hair using the current pen.

This is a vertical and horizontal line the height and width of the window, centred on the given point.

Parameters:


DrawArc(x1, y1, x2, y2, xc, yc)

Draws an arc of a circle, centred on the center point (xc, yc), from the first point to the second. The current pen is used for the outline and the current brush for filling the shape.

The arc is drawn in an anticlockwise direction from the start point to the end point.

Parameters:

  • x1 (int)
  • y1 (int)
  • x2 (int)
  • y2 (int)
  • xc (int)
  • yc (int)

DrawArcPoint(pt1, pt2, center)

Draws an arc of a circle, centred on the center point, from the first point to the second. The current pen is used for the outline and the current brush for filling the shape.

The arc is drawn in an anticlockwise direction from the start point to the end point.

Parameters:


DrawBitmap(bmp, x, y, useMask=False)

Draw a bitmap on the device context at the specified point.

If transparent is True and the bitmap has a transparency mask, (or alpha channel on the platforms that support it) then the bitmap will be drawn transparently.

Parameters:

  • bmp (wx.Bitmap)
  • x (int)
  • y (int)
  • useMask (bool)

DrawBitmapPoint(bmp, pt, useMask=False)

Draw a bitmap on the device context at the specified point.

If transparent is True and the bitmap has a transparency mask, (or alpha channel on the platforms that support it) then the bitmap will be drawn transparently.

Parameters:


DrawCheckMark(x, y, width, height)

Draws a check mark inside the given rectangle.

Parameters:

  • x (int)
  • y (int)
  • width (int)
  • height (int)

DrawCheckMarkRect(rect)

Draws a check mark inside the given rectangle.

Parameters:


DrawCircle(x, y, radius)

Draws a circle with the given center point and radius. The current pen is used for the outline and the current brush for filling the shape.

Parameters:

  • x (int)
  • y (int)
  • radius (int)

DrawCirclePoint(pt, radius)

Draws a circle with the given center point and radius. The current pen is used for the outline and the current brush for filling the shape.

Parameters:


DrawEllipse(x, y, width, height)

Draws an ellipse contained in the specified rectangle. The current pen is used for the outline and the current brush for filling the shape.

Parameters:

  • x (int)
  • y (int)
  • width (int)
  • height (int)

DrawEllipsePointSize(pt, sz)

Draws an ellipse contained in the specified rectangle. The current pen is used for the outline and the current brush for filling the shape.

Parameters:


DrawEllipseRect(rect)

Draws an ellipse contained in the specified rectangle. The current pen is used for the outline and the current brush for filling the shape.

Parameters:


DrawEllipticArc(x, y, w, h, start, end)

Draws an arc of an ellipse, with the given rectangle defining the bounds of the ellipse. The current pen is used for drawing the arc and the current brush is used for drawing the pie.

The start and end parameters specify the start and end of the arc relative to the three-o’clock position from the center of the rectangle. Angles are specified in degrees (360 is a complete circle). Positive values mean counter-clockwise motion. If start is equal to end, a complete ellipse will be drawn.

Parameters:

  • x (int)
  • y (int)
  • w (int)
  • h (int)
  • start (double)
  • end (double)

DrawEllipticArcPointSize(pt, sz, start, end)

Draws an arc of an ellipse, with the given rectangle defining the bounds of the ellipse. The current pen is used for drawing the arc and the current brush is used for drawing the pie.

The start and end parameters specify the start and end of the arc relative to the three-o’clock position from the center of the rectangle. Angles are specified in degrees (360 is a complete circle). Positive values mean counter-clockwise motion. If start is equal to end, a complete ellipse will be drawn.

Parameters:


DrawIcon(icon, x, y)

Draw an icon on the display (does nothing if the device context is PostScript).

This can be the simplest way of drawing bitmaps on a window.

Parameters:


DrawIconPoint(icon, pt)

Draw an icon on the display (does nothing if the device context is PostScript).

This can be the simplest way of drawing bitmaps on a window.

Parameters:


DrawIdToDC(id, dc)

Draw recorded operations of id to dc.

Parameters:


DrawImageLabel(text, image, rect, alignment=wx.ALIGN_LEFT|wx.ALIGN_TOP, indexAccel=-1)

Draw text and an image (which may be wx.NullBitmap to skip drawing it) within the specified rectangle, abiding by the alignment flags. Will additionally emphasize the character at indexAccel if it is not -1.

Parameters:

  • text (string)
  • image (wx.Bitmap)
  • rect (wx.Rect)
  • alignment (int)
  • indexAccel (int)

DrawLabel(text, rect, alignment=wx.ALIGN_LEFT|wx.ALIGN_TOP, indexAccel=-1)

Draw text within the specified rectangle, abiding by the alignment flags. Will additionally emphasize the character at indexAccel if it is not -1.

Parameters:

  • text (string)
  • rect (wx.Rect)
  • alignment (int)
  • indexAccel (int)

DrawLine(x1, y1, x2, y2)

Draws a line from the first point to the second. The current pen is used for drawing the line.

Parameters:

  • x1 (int)
  • y1 (int)
  • x2 (int)
  • y2 (int)

Note

Note that the second point is not part of the line and is not drawn by this function (this is consistent with the behaviour of many other toolkits).


DrawLinePoint(pt1, pt2)

Draws a line from the first point to the second. The current pen is used for drawing the line.

Parameters:

Note

Note that the second point is not part of the line and is not drawn by this function (this is consistent with the behaviour of many other toolkits).


DrawLines(points, xoffset=0, yoffset=0)

Draws lines using a sequence of wx.Point objects, adding the optional offset coordinate. The current pen is used for drawing the lines.

Parameters:

  • points (list)
  • xoffset (int)
  • yoffset (int)

DrawPoint(x, y)

Draws a point using the current pen.

Parameters:

  • x (int)
  • y (int)

DrawPointPoint(pt)

Draws a point using the current pen.

Parameters:


DrawPolygon(points, xoffset=0, yoffset=0, fillStyle=wx.ODDEVEN_RULE)

Draws a filled polygon using a sequence of wx.Point objects, adding the optional offset coordinate. The last argument specifies the fill rule: wx.ODDEVEN_RULE (the default) or wx.WINDING_RULE.

The current pen is used for drawing the outline, and the current brush for filling the shape. Using a transparent brush suppresses filling.

Parameters:

  • points (list)
  • xoffset (int)
  • yoffset (int)
  • fillStyle (int)

Note

Note that wxWidgets automatically closes the first and last points.


DrawRectangle(x, y, width, height)

Draws a rectangle with the given top left corner, and with the given size. The current pen is used for the outline and the current brush for filling the shape.

Parameters:

  • x (int)
  • y (int)
  • width (int)
  • height (int)

DrawRectanglePointSize(pt, sz)

Draws a rectangle with the given top left corner, and with the given size. The current pen is used for the outline and the current brush for filling the shape.

Parameters:


DrawRectangleRect(rect)

Draws a rectangle with the given top left corner, and with the given size. The current pen is used for the outline and the current brush for filling the shape.

Parameters:


DrawRotatedText(text, x, y, angle)

Draws the text rotated by angle degrees, if supported by the platform.

Parameters:

  • text (string)
  • x (int)
  • y (int)
  • angle (double)

Note

Under Win9x only TrueType fonts can be drawn by this function. In particular, a font different from wx.NORMAL_FONT should be used as the it is not normally a TrueType font. wx.SWISS_FONT is an example of a font which is.


DrawRotatedTextPoint(text, pt, angle)

Draws the text rotated by angle degrees, if supported by the platform.

Parameters:

  • text (string)
  • pt (wx.Point)
  • angle (double)

Note

Under Win9x only TrueType fonts can be drawn by this function. In particular, a font different from wx.NORMAL_FONT should be used as the it is not normally a TrueType font. wx.SWISS_FONT is an example of a font which is.


DrawRoundedRectangle(x, y, width, height, radius)

Draws a rectangle with the given top left corner, and with the given size. The corners are quarter-circles using the given radius. The current pen is used for the outline and the current brush for filling the shape.

If radius is positive, the value is assumed to be the radius of the rounded corner. If radius is negative, the absolute value is assumed to be the proportion of the smallest dimension of the rectangle. This means that the corner can be a sensible size relative to the size of the rectangle, and also avoids the strange effects X produces when the corners are too big for the rectangle.

Parameters:

  • x (int)
  • y (int)
  • width (int)
  • height (int)
  • radius (double)

DrawRoundedRectanglePointSize(pt, sz, radius)

Draws a rectangle with the given top left corner, and with the given size. The corners are quarter-circles using the given radius. The current pen is used for the outline and the current brush for filling the shape.

If radius is positive, the value is assumed to be the radius of the rounded corner. If radius is negative, the absolute value is assumed to be the proportion of the smallest dimension of the rectangle. This means that the corner can be a sensible size relative to the size of the rectangle, and also avoids the strange effects X produces when the corners are too big for the rectangle.

Parameters:


DrawRoundedRectangleRect(r, radius)

Draws a rectangle with the given top left corner, and with the given size. The corners are quarter-circles using the given radius. The current pen is used for the outline and the current brush for filling the shape.

If radius is positive, the value is assumed to be the radius of the rounded corner. If radius is negative, the absolute value is assumed to be the proportion of the smallest dimension of the rectangle. This means that the corner can be a sensible size relative to the size of the rectangle, and also avoids the strange effects X produces when the corners are too big for the rectangle.

Parameters:


DrawSpline(points)

Draws a spline between all given control points, (a list of wx.Point objects) using the current pen. The spline is drawn using a series of lines, using an algorithm taken from the X drawing program ‘XFIG’.

Parameters:

  • points (list)

DrawText(text, x, y)

Draws a text string at the specified point, using the current text font, and the current text foreground and background colours.

The coordinates refer to the top-left corner of the rectangle bounding the string. See wx.DC.GetTextExtent for how to get the dimensions of a text string, which can be used to position the text more precisely, (you will need to use a real DC with GetTextExtent as wx.PseudoDC does not implement it.)

Parameters:

  • text (string)
  • x (int)
  • y (int)

Note

Under wxGTK the current logical function is used by this function but it is ignored by wxMSW. Thus, you should avoid using logical functions with this function in portable programs.


DrawTextPoint(text, pt)

Draws a text string at the specified point, using the current text font, and the current text foreground and background colours.

The coordinates refer to the top-left corner of the rectangle bounding the string. See wx.DC.GetTextExtent for how to get the dimensions of a text string, which can be used to position the text more precisely, (you will need to use a real DC with GetTextExtent as wx.PseudoDC does not implement it.)

Parameters:

Note

Under wxGTK the current logical function is used by this function but it is ignored by wxMSW. Thus, you should avoid using logical functions with this function in portable programs.


DrawToDC(dc)

Draws the recorded operations to dc.

Parameters:


DrawToDCClipped(dc, rect)

Draws the recorded operations to dc unless the operation is known to be outside rect.

Parameters:


DrawToDCClippedRgn(dc, region)

Draws the recorded operations to dc unless the operation is known to be outside region.

Parameters:


EndDrawing()
Ends the group of drawing primitives started with BeginDrawing, and invokes whatever optimization is available for this DC type on the current platform.

FindObjects(x, y, radius=1, bg=wx.WHITE)

Returns a list of all the id’s that draw a pixel with color not equal to bg within radius of (x, y).

Returns an empty list if nothing is found. The list is in reverse drawing order so list[0] is the top id.

Parameters:

  • x (int)
  • y (int)
  • radius (int)
  • bg (wx.Colour)

Returns:

PyObject


FindObjectsByBBox(x, y)

Returns a list of all the id’s whose bounding boxes include (x, y).

Returns an empty list if nothing is found. The list is in reverse drawing order so list[0] is the top id.

Parameters:

  • x (int)
  • y (int)

Returns:

PyObject


FloodFill(x, y, col, style=wx.FLOOD_SURFACE)

Flood fills the device context starting from the given point, using the current brush colour, and using a style:

  • wx.FLOOD_SURFACE: the flooding occurs until a colour other than the given colour is encountered.
  • wx.FLOOD_BORDER: the area to be flooded is bounded by the given colour.

Returns False if the operation failed.

Parameters:

  • x (int)
  • y (int)
  • col (wx.Colour)
  • style (int)

Returns:

bool

Note

The present implementation for non-Windows platforms may fail to find colour borders if the pixels do not match the colour exactly. However the function will still return True.


FloodFillPoint(pt, col, style=wx.FLOOD_SURFACE)

Flood fills the device context starting from the given point, using the current brush colour, and using a style:

  • wx.FLOOD_SURFACE: the flooding occurs until a colour other than the given colour is encountered.
  • wx.FLOOD_BORDER: the area to be flooded is bounded by the given colour.

Returns False if the operation failed.

Parameters:


Returns:

bool

Note

The present implementation for non-Windows platforms may fail to find colour borders if the pixels do not match the colour exactly. However the function will still return True.


GetIdBounds(id)

Returns the bounding rectangle previouly set with SetIdBounds.

If no bounds have been set, it returns wx.Rect(0, 0, 0, 0).

Parameters:

  • id (int)

Returns:

wx.Rect


GetIdGreyedOut(id)

Get whether an object is drawn greyed out or not.

Parameters:

  • id (int)

Returns:

bool


GetLen()

Returns the number of operations in the recorded list.


Returns:

int


RemoveAll()
Removes all objects and operations from the recorded list.

RemoveId(id)

Remove the object node (and all operations) associated with an id.

Parameters:

  • id (int)

SetBackground(brush)

Sets the current background brush for the DC.

Parameters:


SetBackgroundMode(mode)

mode may be one of wx.SOLID and wx.TRANSPARENT.

This setting determines whether text will be drawn with a background colour or not.

Parameters:

  • mode (int)

SetBrush(brush)

Sets the current brush for the DC.

If the argument is wx.NullBrush, the current brush is selected out of the device context, and the original brush restored, allowing the current brush to be destroyed safely.

Parameters:


SetFont(font)

Sets the current font for the DC. It must be a valid font, in particular you should not pass wx.NullFont to this method.

Parameters:


SetId(id)

Sets the id to be associated with subsequent operations.

Parameters:

  • id (int)

SetIdBounds(id, rect)

Set the bounding rect of a given object. This will create an object node if one doesn’t exist.

Parameters:


SetIdGreyedOut(id, greyout=True)

Set whether an object is drawn greyed out or not.

Parameters:

  • id (int)
  • greyout (bool)

SetLogicalFunction(function)

Sets the current logical function for the device context. This determines how a source pixel (from a pen or brush colour, combines with a destination pixel in the current device context.

The possible values and their meaning in terms of source and destination pixel values are as follows:

Function Flag Description
wx.AND src AND dst
wx.AND_INVERT (NOT src) AND dst
wx.AND_REVERSE src AND (NOT dst)
wx.CLEAR 0
wx.COPY src
wx.EQUIV (NOT src) XOR dst
wx.INVERT NOT dst
wx.NAND (NOT src) OR (NOT dst)
wx.NOR (NOT src) AND (NOT dst)
wx.NO_OP dst
wx.OR src OR dst
wx.OR_INVERT (NOT src) OR dst
wx.OR_REVERSE src OR (NOT dst)
wx.SET 1
wx.SRC_INVERT NOT src
wx.XOR src XOR dst

The default is wx.COPY, which simply draws with the current colour. The others combine the current colour and the background using a logical operation.

wx.INVERT is commonly used for drawing rubber bands or moving outlines, since drawing twice reverts to the original colour.

Parameters:

  • function (int)

SetPalette(palette)

If this is a window DC or memory DC, assigns the given palette to the window or bitmap associated with the DC. If the argument is wx.NullPalette, the current palette is selected out of the device context, and the original palette restored.

Parameters:


SetPen(pen)

Sets the current pen for the DC.

If the argument is wx.NullPen, the current pen is selected out of the device context, and the original pen restored.

Parameters:


SetTextBackground(colour)

Sets the current text background colour for the DC.

Parameters:


SetTextForeground(colour)

Sets the current text foreground colour for the DC.

Parameters:


TranslateId(id, dx, dy)

Translate the operations of id by dx, dy.

Parameters:

  • id (int)
  • dx (int)
  • dy (int)

Properties

IdBounds
See GetIdBounds and SetIdBounds
Len
See GetLen