# wxDC Class Reference
[Device Contexts, Graphics Device Interface (GDI)]

`#include </home/work/projects/wx/2.9/wx/interface/wx/dc.h>`

Inheritance diagram for wxDC:
[legend]

## Detailed Description

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 and Cairo. 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. 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 wxPoint parameter instead of the two wxCoord ones or wxPoint and wxSize 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 wxDC::SetMapMode).

This mechanism allows to reuse 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 wxColour is simply ignored and you need to use wxGraphicsContext for full transparency support. There are, however, a few exceptions: first, under Mac OS X colours with alpha channel are supported in all the normal wxDC-derived classes as they use wxGraphicsContext internally. Second, under all platforms wxSVGFileDC also fully supports alpha channel. In both of these cases the instances of wxPen or wxBrush that are built from wxColour use the colour's alpha values when stroking or filling.

## for Transformation Matrix

On some platforms (currently only under MSW and only on Windows NT, i.e. not Windows 9x/ME, systems) wxDC has support for applying an arbitrary affine transformation matrix to its coordinate system. Call CanUseTransformMatrix() to check if this support is available and then call SetTransformMatrix() if it is. If the transformation matrix is not supported, SetTransformMatrix() always simply returns false and doesn't do anything.

##

Library: wxCore
Category: Device Contexts, Graphics Device Interface (GDI)

See also:
  Device Contexts, wxGraphicsContext, wxDCFontChanger, wxDCTextColourChanger, wxDCPenChanger, wxDCBrushChanger, wxDCClipper

Todo:

  Precise definition of default/initial state.

  Pixelwise definition of operations (e.g. last point of a line not drawn).

## Public Member Functions

void | CopyAttributes (const wxDC &dc)
| Copy attributes from another DC.
int | GetDepth () const
| Returns the depth (number of bits/pixel) of this DC.
wxPoint | GetDeviceOrigin () const
| Returns the current device origin.
wxRasterOperationMode | GetLogicalFunction () const
| Gets the current logical function.
wxMappingMode | GetMapMode () const
| Gets the current mapping mode for the device context.
bool | GetPixel (wxCoord x, wxCoord y, wxColour *colour) const
| Gets in colour the colour at the specified location.
wxSize | GetPPI () const
| Returns the resolution of the device in pixels per inch.
void | GetSize (wxCoord *width, wxCoord *height) const
| Gets the horizontal and vertical extent of this device context in device units.
wxSize | GetSize () const
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | GetSizeMM (wxCoord *width, wxCoord *height) const
| Returns the horizontal and vertical resolution in millimetres.
wxSize | GetSizeMM () const
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | GetUserScale (double *x, double *y) const
| Gets the current user scale factor.
bool | IsOk () const
| Returns true if the DC is ok to use.
void | SetAxisOrientation (bool xLeftRight, bool yBottomUp)
| Sets the x and y axis orientation (i.e., the direction from lowest to highest values on the axis).
void | SetDeviceOrigin (wxCoord x, wxCoord y)
| Sets the device origin (i.e., the origin in pixels after scaling has been applied).
void | SetLogicalFunction (wxRasterOperationMode function)
| Sets the current logical function for the device context.
void | SetMapMode (wxMappingMode mode)
| The mapping mode of the device context defines the unit of measurement used to convert logical units to device units.
void | SetPalette (const wxPalette &palette)
| If this is a window DC or memory DC, assigns the given palette to the window or bitmap associated with the DC.
void | SetUserScale (double xScale, double yScale)
| Sets the user scaling factor, useful for applications which require 'zooming'.
Coordinate conversion functions
wxCoord | DeviceToLogicalX (wxCoord x) const
| Convert device X coordinate to logical coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.
wxCoord | DeviceToLogicalXRel (wxCoord x) const
| Convert device X coordinate to relative logical coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.
wxCoord | DeviceToLogicalY (wxCoord y) const
| Converts device Y coordinate to logical coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.
wxCoord | DeviceToLogicalYRel (wxCoord y) const
| Convert device Y coordinate to relative logical coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.
wxCoord | LogicalToDeviceX (wxCoord x) const
| Converts logical X coordinate to device coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.
wxCoord | LogicalToDeviceXRel (wxCoord x) const
| Converts logical X coordinate to relative device coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.
wxCoord | LogicalToDeviceY (wxCoord y) const
| Converts logical Y coordinate to device coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.
wxCoord | LogicalToDeviceYRel (wxCoord y) const
| Converts logical Y coordinate to relative device coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.
Drawing functions
void | Clear ()
| Clears the device context using the current background brush.
void | DrawArc (wxCoord xStart, wxCoord yStart, wxCoord xEnd, wxCoord yEnd, wxCoord xc, wxCoord yc)
| Draws an arc of a circle, centred on (xc, yc), with starting point (xStart, yStart) and ending at (xEnd, yEnd).
void | DrawArc (const wxPoint &ptStart, const wxPoint &ptEnd, const wxPoint &centre)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawBitmap (const wxBitmap &bitmap, wxCoord x, wxCoord y, bool useMask=false)
| Draw a bitmap on the device context at the specified point.
void | DrawBitmap (const wxBitmap &bmp, const wxPoint &pt, bool useMask=false)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawCheckMark (wxCoord x, wxCoord y, wxCoord width, wxCoord height)
| Draws a check mark inside the given rectangle.
void | DrawCheckMark (const wxRect &rect)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawCircle (wxCoord x, wxCoord y, wxCoord radius)
| Draws a circle with the given centre and radius.
void | DrawCircle (const wxPoint &pt, wxCoord radius)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord height)
| Draws an ellipse contained in the rectangle specified either with the given top left corner and the given size or directly.
void | DrawEllipse (const wxPoint &pt, const wxSize &size)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawEllipse (const wxRect &rect)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawEllipticArc (wxCoord x, wxCoord y, wxCoord width, wxCoord height, double start, double end)
| Draws an arc of an ellipse.
void | DrawEllipticArc (const wxPoint &pt, const wxSize &sz, double sa, double ea)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawIcon (const wxIcon &icon, wxCoord x, wxCoord y)
| Draw an icon on the display (does nothing if the device context is PostScript).
void | DrawIcon (const wxIcon &icon, const wxPoint &pt)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawLabel (const wxString &text, const wxBitmap &image, const wxRect &rect, int alignment=wxALIGN_LEFT|wxALIGN_TOP, int indexAccel=-1, wxRect *rectBounding=NULL)
| Draw optional bitmap and the text into the given rectangle and aligns it as specified by alignment parameter; it also will emphasize the character with the given index if it is != -1 and return the bounding rectangle if required.
void | DrawLabel (const wxString &text, const wxRect &rect, int alignment=wxALIGN_LEFT|wxALIGN_TOP, int indexAccel=-1)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
| Draws a line from the first point to the second.
void | DrawLine (const wxPoint &pt1, const wxPoint &pt2)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawLines (int n, wxPoint points[], wxCoord xoffset=0, wxCoord yoffset=0)
| Draws lines using an array of points of size n adding the optional offset coordinate.
void | DrawLines (const wxPointList *points, wxCoord xoffset=0, wxCoord yoffset=0)
| This method uses a list of wxPoints, adding the optional offset coordinate.
void | DrawPoint (wxCoord x, wxCoord y)
| Draws a point using the color of the current pen.
void | DrawPoint (const wxPoint &pt)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawPolygon (int n, wxPoint points[], wxCoord xoffset=0, wxCoord yoffset=0, wxPolygonFillMode fill_style=wxODDEVEN_RULE)
| Draws a filled polygon using an array of points of size n, adding the optional offset coordinate.
void | DrawPolygon (const wxPointList *points, wxCoord xoffset=0, wxCoord yoffset=0, wxPolygonFillMode fill_style=wxODDEVEN_RULE)
| This method draws a filled polygon using a list of wxPoints, adding the optional offset coordinate.
void | DrawPolyPolygon (int n, int count[], wxPoint points[], wxCoord xoffset=0, wxCoord yoffset=0, wxPolygonFillMode fill_style=wxODDEVEN_RULE)
| Draws two or more filled polygons using an array of points, adding the optional offset coordinates.
void | DrawRectangle (wxCoord x, wxCoord y, wxCoord width, wxCoord height)
| Draws a rectangle with the given top left corner, and with the given size.
void | DrawRectangle (const wxPoint &pt, const wxSize &sz)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawRectangle (const wxRect &rect)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawRotatedText (const wxString &text, wxCoord x, wxCoord y, double angle)
| Draws the text rotated by angle degrees (positive angles are counterclockwise; the full angle is 360 degrees).
void | DrawRotatedText (const wxString &text, const wxPoint &, double angle)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
| Draws a rectangle with the given top left corner, and with the given size.
void | DrawRoundedRectangle (const wxPoint &pt, const wxSize &sz, double radius)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawRoundedRectangle (const wxRect &rect, double radius)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawSpline (int n, wxPoint points[])
| Draws a spline between all given points using the current pen.
void | DrawSpline (const wxPointList *points)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawSpline (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | DrawText (const wxString &text, wxCoord x, wxCoord y)
| Draws a text string at the specified point, using the current text font, and the current text foreground and background colours.
void | DrawText (const wxString &text, const wxPoint &pt)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | GradientFillConcentric (const wxRect &rect, const wxColour &initialColour, const wxColour &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.
void | GradientFillConcentric (const wxRect &rect, const wxColour &initialColour, const wxColour &destColour, const wxPoint &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.
void | GradientFillLinear (const wxRect &rect, const wxColour &initialColour, const wxColour &destColour, wxDirection nDirection=wxRIGHT)
| Fill the area specified by rect with a linear gradient, starting from initialColour and eventually fading to destColour.
bool | FloodFill (wxCoord x, wxCoord y, const wxColour &colour, wxFloodFillStyle style=wxFLOOD_SURFACE)
| Flood fills the device context starting from the given point, using the current brush colour, and using a style:
bool | FloodFill (const wxPoint &pt, const wxColour &col, int style=wxFLOOD_SURFACE)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | CrossHair (wxCoord x, wxCoord y)
| Displays a cross hair using the current pen.
void | CrossHair (const wxPoint &pt)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Clipping region functions
void | DestroyClippingRegion ()
| Destroys the current clipping region so that none of the DC is clipped.
void | GetClippingBox (wxCoord *x, wxCoord *y, wxCoord *width, wxCoord *height) const
| Gets the rectangle surrounding the current clipping region.
void | SetClippingRegion (wxCoord x, wxCoord y, wxCoord width, wxCoord 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.
void | SetClippingRegion (const wxPoint &pt, const wxSize &sz)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | SetClippingRegion (const wxRect &rect)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | SetDeviceClippingRegion (const wxRegion &region)
| Sets the clipping region for this device context.
Text/character extent functions
wxCoord | GetCharHeight () const
| Gets the character height of the currently set font.
wxCoord | GetCharWidth () const
| Gets the average character width of the currently set font.
wxFontMetrics | GetFontMetrics () const
| Returns the various font characteristics.
void | GetMultiLineTextExtent (const wxString &string, wxCoord *w, wxCoord *h, wxCoord *heightLine=NULL, const wxFont *font=NULL) const
| Gets the dimensions of the string using the currently selected font.
wxSize | GetMultiLineTextExtent (const wxString &string) const
| Gets the dimensions of the string using the currently selected font.
bool | GetPartialTextExtents (const wxString &text, wxArrayInt &widths) const
| Fills the widths array with the widths from the beginning of text to the corresponding character of text.
void | GetTextExtent (const wxString &string, wxCoord *w, wxCoord *h, wxCoord *descent=NULL, wxCoord *externalLeading=NULL, const wxFont *font=NULL) const
| Gets the dimensions of the string using the currently selected font.
wxSize | GetTextExtent (const wxString &string) const
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Text properties functions
int | GetBackgroundMode () const
| Returns the current background mode: `wxSOLID` or `wxTRANSPARENT`.
const wxFont & | GetFont () const
| Gets the current font.
wxLayoutDirection | GetLayoutDirection () const
| Gets the current layout direction of the device context.
const wxColour & | GetTextBackground () const
| Gets the current text background colour.
const wxColour & | GetTextForeground () const
| Gets the current text foreground colour.
void | SetBackgroundMode (int mode)
| mode may be one of `wxSOLID` and `wxTRANSPARENT`.
void | SetFont (const wxFont &font)
| Sets the current font for the DC.
void | SetTextBackground (const wxColour &colour)
| Sets the current text background colour for the DC.
void | SetTextForeground (const wxColour &colour)
| Sets the current text foreground colour for the DC.
void | SetLayoutDirection (wxLayoutDirection dir)
| Sets the current layout direction for the device context.
Bounding box functions
void | CalcBoundingBox (wxCoord x, wxCoord y)
| Adds the specified point to the bounding box which can be retrieved with MinX(), MaxX() and MinY(), MaxY() functions.
wxCoord | MaxX () const
| Gets the maximum horizontal extent used in drawing commands so far.
wxCoord | MaxY () const
| Gets the maximum vertical extent used in drawing commands so far.
wxCoord | MinX () const
| Gets the minimum horizontal extent used in drawing commands so far.
wxCoord | MinY () const
| Gets the minimum vertical extent used in drawing commands so far.
void | ResetBoundingBox ()
| Resets the bounding box: after a call to this function, the bounding box doesn't contain anything.
Page and document start/end functions
bool | StartDoc (const wxString &message)
| Starts a document (only relevant when outputting to a printer).
void | StartPage ()
| Starts a document page (only relevant when outputting to a printer).
void | EndDoc ()
| Ends a document (only relevant when outputting to a printer).
void | EndPage ()
| Ends a document page (only relevant when outputting to a printer).
Bit-Block Transfer operations (blit)
bool | Blit (wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, wxRasterOperationMode logicalFunc=wxCOPY, bool useMask=false, wxCoord xsrcMask=wxDefaultCoord, wxCoord ysrcMask=wxDefaultCoord)
| 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.
bool | StretchBlit (wxCoord xdest, wxCoord ydest, wxCoord dstWidth, wxCoord dstHeight, wxDC *source, wxCoord xsrc, wxCoord ysrc, wxCoord srcWidth, wxCoord srcHeight, wxRasterOperationMode logicalFunc=wxCOPY, bool useMask=false, wxCoord xsrcMask=wxDefaultCoord, wxCoord ysrcMask=wxDefaultCoord)
| Copy from a source DC to this DC, specifying the destination coordinates, destination size, source DC, source coordinates, size of source area to copy, logical function, whether to use a bitmap mask, and mask source position.
Background/foreground brush and pen
const wxBrush & | GetBackground () const
| Gets the brush used for painting the background.
const wxBrush & | GetBrush () const
| Gets the current brush.
const wxPen & | GetPen () const
| Gets the current pen.
void | SetBackground (const wxBrush &brush)
| Sets the current background brush for the DC.
void | SetBrush (const wxBrush &brush)
| Sets the current brush for the DC.
void | SetPen (const wxPen &pen)
| Sets the current pen for the DC.
Transformation matrix
See the notes about the availability of these functions in the class documentation.
bool | CanUseTransformMatrix () const
| Check if the use of transformation matrix is supported by the current system.
bool | SetTransformMatrix (const wxAffineMatrix2D &matrix)
| Set the transformation matrix.
wxAffineMatrix2D | GetTransformMatrix () const
| Return the transformation matrix used by this device context.
void | ResetTransformMatrix ()
| Revert the transformation matrix to identity matrix.

List of all members.

## Member Function Documentation

bool wxDC::Blit | ( | wxCoord | xdest,
|  | wxCoord | ydest,
|  | wxCoord | width,
|  | wxCoord | height,
|  | wxDC * | source,
|  | wxCoord | xsrc,
|  | wxCoord | ysrc,
|  | wxRasterOperationMode | logicalFunc = `wxCOPY`,
|  | bool | useMask = `false`,
|  | wxCoord | xsrcMask = `wxDefaultCoord`,
|  | wxCoord | ysrcMask = `wxDefaultCoord` |
| ) |  |  |

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 | Destination device context x position.
  | ydest | Destination device context y position.
  | width | Width of source area to be copied.
  | height | Height of source area to be copied.
  | source | Source device context.
  | xsrc | Source device context x position.
  | ysrc | Source device context y position.
  | logicalFunc | Logical function to use, see SetLogicalFunction().

  useMask

  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.
  Note: on Windows, blitting with masks can be speeded up considerably by compiling wxWidgets with the wxUSE_DC_CACHEING option enabled. You can also influence whether MaskBlt or the explicit mask blitting code above is used, by using wxSystemOptions and setting the `no-maskblt` option to 1.

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

Remarks:
  There is partial support for Blit() in wxPostScriptDC, under X.

See also:
  StretchBlit(), wxMemoryDC, wxBitmap, wxMask

void wxDC::CalcBoundingBox | ( | wxCoord | x,
|  | wxCoord | y |
| ) |  |  |

Adds the specified point to the bounding box which can be retrieved with MinX(), MaxX() and MinY(), MaxY() functions.

See also:
  ResetBoundingBox()

bool wxDC::CanUseTransformMatrix | ( |  | ) | const

Check if the use of transformation matrix is supported by the current system.

Currently this function always returns false for non-MSW platforms and may return false for old (Windows 9x/ME) Windows systems. Normally support for the transformation matrix is always available in any relatively recent Windows versions.

Since:
  2.9.2

void wxDC::Clear | ( |  | ) |

Clears the device context using the current background brush.

Reimplemented in wxSVGFileDC.

void wxDC::CopyAttributes | ( | const wxDC & | dc | ) |

Copy attributes from another DC.

The copied attributes currently are:

- Font
- Text foreground and background colours
- Background brush
- Layout direction

Parameters:

  | dc | A valid (i.e. its IsOk() must return true) source device context.

void wxDC::CrossHair | ( | wxCoord | x,
|  | wxCoord | 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.

Reimplemented in wxSVGFileDC.

void wxDC::CrossHair | ( | const wxPoint & | pt | ) |

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

void wxDC::DestroyClippingRegion | ( |  | ) |

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

See also:
  SetClippingRegion()

Reimplemented in wxSVGFileDC.

wxCoord wxDC::DeviceToLogicalX | ( | wxCoord | x | ) | const

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

wxCoord wxDC::DeviceToLogicalXRel | ( | wxCoord | x | ) | const

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.

wxCoord wxDC::DeviceToLogicalY | ( | wxCoord | y | ) | const

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

wxCoord wxDC::DeviceToLogicalYRel | ( | wxCoord | y | ) | const

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.

void wxDC::DrawArc | ( | wxCoord | xStart,
|  | wxCoord | yStart,
|  | wxCoord | xEnd,
|  | wxCoord | yEnd,
|  | wxCoord | xc,
|  | wxCoord | yc |
| ) |  |  |

Draws an arc of a circle, centred on (xc, yc), with starting point (xStart, yStart) and ending at (xEnd, yEnd).

The current pen is used for the outline and the current brush for filling the shape.

The arc is drawn in a counter-clockwise direction from the start point to the end point.

void wxDC::DrawArc | ( | const wxPoint & | ptStart,
|  | const wxPoint & | ptEnd,
|  | const wxPoint & | centre |
| ) |  |  |

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

void wxDC::DrawBitmap | ( | const wxBitmap & | bitmap,
|  | wxCoord | x,
|  | wxCoord | y,
|  | bool | useMask = `false` |
| ) |  |  |

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

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

See also:
  SetTextForeground(), SetTextBackground(), wxMemoryDC

void wxDC::DrawBitmap | ( | const wxBitmap & | bmp,
|  | const wxPoint & | pt,
|  | bool | useMask = `false` |
| ) |  |  |

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

void wxDC::DrawCheckMark | ( | wxCoord | x,
|  | wxCoord | y,
|  | wxCoord | width,
|  | wxCoord | height |
| ) |  |  |

Draws a check mark inside the given rectangle.

void wxDC::DrawCheckMark | ( | const wxRect & | rect | ) |

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

void wxDC::DrawCircle | ( | wxCoord | x,
|  | wxCoord | y,
|  | wxCoord | radius |
| ) |  |  |

Draws a circle with the given centre and radius.

See also:
  DrawEllipse()

void wxDC::DrawCircle | ( | const wxPoint & | pt,
|  | wxCoord | radius |
| ) |  |  |

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

void wxDC::DrawEllipse | ( | wxCoord | x,
|  | wxCoord | y,
|  | wxCoord | width,
|  | wxCoord | 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.

See also:
  DrawCircle()

void wxDC::DrawEllipse | ( | const wxPoint & | pt,
|  | const wxSize & | size |
| ) |  |  |

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

void wxDC::DrawEllipse | ( | const wxRect & | rect | ) |

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

void wxDC::DrawEllipticArc | ( | wxCoord | x,
|  | wxCoord | y,
|  | wxCoord | width,
|  | wxCoord | height,
|  | double | start,
|  | double | 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.

void wxDC::DrawEllipticArc | ( | const wxPoint & | pt,
|  | const wxSize & | sz,
|  | double | sa,
|  | double | ea |
| ) |  |  |

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

void wxDC::DrawIcon | ( | const wxIcon & | icon,
|  | wxCoord | x,
|  | wxCoord | y |
| ) |  |  |

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

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

void wxDC::DrawIcon | ( | const wxIcon & | icon,
|  | const wxPoint & | pt |
| ) |  |  |

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

void wxDC::DrawLabel | ( | const wxString & | text,
|  | const wxBitmap & | image,
|  | const wxRect & | rect,
|  | int | alignment = `wxALIGN_LEFT|wxALIGN_TOP`,
|  | int | indexAccel = `-1`,
|  | wxRect * | rectBounding = `NULL` |
| ) |  |  |

Draw optional bitmap and the text into the given rectangle and aligns it as specified by alignment parameter; it also will emphasize the character with the given index if it is != -1 and return the bounding rectangle if required.

void wxDC::DrawLabel | ( | const wxString & | text,
|  | const wxRect & | rect,
|  | int | alignment = `wxALIGN_LEFT|wxALIGN_TOP`,
|  | int | indexAccel = `-1` |
| ) |  |  |

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

void wxDC::DrawLine | ( | wxCoord | x1,
|  | wxCoord | y1,
|  | wxCoord | x2,
|  | wxCoord | y2 |
| ) |  |  |

Draws a line from the first point to the second.

The current pen is used for drawing the line. 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).

void wxDC::DrawLine | ( | const wxPoint & | pt1,
|  | const wxPoint & | pt2 |
| ) |  |  |

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

void wxDC::DrawLines | ( | int | n,
|  | wxPoint | points[],
|  | wxCoord | xoffset = `0`,
|  | wxCoord | yoffset = `0` |
| ) |  |  |

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

The current pen is used for drawing the lines.

wxPython Note: The wxPython version of this method accepts a Python list of wxPoint objects.

wxPerl Note: Not supported by wxPerl.

void wxDC::DrawLines | ( | const wxPointList * | points,
|  | wxCoord | xoffset = `0`,
|  | wxCoord | yoffset = `0` |
| ) |  |  |

This method uses a list of wxPoints, adding the optional offset coordinate.

The programmer is responsible for deleting the list of points.

wxPython Note: The wxPython version of this method accepts a Python list of wxPoint objects.

wxPerl Note: The wxPerl version of this method accepts as its first parameter a reference to an array of wxPoint objects.

void wxDC::DrawPoint | ( | const wxPoint & | pt | ) |

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

void wxDC::DrawPoint | ( | wxCoord | x,
|  | wxCoord | y |
| ) |  |  |

Draws a point using the color of the current pen.

Note that the other properties of the pen are not used, such as width.

void wxDC::DrawPolygon | ( | int | n,
|  | wxPoint | points[],
|  | wxCoord | xoffset = `0`,
|  | wxCoord | yoffset = `0`,
|  | wxPolygonFillMode | fill_style = `wxODDEVEN_RULE` |
| ) |  |  |

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.

wxPerl Note: Not supported by wxPerl.

void wxDC::DrawPolygon | ( | const wxPointList * | points,
|  | wxCoord | xoffset = `0`,
|  | wxCoord | yoffset = `0`,
|  | wxPolygonFillMode | fill_style = `wxODDEVEN_RULE` |
| ) |  |  |

This method draws a filled polygon using a list of wxPoints, 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.

The programmer is responsible for deleting the list of points.

wxPython Note: The wxPython version of this method accepts a Python list of wxPoint objects.

wxPerl Note: The wxPerl version of this method accepts as its first parameter a reference to an array of wxPoint objects.

void wxDC::DrawPolyPolygon | ( | int | n,
|  | int | count[],
|  | wxPoint | points[],
|  | wxCoord | xoffset = `0`,
|  | wxCoord | yoffset = `0`,
|  | wxPolygonFillMode | fill_style = `wxODDEVEN_RULE` |
| ) |  |  |

Draws two or more filled polygons using an array of points, adding the optional offset coordinates.

Notice that for the platforms providing a native implementation of this function (Windows and PostScript-based wxDC currently), this is more efficient than using DrawPolygon() in a loop.

n specifies the number of polygons to draw, the array count of size n specifies the number of points in each of the polygons in the points array.

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.

The polygons maybe disjoint or overlapping. Each polygon specified in a call to DrawPolyPolygon() must be closed. Unlike polygons created by the DrawPolygon() member function, the polygons created by this method are not closed automatically.

wxPython Note: Not implemented yet.

void wxDC::DrawRectangle | ( | wxCoord | x,
|  | wxCoord | y,
|  | wxCoord | width,
|  | wxCoord | 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.

void wxDC::DrawRectangle | ( | const wxPoint & | pt,
|  | const wxSize & | sz |
| ) |  |  |

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

void wxDC::DrawRectangle | ( | const wxRect & | rect | ) |

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

void wxDC::DrawRotatedText | ( | const wxString & | text,
|  | wxCoord | x,
|  | wxCoord | y,
|  | double | angle |
| ) |  |  |

Draws the text rotated by angle degrees (positive angles are counterclockwise; the full angle is 360 degrees).

Note:
  Under Win9x only TrueType fonts can be drawn by this function. In particular, a font different from `wxNORMAL_FONT` should be used as the latter is not a TrueType font. `wxSWISS_FONT` is an example of a font which is.

See also:
  DrawText()

void wxDC::DrawRotatedText | ( | const wxString & | text,
|  | const wxPoint & | ,
|  | double | angle |
| ) |  |  |

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

void wxDC::DrawRoundedRectangle | ( | wxCoord | x,
|  | wxCoord | y,
|  | wxCoord | width,
|  | wxCoord | height,
|  | double | 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.

void wxDC::DrawRoundedRectangle | ( | const wxPoint & | pt,
|  | const wxSize & | sz,
|  | double | radius |
| ) |  |  |

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

void wxDC::DrawRoundedRectangle | ( | const wxRect & | rect,
|  | double | radius |
| ) |  |  |

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

void wxDC::DrawSpline | ( | int | n,
|  | wxPoint | points[] |
| ) |  |  |

Draws a spline between all given points using the current pen.

wxPython Note: The wxPython version of this method accepts a Python list of wxPoint objects.

wxPerl Note: Not supported by wxPerl.

void wxDC::DrawSpline | ( | const wxPointList * | points | ) |

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

wxPerl Note: The wxPerl version of this method accepts as its first parameter a reference to an array of wxPoint objects.

void wxDC::DrawSpline | ( | wxCoord | x1,
|  | wxCoord | y1,
|  | wxCoord | x2,
|  | wxCoord | y2,
|  | wxCoord | x3,
|  | wxCoord | y3 |
| ) |  |  |

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

wxPerl Note: Not supported by wxPerl.

void wxDC::DrawText | ( | const wxString & | text,
|  | wxCoord | x,
|  | wxCoord | 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() for how to get the dimensions of a text string, which can be used to position the text more precisely and DrawLabel() if you need to align the string differently.

Starting from wxWidgets 2.9.2 text parameter can be a multi-line string, i.e. contain new line characters, and will be rendered correctly.

Note:
  The current logical function is ignored by this function.

void wxDC::DrawText | ( | const wxString & | text,
|  | const wxPoint & | pt |
| ) |  |  |

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

void wxDC::EndDoc | ( |  | ) |

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

Reimplemented in wxSVGFileDC.

void wxDC::EndPage | ( |  | ) |

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

Reimplemented in wxSVGFileDC.

bool wxDC::FloodFill | ( | wxCoord | x,
|  | wxCoord | y,
|  | const wxColour & | colour,
|  | wxFloodFillStyle | style = `wxFLOOD_SURFACE` |
| ) |  |  |

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

- wxFLOOD_SURFACE: The flooding occurs until a colour other than the given colour is encountered.
- wxFLOOD_BORDER: The area to be flooded is bounded by the given colour.

Returns:
  false if the operation failed.

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.

Reimplemented in wxSVGFileDC.

bool wxDC::FloodFill | ( | const wxPoint & | pt,
|  | const wxColour & | col,
|  | int | style = `wxFLOOD_SURFACE` |
| ) |  |  |

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

const wxBrush& wxDC::GetBackground | ( |  | ) | const

Gets the brush used for painting the background.

See also:
  wxDC::SetBackground()

int wxDC::GetBackgroundMode | ( |  | ) | const

Returns the current background mode: `wxSOLID` or `wxTRANSPARENT`.

See also:
  SetBackgroundMode()

const wxBrush& wxDC::GetBrush | ( |  | ) | const

Gets the current brush.

See also:
  wxDC::SetBrush()

wxCoord wxDC::GetCharHeight | ( |  | ) | const

Gets the character height of the currently set font.

wxCoord wxDC::GetCharWidth | ( |  | ) | const

Gets the average character width of the currently set font.

void wxDC::GetClippingBox | ( | wxCoord * | x,
|  | wxCoord * | y,
|  | wxCoord * | width,
|  | wxCoord * | height |
| ) |  |  | const

Gets the rectangle surrounding the current clipping region.

wxPython Note: No arguments are required and the four values defining the rectangle are returned as a tuple.

Reimplemented in wxSVGFileDC.

int wxDC::GetDepth | ( |  | ) | const

Returns the depth (number of bits/pixel) of this DC.

See also:
  wxDisplayDepth()

wxPoint wxDC::GetDeviceOrigin | ( |  | ) | const

Returns the current device origin.

See also:
  SetDeviceOrigin()

const wxFont& wxDC::GetFont | ( |  | ) | const

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() a valid font is returned.

wxFontMetrics wxDC::GetFontMetrics | ( |  | ) | const

Returns the various font characteristics.

This method allows to retrieve some of the font characteristics not returned by GetTextExtent(), notably internal leading and average character width.

Currently this method returns correct results only under wxMSW, in the other ports the internal leading will always be 0 and the average character width will be computed as the width of the character 'x'.

Since:
  2.9.2

wxLayoutDirection wxDC::GetLayoutDirection | ( |  | ) | const

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 also:
  SetLayoutDirection()

wxRasterOperationMode wxDC::GetLogicalFunction | ( |  | ) | const

Gets the current logical function.

See also:
  SetLogicalFunction()

wxMappingMode wxDC::GetMapMode | ( |  | ) | const

Gets the current mapping mode for the device context.

See also:
  SetMapMode()

void wxDC::GetMultiLineTextExtent | ( | const wxString & | string,
|  | wxCoord * | w,
|  | wxCoord * | h,
|  | wxCoord * | heightLine = `NULL`,
|  | const wxFont * | font = `NULL` |
| ) |  |  | const

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.

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

wxPerl Note: In wxPerl this method is implemented as GetMultiLineTextExtent(string, font = undef) returning a 3-element list (width, height, line_height)

See also:
  wxFont, SetFont(), GetPartialTextExtents(), GetTextExtent()

wxSize wxDC::GetMultiLineTextExtent | ( | const wxString & | string | ) | const

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.

Returns:
  The text extent as a wxSize object.

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

wxPerl Note: Not supported by wxPerl.

See also:
  wxFont, SetFont(), GetPartialTextExtents(), GetTextExtent()

bool wxDC::GetPartialTextExtents | ( | const wxString & | text,
|  | wxArrayInt & | widths |
| ) |  |  | const

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

wxPython Note: This method only takes the text parameter and returns a Python list of integers.

wxPerl Note: In wxPerl this method only takes the text parameter and returns the widths as a list of integers.

See also:
  GetMultiLineTextExtent(), GetTextExtent()

const wxPen& wxDC::GetPen | ( |  | ) | const

Gets the current pen.

See also:
  SetPen()

bool wxDC::GetPixel | ( | wxCoord | x,
|  | wxCoord | y,
|  | wxColour * | colour |
| ) |  |  | const

Gets in colour the colour at the specified location.

Not available for wxPostScriptDC or wxMetafileDC.

Note:
  Setting a pixel can be done using DrawPoint().

wxPython Note: The wxColour value is returned and is not required as a parameter.

Reimplemented in wxSVGFileDC.

wxSize wxDC::GetPPI | ( |  | ) | const

Returns the resolution of the device in pixels per inch.

void wxDC::GetSize | ( | wxCoord * | width,
|  | wxCoord * | height |
| ) |  |  | const

Gets the horizontal and vertical extent of this device context 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:

            wxCoord w, h;
            dc.GetSize(&w, &h);
            double scaleX = (double)(maxX / w);
            double scaleY = (double)(maxY / h);
            dc.SetUserScale(min(scaleX, scaleY),min(scaleX, scaleY));

wxPython Note: In place of a single overloaded method name, wxPython implements the following methods:

- GetSize() - Returns a wxSize.
- GetSizeWH() - Returns a 2-tuple (width, height).

wxPerl Note: In wxPerl there are two methods instead of a single overloaded method:

- GetSize(): returns a Wx::Size object.
- GetSizeWH(): returns a 2-element list (width, height).

wxSize wxDC::GetSize | ( |  | ) | const

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

void wxDC::GetSizeMM | ( | wxCoord * | width,
|  | wxCoord * | height |
| ) |  |  | const

Returns the horizontal and vertical resolution in millimetres.

wxSize wxDC::GetSizeMM | ( |  | ) | const

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

const wxColour& wxDC::GetTextBackground | ( |  | ) | const

Gets the current text background colour.

See also:
  SetTextBackground()

void wxDC::GetTextExtent | ( | const wxString & | string,
|  | wxCoord * | w,
|  | wxCoord * | h,
|  | wxCoord * | descent = `NULL`,
|  | wxCoord * | externalLeading = `NULL`,
|  | const wxFont * | font = `NULL` |
| ) |  |  | const

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

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

wxPython Note: The following methods are implemented in wxPython:

- GetTextExtent(string) - Returns a 2-tuple, (width, height).
- GetFullTextExtent(string, font=NULL) - Returns a 4-tuple, (width, height, descent, externalLeading).

wxPerl Note: In wxPerl this method is implemented as GetTextExtent(string, font = undef) returning a 4-element list (width, height, descent, externalLeading)

See also:
  wxFont, SetFont(), GetPartialTextExtents(), GetMultiLineTextExtent()

wxSize wxDC::GetTextExtent | ( | const wxString & | string | ) | const

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

wxPerl Note: Not supported by wxPerl.

const wxColour& wxDC::GetTextForeground | ( |  | ) | const

Gets the current text foreground colour.

See also:
  SetTextForeground()

wxAffineMatrix2D wxDC::GetTransformMatrix | ( |  | ) | const

Return the transformation matrix used by this device context.

By default the transformation matrix is the identity matrix.

Since:
  2.9.2

void wxDC::GetUserScale | ( | double * | x,
|  | double * | y |
| ) |  |  | const

Gets the current user scale factor.

wxPerl Note: In wxPerl this method takes no arguments and return a two element array (x, y).

See also:
  SetUserScale()

void wxDC::GradientFillConcentric | ( | const wxRect & | rect,
|  | const wxColour & | initialColour,
|  | const wxColour & | destColour,
|  | const wxPoint & | 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.

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

void wxDC::GradientFillConcentric | ( | const wxRect & | rect,
|  | const wxColour & | initialColour,
|  | const wxColour & | 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.

The circle is placed at the centre of rect.

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

void wxDC::GradientFillLinear | ( | const wxRect & | rect,
|  | const wxColour & | initialColour,
|  | const wxColour & | destColour,
|  | wxDirection | nDirection = `wxRIGHT` |
| ) |  |  |

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.

bool wxDC::IsOk | ( |  | ) | const

Returns true if the DC is ok to use.

wxCoord wxDC::LogicalToDeviceX | ( | wxCoord | x | ) | const

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

wxCoord wxDC::LogicalToDeviceXRel | ( | wxCoord | x | ) | const

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.

wxCoord wxDC::LogicalToDeviceY | ( | wxCoord | y | ) | const

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

wxCoord wxDC::LogicalToDeviceYRel | ( | wxCoord | y | ) | const

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.

wxCoord wxDC::MaxX | ( |  | ) | const

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

wxCoord wxDC::MaxY | ( |  | ) | const

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

wxCoord wxDC::MinX | ( |  | ) | const

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

wxCoord wxDC::MinY | ( |  | ) | const

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

void wxDC::ResetBoundingBox | ( |  | ) |

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

See also:
  CalcBoundingBox()

void wxDC::ResetTransformMatrix | ( |  | ) |

Revert the transformation matrix to identity matrix.

Since:
  2.9.2

void wxDC::SetAxisOrientation | ( | bool | xLeftRight,
|  | bool | 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 | True to set the x axis orientation to the natural left to right orientation, false to invert it.
  | yBottomUp | True to set the y axis orientation to the natural bottom up orientation, false to invert it.

void wxDC::SetBackground | ( | const wxBrush & | brush | ) |

Sets the current background brush for the DC.

void wxDC::SetBackgroundMode | ( | int | mode | ) |

mode may be one of `wxSOLID` and `wxTRANSPARENT`.

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

void wxDC::SetBrush | ( | const wxBrush & | brush | ) |

Sets the current brush for the DC.

If the argument is wxNullBrush (or another invalid brush; see wxBrush::IsOk), 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 also:
  wxBrush, wxMemoryDC (for the interpretation of colours when drawing into a monochrome bitmap)

void wxDC::SetClippingRegion | ( | wxCoord | x,
|  | wxCoord | y,
|  | wxCoord | width,
|  | wxCoord | 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.

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.

Notice that you need to call DestroyClippingRegion() if you want to set the clipping region exactly to the region specified.

Also note that if the clipping region is empty, any previously set clipping region is destroyed, i.e. it is equivalent to calling DestroyClippingRegion(), and not to clipping out all drawing on the DC as might be expected.

See also:
  DestroyClippingRegion(), wxRegion

Reimplemented in wxSVGFileDC.

void wxDC::SetClippingRegion | ( | const wxPoint & | pt,
|  | const wxSize & | sz |
| ) |  |  |

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

Reimplemented in wxSVGFileDC.

void wxDC::SetClippingRegion | ( | const wxRect & | rect | ) |

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

Reimplemented in wxSVGFileDC.

void wxDC::SetDeviceClippingRegion | ( | const wxRegion & | region | ) |

Sets the clipping region for this device context.

Unlike SetClippingRegion(), this function works with physical coordinates and not with the logical ones.

void wxDC::SetDeviceOrigin | ( | wxCoord | x,
|  | wxCoord | 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.

void wxDC::SetFont | ( | const wxFont & | font | ) |

Sets the current font for the DC.

If the argument is wxNullFont (or another invalid font; see wxFont::IsOk), 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 also:
  wxFont

void wxDC::SetLayoutDirection | ( | wxLayoutDirection | dir | ) |

Sets the current layout direction for the device context.

Parameters:

  | dir | May be either `wxLayout_Default`, `wxLayout_LeftToRight` or `wxLayout_RightToLeft`.

See also:
  GetLayoutDirection()

void wxDC::SetLogicalFunction | ( | wxRasterOperationMode | function | ) |

Sets the current logical function for the device context.

It determines how a source pixel (from a pen or brush colour, or source device context if using Blit()) 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. `wxINVERT` is commonly used for drawing rubber bands or moving outlines, since drawing twice reverts to the original colour.

Reimplemented in wxSVGFileDC.

void wxDC::SetMapMode | ( | wxMappingMode | mode | ) |

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

void wxDC::SetPalette | ( | const wxPalette & | 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 wxNullPalette, the current palette is selected out of the device context, and the original palette restored.

See also:
  wxPalette

Reimplemented in wxSVGFileDC.

void wxDC::SetPen | ( | const wxPen & | pen | ) |

Sets the current pen for the DC.

If the argument is wxNullPen (or another invalid pen; see wxPen::IsOk), 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 also:
  wxMemoryDC for the interpretation of colours when drawing into a monochrome bitmap.

void wxDC::SetTextBackground | ( | const wxColour & | colour | ) |

Sets the current text background colour for the DC.

void wxDC::SetTextForeground | ( | const wxColour & | colour | ) |

Sets the current text foreground colour for the DC.

See also:
  wxMemoryDC for the interpretation of colours when drawing into a monochrome bitmap.

bool wxDC::SetTransformMatrix | ( | const wxAffineMatrix2D & | matrix | ) |

Set the transformation matrix.

If transformation matrix is supported on the current system, the specified matrix will be used to transform between wxDC and physical coordinates. Otherwise the function returns false and doesn't change the coordinate mapping.

Since:
  2.9.2

void wxDC::SetUserScale | ( | double | xScale,
|  | double | yScale |
| ) |  |  |

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

bool wxDC::StartDoc | ( | const wxString & | message | ) |

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

message is a message to show while printing.

Reimplemented in wxSVGFileDC.

void wxDC::StartPage | ( |  | ) |

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

bool wxDC::StretchBlit | ( | wxCoord | xdest,
|  | wxCoord | ydest,
|  | wxCoord | dstWidth,
|  | wxCoord | dstHeight,
|  | wxDC * | source,
|  | wxCoord | xsrc,
|  | wxCoord | ysrc,
|  | wxCoord | srcWidth,
|  | wxCoord | srcHeight,
|  | wxRasterOperationMode | logicalFunc = `wxCOPY`,
|  | bool | useMask = `false`,
|  | wxCoord | xsrcMask = `wxDefaultCoord`,
|  | wxCoord | ysrcMask = `wxDefaultCoord` |
| ) |  |  |

Copy from a source DC to this DC, specifying the destination coordinates, destination size, source DC, source coordinates, size of source area to copy, logical function, whether to use a bitmap mask, and mask source position.

Parameters:

  | xdest | Destination device context x position.
  | ydest | Destination device context y position.
  | dstWidth | Width of destination area.
  | dstHeight | Height of destination area.
  | source | Source device context.
  | xsrc | Source device context x position.
  | ysrc | Source device context y position.
  | srcWidth | Width of source area to be copied.
  | srcHeight | Height of source area to be copied.
  | logicalFunc | Logical function to use, see SetLogicalFunction().

  useMask

  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.
  Note: on Windows, blitting with masks can be speeded up considerably by compiling wxWidgets with the wxUSE_DC_CACHEING option enabled. You can also influence whether MaskBlt or the explicit mask blitting code above is used, by using wxSystemOptions and setting the `no-maskblt` option to 1.

  | xsrcMask | Source x position on the mask. If both xsrcMask and ysrcMask are wxDefaultCoord, xsrc and ysrc will be assumed for the mask source position. Currently only implemented on Windows.
  | ysrcMask | Source y position on the mask. If both xsrcMask and ysrcMask are wxDefaultCoord, xsrc and ysrc will be assumed for the mask source position. Currently only implemented on Windows.

There is partial support for Blit() in wxPostScriptDC, under X.

StretchBlit() is only implemented under wxMAC and wxMSW.

See wxMemoryDC for typical usage.

Since:
  2.9.0

See also:
  Blit(), wxMemoryDC, wxBitmap, wxMask

|  | [ top ]