Search documentation of wx

# View Source wxDC (wx v2.4.3.1)

A `wxDC` is a `"device context"` onto which graphics and text can be drawn.

It is intended to represent different output devices and offers a common abstract API for drawing on any of them.

wxWidgets offers an alternative drawing API based on the modern drawing backends GDI+, CoreGraphics, Cairo and Direct2D. See `wxGraphicsContext`, `wxGraphicsRenderer` and related classes. There is also a `wxGCDC` linking the APIs by offering the `wxDC` API on top of a `wxGraphicsContext`.

`wxDC` is an abstract base class and cannot be created directly. Use `wxPaintDC`, `wxClientDC`, `wxWindowDC`, `wxScreenDC`, `wxMemoryDC` or `wxPrinterDC` (not implemented in wx). Notice that device contexts which are associated with windows (i.e. `wxClientDC`, `wxWindowDC` and `wxPaintDC`) use the window font and colours by default (starting with wxWidgets 2.9.0) but the other device context classes use system-default values so you always must set the appropriate fonts and colours before using them.

In addition to the versions of the methods documented below, there are also versions which accept single {X,Y} parameter instead of the two wxCoord ones or {X,Y} and {Width,Height} instead of the four wxCoord parameters.

Beginning with wxWidgets 2.9.0 the entire `wxDC` code has been reorganized. All platform dependent code (actually all drawing code) has been moved into backend classes which derive from a common wxDCImpl class. The user-visible classes such as `wxClientDC` and `wxPaintDC` merely forward all calls to the backend implementation.

Device and logical units

In the `wxDC` context there is a distinction between `logical` units and `device` units.

`Device` units are the units native to the particular device; e.g. for a screen, a device unit is a `pixel`. For a printer, the device unit is defined by the resolution of the printer (usually given in `DPI:` dot-per-inch).

All `wxDC` functions use instead `logical` units, unless where explicitly stated. Logical units are arbitrary units mapped to device units using the current mapping mode (see `setMapMode/2`).

This mechanism allows reusing the same code which prints on e.g. a window on the screen to print on e.g. a paper.

Support for Transparency / Alpha Channel

In general `wxDC` methods don't support alpha transparency and the alpha component of `wx_color()` is simply ignored and you need to use `wxGraphicsContext` for full transparency support. There are, however, a few exceptions: first, under macOS and GTK+ 3 colours with alpha channel are supported in all the normal wxDC-derived classes as they use `wxGraphicsContext` internally. Second, under all platforms `wxSVGFileDC` (not implemented in wx) also fully supports alpha channel. In both of these cases the instances of `wxPen` or `wxBrush` that are built from `wx_color()` use the colour's alpha values when stroking or filling.

Support for Transformation Matrix

On some platforms (currently under MSW, GTK+ 3, macOS) `wxDC` has support for applying an arbitrary affine transformation matrix to its coordinate system (since 3.1.1 this feature is also supported by `wxGCDC` in all ports). Call `CanUseTransformMatrix()` (not implemented in wx) to check if this support is available and then call `SetTransformMatrix()` (not implemented in wx) if it is. If the transformation matrix is not supported, `SetTransformMatrix()` (not implemented in wx) always simply returns `false` and doesn't do anything.

This feature is only available when `wxUSE_DC_TRANSFORM_MATRIX` build option is enabled.

See:

- Overview dc

- `wxGraphicsContext`

wxWidgets docs: wxDC

# Summary

## Types

wxDC()

## Functions

blit(This, Dest, Size, Source, Src)

Equivalent to `blit(This, Dest, Size, Source, Src, [])`.

blit/6

Copy from a source DC to this DC.

calcBoundingBox(This, X, Y)

Adds the specified point to the bounding box which can be retrieved with `minX/1`, `maxX/1` and `minY/1`, `maxY/1` functions.

clear(This)

Clears the device context using the current background brush.

crossHair(This, Pt)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

destroyClippingRegion(This)

Destroys the current clipping region so that none of the DC is clipped.

deviceToLogicalX(This, X)

Convert `device` X coordinate to logical coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.

deviceToLogicalXRel(This, X)

Convert `device` X coordinate to relative logical coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.

deviceToLogicalY(This, Y)

Converts `device` Y coordinate to logical coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.

deviceToLogicalYRel(This, Y)

Convert `device` Y coordinate to relative logical coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.

drawArc(This, PtStart, PtEnd, Centre)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawBitmap(This, Bmp, Pt)

Equivalent to `drawBitmap(This, Bmp, Pt, [])`.

drawBitmap/4

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawCheckMark(This, Rect)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawCircle(This, Pt, Radius)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawEllipse(This, Rect)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawEllipse(This, Pt, Size)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawEllipticArc(This, Pt, Sz, Sa, Ea)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawIcon(This, Icon, Pt)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawLabel(This, Text, Rect)

Equivalent to `drawLabel(This, Text, Rect, [])`.

drawLabel/4

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawLine(This, Pt1, Pt2)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawLines(This, Points)

Equivalent to `drawLines(This, Points, [])`.

drawLines/3

Draws lines using an array of points of size `n` adding the optional offset coordinate.

drawPoint(This, Pt)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawPolygon(This, Points)

Equivalent to `drawPolygon(This, Points, [])`.

drawPolygon/3

Draws a filled polygon using an array of points of size `n`, adding the optional offset coordinate.

drawRectangle(This, Rect)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawRectangle(This, Pt, Sz)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawRotatedText(This, Text, Point, Angle)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawRoundedRectangle(This, Rect, Radius)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawRoundedRectangle(This, Pt, Sz, Radius)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

drawText(This, Text, Pt)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

endDoc(This)

Ends a document (only relevant when outputting to a printer).

endPage(This)

Ends a document page (only relevant when outputting to a printer).

floodFill(This, Pt, Col)

Equivalent to `floodFill(This, Pt, Col, [])`.

floodFill/4

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

getBackground(This)

Gets the brush used for painting the background.

getBackgroundMode(This)

Returns the current background mode: `wxPENSTYLE\_SOLID` or `wxPENSTYLE\_TRANSPARENT`.

getBrush(This)

Gets the current brush.

getCharHeight(This)

Gets the character height of the currently set font.

getCharWidth(This)

Gets the average character width of the currently set font.

getClippingBox(This)

`Gets the rectangle surrounding the current clipping region. If no clipping region is set this function returns the extent of the device context. @remarks Clipping region is given in logical coordinates. @param x If non-<span class='literal'>NULL</span>, filled in with the logical horizontal coordinate of the top left corner of the clipping region if the function returns true or 0 otherwise. @param y If non-<span class='literal'>NULL</span>, filled in with the logical vertical coordinate of the top left corner of the clipping region if the function returns true or 0 otherwise. @param width If non-<span class='literal'>NULL</span>, filled in with the width of the clipping region if the function returns true or the device context width otherwise. @param height If non-<span class='literal'>NULL</span>, filled in with the height of the clipping region if the function returns true or the device context height otherwise.`

getFont(This)

Gets the current font.

getLayoutDirection(This)

Gets the current layout direction of the device context.

getLogicalFunction(This)

Gets the current logical function.

getMapMode(This)

Gets the current mapping mode for the device context.

getMultiLineTextExtent(This, String)

Gets the dimensions of the string using the currently selected font.

getMultiLineTextExtent/3

Gets the dimensions of the string using the currently selected font.

getPartialTextExtents(This, Text)

Fills the `widths` array with the widths from the beginning of `text` to the corresponding character of `text`.

getPen(This)

Gets the current pen.

getPixel(This, Pos)

Gets in `colour` the colour at the specified location.

getPPI(This)

Returns the resolution of the device in pixels per inch.

getSize(This)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

getSizeMM(This)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

getTextBackground(This)

Gets the current text background colour.

getTextExtent(This, String)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

getTextExtent/3

Gets the dimensions of the string using the currently selected font.

getTextForeground(This)

Gets the current text foreground colour.

getUserScale(This)

Gets the current user scale factor.

gradientFillConcentric(This, Rect, InitialColour, DestColour)

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.

gradientFillConcentric(This, 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.

gradientFillLinear(This, Rect, InitialColour, DestColour)

Equivalent to `gradientFillLinear(This, Rect, InitialColour, DestColour, [])`.

gradientFillLinear/5

Fill the area specified by `rect` with a linear gradient, starting from `initialColour` and eventually fading to `destColour`.

isOk(This)

Returns true if the DC is ok to use.

logicalToDeviceX(This, X)

Converts logical X coordinate to device coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.

logicalToDeviceXRel(This, X)

Converts logical X coordinate to relative device coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.

logicalToDeviceY(This, Y)

Converts logical Y coordinate to device coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.

logicalToDeviceYRel(This, Y)

Converts logical Y coordinate to relative device coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.

maxX(This)

Gets the maximum horizontal extent used in drawing commands so far.

maxY(This)

Gets the maximum vertical extent used in drawing commands so far.

minX(This)

Gets the minimum horizontal extent used in drawing commands so far.

minY(This)

Gets the minimum vertical extent used in drawing commands so far.

resetBoundingBox(This)

Resets the bounding box: after a call to this function, the bounding box doesn't contain anything.

setAxisOrientation(This, XLeftRight, YBottomUp)

Sets the x and y axis orientation (i.e. the direction from lowest to highest values on the axis).

setBackground(This, Brush)

Sets the current background brush for the DC.

setBackgroundMode(This, Mode)

`mode` may be one of `wxPENSTYLE\_SOLID` and `wxPENSTYLE\_TRANSPARENT`.

setBrush(This, Brush)

Sets the current brush for the DC.

setClippingRegion(This, Rect)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

setClippingRegion(This, Pt, Sz)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

setDeviceOrigin(This, X, Y)

Sets the device origin (i.e. the origin in pixels after scaling has been applied).

setFont(This, Font)

Sets the current font for the DC.

setLayoutDirection(This, Dir)

Sets the current layout direction for the device context.

setLogicalFunction(This, Function)

Sets the current logical function for the device context.

setMapMode(This, Mode)

The mapping mode of the device context defines the unit of measurement used to convert `logical` units to `device` units.

setPalette(This, Palette)

If this is a window DC or memory DC, assigns the given palette to the window or bitmap associated with the DC.

setPen(This, Pen)

Sets the current pen for the DC.

setTextBackground(This, Colour)

Sets the current text background colour for the DC.

setTextForeground(This, Colour)

Sets the current text foreground colour for the DC.

setUserScale(This, XScale, YScale)

Sets the user scaling factor, useful for applications which require 'zooming'.

startDoc(This, Message)

Starts a document (only relevant when outputting to a printer).

startPage(This)

Starts a document page (only relevant when outputting to a printer).

# Types

# wxDC()

    -type wxDC() :: wx:wx_object().

# Functions

# blit(This, Dest, Size, Source, Src)

    -spec blit(This, Dest, Size, Source, Src) -> boolean()
                  when
                      This :: wxDC(),
                      Dest :: {X :: integer(), Y :: integer()},
                      Size :: {W :: integer(), H :: integer()},
                      Source :: wxDC(),
                      Src :: {X :: integer(), Y :: integer()}.

Equivalent to `blit(This, Dest, Size, Source, Src, [])`.

# blit/6

    -spec blit(This, Dest, Size, Source, Src, [Option]) -> boolean()
                  when
                      This :: wxDC(),
                      Dest :: {X :: integer(), Y :: integer()},
                      Size :: {W :: integer(), H :: integer()},
                      Source :: wxDC(),
                      Src :: {X :: integer(), Y :: integer()},
                      Option ::
                          {rop, wx:wx_enum()} |
                          {useMask, boolean()} |
                          {srcPtMask, {X :: integer(), Y :: integer()}}.

Copy from a source DC to this DC.

With this method you can specify the destination coordinates and the size of area to copy which will be the same for both the source and target DCs. If you need to apply scaling while copying, use `StretchBlit()` (not implemented in wx).

Notice that source DC coordinates `xsrc` and `ysrc` are interpreted using the current source DC coordinate system, i.e. the scale, origin position and axis directions are taken into account when transforming them to physical (pixel) coordinates.

Remark: There is partial support for `blit/6` in `wxPostScriptDC`, under X.

See:

- `wxMemoryDC`

- `wxBitmap`

- `wxMask`

# calcBoundingBox(This, X, Y)

    -spec calcBoundingBox(This, X, Y) -> ok when This :: wxDC(), X :: integer(), Y :: integer().

Adds the specified point to the bounding box which can be retrieved with `minX/1`, `maxX/1` and `minY/1`, `maxY/1` functions.

See: `resetBoundingBox/1`

# clear(This)

    -spec clear(This) -> ok when This :: wxDC().

Clears the device context using the current background brush.

Note that `setBackground/2` method must be used to set the brush used by `clear/1`, the brush used for filling the shapes set by `setBrush/2` is ignored by it.

If no background brush was set, solid white brush is used to clear the device context.

# crossHair(This, Pt)

    -spec crossHair(This, Pt) -> ok when This :: wxDC(), Pt :: {X :: integer(), Y :: integer()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# destroyClippingRegion(This)

    -spec destroyClippingRegion(This) -> ok when This :: wxDC().

Destroys the current clipping region so that none of the DC is clipped.

See: `setClippingRegion/3`

# deviceToLogicalX(This, X)

    -spec deviceToLogicalX(This, X) -> integer() when This :: wxDC(), X :: integer().

Convert `device` X coordinate to logical coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.

# deviceToLogicalXRel(This, X)

    -spec deviceToLogicalXRel(This, X) -> integer() when This :: wxDC(), X :: integer().

Convert `device` X coordinate to relative logical coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.

Use this for converting a width, for example.

# deviceToLogicalY(This, Y)

    -spec deviceToLogicalY(This, Y) -> integer() when This :: wxDC(), Y :: integer().

Converts `device` Y coordinate to logical coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.

# deviceToLogicalYRel(This, Y)

    -spec deviceToLogicalYRel(This, Y) -> integer() when This :: wxDC(), Y :: integer().

Convert `device` Y coordinate to relative logical coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.

Use this for converting a height, for example.

# drawArc(This, PtStart, PtEnd, Centre)

    -spec drawArc(This, PtStart, PtEnd, Centre) -> ok
                     when
                         This :: wxDC(),
                         PtStart :: {X :: integer(), Y :: integer()},
                         PtEnd :: {X :: integer(), Y :: integer()},
                         Centre :: {X :: integer(), Y :: integer()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawBitmap(This, Bmp, Pt)

    -spec drawBitmap(This, Bmp, Pt) -> ok
                        when
                            This :: wxDC(),
                            Bmp :: wxBitmap:wxBitmap(),
                            Pt :: {X :: integer(), Y :: integer()}.

Equivalent to `drawBitmap(This, Bmp, Pt, [])`.

# drawBitmap/4

    -spec drawBitmap(This, Bmp, Pt, [Option]) -> ok
                        when
                            This :: wxDC(),
                            Bmp :: wxBitmap:wxBitmap(),
                            Pt :: {X :: integer(), Y :: integer()},
                            Option :: {useMask, boolean()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawCheckMark(This, Rect)

    -spec drawCheckMark(This, Rect) -> ok
                           when
                               This :: wxDC(),
                               Rect :: {X :: integer(), Y :: integer(), W :: integer(), H :: integer()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawCircle(This, Pt, Radius)

    -spec drawCircle(This, Pt, Radius) -> ok
                        when This :: wxDC(), Pt :: {X :: integer(), Y :: integer()}, Radius :: integer().

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawEllipse(This, Rect)

    -spec drawEllipse(This, Rect) -> ok
                         when
                             This :: wxDC(),
                             Rect :: {X :: integer(), Y :: integer(), W :: integer(), H :: integer()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawEllipse(This, Pt, Size)

    -spec drawEllipse(This, Pt, Size) -> ok
                         when
                             This :: wxDC(),
                             Pt :: {X :: integer(), Y :: integer()},
                             Size :: {W :: integer(), H :: integer()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawEllipticArc(This, Pt, Sz, Sa, Ea)

    -spec drawEllipticArc(This, Pt, Sz, Sa, Ea) -> ok
                             when
                                 This :: wxDC(),
                                 Pt :: {X :: integer(), Y :: integer()},
                                 Sz :: {W :: integer(), H :: integer()},
                                 Sa :: number(),
                                 Ea :: number().

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawIcon(This, Icon, Pt)

    -spec drawIcon(This, Icon, Pt) -> ok
                      when This :: wxDC(), Icon :: wxIcon:wxIcon(), Pt :: {X :: integer(), Y :: integer()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawLabel(This, Text, Rect)

    -spec drawLabel(This, Text, Rect) -> ok
                       when
                           This :: wxDC(),
                           Text :: unicode:chardata(),
                           Rect :: {X :: integer(), Y :: integer(), W :: integer(), H :: integer()}.

Equivalent to `drawLabel(This, Text, Rect, [])`.

# drawLabel/4

    -spec drawLabel(This, Text, Rect, [Option]) -> ok
                       when
                           This :: wxDC(),
                           Text :: unicode:chardata(),
                           Rect :: {X :: integer(), Y :: integer(), W :: integer(), H :: integer()},
                           Option :: {alignment, integer()} | {indexAccel, integer()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawLine(This, Pt1, Pt2)

    -spec drawLine(This, Pt1, Pt2) -> ok
                      when
                          This :: wxDC(),
                          Pt1 :: {X :: integer(), Y :: integer()},
                          Pt2 :: {X :: integer(), Y :: integer()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawLines(This, Points)

    -spec drawLines(This, Points) -> ok when This :: wxDC(), Points :: [{X :: integer(), Y :: integer()}].

Equivalent to `drawLines(This, Points, [])`.

# drawLines/3

    -spec drawLines(This, Points, [Option]) -> ok
                       when
                           This :: wxDC(),
                           Points :: [{X :: integer(), Y :: integer()}],
                           Option :: {xoffset, integer()} | {yoffset, integer()}.

Draws lines using an array of points of size `n` adding the optional offset coordinate.

The current pen is used for drawing the lines.

# drawPoint(This, Pt)

    -spec drawPoint(This, Pt) -> ok when This :: wxDC(), Pt :: {X :: integer(), Y :: integer()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawPolygon(This, Points)

    -spec drawPolygon(This, Points) -> ok when This :: wxDC(), Points :: [{X :: integer(), Y :: integer()}].

Equivalent to `drawPolygon(This, Points, [])`.

# drawPolygon/3

    -spec drawPolygon(This, Points, [Option]) -> ok
                         when
                             This :: wxDC(),
                             Points :: [{X :: integer(), Y :: integer()}],
                             Option ::
                                 {xoffset, integer()} | {yoffset, integer()} | {fillStyle, wx:wx_enum()}.

Draws a filled polygon using an array of points of size `n`, adding the optional offset coordinate.

The first and last points are automatically closed.

The last argument specifies the fill rule: `wxODDEVEN_RULE` (the default) or `wxWINDING_RULE`.

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

# drawRectangle(This, Rect)

    -spec drawRectangle(This, Rect) -> ok
                           when
                               This :: wxDC(),
                               Rect :: {X :: integer(), Y :: integer(), W :: integer(), H :: integer()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawRectangle(This, Pt, Sz)

    -spec drawRectangle(This, Pt, Sz) -> ok
                           when
                               This :: wxDC(),
                               Pt :: {X :: integer(), Y :: integer()},
                               Sz :: {W :: integer(), H :: integer()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawRotatedText(This, Text, Point, Angle)

    -spec drawRotatedText(This, Text, Point, Angle) -> ok
                             when
                                 This :: wxDC(),
                                 Text :: unicode:chardata(),
                                 Point :: {X :: integer(), Y :: integer()},
                                 Angle :: number().

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawRoundedRectangle(This, Rect, Radius)

    -spec drawRoundedRectangle(This, Rect, Radius) -> ok
                                  when
                                      This :: wxDC(),
                                      Rect ::
                                          {X :: integer(), Y :: integer(), W :: integer(), H :: integer()},
                                      Radius :: number().

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawRoundedRectangle(This, Pt, Sz, Radius)

    -spec drawRoundedRectangle(This, Pt, Sz, Radius) -> ok
                                  when
                                      This :: wxDC(),
                                      Pt :: {X :: integer(), Y :: integer()},
                                      Sz :: {W :: integer(), H :: integer()},
                                      Radius :: number().

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# drawText(This, Text, Pt)

    -spec drawText(This, Text, Pt) -> ok
                      when
                          This :: wxDC(), Text :: unicode:chardata(), Pt :: {X :: integer(), Y :: integer()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# endDoc(This)

    -spec endDoc(This) -> ok when This :: wxDC().

Ends a document (only relevant when outputting to a printer).

# endPage(This)

    -spec endPage(This) -> ok when This :: wxDC().

Ends a document page (only relevant when outputting to a printer).

# floodFill(This, Pt, Col)

    -spec floodFill(This, Pt, Col) -> boolean()
                       when This :: wxDC(), Pt :: {X :: integer(), Y :: integer()}, Col :: wx:wx_colour().

Equivalent to `floodFill(This, Pt, Col, [])`.

# floodFill/4

    -spec floodFill(This, Pt, Col, [Option]) -> boolean()
                       when
                           This :: wxDC(),
                           Pt :: {X :: integer(), Y :: integer()},
                           Col :: wx:wx_colour(),
                           Option :: {style, wx:wx_enum()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# getBackground(This)

    -spec getBackground(This) -> wxBrush:wxBrush() when This :: wxDC().

Gets the brush used for painting the background.

See: `setBackground/2`

# getBackgroundMode(This)

    -spec getBackgroundMode(This) -> integer() when This :: wxDC().

Returns the current background mode: `wxPENSTYLE\_SOLID` or `wxPENSTYLE\_TRANSPARENT`.

See: `setBackgroundMode/2`

# getBrush(This)

    -spec getBrush(This) -> wxBrush:wxBrush() when This :: wxDC().

Gets the current brush.

See: `setBrush/2`

# getCharHeight(This)

    -spec getCharHeight(This) -> integer() when This :: wxDC().

Gets the character height of the currently set font.

# getCharWidth(This)

    -spec getCharWidth(This) -> integer() when This :: wxDC().

Gets the average character width of the currently set font.

# getClippingBox(This)

    -spec getClippingBox(This) -> Result
                            when
                                Result ::
                                    {X :: integer(),
                                     Y :: integer(),
                                     Width :: integer(),
                                     Height :: integer()},
                                This :: wxDC().

`Gets the rectangle surrounding the current clipping region. If no clipping region is set this function returns the extent of the device context. @remarks Clipping region is given in logical coordinates. @param x If non-<span class='literal'>NULL</span>, filled in with the logical horizontal coordinate of the top left corner of the clipping region if the function returns true or 0 otherwise. @param y If non-<span class='literal'>NULL</span>, filled in with the logical vertical coordinate of the top left corner of the clipping region if the function returns true or 0 otherwise. @param width If non-<span class='literal'>NULL</span>, filled in with the width of the clipping region if the function returns true or the device context width otherwise. @param height If non-<span class='literal'>NULL</span>, filled in with the height of the clipping region if the function returns true or the device context height otherwise.`

Return: true if there is a clipping region or false if there is no active clipping region (note that this return value is available only since wxWidgets 3.1.2, this function didn't return anything in the previous versions).

# getFont(This)

    -spec getFont(This) -> wxFont:wxFont() when This :: wxDC().

Gets the current font.

Notice that even although each device context object has some default font after creation, this method would return a ?wxNullFont initially and only after calling `setFont/2` a valid font is returned.

# getLayoutDirection(This)

    -spec getLayoutDirection(This) -> wx:wx_enum() when This :: wxDC().

Gets the current layout direction of the device context.

On platforms where RTL layout is supported, the return value will either be `wxLayout_LeftToRight` or `wxLayout_RightToLeft`. If RTL layout is not supported, the return value will be `wxLayout_Default`.

See: `setLayoutDirection/2`

# getLogicalFunction(This)

    -spec getLogicalFunction(This) -> wx:wx_enum() when This :: wxDC().

Gets the current logical function.

See: `setLogicalFunction/2`

# getMapMode(This)

    -spec getMapMode(This) -> wx:wx_enum() when This :: wxDC().

Gets the current mapping mode for the device context.

See: `setMapMode/2`

# getMultiLineTextExtent(This, String)

    -spec getMultiLineTextExtent(This, String) -> {W :: integer(), H :: integer()}
                                    when This :: wxDC(), String :: unicode:chardata().

Gets the dimensions of the string using the currently selected font.

`string` is the text string to measure.

Return: The text extent as a {Width,Height} object.

Note: This function works with both single-line and multi-line strings.

See:

- `wxFont`

- `setFont/2`

- `getPartialTextExtents/2`

- `getTextExtent/3`

# getMultiLineTextExtent/3

    -spec getMultiLineTextExtent(This, String, [Option]) ->
                                    {W :: integer(), H :: integer(), HeightLine :: integer()}
                                    when
                                        This :: wxDC(),
                                        String :: unicode:chardata(),
                                        Option :: {font, wxFont:wxFont()}.

Gets the dimensions of the string using the currently selected font.

`string` is the text string to measure, `heightLine`, if non NULL, is where to store the height of a single line.

The text extent is set in the given `w` and `h` pointers.

If the optional parameter `font` is specified and valid, then it is used for the text extent calculation, otherwise the currently selected font is used.

If `string` is empty, its horizontal extent is 0 but, for convenience when using this function for allocating enough space for a possibly multi-line string, its vertical extent is the same as the height of an empty line of text. Please note that this behaviour differs from that of `getTextExtent/3`.

Note: This function works with both single-line and multi-line strings.

See:

- `wxFont`

- `setFont/2`

- `getPartialTextExtents/2`

- `getTextExtent/3`

# getPartialTextExtents(This, Text)

    -spec getPartialTextExtents(This, Text) -> Result
                                   when
                                       Result :: {Res :: boolean(), Widths :: [integer()]},
                                       This :: wxDC(),
                                       Text :: unicode:chardata().

Fills the `widths` array with the widths from the beginning of `text` to the corresponding character of `text`.

The generic version simply builds a running total of the widths of each character using `getTextExtent/3`, however if the various platforms have a native API function that is faster or more accurate than the generic implementation then it should be used instead.

See:

- `getMultiLineTextExtent/3`

- `getTextExtent/3`

# getPen(This)

    -spec getPen(This) -> wxPen:wxPen() when This :: wxDC().

Gets the current pen.

See: `setPen/2`

# getPixel(This, Pos)

    -spec getPixel(This, Pos) -> Result
                      when
                          Result :: {Res :: boolean(), Colour :: wx:wx_colour4()},
                          This :: wxDC(),
                          Pos :: {X :: integer(), Y :: integer()}.

Gets in `colour` the colour at the specified location.

This method isn't available for `wxPostScriptDC` or `wxMetafileDC` (not implemented in wx) nor for any DC in wxOSX port and simply returns false there.

Note: Setting a pixel can be done using `drawPoint/2`.

Note: This method shouldn't be used with `wxPaintDC` as accessing the DC while drawing can result in unexpected results, notably in wxGTK.

# getPPI(This)

    -spec getPPI(This) -> {W :: integer(), H :: integer()} when This :: wxDC().

Returns the resolution of the device in pixels per inch.

# getSize(This)

    -spec getSize(This) -> {W :: integer(), H :: integer()} when This :: wxDC().

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# getSizeMM(This)

    -spec getSizeMM(This) -> {W :: integer(), H :: integer()} when This :: wxDC().

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# getTextBackground(This)

    -spec getTextBackground(This) -> wx:wx_colour4() when This :: wxDC().

Gets the current text background colour.

See: `setTextBackground/2`

# getTextExtent(This, String)

    -spec getTextExtent(This, String) -> {W :: integer(), H :: integer()}
                           when This :: wxDC(), String :: unicode:chardata().

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# getTextExtent/3

    -spec getTextExtent(This, String, [Option]) -> Result
                           when
                               Result ::
                                   {W :: integer(),
                                    H :: integer(),
                                    Descent :: integer(),
                                    ExternalLeading :: integer()},
                               This :: wxDC(),
                               String :: unicode:chardata(),
                               Option :: {theFont, wxFont:wxFont()}.

Gets the dimensions of the string using the currently selected font.

`string` is the text string to measure, `descent` is the dimension from the baseline of the font to the bottom of the descender, and `externalLeading` is any extra vertical space added to the font by the font designer (usually is zero).

The text extent is returned in `w` and `h` pointers or as a {Width,Height} object depending on which version of this function is used.

If the optional parameter `font` is specified and valid, then it is used for the text extent calculation. Otherwise the currently selected font is.

If `string` is empty, its extent is 0 in both directions, as expected.

Note: This function only works with single-line strings.

See:

- `wxFont`

- `setFont/2`

- `getPartialTextExtents/2`

- `getMultiLineTextExtent/3`

# getTextForeground(This)

    -spec getTextForeground(This) -> wx:wx_colour4() when This :: wxDC().

Gets the current text foreground colour.

See: `setTextForeground/2`

# getUserScale(This)

    -spec getUserScale(This) -> {X :: number(), Y :: number()} when This :: wxDC().

Gets the current user scale factor.

See: `setUserScale/3`

# gradientFillConcentric(This, Rect, InitialColour, DestColour)

    -spec gradientFillConcentric(This, Rect, InitialColour, DestColour) -> ok
                                    when
                                        This :: wxDC(),
                                        Rect ::
                                            {X :: integer(), Y :: integer(), W :: integer(), H :: integer()},
                                        InitialColour :: wx:wx_colour(),
                                        DestColour :: wx:wx_colour().

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.

The circle is placed at the centre of `rect`.

Note: Currently this function is very slow, don't use it for real-time drawing.

# gradientFillConcentric(This, Rect, InitialColour, DestColour, CircleCenter)

    -spec gradientFillConcentric(This, Rect, InitialColour, DestColour, CircleCenter) -> ok
                                    when
                                        This :: wxDC(),
                                        Rect ::
                                            {X :: integer(), Y :: integer(), W :: integer(), H :: integer()},
                                        InitialColour :: wx:wx_colour(),
                                        DestColour :: wx:wx_colour(),
                                        CircleCenter :: {X :: integer(), Y :: integer()}.

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

Note: Currently this function is very slow, don't use it for real-time drawing.

# gradientFillLinear(This, Rect, InitialColour, DestColour)

    -spec gradientFillLinear(This, Rect, InitialColour, DestColour) -> ok
                                when
                                    This :: wxDC(),
                                    Rect :: {X :: integer(), Y :: integer(), W :: integer(), H :: integer()},
                                    InitialColour :: wx:wx_colour(),
                                    DestColour :: wx:wx_colour().

Equivalent to `gradientFillLinear(This, Rect, InitialColour, DestColour, [])`.

# gradientFillLinear/5

    -spec gradientFillLinear(This, Rect, InitialColour, DestColour, [Option]) -> ok
                                when
                                    This :: wxDC(),
                                    Rect :: {X :: integer(), Y :: integer(), W :: integer(), H :: integer()},
                                    InitialColour :: wx:wx_colour(),
                                    DestColour :: wx:wx_colour(),
                                    Option :: {nDirection, wx:wx_enum()}.

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.

# isOk(This)

    -spec isOk(This) -> boolean() when This :: wxDC().

Returns true if the DC is ok to use.

# logicalToDeviceX(This, X)

    -spec logicalToDeviceX(This, X) -> integer() when This :: wxDC(), X :: integer().

Converts logical X coordinate to device coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.

# logicalToDeviceXRel(This, X)

    -spec logicalToDeviceXRel(This, X) -> integer() when This :: wxDC(), X :: integer().

Converts logical X coordinate to relative device coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.

Use this for converting a width, for example.

# logicalToDeviceY(This, Y)

    -spec logicalToDeviceY(This, Y) -> integer() when This :: wxDC(), Y :: integer().

Converts logical Y coordinate to device coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.

# logicalToDeviceYRel(This, Y)

    -spec logicalToDeviceYRel(This, Y) -> integer() when This :: wxDC(), Y :: integer().

Converts logical Y coordinate to relative device coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.

Use this for converting a height, for example.

# maxX(This)

    -spec maxX(This) -> integer() when This :: wxDC().

Gets the maximum horizontal extent used in drawing commands so far.

# maxY(This)

    -spec maxY(This) -> integer() when This :: wxDC().

Gets the maximum vertical extent used in drawing commands so far.

# minX(This)

    -spec minX(This) -> integer() when This :: wxDC().

Gets the minimum horizontal extent used in drawing commands so far.

# minY(This)

    -spec minY(This) -> integer() when This :: wxDC().

Gets the minimum vertical extent used in drawing commands so far.

# resetBoundingBox(This)

    -spec resetBoundingBox(This) -> ok when This :: wxDC().

Resets the bounding box: after a call to this function, the bounding box doesn't contain anything.

See: `calcBoundingBox/3`

# setAxisOrientation(This, XLeftRight, YBottomUp)

    -spec setAxisOrientation(This, XLeftRight, YBottomUp) -> ok
                                when This :: wxDC(), XLeftRight :: boolean(), YBottomUp :: boolean().

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.

# setBackground(This, Brush)

    -spec setBackground(This, Brush) -> ok when This :: wxDC(), Brush :: wxBrush:wxBrush().

Sets the current background brush for the DC.

# setBackgroundMode(This, Mode)

    -spec setBackgroundMode(This, Mode) -> ok when This :: wxDC(), Mode :: integer().

`mode` may be one of `wxPENSTYLE\_SOLID` and `wxPENSTYLE\_TRANSPARENT`.

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

# setBrush(This, Brush)

    -spec setBrush(This, Brush) -> ok when This :: wxDC(), Brush :: wxBrush:wxBrush().

Sets the current brush for the DC.

If the argument is ?wxNullBrush (or another invalid brush; see `wxBrush:isOk/1`), the current brush is selected out of the device context (leaving `wxDC` without any valid brush), allowing the current brush to be destroyed safely.

See:

- `wxBrush`

- `wxMemoryDC`

# setClippingRegion(This, Rect)

    -spec setClippingRegion(This, Rect) -> ok
                               when
                                   This :: wxDC(),
                                   Rect :: {X :: integer(), Y :: integer(), W :: integer(), H :: integer()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# setClippingRegion(This, Pt, Sz)

    -spec setClippingRegion(This, Pt, Sz) -> ok
                               when
                                   This :: wxDC(),
                                   Pt :: {X :: integer(), Y :: integer()},
                                   Sz :: {W :: integer(), H :: integer()}.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

# setDeviceOrigin(This, X, Y)

    -spec setDeviceOrigin(This, X, Y) -> ok when This :: wxDC(), X :: integer(), Y :: integer().

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.

# setFont(This, Font)

    -spec setFont(This, Font) -> ok when This :: wxDC(), Font :: wxFont:wxFont().

Sets the current font for the DC.

If the argument is ?wxNullFont (or another invalid font; see `wxFont:isOk/1`), the current font is selected out of the device context (leaving `wxDC` without any valid font), allowing the current font to be destroyed safely.

See: `wxFont`

# setLayoutDirection(This, Dir)

    -spec setLayoutDirection(This, Dir) -> ok when This :: wxDC(), Dir :: wx:wx_enum().

Sets the current layout direction for the device context.

See: `getLayoutDirection/1`

# setLogicalFunction(This, Function)

    -spec setLogicalFunction(This, Function) -> ok when This :: wxDC(), Function :: wx:wx_enum().

Sets the current logical function for the device context.

Note: This function is not fully supported in all ports, due to the limitations of the underlying drawing model. Notably, `wxINVERT` which was commonly used for drawing rubber bands or other moving outlines in the past, is not, and will not, be supported by wxGTK3 and wxMac. The suggested alternative is to draw temporarily objects normally and refresh the (affected part of the) window to remove them later.

It determines how a `source` pixel (from a pen or brush colour, or source device context if using `blit/6`) combines with a `destination` pixel in the current device context. Text drawing is not affected by this function.

See ?wxRasterOperationMode enumeration values for more info.

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

# setMapMode(This, Mode)

    -spec setMapMode(This, Mode) -> ok when This :: wxDC(), Mode :: wx:wx_enum().

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/3`) 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.

# setPalette(This, Palette)

    -spec setPalette(This, Palette) -> ok when This :: wxDC(), Palette :: wxPalette:wxPalette().

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 ?wxNullPalette, the current palette is selected out of the device context, and the original palette restored.

See: `wxPalette`

# setPen(This, Pen)

    -spec setPen(This, Pen) -> ok when This :: wxDC(), Pen :: wxPen:wxPen().

Sets the current pen for the DC.

If the argument is ?wxNullPen (or another invalid pen; see `wxPen:isOk/1`), the current pen is selected out of the device context (leaving `wxDC` without any valid pen), allowing the current pen to be destroyed safely.

See: `wxMemoryDC`

# setTextBackground(This, Colour)

    -spec setTextBackground(This, Colour) -> ok when This :: wxDC(), Colour :: wx:wx_colour().

Sets the current text background colour for the DC.

# setTextForeground(This, Colour)

    -spec setTextForeground(This, Colour) -> ok when This :: wxDC(), Colour :: wx:wx_colour().

Sets the current text foreground colour for the DC.

See: `wxMemoryDC`

# setUserScale(This, XScale, YScale)

    -spec setUserScale(This, XScale, YScale) -> ok
                          when This :: wxDC(), XScale :: number(), YScale :: number().

Sets the user scaling factor, useful for applications which require 'zooming'.

# startDoc(This, Message)

    -spec startDoc(This, Message) -> boolean() when This :: wxDC(), Message :: unicode:chardata().

Starts a document (only relevant when outputting to a printer).

`message` is a message to show while printing.

# startPage(This)

    -spec startPage(This) -> ok when This :: wxDC().

Starts a document page (only relevant when outputting to a printer).