wxFont::MakeXXX() and Scale() methods now modify the font in place; XXX() and Scaled() create new font
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61099 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -356,7 +356,7 @@ All (GUI):
|
||||
- Added wxMouseEventsManager.
|
||||
- Building OpenGL library is now enabled by default.
|
||||
- Improve wxTreeCtrl::ScrollTo() in generic version (Raanan Barzel).
|
||||
- Added wxFont::Make{Bold,Italic,Smaller,Larger} and Scale() methods.
|
||||
- Added wxFont::[Make]{Bold,Italic,Smaller,Larger} and Scale[d]() methods.
|
||||
- Added wxDC::CopyAttributes() and use it in wxBufferedDC.
|
||||
- Added wxTextWrapper helper class useful for wrapping lines of text.
|
||||
|
||||
|
@@ -297,12 +297,18 @@ WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxFontBase* font);
|
||||
#define wxDECLARE_COMMON_FONT_METHODS() \
|
||||
wxDECLARE_FONT_COMPAT_SETTER \
|
||||
\
|
||||
/* functions for modifying font in place */ \
|
||||
wxFont& MakeBold(); \
|
||||
wxFont& MakeItalic(); \
|
||||
wxFont& MakeLarger() { return Scale(1.2f); } \
|
||||
wxFont& MakeSmaller() { return Scale(1/1.2f); } \
|
||||
wxFont& Scale(float x); \
|
||||
/* functions for creating fonts based on this one */ \
|
||||
wxFont MakeBold() const; \
|
||||
wxFont MakeItalic() const; \
|
||||
wxFont MakeLarger() const { return Scale(1.2f); } \
|
||||
wxFont MakeSmaller() const { return Scale(1/1.2f); } \
|
||||
wxFont Scale(float x) const
|
||||
wxFont Bold() const; \
|
||||
wxFont Italic() const; \
|
||||
wxFont Larger() const { return Scaled(1.2f); } \
|
||||
wxFont Smaller() const { return Scaled(1/1.2f); } \
|
||||
wxFont Scaled(float x) const
|
||||
|
||||
// include the real class declaration
|
||||
#if defined(__WXPALMOS__)
|
||||
|
@@ -526,20 +526,29 @@ public:
|
||||
/**
|
||||
@name Similar fonts creation
|
||||
|
||||
The functions in this section create a font similar to the given one
|
||||
but with its weight, style or size changed.
|
||||
The functions in this section either modify the font in place or create
|
||||
a new font similar to the given one but with its weight, style or size
|
||||
changed.
|
||||
*/
|
||||
//@{
|
||||
|
||||
/**
|
||||
Return a bold version of this font.
|
||||
|
||||
@see MakeBold()
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
wxFont MakeBold() const;
|
||||
wxFont Bold() const;
|
||||
|
||||
/**
|
||||
Return an italic version of this font.
|
||||
|
||||
@see MakeItalic()
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
wxFont MakeItalic() const;
|
||||
wxFont Italic() const;
|
||||
|
||||
/**
|
||||
Return a larger version of this font.
|
||||
@@ -547,9 +556,41 @@ public:
|
||||
The font size is multiplied by CSS specification inspired factor of @c
|
||||
1.2.
|
||||
|
||||
@see MakeSmaller(), Scale()
|
||||
@see Larger(), MakeSmaller(), Scale()
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
wxFont MakeLarger() const;
|
||||
wxFont Larger() const;
|
||||
|
||||
/**
|
||||
Changes this font to be bold.
|
||||
|
||||
@see Bold()
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
wxFont& MakeBold();
|
||||
|
||||
/**
|
||||
Changes this font to be italic.
|
||||
|
||||
@see Italic()
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
wxFont& MakeItalic();
|
||||
|
||||
/**
|
||||
Changes this font to be larger.
|
||||
|
||||
The font size is multiplied by CSS specification inspired factor of @c
|
||||
1.2.
|
||||
|
||||
@see Larger(), MakeSmaller(), Scale()
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
wxFont& MakeLarger();
|
||||
|
||||
/**
|
||||
Return a smaller version of this font.
|
||||
@@ -557,17 +598,47 @@ public:
|
||||
The font size is divided by CSS specification inspired factor of @c
|
||||
1.2.
|
||||
|
||||
@see MakeLarger(), Scale()
|
||||
@see MakeLarger(), Scale(), Smaller()
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
wxFont MakeSmaller() const;
|
||||
wxFont& MakeSmaller();
|
||||
|
||||
/**
|
||||
Changes the size of this font.
|
||||
|
||||
The font size is multiplied by the given factor (which may be less than
|
||||
1 to create a smaller version of the font).
|
||||
|
||||
@see Scaled(), MakeLarger(), MakeSmaller()
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
wxFont& Scale(float x);
|
||||
|
||||
/**
|
||||
Return a scaled version of this font.
|
||||
|
||||
The font size is multiplied by the given factor (which may be less than
|
||||
1 to create a smaller version of the font).
|
||||
|
||||
@see Scale(), Larger(), Smaller()
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
wxFont Scale(float x) const;
|
||||
wxFont Scaled(float x) const;
|
||||
|
||||
/**
|
||||
Return a smaller version of this font.
|
||||
|
||||
The font size is divided by CSS specification inspired factor of @c
|
||||
1.2.
|
||||
|
||||
@see Larger(), MakeSmaller(), Scaled()
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
wxFont Smaller() const;
|
||||
|
||||
//@}
|
||||
|
||||
|
@@ -421,24 +421,42 @@ bool wxFontBase::SetFaceName(const wxString& facename)
|
||||
return true;
|
||||
}
|
||||
|
||||
wxFont wxFont::MakeBold() const
|
||||
wxFont& wxFont::MakeBold()
|
||||
{
|
||||
SetWeight(wxFONTWEIGHT_BOLD);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxFont wxFont::Bold() const
|
||||
{
|
||||
wxFont font(*this);
|
||||
font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
font.MakeBold();
|
||||
return font;
|
||||
}
|
||||
|
||||
wxFont wxFont::MakeItalic() const
|
||||
wxFont& wxFont::MakeItalic()
|
||||
{
|
||||
SetStyle(wxFONTSTYLE_ITALIC);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxFont wxFont::Italic() const
|
||||
{
|
||||
wxFont font(*this);
|
||||
font.SetStyle(wxFONTSTYLE_ITALIC);
|
||||
return font;
|
||||
}
|
||||
|
||||
wxFont wxFont::Scale(float x) const
|
||||
wxFont& wxFont::Scale(float x)
|
||||
{
|
||||
SetPointSize(int(x*GetPointSize() + 0.5));
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxFont wxFont::Scaled(float x) const
|
||||
{
|
||||
wxFont font(*this);
|
||||
font.SetPointSize(int(x*GetPointSize() + 0.5));
|
||||
font.Scale(x);
|
||||
return font;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user