***** wx.DC ***** Inheritance diagram for `wx.DC`: | .. inheritance-diagram:: wx.DC | Description =========== A `wx.DC` is a *device context* onto which graphics and text can be drawn. It is intended to represent a number of output devices in a generic way, so a window can have a device context associated with it, and a printer also has a device context. In this way, the same piece of code may write to a number of different devices, if the device context is used as a parameter. .. note:: Notice that wx.DC is an abstract base class and can't be created directly, please use `wx.PaintDC `_ , `wx.ClientDC `_, `wx.WindowDC `_, `wx.ScreenDC `_, `wx.MemoryDC `_ or `wx.PrinterDC `_. Derived From ^^^^^^^^^^^^^ * `wx.Object `_ Known Subclasses ^^^^^^^^^^^^^^^^ `wx.AutoBufferedPaintDC `_, `wx.BufferedDC `_, `wx.BufferedPaintDC `_, `wx.ClientDC `_, `wx.GCDC `_, `wx.MemoryDC `_, `wx.MetaFileDC `_, `wx.MirrorDC `_, `wx.PaintDC `_, `wx.PostScriptDC `_, `wx.PrinterDC `_, `wx.ScreenDC `_, `wx.WindowDC `_ Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `BeginDrawing <#BeginDrawing>`_ * `Blit <#Blit>`_ * `BlitPointSize <#BlitPointSize>`_ * `CalcBoundingBox <#CalcBoundingBox>`_ * `CalcBoundingBoxPoint <#CalcBoundingBoxPoint>`_ * `CanDrawBitmap <#CanDrawBitmap>`_ * `CanGetTextExtent <#CanGetTextExtent>`_ * `Clear <#Clear>`_ * `ComputeScaleAndOrigin <#ComputeScaleAndOrigin>`_ * `CrossHair <#CrossHair>`_ * `CrossHairPoint <#CrossHairPoint>`_ * `DestroyClippingRegion <#DestroyClippingRegion>`_ * `DeviceToLogicalX <#DeviceToLogicalX>`_ * `DeviceToLogicalXRel <#DeviceToLogicalXRel>`_ * `DeviceToLogicalY <#DeviceToLogicalY>`_ * `DeviceToLogicalYRel <#DeviceToLogicalYRel>`_ * `DrawArc <#DrawArc>`_ * `DrawArcPoint <#DrawArcPoint>`_ * `DrawBitmap <#DrawBitmap>`_ * `DrawBitmapPoint <#DrawBitmapPoint>`_ * `DrawCheckMark <#DrawCheckMark>`_ * `DrawCheckMarkRect <#DrawCheckMarkRect>`_ * `DrawCircle <#DrawCircle>`_ * `DrawCirclePoint <#DrawCirclePoint>`_ * `DrawEllipse <#DrawEllipse>`_ * `DrawEllipseList <#DrawEllipseList>`_ * `DrawEllipsePointSize <#DrawEllipsePointSize>`_ * `DrawEllipseRect <#DrawEllipseRect>`_ * `DrawEllipticArc <#DrawEllipticArc>`_ * `DrawEllipticArcPointSize <#DrawEllipticArcPointSize>`_ * `DrawIcon <#DrawIcon>`_ * `DrawIconPoint <#DrawIconPoint>`_ * `DrawImageLabel <#DrawImageLabel>`_ * `DrawLabel <#DrawLabel>`_ * `DrawLine <#DrawLine>`_ * `DrawLineList <#DrawLineList>`_ * `DrawLinePoint <#DrawLinePoint>`_ * `DrawLines <#DrawLines>`_ * `DrawPoint <#DrawPoint>`_ * `DrawPointList <#DrawPointList>`_ * `DrawPointPoint <#DrawPointPoint>`_ * `DrawPolygon <#DrawPolygon>`_ * `DrawPolygonList <#DrawPolygonList>`_ * `DrawRectangle <#DrawRectangle>`_ * `DrawRectangleList <#DrawRectangleList>`_ * `DrawRectanglePointSize <#DrawRectanglePointSize>`_ * `DrawRectangleRect <#DrawRectangleRect>`_ * `DrawRotatedText <#DrawRotatedText>`_ * `DrawRotatedTextPoint <#DrawRotatedTextPoint>`_ * `DrawRoundedRectangle <#DrawRoundedRectangle>`_ * `DrawRoundedRectanglePointSize <#DrawRoundedRectanglePointSize>`_ * `DrawRoundedRectangleRect <#DrawRoundedRectangleRect>`_ * `DrawSpline <#DrawSpline>`_ * `DrawText <#DrawText>`_ * `DrawTextList <#DrawTextList>`_ * `DrawTextPoint <#DrawTextPoint>`_ * `EndDoc <#EndDoc>`_ * `EndDrawing <#EndDrawing>`_ * `EndPage <#EndPage>`_ * `FloodFill <#FloodFill>`_ * `FloodFillPoint <#FloodFillPoint>`_ * `GetAsBitmap <#GetAsBitmap>`_ * `GetBackground <#GetBackground>`_ * `GetBackgroundMode <#GetBackgroundMode>`_ * `GetBoundingBox <#GetBoundingBox>`_ * `GetBrush <#GetBrush>`_ * `GetCharHeight <#GetCharHeight>`_ * `GetCharWidth <#GetCharWidth>`_ * `GetClippingBox <#GetClippingBox>`_ * `GetClippingRect <#GetClippingRect>`_ * `GetDepth <#GetDepth>`_ * `GetDeviceOrigin <#GetDeviceOrigin>`_ * `GetDeviceOriginTuple <#GetDeviceOriginTuple>`_ * `GetFont <#GetFont>`_ * `GetFullTextExtent <#GetFullTextExtent>`_ * `GetHDC <#GetHDC>`_ * `GetLayoutDirection <#GetLayoutDirection>`_ * `GetLogicalFunction <#GetLogicalFunction>`_ * `GetLogicalOrigin <#GetLogicalOrigin>`_ * `GetLogicalOriginTuple <#GetLogicalOriginTuple>`_ * `GetLogicalScale <#GetLogicalScale>`_ * `GetMapMode <#GetMapMode>`_ * `GetMultiLineTextExtent <#GetMultiLineTextExtent>`_ * `GetPPI <#GetPPI>`_ * `GetPartialTextExtents <#GetPartialTextExtents>`_ * `GetPen <#GetPen>`_ * `GetPixel <#GetPixel>`_ * `GetPixelPoint <#GetPixelPoint>`_ * `GetSize <#GetSize>`_ * `GetSizeMM <#GetSizeMM>`_ * `GetSizeMMTuple <#GetSizeMMTuple>`_ * `GetSizeTuple <#GetSizeTuple>`_ * `GetTextBackground <#GetTextBackground>`_ * `GetTextExtent <#GetTextExtent>`_ * `GetTextForeground <#GetTextForeground>`_ * `GetUserScale <#GetUserScale>`_ * `GradientFillConcentric <#GradientFillConcentric>`_ * `GradientFillLinear <#GradientFillLinear>`_ * `IsOk <#IsOk>`_ * `LogicalToDeviceX <#LogicalToDeviceX>`_ * `LogicalToDeviceXRel <#LogicalToDeviceXRel>`_ * `LogicalToDeviceY <#LogicalToDeviceY>`_ * `LogicalToDeviceYRel <#LogicalToDeviceYRel>`_ * `MaxX <#MaxX>`_ * `MaxY <#MaxY>`_ * `MinX <#MinX>`_ * `MinY <#MinY>`_ * `ResetBoundingBox <#ResetBoundingBox>`_ * `SetAxisOrientation <#SetAxisOrientation>`_ * `SetBackground <#SetBackground>`_ * `SetBackgroundMode <#SetBackgroundMode>`_ * `SetBrush <#SetBrush>`_ * `SetClippingRect <#SetClippingRect>`_ * `SetClippingRegion <#SetClippingRegion>`_ * `SetClippingRegionAsRegion <#SetClippingRegionAsRegion>`_ * `SetClippingRegionPointSize <#SetClippingRegionPointSize>`_ * `SetDeviceOrigin <#SetDeviceOrigin>`_ * `SetDeviceOriginPoint <#SetDeviceOriginPoint>`_ * `SetFont <#SetFont>`_ * `SetLayoutDirection <#SetLayoutDirection>`_ * `SetLogicalFunction <#SetLogicalFunction>`_ * `SetLogicalOrigin <#SetLogicalOrigin>`_ * `SetLogicalOriginPoint <#SetLogicalOriginPoint>`_ * `SetLogicalScale <#SetLogicalScale>`_ * `SetMapMode <#SetMapMode>`_ * `SetPalette <#SetPalette>`_ * `SetPen <#SetPen>`_ * `SetTextBackground <#SetTextBackground>`_ * `SetTextForeground <#SetTextForeground>`_ * `SetUserScale <#SetUserScale>`_ * `StartDoc <#StartDoc>`_ * `StartPage <#StartPage>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `Background <#Background>`_ * `BackgroundMode <#BackgroundMode>`_ * `BoundingBox <#BoundingBox>`_ * `Brush <#Brush>`_ * `CharHeight <#CharHeight>`_ * `CharWidth <#CharWidth>`_ * `ClippingBox <#ClippingBox>`_ * `ClippingRect <#ClippingRect>`_ * `Depth <#Depth>`_ * `DeviceOrigin <#DeviceOrigin>`_ * `Font <#Font>`_ * `FullTextExtent <#FullTextExtent>`_ * `LayoutDirection <#LayoutDirection>`_ * `LogicalFunction <#LogicalFunction>`_ * `LogicalOrigin <#LogicalOrigin>`_ * `LogicalScale <#LogicalScale>`_ * `MapMode <#MapMode>`_ * `MultiLineTextExtent <#MultiLineTextExtent>`_ * `Optimization <#Optimization>`_ * `PPI <#PPI>`_ * `PartialTextExtents <#PartialTextExtents>`_ * `Pen <#Pen>`_ * `Pixel <#Pixel>`_ * `PixelPoint <#PixelPoint>`_ * `Size <#Size>`_ * `SizeMM <#SizeMM>`_ * `TextBackground <#TextBackground>`_ * `TextExtent <#TextExtent>`_ * `TextForeground <#TextForeground>`_ * `UserScale <#UserScale>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__() `No docstrings available for this method.` -------- .. method:: BeginDrawing() `No docstrings available for this method.` -------- .. method:: Blit(xdest, ydest, width, height, source, xsrc, ysrc, useMask=False, xsrcMask=-1, ysrcMask=-1) Copy from a source DC to this DC, specifying the destination coordinates, size of area to copy, source DC, source coordinates, logical function, whether to use a bitmap mask, and mask source position. **Parameters:** * `xdest` (int): Destination device context x position. * `ydest` (int): Destination device context y position. * `width` (int): Width of source area to be copied. * `height` (int): Height of source area to be copied. * `source` (`wx.DC `_): Source device context. * `xsrc` (int): Source device context x position. * `ysrc` (int): Source device context y position. * `useMask` (bool): If ``True``, Blit does a transparent blit using the mask that is associated with the bitmap selected into the source device context. The Windows implementation does the following if MaskBlt cannot be used: 1. Creates a temporary bitmap and copies the destination area into it. 2. Copies the source area into the temporary bitmap using the specified logical function. 3. Sets the masked area in the temporary bitmap to BLACK by ANDing the mask bitmap with the temp bitmap with the foreground colour set to WHITE and the bg colour set to BLACK. 4. Sets the unmasked area in the destination area to BLACK by ANDing the mask bitmap with the destination area with the foreground colour set to BLACK and the background colour set to WHITE. 5. ORs the temporary bitmap with the destination area. 6. Deletes the temporary bitmap. This sequence of operations ensures that the source's transparent area need not be black, and logical functions are supported. On Windows, blitting with masks can be speeded up considerably by compiling wxWidgets with the ``wx.USE_DC_CACHE`` option enabled. You can also influence whether MaskBlt or the explicit mask blitting code above is used, by using `wx.SystemOptions `_ and setting the `no-maskblt` option to 1. * `xsrcMask` (int): Source x position on the mask. If both xsrcMask and ysrcMask are -1, xsrc and ysrc will be assumed for the mask source position. Currently only implemented on Windows. * `ysrcMask` (int): Source y position on the mask. If both xsrcMask and ysrcMask are -1, xsrc and ysrc will be assumed for the mask source position. Currently only implemented on Windows. | **Returns:** `bool` .. note:: There is partial support for `Blit` in `wx.PostScriptDC `_, under X. See `wx.MemoryDC `_ for typical usage. .. seealso:: `wx.MemoryDC `_, `wx.Bitmap `_, `wx.Mask `_ -------- .. method:: BlitPointSize(destPt, sz, source, srcPt, rop=wx.COPY, useMask=False, srcPtMask=wx.DefaultPosition) Copy from a source DC to this DC. Parameters specify the destination coordinates, size of area to copy, source DC, source coordinates, logical function, whether to use a bitmap mask, and mask source position. **Parameters:** * `destPt` (`wx.Point `_) * `sz` (`wx.Size `_) * `source` (`wx.DC `_) * `srcPt` (`wx.Point `_) * `rop` (int) * `useMask` (bool) * `srcPtMask` (`wx.Point `_) | **Returns:** `bool` -------- .. method:: CalcBoundingBox(x, y) Adds the specified point to the bounding box which can be retrieved with `MinX <#MinX>`_, `MaxX <#MaxX>`_ and `MinY <#MinY>`_, `MaxY <#MaxY>`_ functions. **Parameters:** * `x` (int) * `y` (int) .. seealso:: `ResetBoundingBox <#ResetBoundingBox>`_ -------- .. method:: CalcBoundingBoxPoint(point) Adds the specified point to the bounding box which can be retrieved with `MinX <#MinX>`_, `MaxX <#MaxX>`_ and `MinY <#MinY>`_, `MaxY <#MaxY>`_ or `GetBoundingBox <#GetBoundingBox>`_ functions. **Parameters:** * `point` (`wx.Point `_) -------- .. method:: CanDrawBitmap() `No docstrings available for this method.` -------- .. method:: CanGetTextExtent() `No docstrings available for this method.` -------- .. method:: Clear() Clears the device context using the current background brush. -------- .. method:: ComputeScaleAndOrigin() Performs all necessary computations for given platform and context type after each change of scale and origin parameters. Usually called automatically internally after such changes. -------- .. method:: 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) -------- .. method:: 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:** * `pt` (`wx.Point `_) -------- .. method:: DestroyClippingRegion() Destroys the current clipping region so that none of the DC is clipped. .. seealso:: `SetClippingRegion <#SetClippingRegion>`_ -------- .. method:: DeviceToLogicalX(x) Convert device `X` coordinate to logical coordinate, using the current mapping mode. **Parameters:** * `x` (int) | **Returns:** `int` -------- .. method:: DeviceToLogicalXRel(x) Convert device `X` coordinate to relative logical coordinate, using the current mapping mode but ignoring the x axis orientation. Use this function for converting a width, for example. **Parameters:** * `x` (int) | **Returns:** `int` -------- .. method:: DeviceToLogicalY(y) Converts device `Y` coordinate to logical coordinate, using the current mapping mode. **Parameters:** * `y` (int) | **Returns:** `int` -------- .. method:: DeviceToLogicalYRel(y) Convert device `Y` coordinate to relative logical coordinate, using the current mapping mode but ignoring the y axis orientation. Use this function for converting a height, for example. **Parameters:** * `y` (int) | **Returns:** `int` -------- .. method:: DrawArc(x1, y1, x2, x2, xc, yc) Draws an arc of a circle, centred on (`xc`, `yc`), with starting point (`x1`, `y1`) and ending at (`x2`, `y2`). 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) -------- .. method:: DrawArcPoint(pt1, pt2, center) 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:** * `pt1` (`wx.Point `_) * `pt2` (`wx.Point `_) * `center` (`wx.Point `_) -------- .. method:: DrawBitmap(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, 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 <#SetTextForeground>`_, `SetTextBackground <#SetTextBackground>`_ and `wx.MemoryDC `_ -------- .. method:: DrawBitmapPoint(bmp, pt, 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. **Parameters:** * `bmp` (`wx.Bitmap `_) * `pt` (`wx.Point `_) * `useMask` (bool) -------- .. method:: DrawCheckMark(x, y, width, height) Draws a check mark inside the given rectangle. **Parameters:** * `x` (int) * `y` (int) * `width` (int) * `height` (int) -------- .. method:: DrawCheckMarkRect(rect) Draws a check mark inside the given rectangle. **Parameters:** * `rect` (`wx.Rect `_) -------- .. method:: DrawCircle(x, y, radius) Draws a circle with the given centre and radius. **Parameters:** * `x` (int) * `y` (int) * `radius` (int) .. seealso:: `DrawEllipse <#DrawEllipse>`_ -------- .. method:: 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:** * `pt` (`wx.Point `_) * `radius` (int) -------- .. method:: DrawEllipse(x, y, width, height) Draws an ellipse contained in the rectangle specified either with the given top left corner and the given size or directly. 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) .. seealso:: `DrawCircle <#DrawCircle>`_ -------- .. method:: DrawEllipseList(ellipses, pens=None, brushes=None) Draw a list of ellipses as quickly as possible. **Parameters:** * `ellipses`: A sequence of 4-element sequences representing each ellipse to draw, (x, y, w, h). * `pens`: If ``None``, then the current pen is used. If a single pen then it will be used for all ellipses. If a list of pens then there should be one for each ellipse in ellipses. * `brushes`: A brush or brushes to be used to fill the ellipses, with similar semantics as the `pens` parameter. -------- .. method:: 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:** * `pt` (`wx.Point `_) * `sz` (`wx.Size `_) -------- .. method:: 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:** * `rect` (`wx.Rect `_) -------- .. method:: DrawEllipticArc(x, y, w, h, start, end) Draws an arc of an ellipse. The current pen is used for drawing the arc and the current brush is used for drawing the pie. `x` and `y` specify the x and y coordinates of the upper-left corner of the rectangle that contains the ellipse. `width` and `height` specify the width and height of the rectangle that contains the ellipse. `start` and `end` 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) -------- .. method:: 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:** * `pt` (`wx.Point `_) * `sz` (`wx.Size `_) * `start` (double) * `end` (double) -------- .. method:: DrawIcon(icon, x, y) Draw an icon on the display (does nothing if the device context is `wx.PostScriptDC `_). This can be the simplest way of drawing bitmaps on a window. **Parameters:** * `icon` (`wx.Icon `_) * `x` (int) * `y` (int) -------- .. method:: DrawIconPoint(icon, pt) Draw an icon on the display (does nothing if the device context is `wx.PostScriptDC `_). This can be the simplest way of drawing bitmaps on a window. **Parameters:** * `icon` (`wx.Icon `_) * `pt` (`wx.Point `_) -------- .. method:: 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. Returns the bounding rectangle. **Parameters:** * `text` (string) * `image` (`wx.Bitmap `_) * `rect` (`wx.Rect `_) * `alignment` (int) * `indexAccel` (int) | **Returns:** `wx.Rect `_ -------- .. method:: DrawLabel(text, rect, alignment=wx.ALIGN_LEFT|wx.ALIGN_TOP, indexAccel=-1) Draw optional bitmap and the text into the given rectangle and aligns it as specified by the `alignment` parameter; it also will emphasize the character with the given index if it is != -1. **Parameters:** * `text` (string) * `rect` (`wx.Rect `_) * `alignment` (int) * `indexAccel` (int) -------- .. method:: 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 point (`x2`, `y2`) is **not** part of the line and is not drawn by this function (this is consistent with the behaviour of many other toolkits). -------- .. method:: DrawLineList(lines, pens=None) Draw a list of lines as quickly as possible. **Parameters:** * `lines`: A sequence of 4-element sequences representing each line to draw, (x1, y1, x2, y2). * `pens`: If ``None``, then the current pen is used. If a single pen then it will be used for all lines. If a list of pens then there should be one for each line in lines. -------- .. method:: DrawLinePoint(pt1, pt2) Draws a line from the first point to the second. The current pen is used for drawing the line. **Parameters:** * `pt1` (`wx.Point `_) * `pt2` (`wx.Point `_) .. note:: Note that the second point `pt2` is **not** part of the line and is not drawn by this function (this is consistent with the behaviour of many other toolkits). -------- .. method:: DrawLines(points, xoffset=0, yoffset=0) Draws lines using an array of `points`, adding the optional offset coordinate. The current pen is used for drawing the lines. The programmer is responsible for deleting the list of points. **Parameters:** * `points` (list of `wx.Points `_) * `xoffset` (int) * `yoffset` (int) -------- .. method:: DrawPoint(x, y) Draws a point using the color of the current pen. **Parameters:** * `x` (int) * `y` (int) .. note:: Note that the other properties of the pen are not used, such as width etc.. -------- .. method:: DrawPointList(points, pens=None) Draw a list of points as quickly as possible. **Parameters:** * `points`: A sequence of 2-element sequences representing each point to draw, (x, y). * `pens`: If ``None``, then the current pen is used. If a single pen then it will be used for all points. If a list of pens then there should be one for each point in points. -------- .. method:: DrawPointPoint(pt) Draws a point using the current pen. **Parameters:** * `pt` (`wx.Point `_) -------- .. method:: DrawPolygon(points, xoffset=0, yoffset=0, fillStyle=wx.ODDEVEN_RULE) Draws a filled polygon using an array of `points`, 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. The programmer is responsible for deleting the list of points. **Parameters:** * `points` (list of `wx.Points `_) * `xoffset` (int) * `yoffset` (int) * `fillStyle` (int) .. note:: Note that wxPython automatically closes the first and last points. -------- .. method:: DrawPolygonList(polygons, pens=None, brushes=None) Draw a list of polygons, each of which is a list of points. **Parameters:** * `polygons`: A sequence of sequences of sequences., i.e. :: [[(x1,y1),(x2,y2),(x3,y3)...], [(x1,y1),(x2,y2),(x3,y3)...]] * `pens`: If ``None``, then the current pen is used. If a single pen then it will be used for all polygons. If a list of pens then there should be one for each polygon. * `brushes`: A brush or brushes to be used to fill the polygons, with similar semantics as the `pens` parameter. -------- .. method:: 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) -------- .. method:: DrawRectangleList(rectangles, pens=None, brushes=None) Draw a list of rectangles as quickly as possible. **Parameters:** * `rectangles`: A sequence of 4-element sequences representing each rectangle to draw, (x, y, w, h). * `pens`: If ``None``, then the current pen is used. If a single pen then it will be used for all rectangles. If a list of pens then there should be one for each rectangle in rectangles. * `brushes`: A brush or brushes to be used to fill the rectagles, with similar semantics as the `pens` parameter. -------- .. method:: 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:** * `pt` (`wx.Point `_) * `sz` (`wx.Size `_) -------- .. method:: 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:** * `rect` (`wx.Rect `_) -------- .. method:: DrawRotatedText(text, x, y, angle) Draws the text rotated by `angle` degrees. **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 latter is not a TrueType font. ``wx.SWISS_FONT`` is an example of a font which is. .. seealso:: `DrawText <#DrawText>`_ -------- .. method:: 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 latter is not a TrueType font. ``wx.SWISS_FONT`` is an example of a font which is. -------- .. method:: 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) * `angle` (double) -------- .. method:: 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:** * `pt` (`wx.Point `_) * `sz` (`wx.Size `_) * `radius` (double) -------- .. method:: DrawRoundedRectangleRect(r, radius) Draws a rectangle with the given rect. 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:** * `r` (`wx.Rect `_) * `radius` (double) -------- .. method:: DrawSpline(points) Draws a three-point spline using the current pen. **Parameters:** * `points` (list of `wx.Points `_) -------- .. method:: 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 `GetTextExtent <#GetTextExtent>`_ for how to get the dimensions of a text string, which can be used to position the text more precisely. **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. -------- .. method:: DrawTextList(textList, coords, foregrounds=None, backgrounds=None) Draw a list of strings using a list of coordinants for positioning each string. **Parameters:** * `textList` (list of strings): A list of strings * `coords` (list of tuples): A list of (x, y) positions * `foregrounds` (list of `wx.Colour `_): A list of `wx.Colour `_ objects to use for the foregrounds of the strings. * `backgrounds` (list of `wx.Colour `_): A list of `wx.Colour `_ objects to use for the backgrounds of the strings. .. note:: Make sure you set background mode to ``wx.SOLID`` (using `SetBackgroundMode <#SetBackgroundMode>`_) If you want backgrounds to do anything. -------- .. method:: 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 `GetTextExtent <#GetTextExtent>`_ for how to get the dimensions of a text string, which can be used to position the text more precisely. **Parameters:** * `text` (string) * `pt` (`wx.Point `_) .. 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. -------- .. method:: EndDoc() Ends a document (only relevant when outputting to a printer). -------- .. method:: EndDrawing() `No docstrings available for this method.` -------- .. method:: EndPage() Ends a document page (only relevant when outputting to a printer). -------- .. method:: 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``. -------- .. method:: 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:** * `pt` (`wx.Point `_) * `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``. -------- .. method:: GetAsBitmap(subrect=None) | **Parameters:** * `subrect` (`wx.Rect `_) | **Returns:** `wx.Bitmap `_ -------- .. method:: GetBackground() Gets the brush used for painting the background | **Returns:** `wx.Brush `_ .. seealso:: `SetBackground <#SetBackground>`_ -------- .. method:: GetBackgroundMode() Returns the current background mode: ``wx.SOLID`` or ``wx.TRANSPARENT``. | **Returns:** `int` .. seealso:: `SetBackgroundMode <#SetBackgroundMode>`_ -------- .. method:: GetBoundingBox() Returns the min and max points used in drawing commands so far. | **Returns:** `(x1, y1, x2, y2)` -------- .. method:: GetBrush() Gets the current brush. | **Returns:** `wx.Brush `_ .. seealso:: `SetBrush <#SetBrush>`_ -------- .. method:: GetCharHeight() Gets the character height of the currently set font. | **Returns:** `int` -------- .. method:: GetCharWidth() Gets the average character width of the currently set font. | **Returns:** `int` -------- .. method:: GetClippingBox() Gets the rectangle surrounding the current clipping region. | **Returns:** `(x1, y1, width, height)` -------- .. method:: GetClippingRect() Gets the rectangle surrounding the current clipping region. | **Returns:** `wx.Rect `_ -------- .. method:: GetDepth() Returns the colour depth of the DC. | **Returns:** `int` -------- .. method:: GetDeviceOrigin() `No docstrings available for this method.` -------- .. method:: GetDeviceOriginTuple() `No docstrings available for this method.` -------- .. method:: GetFont() Gets the current font. | **Returns:** `wx.Font `_ .. note:: Notice that even although each device context object has some default font after creation, this method would return a `wx.NullFont` initially and only after calling `SetFont <#SetFont>`_ a valid font is returned. -------- .. method:: GetFullTextExtent(string, font=None) Get the width, height, decent and leading of the text using the current or specified font. Only works for single line strings. **Parameters:** * `string` (wx.string) * `font` (`wx.Font `_) | **Returns:** `(width, height, descent, externalLeading)` -------- .. method:: GetHDC() `No docstrings available for this method.` -------- .. method:: GetLayoutDirection() Gets the current layout direction of the device context. On platforms where RTL layout is supported, the return value will either be ``wx.Layout_LeftToRight`` or ``wx.Layout_RightToLeft``. If RTL layout is not supported, the return value will be ``wx.Layout_Default``. | **Returns:** `int` .. seealso:: `SetLayoutDirection <#SetLayoutDirection>`_ -------- .. method:: GetLogicalFunction() Gets the current logical function. | **Returns:** `int` .. seealso:: `SetLogicalFunction <#SetLogicalFunction>`_ -------- .. method:: GetLogicalOrigin() `No docstrings available for this method.` -------- .. method:: GetLogicalOriginTuple() `No docstrings available for this method.` -------- .. method:: GetLogicalScale() `No docstrings available for this method.` -------- .. method:: GetMapMode() Gets the *mapping mode* for the device context. | **Returns:** `int` .. seealso:: `SetMapMode <#SetMapMode>`_ -------- .. method:: GetMultiLineTextExtent(string, font=None) Gets the dimensions of the string using the currently selected font. `string` is the text string to measure. If the optional parameter `font` is specified and valid, then it is used for the text extent calculation. Otherwise the currently selected font is. **Parameters:** * `string` (string) * `font` (`wx.Font `_) .. note:: Note that this function works both with single-line and multi-line strings. .. seealso:: `wx.Font `_, `SetFont <#SetFont>`_, `GetPartialTextExtents <#GetPartialTextExtents>`_, `GetTextExtent <#GetTextExtent>`_ -------- .. method:: GetPPI() Returns the resolution of the device in pixels per inch. | **Returns:** `wx.Size `_ -------- .. method:: GetPartialTextExtents(text) Returns a list of integers such that each value is the distance in pixels from the begining of text to the corresponding character of `text`. The generic version simply builds a running total of the widths of each character using `GetTextExtent <#GetTextExtent>`_, however if the various platforms have a native API function that is faster or more accurate than the generic implementation then it will be used instead. **Parameters:** * `text` (string) | **Returns:** `list of integers` .. seealso:: `GetMultiLineTextExtent <#GetMultiLineTextExtent>`_, `GetTextExtent <#GetTextExtent>`_ -------- .. method:: GetPen() Gets the current pen. | **Returns:** `wx.Pen `_ .. seealso:: `SetPen <#SetPen>`_ -------- .. method:: GetPixel(x, y) Gets the colour at the specified location on the DC. **Parameters:** * `x` (int) * `y` (int) | **Returns:** `wx.Colour `_ .. note:: Note that setting a pixel can be done using `DrawPoint <#DrawPoint>`_ -------- .. method:: GetPixelPoint(pt) Gets the colour at the specified location on the DC. **Parameters:** * `pt` (`wx.Point `_) | **Returns:** `wx.Colour `_ -------- .. method:: GetSize() This gets the horizontal and vertical resolution in device units. It can be used to scale graphics to fit the page. For example, if `maxX` and `maxY` represent the maximum horizontal and vertical 'pixel' values used in your application, the following code will scale the graphic to fit on the printer page:: w, h = dc.GetSize() scaleX = maxX*1.0/w scaleY = maxY*1.0/h dc.SetUserScale(min(scaleX, scaleY), min(scaleX, scaleY)) | **Returns:** `wx.Size `_ -------- .. method:: GetSizeMM() Returns the horizontal and vertical resolution in millimetres. | **Returns:** `wx.Size `_ -------- .. method:: GetSizeMMTuple() Get the DC size in millimeters as a tuple. | **Returns:** `(width, height)` -------- .. method:: GetSizeTuple() This gets the horizontal and vertical resolution in device units. It can be used to scale graphics to fit the page. For example, if `maxX` and `maxY` represent the maximum horizontal and vertical 'pixel' values used in your application, the following code will scale the graphic to fit on the printer page:: w, h = dc.GetSize() scaleX = maxX*1.0/w scaleY = maxY*1.0/h dc.SetUserScale(min(scaleX, scaleY), min(scaleX, scaleY)) | **Returns:** `(width, height)` -------- .. method:: GetTextBackground() Gets the current text background colour. | **Returns:** `wx.Colour `_ .. seealso:: `SetTextBackground <#SetTextBackground>`_ -------- .. method:: GetTextExtent(string) Gets the dimensions of the string using the currently selected font. `string` is the text string to measure. **Parameters:** * `string` (string) | **Returns:** `(width, height)` .. note:: Note that this function only works with single-line strings. .. seealso:: `wx.Font `_, `SetFont <#SetFont>`_, `GetPartialTextExtents <#GetPartialTextExtents>`_, `GetMultiLineTextExtent <#GetMultiLineTextExtent>`_ -------- .. method:: GetTextForeground() Gets the current text foreground colour. | **Returns:** `wx.Colour `_ .. seealso:: `SetTextForeground <#SetTextForeground>`_ -------- .. method:: GetUserScale() Gets the current user scale factor (set by `SetUserScale <#SetUserScale>`_). | **Returns:** `(xScale, yScale)` -------- .. method:: GradientFillConcentric(rect, initialColour, destColour, circleCenter) Fill the area specified by rect with a radial gradient, starting from `initialColour` at the centre of the circle and fading to `destColour` on the circle outside. `circleCenter` are the relative coordinates of centre of the circle in the specified `rect`. If not specified, the cercle is placed at the centre of rect. **Parameters:** * `rect` (`wx.Rect `_) * `initialColour` (`wx.Colour `_) * `destColour` (`wx.Colour `_) * `circleCenter` (`wx.Point `_) .. warning:: Currently this function is very slow, don't use it for real-time drawing. -------- .. method:: GradientFillLinear(rect, initialColour, destColour, nDirection=wx.EAST) Fill the area specified by `rect` with a linear gradient, starting from `initialColour` and eventually fading to `destColour`. The `nDirection` specifies the direction of the colour change, default is to use `initialColour` on the left part of the rectangle and `destColour` on the right one. **Parameters:** * `rect` (`wx.Rect `_) * `initialColour` (`wx.Colour `_) * `destColour` (`wx.Colour `_) * `nDirection` (int) -------- .. method:: IsOk() Returns ``True`` if the DC is ok to use. | **Returns:** `bool` -------- .. method:: LogicalToDeviceX(x) Converts logical `X` coordinate to device coordinate, using the current mapping mode. **Parameters:** * `x` (int) | **Returns:** `int` -------- .. method:: LogicalToDeviceXRel(x) Converts logical `X` coordinate to relative device coordinate, using the current mapping mode but ignoring the x axis orientation. Use this for converting a width, for example. **Parameters:** * `x` (int) | **Returns:** `int` -------- .. method:: LogicalToDeviceY(y) Converts logical `Y` coordinate to device coordinate, using the current mapping mode. **Parameters:** * `y` (int) | **Returns:** `int` -------- .. method:: LogicalToDeviceYRel(y) Converts logical `Y` coordinate to relative device coordinate, using the current mapping mode but ignoring the y axis orientation. Use this for converting a height, for example. **Parameters:** * `y` (int) | **Returns:** `int` -------- .. method:: MaxX() Gets the maximum horizontal extent used in drawing commands so far. | **Returns:** `int` -------- .. method:: MaxY() Gets the maximum vertical extent used in drawing commands so far. | **Returns:** `int` -------- .. method:: MinX() Gets the minimum horizontal extent used in drawing commands so far. | **Returns:** `int` -------- .. method:: MinY() Gets the minimum vertical extent used in drawing commands so far. | **Returns:** `int` -------- .. method:: ResetBoundingBox() Resets the bounding box: after a call to this function, the bounding box doesn't contain anything. .. seealso:: `CalcBoundingBox <#CalcBoundingBox>`_ -------- .. method:: SetAxisOrientation(xLeftRight, yBottomUp) Sets the x and y axis orientation (i.e., the direction from lowest to highest values on the axis). The default orientation is x axis from left to right and y axis from top down. **Parameters:** * `xLeftRight` (bool): ``True`` to set the x axis orientation to the natural left to right orientation, ``False`` to invert it. * `yBottomUp` (bool): ``True`` to set the y axis orientation to the natural bottom up orientation, ``False`` to invert it. -------- .. method:: SetBackground(brush) Sets the current background brush for the DC. **Parameters:** * `brush` (`wx.Brush `_) -------- .. method:: 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) -------- .. method:: 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:** * `brush` (`wx.Brush `_) .. seealso:: `wx.Brush `_, `wx.MemoryDC `_ -------- .. method:: SetClippingRect(rect) Sets the clipping region for this device context to the intersection of the given region described by the parameters of this method and the previously set clipping region. You should call `DestroyClippingRegion <#DestroyClippingRegion>`_ if you want to set the clipping region exactly to the region specified. The clipping region is an area to which drawing is restricted. Possible uses for the clipping region are for clipping text or for speeding up window redraws when only a known area of the screen is damaged. **Parameters:** * `rect` (`wx.Rect `_) -------- .. method:: SetClippingRegion(x, y, width, height) Sets the clipping region for this device context to the intersection of the given region described by the parameters of this method and the previously set clipping region. You should call `DestroyClippingRegion <#DestroyClippingRegion>`_ if you want to set the clipping region exactly to the region specified. The clipping region is an area to which drawing is restricted. Possible uses for the clipping region are for clipping text or for speeding up window redraws when only a known area of the screen is damaged. **Parameters:** * `x` (int) * `y` (int) * `width` (int) * `height` (int) .. seealso:: `DestroyClippingRegion <#DestroyClippingRegion>`_, `wx.Region `_ -------- .. method:: SetClippingRegionAsRegion(region) Sets the clipping region for this device context to the intersection of the given region described by the parameters of this method and the previously set clipping region. You should call `DestroyClippingRegion <#DestroyClippingRegion>`_ if you want to set the clipping region exactly to the region specified. The clipping region is an area to which drawing is restricted. Possible uses for the clipping region are for clipping text or for speeding up window redraws when only a known area of the screen is damaged. **Parameters:** * `region` (`wx.Region `_) -------- .. method:: SetClippingRegionPointSize(pt, sz) Sets the clipping region for this device context to the intersection of the given region described by the parameters of this method and the previously set clipping region. You should call `DestroyClippingRegion <#DestroyClippingRegion>`_ if you want to set the clipping region exactly to the region specified. The clipping region is an area to which drawing is restricted. Possible uses for the clipping region are for clipping text or for speeding up window redraws when only a known area of the screen is damaged. **Parameters:** * `pt` (`wx.Point `_) * `sz` (`wx.Size `_) -------- .. method:: SetDeviceOrigin(x, y) Sets the device origin (i.e., the origin in pixels after scaling has been applied). This function may be useful in Windows printing operations for placing a graphic on a page. **Parameters:** * `x` (int) * `y` (int) -------- .. method:: SetDeviceOriginPoint(point) Sets the device origin (i.e., the origin in pixels after scaling has been applied). This function may be useful in Windows printing operations for placing a graphic on a page. **Parameters:** * `point` (`wx.Point `_) -------- .. method:: 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:** * `font` (`wx.Font `_) .. seealso:: `wx.Font `_ -------- .. method:: SetLayoutDirection(dir) Sets the current layout direction for the device context. `dir` may be either ``wx.Layout_Default``, ``wx.Layout_LeftToRight`` or ``wx.Layout_RightToLeft``. **Parameters:** * `dir` (int) .. seealso:: `GetLayoutDirection <#GetLayoutDirection>`_ -------- .. method:: SetLogicalFunction(function) Sets the current logical function for the device context. This determines how a source pixel (from a pen or brush colour, or source device context if using `Blit <#Blit>`_) 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) -------- .. method:: SetLogicalOrigin(x, y) | **Parameters:** * `x` (int) * `y` (int) -------- .. method:: SetLogicalOriginPoint(point) | **Parameters:** * `point` (`wx.Point `_) -------- .. method:: SetLogicalScale(x, y) | **Parameters:** * `x` (double) * `y` (double) -------- .. method:: SetMapMode(int) The *mapping mode* of the device context defines the unit of measurement used to convert logical units to device units. Note that in X, text drawing isn't handled consistently with the mapping mode; a font is always specified in point size. However, setting the *user scale* (see `SetUserScale <#SetUserScale>`_) scales the text appropriately. In Windows, scalable TrueType fonts are always used; in X, results depend on availability of fonts, but usually a reasonable match is found. The coordinate origin is always at the top left of the screen/printer. Drawing to a Windows printer device context uses the current mapping mode, but mapping mode is currently ignored for PostScript output. The mapping mode can be one of the following: ====================== ============================================= Mapping Mode Description ====================== ============================================= ``wx.MM_TWIPS`` Each logical unit is 1/20 of a point, or 1/1440 of an inch. ``wx.MM_POINTS`` Each logical unit is a point, or 1/72 of an inch. ``wx.MM_METRIC`` Each logical unit is 1 mm. ``wx.MM_LOMETRIC`` Each logical unit is 1/10 of a mm. ``wx.MM_TEXT`` Each logical unit is 1 pixel. ====================== ============================================= | **Parameters:** * `int` (int) -------- .. method:: 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:** * `palette` (`wx.Palette `_) .. seealso:: `wx.Palette `_ -------- .. method:: 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:** * `pen` (`wx.Pen `_) .. seealso:: `wx.MemoryDC `_ -------- .. method:: SetTextBackground(colour) Sets the current text background colour for the DC. **Parameters:** * `colour` (`wx.Colour `_) -------- .. method:: SetTextForeground(colour) Sets the current text foreground colour for the DC. **Parameters:** * `colour` (`wx.Colour `_) .. seealso:: `wx.MemoryDC `_ -------- .. method:: SetUserScale(xScale, yScale) Sets the user scaling factor, useful for applications which require 'zooming'. **Parameters:** * `xScale` (double) * `yScale` (double) -------- .. method:: StartDoc(message) Starts a document (only relevant when outputting to a printer). Message is a message to show while printing. **Parameters:** * `message` (string) | **Returns:** `bool` -------- .. method:: StartPage() Starts a document page (only relevant when outputting to a printer). | **Returns:** `bool` -------- Properties ^^^^^^^^^^ .. attribute:: Background See `GetBackground <#GetBackground>`_ and `SetBackground <#SetBackground>`_ .. attribute:: BackgroundMode See `GetBackgroundMode <#GetBackgroundMode>`_ and `SetBackgroundMode <#SetBackgroundMode>`_ .. attribute:: BoundingBox See `GetBoundingBox <#GetBoundingBox>`_ .. attribute:: Brush See `GetBrush <#GetBrush>`_ and `SetBrush <#SetBrush>`_ .. attribute:: CharHeight See `GetCharHeight <#GetCharHeight>`_ .. attribute:: CharWidth See `GetCharWidth <#GetCharWidth>`_ .. attribute:: ClippingBox See `GetClippingBox <#GetClippingBox>`_ .. attribute:: ClippingRect See `GetClippingRect <#GetClippingRect>`_ and `SetClippingRect <#SetClippingRect>`_ .. attribute:: Depth See `GetDepth <#GetDepth>`_ .. attribute:: DeviceOrigin See `GetDeviceOrigin <#GetDeviceOrigin>`_ and `SetDeviceOrigin <#SetDeviceOrigin>`_ .. attribute:: Font See `GetFont <#GetFont>`_ and `SetFont <#SetFont>`_ .. attribute:: FullTextExtent See `GetFullTextExtent <#GetFullTextExtent>`_ .. attribute:: LayoutDirection Get the layout direction (LTR or RTL)_ for this dc. On platforms where RTL layout is supported, the return value will either be ``wx.Layout_LeftToRight`` or ``wx.Layout_RightToLeft``. ``wx.Layout_Default`` is returned if layout direction is not supported. .. attribute:: LogicalFunction See `GetLogicalFunction <#GetLogicalFunction>`_ and `SetLogicalFunction <#SetLogicalFunction>`_ .. attribute:: LogicalOrigin See `GetLogicalOrigin <#GetLogicalOrigin>`_ and `SetLogicalOrigin <#SetLogicalOrigin>`_ .. attribute:: LogicalScale See `GetLogicalScale <#GetLogicalScale>`_ and `SetLogicalScale <#SetLogicalScale>`_ .. attribute:: MapMode See `GetMapMode <#GetMapMode>`_ and `SetMapMode <#SetMapMode>`_ .. attribute:: MultiLineTextExtent See `GetMultiLineTextExtent <#GetMultiLineTextExtent>`_ .. attribute:: Optimization See `GetOptimization` and `SetOptimization` .. attribute:: PPI See `GetPPI <#GetPPI>`_ .. attribute:: PartialTextExtents See `GetPartialTextExtents <#GetPartialTextExtents>`_ .. attribute:: Pen See `GetPen <#GetPen>`_ and `SetPen <#SetPen>`_ .. attribute:: Pixel See `GetPixel <#GetPixel>`_ .. attribute:: PixelPoint See `GetPixelPoint <#GetPixelPoint>`_ .. attribute:: Size See `GetSize <#GetSize>`_ .. attribute:: SizeMM See `GetSizeMM <#GetSizeMM>`_ .. attribute:: TextBackground See `GetTextBackground <#GetTextBackground>`_ and `SetTextBackground <#SetTextBackground>`_ .. attribute:: TextExtent See `GetTextExtent <#GetTextExtent>`_ .. attribute:: TextForeground See `GetTextForeground <#GetTextForeground>`_ and `SetTextForeground <#SetTextForeground>`_ .. attribute:: UserScale See `GetUserScale <#GetUserScale>`_ and `SetUserScale <#SetUserScale>`_