Added wxDCFontChanger ctor not changing font.
This is similar to the existing wxDCTextColourChanger ctor not changing colour and is useful in the same kind of situations: when the font may or not be changed. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62382 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1377,8 +1377,21 @@ private:
|
|||||||
class WXDLLIMPEXP_CORE wxDCFontChanger
|
class WXDLLIMPEXP_CORE wxDCFontChanger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxDCFontChanger(wxDC& dc, const wxFont& font) : m_dc(dc), m_fontOld(dc.GetFont())
|
wxDCFontChanger(wxDC& dc)
|
||||||
|
: m_dc(dc), m_fontOld()
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDCFontChanger(wxDC& dc, const wxFont& font)
|
||||||
|
: m_dc(dc), m_fontOld(dc.GetFont())
|
||||||
|
{
|
||||||
|
m_dc.SetFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set(const wxFont& font)
|
||||||
|
{
|
||||||
|
if ( !m_fontOld.Ok() )
|
||||||
|
m_fontOld = m_dc.GetFont();
|
||||||
m_dc.SetFont(font);
|
m_dc.SetFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1493,6 +1493,18 @@ public:
|
|||||||
class wxDCFontChanger
|
class wxDCFontChanger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
Trivial constructor not changing anything.
|
||||||
|
|
||||||
|
This constructor is useful if you don't know beforehand if the font
|
||||||
|
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 font.
|
||||||
|
|
||||||
|
@since 2.9.1
|
||||||
|
*/
|
||||||
|
wxDCFontChanger(wxDC& dc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets @a font on the given @a dc, storing the old one.
|
Sets @a font on the given @a dc, storing the old one.
|
||||||
|
|
||||||
@@ -1504,7 +1516,18 @@ public:
|
|||||||
wxDCFontChanger(wxDC& dc, const wxFont& font);
|
wxDCFontChanger(wxDC& dc, const wxFont& font);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Restores the colour originally selected in the DC passed to the ctor.
|
Set the font 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 font to
|
||||||
|
the given @a font and ensures that the old value is restored when this
|
||||||
|
object is destroyed.
|
||||||
|
*/
|
||||||
|
void Set(const wxFont& font);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Restores the font originally selected in the DC passed to the ctor.
|
||||||
*/
|
*/
|
||||||
~wxDCFontChanger();
|
~wxDCFontChanger();
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user