phoenix_title wx.adv.PseudoDC

A PseudoDC is an object that can be used much like real wx.DC, however it provides some additional features for object recording and manipulation beyond what a wx.DC can provide.

All commands issued to the PseudoDC are stored in a list. You can then play these commands back to a real DC object as often as needed, using the DrawToDC method or one of the similar methods. Commands in the command list can be tagged by an ID. You can use this ID to clear the operations associated with a single ID, redraw the objects associated with that ID, grey them, adjust their position, etc.


class_hierarchy Class Hierarchy

Inheritance diagram for class PseudoDC:

method_summary Methods Summary

__init__

Constructs a new Pseudo device context for recording and

Clear

Clears the device context using the current background brush.

ClearId

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

CrossHair

Displays a cross hair using the current pen. This is a

DrawArc

Draws an arc of a circle, centred on the center point

DrawBitmap

Draw a bitmap on the device context at the specified

DrawCheckMark

Draws a check mark inside the given rectangle

DrawCircle

Draws a circle with the given center point and radius.

DrawEllipse

Draws an ellipse contained in the specified rectangle. The current pen

DrawEllipticArc

Draws an arc of an ellipse, with the given rectangle

DrawIcon

Draw an icon on the display at the given position.

DrawIdToDC

Draw recorded operations tagged with id to dc.

DrawLabel

Draw text within the specified rectangle, abiding by the

DrawLine

Draws a line from the first point to the second.

DrawLines

Draws lines using a sequence of wx.Point objects, adding the

DrawPoint

Draws a point using the current pen.

DrawPolygon

Draws a filled polygon using a sequence of wx.Point objects, adding

DrawRectangle

Draws a rectangle with the given top left corner, and with

DrawRotatedText

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

DrawRoundedRectangle

Draws a rectangle with the given top left corner, and with

DrawSpline

Draws a spline between all given control points, (a list of wx.Point

DrawText

Draws a text string at the specified point, using the

DrawToDC

Draws the recorded operations to dc.

DrawToDCClipped

Draws the recorded operations to dc,

DrawToDCClippedRgn

Draws the recorded operations to dc,

FindObjects

Returns a list of all the id’s that draw a pixel with

FindObjectsByBBox

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

FloodFill

Flood fills the device context starting from the given point,

GetIdBounds

Returns the bounding rectangle previously set with SetIdBounds.

GetIdGreyedOut

Get whether the set of objects with tag id are drawn greyed out or not.

GetLen

Returns the number of operations in the recorded list.

RemoveAll

Removes all objects and operations from the recorded list.

RemoveId

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

SetBackground

Sets the current background brush for the DC.

SetBackgroundMode

The mode parameter may be one of wx.SOLID and

SetBrush

Sets the current brush for the DC.

SetFont

Sets the current font for the DC. It must be a valid font, in

SetId

Sets the id to be associated with subsequent operations.

SetIdBounds

Set the bounding rect of a given object.

SetIdGreyedOut

Set whether the set of objects with tag id are drawn greyed out or not.

SetLogicalFunction

Sets the current logical function for the device context. This

SetPen

Sets the current pen for the DC.

SetTextBackground

Sets the current text background colour for the DC.

SetTextForeground

Sets the current text foreground colour for the DC.

TranslateId

Translate the position of the operations of tag id by (dx, dy).


property_summary Properties Summary

Len

See GetLen


api Class API

class wx.adv.PseudoDC(Object)

Possible constructors:

PseudoDC() -> None

A PseudoDC is an object that can be used much like real wx.DC, however it provides some additional features for object recording and manipulation beyond what a wx.DC can provide.

All commands issued to the PseudoDC are stored in a list. You can then play these commands back to a real DC object as often as needed, using the DrawToDC method or one of the similar methods. Commands in the command list can be tagged by an ID. You can use this ID to clear the operations associated with a single ID, redraw the objects associated with that ID, grey them, adjust their position, etc.


Methods

__init__(self)

Constructs a new Pseudo device context for recording and replaying DC operations.

Return type:

None



Clear(self)

Clears the device context using the current background brush.

Return type:

None



ClearId(self, id : int)

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

Parameters:

id (int) –

Return type:

None



CrossHair(self, *args, **kw)

overload Overloaded Implementations:



CrossHair (self, x : int, y : int)

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) –

Return type:

None



CrossHair (self, pt : Point)

Parameters:

pt (wx.Point) –

Return type:

None





DrawArc(self, x1 : int, y1 : int, x2 : int, y2 : int, xc : int, yc : int)

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) –

Return type:

None



DrawBitmap(self, *args, **kw)

overload Overloaded Implementations:



DrawBitmap (self, bmp : Bitmap, x : int, y : int, useMask: bool=False)

Draw a bitmap on the device context at the specified point. If useMask 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.

When drawing a mono-bitmap, the current text foreground colour will be used to draw the foreground of the bitmap (all bits set to 1), and the current text background colour to draw the background (all bits set to 0).

Parameters:
  • bmp (wx.Bitmap) –

  • x (int) –

  • y (int) –

  • useMask (bool) –

Return type:

None



DrawBitmap (self, bmp : Bitmap, pt : Point, useMask: bool=False)

Parameters:
Return type:

None





DrawCheckMark(self, *args, **kw)

overload Overloaded Implementations:



DrawCheckMark (self, x : int, y : int, width : int, height : int)

Draws a check mark inside the given rectangle

Parameters:
  • x (int) –

  • y (int) –

  • width (int) –

  • height (int) –

Return type:

None



DrawCheckMark (self, rect : Rect)

Parameters:

rect (wx.Rect) –

Return type:

None





DrawCircle(self, *args, **kw)

overload Overloaded Implementations:



DrawCircle (self, x : int, y : int, radius : int)

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.

See also

DrawEllipse

Parameters:
  • x (int) –

  • y (int) –

  • radius (int) –

Return type:

None



DrawCircle (self, pt : Point, radius : int)

Parameters:
Return type:

None





DrawEllipse(self, *args, **kw)

overload Overloaded Implementations:



DrawEllipse (self, x : int, y : int, width : int, height : int)

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

See also

DrawCircle

Parameters:
  • x (int) –

  • y (int) –

  • width (int) –

  • height (int) –

Return type:

None



DrawEllipse (self, rect : Rect)

Parameters:

rect (wx.Rect) –

Return type:

None



DrawEllipse (self, pt : Point, sz : Size)

Parameters:
Return type:

None





DrawEllipticArc(self, *args, **kw)

overload Overloaded Implementations:



DrawEllipticArc (self, x : int, y : int, w : int, h : int, start : float, end : float)

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 (float) –

  • end (float) –

Return type:

None



DrawEllipticArc (self, pt : Point, sz : Size, start : float, end : float)

Parameters:
Return type:

None





DrawIcon(self, *args, **kw)

overload Overloaded Implementations:



DrawIcon (self, icon : Icon, x : int, y : int)

Draw an icon on the display at the given position.

Parameters:
  • icon (wx.Icon) –

  • x (int) –

  • y (int) –

Return type:

None



DrawIcon (self, icon : Icon, pt : Point)

Parameters:
Return type:

None





DrawIdToDC(self, id : int, dc : DC)

Draw recorded operations tagged with id to dc.

Parameters:
  • id (int) –

  • dc (wx.DC) –

Return type:

None



DrawLabel(self, *args, **kw)

overload Overloaded Implementations:



DrawLabel (self, text : str, rect : Rect, alignment: int=ALIGN_LEFT|ALIGN_TOP, indexAccel: int=-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) –

Return type:

None



DrawLabel (self, text : str, image : Bitmap, rect : Rect, alignment: int=ALIGN_LEFT|ALIGN_TOP, indexAccel: int=-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) –

Return type:

None





DrawLine(self, *args, **kw)

overload Overloaded Implementations:



DrawLine (self, x1 : int, y1 : int, x2 : int, y2 : int)

Draws a line from the first point to the second. The current pen is used for drawing the line. 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).

Parameters:
  • x1 (int) –

  • y1 (int) –

  • x2 (int) –

  • y2 (int) –

Return type:

None



DrawLine (self, pt1 : Point, pt2 : Point)

Parameters:
Return type:

None





DrawLines(self, points : PointList, xoffset: int=0, yoffset: int=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 (PointList) –

  • xoffset (int) –

  • yoffset (int) –

Return type:

None



DrawPoint(self, *args, **kw)

overload Overloaded Implementations:



DrawPoint (self, x : int, y : int)

Draws a point using the current pen.

Parameters:
  • x (int) –

  • y (int) –

Return type:

None



DrawPoint (self, pt : Point)

Parameters:

pt (wx.Point) –

Return type:

None





DrawPolygon(self, points : PointList, xoffset: int=0, yoffset: int=0, fillStyle: PolygonFillMode=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. Note that wxWidgets automatically closes the first and last points.

Parameters:
  • points (PointList) –

  • xoffset (int) –

  • yoffset (int) –

  • fillStyle (PolygonFillMode) –

Return type:

None



DrawRectangle(self, *args, **kw)

overload Overloaded Implementations:



DrawRectangle (self, x : int, y : int, width : int, height : int)

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) –

Return type:

None



DrawRectangle (self, rect : Rect)

Parameters:

rect (wx.Rect) –

Return type:

None



DrawRectangle (self, pt : Point, sz : Size)

Parameters:
Return type:

None





DrawRotatedText(self, *args, **kw)

overload Overloaded Implementations:



DrawRotatedText (self, text : str, x : int, y : int, angle : float)

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

Parameters:
  • text (string) –

  • x (int) –

  • y (int) –

  • angle (float) –

Return type:

None



DrawRotatedText (self, text : str, pt : Point, angle : float)

Parameters:
  • text (string) –

  • pt (wx.Point) –

  • angle (float) –

Return type:

None





DrawRoundedRectangle(self, *args, **kw)

overload Overloaded Implementations:



DrawRoundedRectangle (self, x : int, y : int, width : int, height : int, radius : float)

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) –

  • radius (float) –

Return type:

None



DrawRoundedRectangle (self, rect : Rect, radius : float)

Parameters:
  • rect (wx.Rect) –

  • radius (float) –

Return type:

None



DrawRoundedRectangle (self, pt : Point, sz : Size, radius : float)

Parameters:
Return type:

None





DrawSpline(self, points : PointList)

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 (PointList) –

Return type:

None



DrawText(self, *args, **kw)

overload Overloaded Implementations:



DrawText (self, text : str, x : int, y : int)

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.)

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.”, “

See also

DrawRotatedText

Parameters:
  • text (string) –

  • x (int) –

  • y (int) –

Return type:

None



DrawText (self, text : str, pt : Point)

Parameters:
Return type:

None





DrawToDC(self, dc : DC)

Draws the recorded operations to dc.

Parameters:

dc (wx.DC) –

Return type:

None



DrawToDCClipped(self, dc : DC, rect : Rect)

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

Parameters:
Return type:

None



DrawToDCClippedRgn(self, dc : DC, region : Region)

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

Parameters:
Return type:

None



FindObjects(self, x : int, y : int, radius: int=1, bg: Colour=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) –

Return type:

Any



FindObjectsByBBox(self, x : int, y : int)

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) –

Return type:

Any



FloodFill(self, *args, **kw)

overload Overloaded Implementations:



FloodFill (self, x : int, y : int, col : Colour, style: FloodFillStyle=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.

Parameters:
Return type:

None



FloodFill (self, pt : Point, col : Colour, style: FloodFillStyle=FLOOD_SURFACE)

Parameters:
Return type:

None





GetIdBounds(self, id : int)

Returns the bounding rectangle previously set with SetIdBounds. If no bounds have been set, it returns wx.Rect(0,0,0,0).

Parameters:

id (int) –

Return type:

Rect



GetIdGreyedOut(self, id : int)

Get whether the set of objects with tag id are drawn greyed out or not.

Parameters:

id (int) –

Return type:

bool



GetLen(self)

Returns the number of operations in the recorded list.

Return type:

int



RemoveAll(self)

Removes all objects and operations from the recorded list.

Return type:

None



RemoveId(self, id : int)

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

Parameters:

id (int) –

Return type:

None



SetBackground(self, brush : Brush)

Sets the current background brush for the DC.

Parameters:

brush (wx.Brush) –

Return type:

None



SetBackgroundMode(self, mode : int)

The mode parameter 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) –

Return type:

None



SetBrush(self, brush : 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.

See also

wx.Brush

Parameters:

brush (wx.Brush) –

Return type:

None



SetFont(self, font : 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.

See also

wx.Font

Parameters:

font (wx.Font) –

Return type:

None



SetId(self, id : int)

Sets the id to be associated with subsequent operations.

Parameters:

id (int) –

Return type:

None



SetIdBounds(self, id : int, rect : Rect)

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

Parameters:
Return type:

None



SetIdGreyedOut(self, id : int, greyout : bool)

Set whether the set of objects with tag id are drawn greyed out or not.

Parameters:
  • id (int) –

  • greyout (bool) –

Return type:

None



SetLogicalFunction(self, function : RasterOperationMode)

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 defined in the wx.RasterOperationMode enumeration.

The default is wx.``wx.COPY``, which simply draws with the current colour. The others combine the current colour and the background using a logical operation. wx.``wx.INVERT`` is commonly used for drawing rubber bands or moving outlines, since drawing twice reverts to the original colour.

Parameters:

function (RasterOperationMode) –

Return type:

None



SetPen(self, pen : 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.

See also

wx.Pen

Parameters:

pen (wx.Pen) –

Return type:

None



SetTextBackground(self, colour : Colour)

Sets the current text background colour for the DC.

Parameters:

colour (Colour) –

Return type:

None



SetTextForeground(self, colour : Colour)

Sets the current text foreground colour for the DC.

Parameters:

colour (wx.Colour) –

Return type:

None



TranslateId(self, id : int, dx : int, dy : int)

Translate the position of the operations of tag id by (dx, dy).

Parameters:
  • id (int) –

  • dx (int) –

  • dy (int) –

Return type:

None


Properties

Len

See GetLen