.. wxPython Phoenix documentation This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. Copyright: (c) 2011-2020 by Total Control Software License: wxWindows License .. include:: headings.inc .. _wx.adv.PseudoDC: ========================================================================================================================================== |phoenix_title| **wx.adv.PseudoDC** ========================================================================================================================================== A PseudoDC is an object that can be used much like real :class:`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 :meth:`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 ================================= .. raw:: html
Inheritance diagram for class PseudoDC:
| |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.adv.PseudoDC.__init__` Constructs a new Pseudo device context for recording and :meth:`~wx.adv.PseudoDC.Clear` Clears the device context using the current background brush. :meth:`~wx.adv.PseudoDC.ClearId` Removes all operations associated with id so the object can be redrawn. :meth:`~wx.adv.PseudoDC.CrossHair` Displays a cross hair using the current pen. This is a :meth:`~wx.adv.PseudoDC.DrawArc` Draws an arc of a circle, centred on the center point :meth:`~wx.adv.PseudoDC.DrawBitmap` Draw a bitmap on the device context at the specified :meth:`~wx.adv.PseudoDC.DrawCheckMark` Draws a check mark inside the given rectangle :meth:`~wx.adv.PseudoDC.DrawCircle` Draws a circle with the given center point and radius. :meth:`~wx.adv.PseudoDC.DrawEllipse` Draws an ellipse contained in the specified rectangle. The current pen :meth:`~wx.adv.PseudoDC.DrawEllipticArc` Draws an arc of an ellipse, with the given rectangle :meth:`~wx.adv.PseudoDC.DrawIcon` Draw an icon on the display at the given position. :meth:`~wx.adv.PseudoDC.DrawIdToDC` Draw recorded operations tagged with id to dc. :meth:`~wx.adv.PseudoDC.DrawLabel` Draw text within the specified rectangle, abiding by the :meth:`~wx.adv.PseudoDC.DrawLine` Draws a line from the first point to the second. :meth:`~wx.adv.PseudoDC.DrawLines` Draws lines using a sequence of `wx.Point` objects, adding the :meth:`~wx.adv.PseudoDC.DrawPoint` Draws a point using the current pen. :meth:`~wx.adv.PseudoDC.DrawPolygon` Draws a filled polygon using a sequence of `wx.Point` objects, adding :meth:`~wx.adv.PseudoDC.DrawRectangle` Draws a rectangle with the given top left corner, and with :meth:`~wx.adv.PseudoDC.DrawRotatedText` Draws the text rotated by angle degrees, if supported by the platform. :meth:`~wx.adv.PseudoDC.DrawRoundedRectangle` Draws a rectangle with the given top left corner, and with :meth:`~wx.adv.PseudoDC.DrawSpline` Draws a spline between all given control points, (a list of `wx.Point` :meth:`~wx.adv.PseudoDC.DrawText` Draws a text string at the specified point, using the :meth:`~wx.adv.PseudoDC.DrawToDC` Draws the recorded operations to dc. :meth:`~wx.adv.PseudoDC.DrawToDCClipped` Draws the recorded operations to dc, :meth:`~wx.adv.PseudoDC.DrawToDCClippedRgn` Draws the recorded operations to dc, :meth:`~wx.adv.PseudoDC.FindObjects` Returns a list of all the id's that draw a pixel with :meth:`~wx.adv.PseudoDC.FindObjectsByBBox` Returns a list of all the id's whose bounding boxes include (x,y). :meth:`~wx.adv.PseudoDC.FloodFill` Flood fills the device context starting from the given point, :meth:`~wx.adv.PseudoDC.GetIdBounds` Returns the bounding rectangle previously set with `SetIdBounds`. :meth:`~wx.adv.PseudoDC.GetIdGreyedOut` Get whether the set of objects with tag `id` are drawn greyed out or not. :meth:`~wx.adv.PseudoDC.GetLen` Returns the number of operations in the recorded list. :meth:`~wx.adv.PseudoDC.RemoveAll` Removes all objects and operations from the recorded list. :meth:`~wx.adv.PseudoDC.RemoveId` Remove the object node (and all operations) associated with an id. :meth:`~wx.adv.PseudoDC.SetBackground` Sets the current background brush for the DC. :meth:`~wx.adv.PseudoDC.SetBackgroundMode` The mode parameter may be one of ``wx.SOLID`` and :meth:`~wx.adv.PseudoDC.SetBrush` Sets the current brush for the DC. :meth:`~wx.adv.PseudoDC.SetFont` Sets the current font for the DC. It must be a valid font, in :meth:`~wx.adv.PseudoDC.SetId` Sets the id to be associated with subsequent operations. :meth:`~wx.adv.PseudoDC.SetIdBounds` Set the bounding rect of a given object. :meth:`~wx.adv.PseudoDC.SetIdGreyedOut` Set whether the set of objects with tag `id` are drawn greyed out or not. :meth:`~wx.adv.PseudoDC.SetLogicalFunction` Sets the current logical function for the device context. This :meth:`~wx.adv.PseudoDC.SetPen` Sets the current pen for the DC. :meth:`~wx.adv.PseudoDC.SetTextBackground` Sets the current text background colour for the DC. :meth:`~wx.adv.PseudoDC.SetTextForeground` Sets the current text foreground colour for the DC. :meth:`~wx.adv.PseudoDC.TranslateId` Translate the position of the operations of tag `id` by (`dx`, `dy`). ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~wx.adv.PseudoDC.Len` See :meth:`~wx.adv.PseudoDC.GetLen` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: wx.adv.PseudoDC(Object) **Possible constructors**:: PseudoDC() A PseudoDC is an object that can be used much like real :class:`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 :meth:`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. .. method:: __init__(self) Constructs a new Pseudo device context for recording and replaying DC operations. .. method:: Clear(self) Clears the device context using the current background brush. .. method:: ClearId(self, id) Removes all operations associated with id so the object can be redrawn. :param `id`: :type `id`: int .. method:: CrossHair(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **CrossHair** `(self, 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. :param `x`: :type `x`: int :param `y`: :type `y`: int :html:`

` **CrossHair** `(self, pt)` :param `pt`: :type `pt`: wx.Point :html:`

` .. method:: DrawArc(self, 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. :param `x1`: :type `x1`: int :param `y1`: :type `y1`: int :param `x2`: :type `x2`: int :param `y2`: :type `y2`: int :param `xc`: :type `xc`: int :param `yc`: :type `yc`: int .. method:: DrawBitmap(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **DrawBitmap** `(self, bmp, x, y, useMask=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). .. seealso:: `SetTextForeground`, `SetTextBackground` and `wx.MemoryDC` :param `bmp`: :type `bmp`: wx.Bitmap :param `x`: :type `x`: int :param `y`: :type `y`: int :param `useMask`: :type `useMask`: bool :html:`

` **DrawBitmap** `(self, bmp, pt, useMask=False)` :param `bmp`: :type `bmp`: wx.Bitmap :param `pt`: :type `pt`: wx.Point :param `useMask`: :type `useMask`: bool :html:`

` .. method:: DrawCheckMark(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **DrawCheckMark** `(self, x, y, width, height)` Draws a check mark inside the given rectangle :param `x`: :type `x`: int :param `y`: :type `y`: int :param `width`: :type `width`: int :param `height`: :type `height`: int :html:`

` **DrawCheckMark** `(self, rect)` :param `rect`: :type `rect`: wx.Rect :html:`

` .. method:: DrawCircle(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **DrawCircle** `(self, 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. .. seealso:: `DrawEllipse` :param `x`: :type `x`: int :param `y`: :type `y`: int :param `radius`: :type `radius`: int :html:`

` **DrawCircle** `(self, pt, radius)` :param `pt`: :type `pt`: wx.Point :param `radius`: :type `radius`: int :html:`

` .. method:: DrawEllipse(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **DrawEllipse** `(self, 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.", " .. seealso:: `DrawCircle` :param `x`: :type `x`: int :param `y`: :type `y`: int :param `width`: :type `width`: int :param `height`: :type `height`: int :html:`

` **DrawEllipse** `(self, rect)` :param `rect`: :type `rect`: wx.Rect :html:`

` **DrawEllipse** `(self, pt, sz)` :param `pt`: :type `pt`: wx.Point :param `sz`: :type `sz`: wx.Size :html:`

` .. method:: DrawEllipticArc(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **DrawEllipticArc** `(self, 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. :param `x`: :type `x`: int :param `y`: :type `y`: int :param `w`: :type `w`: int :param `h`: :type `h`: int :param `start`: :type `start`: float :param `end`: :type `end`: float :html:`

` **DrawEllipticArc** `(self, pt, sz, start, end)` :param `pt`: :type `pt`: wx.Point :param `sz`: :type `sz`: wx.Size :param `start`: :type `start`: float :param `end`: :type `end`: float :html:`

` .. method:: DrawIcon(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **DrawIcon** `(self, icon, x, y)` Draw an icon on the display at the given position. :param `icon`: :type `icon`: wx.Icon :param `x`: :type `x`: int :param `y`: :type `y`: int :html:`

` **DrawIcon** `(self, icon, pt)` :param `icon`: :type `icon`: wx.Icon :param `pt`: :type `pt`: wx.Point :html:`

` .. method:: DrawIdToDC(self, id, dc) Draw recorded operations tagged with id to dc. :param `id`: :type `id`: int :param `dc`: :type `dc`: wx.DC .. method:: DrawLabel(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **DrawLabel** `(self, text, rect, alignment=ALIGN_LEFT|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. :param `text`: :type `text`: string :param `rect`: :type `rect`: wx.Rect :param `alignment`: :type `alignment`: int :param `indexAccel`: :type `indexAccel`: int :html:`

` **DrawLabel** `(self, text, image, rect, alignment=ALIGN_LEFT|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. :param `text`: :type `text`: string :param `image`: :type `image`: wx.Bitmap :param `rect`: :type `rect`: wx.Rect :param `alignment`: :type `alignment`: int :param `indexAccel`: :type `indexAccel`: int :html:`

` .. method:: DrawLine(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **DrawLine** `(self, x1, y1, x2, y2)` 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). :param `x1`: :type `x1`: int :param `y1`: :type `y1`: int :param `x2`: :type `x2`: int :param `y2`: :type `y2`: int :html:`

` **DrawLine** `(self, pt1, pt2)` :param `pt1`: :type `pt1`: wx.Point :param `pt2`: :type `pt2`: wx.Point :html:`

` .. method:: DrawLines(self, 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. :param `points`: :type `points`: PointList :param `xoffset`: :type `xoffset`: int :param `yoffset`: :type `yoffset`: int .. method:: DrawPoint(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **DrawPoint** `(self, x, y)` Draws a point using the current pen. :param `x`: :type `x`: int :param `y`: :type `y`: int :html:`

` **DrawPoint** `(self, pt)` :param `pt`: :type `pt`: wx.Point :html:`

` .. method:: DrawPolygon(self, points, xoffset=0, yoffset=0, fillStyle=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. :param `points`: :type `points`: PointList :param `xoffset`: :type `xoffset`: int :param `yoffset`: :type `yoffset`: int :param `fillStyle`: :type `fillStyle`: wx.PolygonFillMode .. method:: DrawRectangle(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **DrawRectangle** `(self, 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. :param `x`: :type `x`: int :param `y`: :type `y`: int :param `width`: :type `width`: int :param `height`: :type `height`: int :html:`

` **DrawRectangle** `(self, rect)` :param `rect`: :type `rect`: wx.Rect :html:`

` **DrawRectangle** `(self, pt, sz)` :param `pt`: :type `pt`: wx.Point :param `sz`: :type `sz`: wx.Size :html:`

` .. method:: DrawRotatedText(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **DrawRotatedText** `(self, text, x, y, angle)` Draws the text rotated by angle degrees, if supported by the platform. :param `text`: :type `text`: string :param `x`: :type `x`: int :param `y`: :type `y`: int :param `angle`: :type `angle`: float :html:`

` **DrawRotatedText** `(self, text, pt, angle)` :param `text`: :type `text`: string :param `pt`: :type `pt`: wx.Point :param `angle`: :type `angle`: float :html:`

` .. method:: DrawRoundedRectangle(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **DrawRoundedRectangle** `(self, x, y, width, height, radius)` 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. :param `x`: :type `x`: int :param `y`: :type `y`: int :param `width`: :type `width`: int :param `height`: :type `height`: int :param `radius`: :type `radius`: float :html:`

` **DrawRoundedRectangle** `(self, rect, radius)` :param `rect`: :type `rect`: wx.Rect :param `radius`: :type `radius`: float :html:`

` **DrawRoundedRectangle** `(self, pt, sz, radius)` :param `pt`: :type `pt`: wx.Point :param `sz`: :type `sz`: wx.Size :param `radius`: :type `radius`: float :html:`

` .. method:: DrawSpline(self, 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``'. :param `points`: :type `points`: PointList .. method:: DrawText(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **DrawText** `(self, 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.) ``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.", " .. seealso:: `DrawRotatedText` :param `text`: :type `text`: string :param `x`: :type `x`: int :param `y`: :type `y`: int :html:`

` **DrawText** `(self, text, pt)` :param `text`: :type `text`: string :param `pt`: :type `pt`: wx.Point :html:`

` .. method:: DrawToDC(self, dc) Draws the recorded operations to dc. :param `dc`: :type `dc`: wx.DC .. method:: DrawToDCClipped(self, dc, rect) Draws the recorded operations to dc, unless the operation is known to be outside of rect. :param `dc`: :type `dc`: wx.DC :param `rect`: :type `rect`: wx.Rect .. method:: DrawToDCClippedRgn(self, dc, region) Draws the recorded operations to dc, unless the operation is known to be outside the given region. :param `dc`: :type `dc`: wx.DC :param `region`: :type `region`: wx.Region .. method:: FindObjects(self, x, y, radius=1, bg=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. :param `x`: :type `x`: int :param `y`: :type `y`: int :param `radius`: :type `radius`: int :param `bg`: :type `bg`: wx.Colour :rtype: `PyObject` .. method:: FindObjectsByBBox(self, 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. :param `x`: :type `x`: int :param `y`: :type `y`: int :rtype: `PyObject` .. method:: FloodFill(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **FloodFill** `(self, x, y, col, style=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. :param `x`: :type `x`: int :param `y`: :type `y`: int :param `col`: :type `col`: wx.Colour :param `style`: :type `style`: wx.FloodFillStyle :html:`

` **FloodFill** `(self, pt, col, style=FLOOD_SURFACE)` :param `pt`: :type `pt`: wx.Point :param `col`: :type `col`: wx.Colour :param `style`: :type `style`: wx.FloodFillStyle :html:`

` .. method:: GetIdBounds(self, id) Returns the bounding rectangle previously set with `SetIdBounds`. If no bounds have been set, it returns wx.Rect(0,0,0,0). :param `id`: :type `id`: int :rtype: `Rect` .. method:: GetIdGreyedOut(self, id) Get whether the set of objects with tag `id` are drawn greyed out or not. :param `id`: :type `id`: int :rtype: `bool` .. method:: GetLen(self) Returns the number of operations in the recorded list. :rtype: `int` .. method:: RemoveAll(self) Removes all objects and operations from the recorded list. .. method:: RemoveId(self, id) Remove the object node (and all operations) associated with an id. :param `id`: :type `id`: int .. method:: SetBackground(self, brush) Sets the current background brush for the DC. :param `brush`: :type `brush`: wx.Brush .. method:: SetBackgroundMode(self, mode) 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. :param `mode`: :type `mode`: int .. method:: SetBrush(self, 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. .. seealso:: `wx.Brush` :param `brush`: :type `brush`: wx.Brush .. method:: SetFont(self, 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. .. seealso:: `wx.Font` :param `font`: :type `font`: wx.Font .. method:: SetId(self, id) Sets the id to be associated with subsequent operations. :param `id`: :type `id`: int .. method:: SetIdBounds(self, id, rect) Set the bounding rect of a given object. This will create an object node if one doesn't exist. :param `id`: :type `id`: int :param `rect`: :type `rect`: wx.Rect .. method:: SetIdGreyedOut(self, id, greyout) Set whether the set of objects with tag `id` are drawn greyed out or not. :param `id`: :type `id`: int :param `greyout`: :type `greyout`: bool .. method:: SetLogicalFunction(self, 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 defined in the :ref:`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. :param `function`: :type `function`: wx.RasterOperationMode .. method:: SetPen(self, 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. .. seealso:: `wx.Pen` :param `pen`: :type `pen`: wx.Pen .. method:: SetTextBackground(self, colour) Sets the current text background colour for the DC. :param `colour`: :type `colour`: :class:`Colour` .. method:: SetTextForeground(self, colour) Sets the current text foreground colour for the DC. :param `colour`: :type `colour`: wx.Colour .. method:: TranslateId(self, id, dx, dy) Translate the position of the operations of tag `id` by (`dx`, `dy`). :param `id`: :type `id`: int :param `dx`: :type `dx`: int :param `dy`: :type `dy`: int .. attribute:: Len See :meth:`~wx.adv.PseudoDC.GetLen`