Add wxDCTextBgColourChanger and wxDCTextBgModeChanger helpers
These classes are similar to the existing wxDCTextColourChanger and allow temporarily changing other wxDC attributes. Closes https://github.com/wxWidgets/wxWidgets/pull/1298
This commit is contained in:
committed by
Vadim Zeitlin
parent
e41f219131
commit
3674bd1c1f
@@ -1799,7 +1799,7 @@ public:
|
||||
@category{gdi}
|
||||
|
||||
@see wxDC::SetTextForeground(), wxDCFontChanger, wxDCPenChanger, wxDCBrushChanger,
|
||||
wxDCClipper
|
||||
wxDCClipper, wxDCTextBgColourChanger, wxDCBgModeChanger
|
||||
*/
|
||||
class wxDCTextColourChanger
|
||||
{
|
||||
@@ -1842,6 +1842,117 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@class wxDCTextBgColourChanger
|
||||
|
||||
wxDCTextBgColourChanger is a small helper class for setting a background
|
||||
text colour on a wxDC and unsetting it automatically in the destructor,
|
||||
restoring the previous one.
|
||||
|
||||
@library{wxcore}
|
||||
@category{gdi}
|
||||
|
||||
@see wxDC::SetTextBackground(), wxDCFontChanger, wxDCPenChanger, wxDCBrushChanger,
|
||||
wxDCClipper, wxDCTextColourChanger, wxDCBgModeChanger
|
||||
|
||||
@since 3.1.3
|
||||
*/
|
||||
class wxDCTextBgColourChanger
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Trivial constructor not changing anything.
|
||||
|
||||
This constructor is useful if you don't know beforehand if the colour
|
||||
needs to be changed or not. It simply creates the object which won't do
|
||||
anything in its destructor unless Set() is called -- in which case it
|
||||
would reset the previous colour.
|
||||
*/
|
||||
wxDCTextBgColourChanger(wxDC& dc);
|
||||
|
||||
/**
|
||||
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 text background colour to set.
|
||||
*/
|
||||
wxDCTextBgColourChanger(wxDC& dc, const wxColour& col);
|
||||
|
||||
/**
|
||||
Set the background colour to use.
|
||||
|
||||
This method is meant to be called once only and only on the objects
|
||||
created with the constructor overload not taking wxColour argument and
|
||||
has the same effect as the other constructor, i.e. sets the background colour to
|
||||
the given @a col and ensures that the old value is restored when this
|
||||
object is destroyed.
|
||||
*/
|
||||
void Set(const wxColour& col);
|
||||
|
||||
/**
|
||||
Restores the background colour originally selected in the DC passed to the ctor.
|
||||
*/
|
||||
~wxDCTextBgColourChanger();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@class wxDCTextBgModeChanger
|
||||
|
||||
wxDCTextBgModeChanger is a small helper class for setting a background
|
||||
text mode on a wxDC and unsetting it automatically in the destructor,
|
||||
restoring the previous one.
|
||||
|
||||
@library{wxcore}
|
||||
@category{gdi}
|
||||
|
||||
@see wxDC::SetBackgroundMode(), wxDCFontChanger, wxDCPenChanger, wxDCBrushChanger,
|
||||
wxDCClipper, wxDCTextColourChanger, wxDCTextBgColourChanger
|
||||
|
||||
@since 3.1.3
|
||||
*/
|
||||
class wxDCBgModeChanger
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Trivial constructor not changing anything.
|
||||
|
||||
This constructor is useful if you don't know beforehand if the background mode
|
||||
needs to be changed or not. It simply creates the object which won't do
|
||||
anything in its destructor unless Set() is called -- in which case it
|
||||
would reset the previous mode.
|
||||
*/
|
||||
wxDCBgModeChanger(wxDC& dc);
|
||||
|
||||
/**
|
||||
Sets @a mode on the given @a dc, storing the old one.
|
||||
|
||||
@param dc
|
||||
The DC where the mode must be temporary set.
|
||||
@param mode
|
||||
The background mode to set.
|
||||
*/
|
||||
wxDCBgModeChanger(wxDC& dc, int mode);
|
||||
|
||||
/**
|
||||
Set the text background mode to use.
|
||||
|
||||
This method is meant to be called once only and only on the objects
|
||||
created with the constructor overload not taking mode argument and
|
||||
has the same effect as the other constructor, i.e. sets the background mode to
|
||||
the given @a one, and ensures that the old value is restored when this
|
||||
object is destroyed.
|
||||
*/
|
||||
void Set(int mode);
|
||||
|
||||
/**
|
||||
Restores the text background mode originally selected in the DC passed to the ctor.
|
||||
*/
|
||||
~wxDCBgModeChanger();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@class wxDCFontChanger
|
||||
|
Reference in New Issue
Block a user