bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width,
wxCoord height, wxDC* source, wxCoord xsrc, wxCoord ysrc,
int logicalFunc = wxCOPY, bool useMask = false,
- wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
+ wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
/**
Adds the specified point to the bounding box which can be retrieved
*/
void Clear();
- /**
- Performs all necessary computations for given platform and context type
- after each change of scale and origin parameters. Usually called
- automatically internally after such changes.
- */
- virtual void ComputeScaleAndOrigin();
-
/**
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
/**
Convert device X coordinate to logical coordinate, using the current
- mapping mode.
+ mapping mode, user scale factor, device origin and axis orientation.
*/
- virtual wxCoord DeviceToLogicalX(wxCoord x);
+ wxCoord DeviceToLogicalX(wxCoord x) const;
/**
Convert device X coordinate to relative logical coordinate, using the
- current mapping mode but ignoring the x axis orientation. Use this
- function for converting a width, for example.
+ current mapping mode and user scale factor but ignoring the
+ axis orientation. Use this for converting a width, for example.
*/
- virtual wxCoord DeviceToLogicalXRel(wxCoord x);
+ wxCoord DeviceToLogicalXRel(wxCoord x) const;
/**
Converts device Y coordinate to logical coordinate, using the current
- mapping mode.
+ mapping mode, user scale factor, device origin and axis orientation.
*/
- virtual wxCoord DeviceToLogicalY(wxCoord y);
+ wxCoord DeviceToLogicalY(wxCoord y) const;
/**
Convert device Y coordinate to relative logical coordinate, using the
- current mapping mode but ignoring the y axis orientation. Use this
- function for converting a height, for example.
+ current mapping mode and user scale factor but ignoring the
+ axis orientation. Use this for converting a height, for example.
*/
- virtual wxCoord DeviceToLogicalYRel(wxCoord y);
+ wxCoord DeviceToLogicalYRel(wxCoord y) const;
/**
Draws an arc of a circle, centred on (@a xc, @a yc), with starting
@see SetTextForeground(), SetTextBackground(), wxMemoryDC
*/
void DrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y,
- bool transparent);
+ bool useMask = false);
//@{
/**
the string. See GetTextExtent() for how to get the dimensions of a text
string, which can be used to position the text more precisely.
- @note Under wxGTK, the current
- @ref GetLogicalFunction() "logical function" is used by this
- function but it is ignored by wxMSW. Thus, you should avoid using
- logical functions with this function in portable programs.
+ @note The current @ref GetLogicalFunction() "logical function" is
+ ignored by this function.
*/
void DrawText(const wxString& text, wxCoord x, wxCoord y);
@see wxDC::SetBackground()
*/
- const wxBrush GetBackground() const;
+ const wxBrush& GetBackground() const;
/**
Returns the current background mode: @c wxSOLID or @c wxTRANSPARENT.
@see wxDC::SetBrush()
*/
- const wxBrush GetBrush() const;
+ const wxBrush& GetBrush() const;
/**
Gets the character height of the currently set font.
*/
- wxCoord GetCharHeight();
+ wxCoord GetCharHeight() const;
/**
Gets the average character width of the currently set font.
*/
- wxCoord GetCharWidth();
+ wxCoord GetCharWidth() const;
/**
Gets the rectangle surrounding the current clipping region.
are returned as a tuple.
@endWxPythonOnly
*/
- void GetClippingBox(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
+ void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *width, wxCoord *height) const;
/**
Returns the depth (number of bits/pixel) of this DC.
wxNullFont initially and only after calling SetFont() a valid font is
returned.
*/
- const wxFont GetFont() const;
+ const wxFont& GetFont() const;
/**
Gets the current layout direction of the device context. On platforms
@see SetLogicalFunction()
*/
- int GetLogicalFunction();
+ int GetLogicalFunction() const;
/**
Gets the mapping mode for the device context.
@see SetMapMode()
*/
- int GetMapMode();
+ int GetMapMode() const;
/**
Gets the dimensions of the string using the currently selected font.
void GetMultiLineTextExtent(const wxString& string, wxCoord* w,
wxCoord* h,
wxCoord* heightLine = NULL,
- wxFont* font = NULL) const;
+ const wxFont* font = NULL) const;
/**
Gets the dimensions of the string using the currently selected font.
@a string is the text string to measure, @e heightLine, if non @NULL,
@see wxFont, SetFont(), GetPartialTextExtents(), GetTextExtent()
*/
- const wxSize GetMultiLineTextExtent(const wxString& string) const;
+ wxSize GetMultiLineTextExtent(const wxString& string) const;
/**
Fills the @a widths array with the widths from the beginning of @a text
@see SetPen()
*/
- const wxPen GetPen() const;
+ const wxPen& GetPen() const;
/**
Gets in @a colour the colour at the specified location. Not available
The wxColour value is returned and is not required as a parameter.
@endWxPythonOnly
*/
- bool GetPixel(wxCoord x, wxCoord y, wxColour* colour);
+ bool GetPixel(wxCoord x, wxCoord y, wxColour* colour) const;
/**
Returns the resolution of the device in pixels per inch.
@see SetTextBackground()
*/
- const wxColour GetTextBackground() const;
+ const wxColour& GetTextBackground() const;
//@{
/**
@see SetTextForeground()
*/
- const wxColour GetTextForeground() const;
+ const wxColour& GetTextForeground() const;
/**
Gets the current user scale factor.
@see SetUserScale()
*/
- void GetUserScale(double x, double y);
+ void GetUserScale(double* x, double* y) const;
//@{
/**
to use @a initialColour on the left part of the rectangle and
@a destColour on the right one.
*/
- void GradientFillLinear(const wxRect& rect,
- const wxColour& initialColour,
+ void GradientFillLinear(const wxRect& rect, const wxColour& initialColour,
const wxColour& destColour,
- wxDirection nDirection = wxEAST);
+ wxDirection nDirection = wxRIGHT);
/**
Returns @true if the DC is ok to use.
*/
- bool Ok();
+ bool IsOk() const;
/**
Converts logical X coordinate to device coordinate, using the current
- mapping mode.
+ mapping mode, user scale factor, device origin and axis orientation.
*/
- virtual wxCoord LogicalToDeviceX(wxCoord x);
+ wxCoord LogicalToDeviceX(wxCoord x) const;
/**
Converts logical X coordinate to relative device coordinate, using the
- current mapping mode but ignoring the x axis orientation. Use this for
- converting a width, for example.
+ current mapping mode and user scale factor but ignoring the
+ axis orientation. Use this for converting a width, for example.
*/
- virtual wxCoord LogicalToDeviceXRel(wxCoord x);
+ wxCoord LogicalToDeviceXRel(wxCoord x) const;
/**
Converts logical Y coordinate to device coordinate, using the current
- mapping mode.
+ mapping mode, user scale factor, device origin and axis orientation.
*/
- virtual wxCoord LogicalToDeviceY(wxCoord y);
+ wxCoord LogicalToDeviceY(wxCoord y) const;
/**
Converts logical Y coordinate to relative device coordinate, using the
- current mapping mode but ignoring the y axis orientation. Use this for
- converting a height, for example.
+ current mapping mode and user scale factor but ignoring the
+ axis orientation. Use this for converting a height, for example.
*/
- virtual wxCoord LogicalToDeviceYRel(wxCoord y);
+ wxCoord LogicalToDeviceYRel(wxCoord y) const;
/**
Gets the maximum horizontal extent used in drawing commands so far.
*/
- wxCoord MaxX();
+ wxCoord MaxX() const;
/**
Gets the maximum vertical extent used in drawing commands so far.
*/
- wxCoord MaxY();
+ wxCoord MaxY() const;
/**
Gets the minimum horizontal extent used in drawing commands so far.
*/
- wxCoord MinX();
+ wxCoord MinX() const;
/**
Gets the minimum vertical extent used in drawing commands so far.
*/
- wxCoord MinY();
+ wxCoord MinY() const;
/**
Resets the bounding box: after a call to this function, the bounding
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.
The possible values and their meaning in terms of source and
destination pixel values are as follows:
/**
Starts a document page (only relevant when outputting to a printer).
*/
- bool StartPage();
+ void StartPage();
/**
Copy from a source DC to this DC, specifying the destination
setting the @c no-maskblt option to 1.
@param 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.
+ wxDefaultCoord, @a xsrc and @a ysrc will be assumed for the mask
+ source position. Currently only implemented on Windows.
@param 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.
+ wxDefaultCoord, @a xsrc and @a ysrc will be assumed for the mask
+ source position. Currently only implemented on Windows.
There is partial support for Blit() in wxPostScriptDC, under X.
wxCoord srcWidth, wxCoord srcHeight,
int logicalFunc = wxCOPY,
bool useMask = false,
- wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
+ wxCoord xsrcMask = wxDefaultCoord,
+ wxCoord ysrcMask = wxDefaultCoord);
};
wxDCClipper(wxDC& dc, const wxRect& rect);
wxDCClipper(wxDC& dc, int x, int y, int w, int h);
//@}
+
+ /**
+ Destroys the clipping region associated with the DC passed to the ctor.
+ */
+ ~wxDCClipper();
+};
+
+
+/**
+ @class wxDCBrushChanger
+
+ wxDCBrushChanger is a small helper class for setting a brush on a wxDC
+ and unsetting it automatically in the destructor, restoring the previous one.
+
+ @library{wxcore}
+ @category{gdi}
+
+ @see wxDC::SetBrush()
+*/
+class wxDCBrushChanger
+{
+public:
+ /**
+ Sets @a brush on the given @a dc, storing the old one.
+
+ @param dc
+ The DC where the brush must be temporary set.
+ @param brush
+ The brush to set.
+ */
+ wxDCBrushChanger(wxDC& dc, const wxBrush& brush);
+
+ /**
+ Restores the brush originally selected in the DC passed to the ctor.
+ */
+ ~wxDCBrushChanger();
+};
+
+
+/**
+ @class wxDCPenChanger
+
+ wxDCPenChanger is a small helper class for setting a pen on a wxDC
+ and unsetting it automatically in the destructor, restoring the previous one.
+
+ @library{wxcore}
+ @category{gdi}
+
+ @see wxDC::SetPen()
+*/
+class wxDCPenChanger
+{
+public:
+ /**
+ Sets @a pen on the given @a dc, storing the old one.
+
+ @param dc
+ The DC where the pen must be temporary set.
+ @param pen
+ The pen to set.
+ */
+ wxDCPenChanger(wxDC& dc, const wxPen& pen);
+
+ /**
+ Restores the pen originally selected in the DC passed to the ctor.
+ */
+ ~wxDCPenChanger();
+};
+
+
+
+/**
+ @class wxDCTextColourChanger
+
+ wxDCTextColourChanger is a small helper class for setting a foreground
+ text colour on a wxDC and unsetting it automatically in the destructor,
+ restoring the previous one.
+
+ @library{wxcore}
+ @category{gdi}
+
+ @see wxDC::SetTextForeground()
+*/
+class wxDCTextColourChanger
+{
+public:
+ /**
+ Sets @a col on the given @a dc, storing the old one.
+
+ @param dc
+ The DC where the colour must be temporary set.
+ @param col
+ The colour to set.
+ */
+ wxDCTextColourChanger(wxDC& dc, const wxColour& col);
+
+ /**
+ Restores the colour originally selected in the DC passed to the ctor.
+ */
+ ~wxDCTextColourChanger();
+};
+
+
+
+/**
+ @class wxDCFontChanger
+
+ wxDCFontChanger is a small helper class for setting a font on a wxDC and
+ unsetting it automatically in the destructor, restoring the previous one.
+
+ @since 2.9.0
+
+ @library{wxcore}
+ @category{gdi}
+
+ @see wxDC::SetFont()
+*/
+class wxDCFontChanger
+{
+public:
+ /**
+ Sets @a font on the given @a dc, storing the old one.
+
+ @param dc
+ The DC where the font must be temporary set.
+ @param font
+ The font to set.
+ */
+ wxDCFontChanger(wxDC& dc, const wxFont& font);
+
+ /**
+ Restores the colour originally selected in the DC passed to the ctor.
+ */
+ ~wxDCFontChanger();
};