Add wxFont ctor taking a single flags argument instead of style/weight/...
Currently this ctor just does the same thing as the existing ctors in a different way but it will be extended to support wxFONTFLAG_STRIKETHROUGH in the next commits. See #9907. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70445 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -75,6 +75,19 @@ public:
|
||||
SetPixelSize(pixelSize);
|
||||
}
|
||||
|
||||
wxFont(int pointSize,
|
||||
wxFontFamily family,
|
||||
int flags = wxFONTFLAG_DEFAULT,
|
||||
const wxString& face = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
||||
{
|
||||
Create(pointSize, family,
|
||||
GetStyleFromFlags(flags),
|
||||
GetWeightFromFlags(flags),
|
||||
GetUnderlinedFromFlags(flags),
|
||||
face, encoding);
|
||||
}
|
||||
|
||||
/*! @abstract Construction with opaque wxNativeFontInfo
|
||||
*/
|
||||
wxFont(const wxNativeFontInfo& info)
|
||||
|
@@ -60,6 +60,19 @@ public:
|
||||
SetPixelSize(pixelSize);
|
||||
}
|
||||
|
||||
wxFont(int pointSize,
|
||||
wxFontFamily family,
|
||||
int flags = wxFONTFLAG_DEFAULT,
|
||||
const wxString& face = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
||||
{
|
||||
Create(pointSize, family,
|
||||
GetStyleFromFlags(flags),
|
||||
GetWeightFromFlags(flags),
|
||||
GetUnderlinedFromFlags(flags),
|
||||
face, encoding);
|
||||
}
|
||||
|
||||
bool Create(int size,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
|
@@ -290,6 +290,33 @@ protected:
|
||||
// wxFONTFAMILY_UNKNOWN unlike the public method (see comment there).
|
||||
virtual wxFontFamily DoGetFamily() const = 0;
|
||||
|
||||
|
||||
// Helper functions to recover wxFONTSTYLE/wxFONTWEIGHT and underlined flg
|
||||
// values from flags containing a combination of wxFONTFLAG_XXX.
|
||||
static wxFontStyle GetStyleFromFlags(int flags)
|
||||
{
|
||||
return flags & wxFONTFLAG_ITALIC
|
||||
? wxFONTSTYLE_ITALIC
|
||||
: flags & wxFONTFLAG_SLANT
|
||||
? wxFONTSTYLE_SLANT
|
||||
: wxFONTSTYLE_NORMAL;
|
||||
}
|
||||
|
||||
static wxFontWeight GetWeightFromFlags(int flags)
|
||||
{
|
||||
return flags & wxFONTFLAG_LIGHT
|
||||
? wxFONTWEIGHT_LIGHT
|
||||
: flags & wxFONTFLAG_BOLD
|
||||
? wxFONTWEIGHT_BOLD
|
||||
: wxFONTWEIGHT_NORMAL;
|
||||
}
|
||||
|
||||
static bool GetUnderlinedFromFlags(int flags)
|
||||
{
|
||||
return (flags & wxFONTFLAG_UNDERLINED) != 0;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
// the currently default encoding: by default, it's the default system
|
||||
// encoding, but may be changed by the application using
|
||||
|
@@ -63,6 +63,12 @@ public:
|
||||
SetPixelSize(pixelSize);
|
||||
}
|
||||
|
||||
wxFont(int pointSize,
|
||||
wxFontFamily family,
|
||||
int flags = wxFONTFLAG_DEFAULT,
|
||||
const wxString& face = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
||||
|
||||
bool Create(int size,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
|
@@ -76,6 +76,19 @@ public:
|
||||
SetPixelSize(pixelSize);
|
||||
}
|
||||
|
||||
wxFont(int pointSize,
|
||||
wxFontFamily family,
|
||||
int flags = wxFONTFLAG_DEFAULT,
|
||||
const wxString& face = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
||||
{
|
||||
Create(pointSize, family,
|
||||
GetStyleFromFlags(flags),
|
||||
GetWeightFromFlags(flags),
|
||||
GetUnderlinedFromFlags(flags),
|
||||
face, encoding);
|
||||
}
|
||||
|
||||
bool Create(int size,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
|
@@ -66,6 +66,19 @@ public:
|
||||
SetPixelSize(pixelSize);
|
||||
}
|
||||
|
||||
wxFont(int pointSize,
|
||||
wxFontFamily family,
|
||||
int flags = wxFONTFLAG_DEFAULT,
|
||||
const wxString& face = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
||||
{
|
||||
Create(pointSize, family,
|
||||
GetStyleFromFlags(flags),
|
||||
GetWeightFromFlags(flags),
|
||||
GetUnderlinedFromFlags(flags),
|
||||
face, encoding);
|
||||
}
|
||||
|
||||
bool Create(int size,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
|
@@ -91,6 +91,12 @@ public:
|
||||
Create(info, hFont);
|
||||
}
|
||||
|
||||
wxFont(int pointSize,
|
||||
wxFontFamily family,
|
||||
int flags = wxFONTFLAG_DEFAULT,
|
||||
const wxString& face = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
||||
|
||||
wxFont(const wxString& fontDesc);
|
||||
|
||||
|
||||
|
@@ -63,6 +63,19 @@ public:
|
||||
SetPixelSize(pixelSize);
|
||||
}
|
||||
|
||||
wxFont(int pointSize,
|
||||
wxFontFamily family,
|
||||
int flags = wxFONTFLAG_DEFAULT,
|
||||
const wxString& face = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
||||
{
|
||||
Create(pointSize, family,
|
||||
GetStyleFromFlags(flags),
|
||||
GetWeightFromFlags(flags),
|
||||
GetUnderlinedFromFlags(flags),
|
||||
face, encoding);
|
||||
}
|
||||
|
||||
bool Create(int size,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
|
@@ -79,6 +79,19 @@ public:
|
||||
SetPixelSize(pixelSize);
|
||||
}
|
||||
|
||||
wxFont(int pointSize,
|
||||
wxFontFamily family,
|
||||
int flags = wxFONTFLAG_DEFAULT,
|
||||
const wxString& face = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
||||
{
|
||||
Create(pointSize, family,
|
||||
GetStyleFromFlags(flags),
|
||||
GetWeightFromFlags(flags),
|
||||
GetUnderlinedFromFlags(flags),
|
||||
face, encoding);
|
||||
}
|
||||
|
||||
bool Create(int size,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
|
@@ -57,6 +57,19 @@ public:
|
||||
SetPixelSize(pixelSize);
|
||||
}
|
||||
|
||||
wxFont(int pointSize,
|
||||
wxFontFamily family,
|
||||
int flags = wxFONTFLAG_DEFAULT,
|
||||
const wxString& face = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
||||
{
|
||||
Create(pointSize, family,
|
||||
GetStyleFromFlags(flags),
|
||||
GetWeightFromFlags(flags),
|
||||
GetUnderlinedFromFlags(flags),
|
||||
face, encoding);
|
||||
}
|
||||
|
||||
bool Create(int size,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
|
@@ -303,7 +303,7 @@ public:
|
||||
wxFont(const wxFont& font);
|
||||
|
||||
/**
|
||||
Creates a font object with the specified attributes.
|
||||
Creates a font object with the specified attributes and size in points.
|
||||
|
||||
@param pointSize
|
||||
Size in points. See SetPointSize() for more info.
|
||||
@@ -349,7 +349,7 @@ public:
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
||||
|
||||
/**
|
||||
Creates a font object with the specified attributes.
|
||||
Creates a font object with the specified attributes and size in pixels.
|
||||
|
||||
@param pixelSize
|
||||
Size in pixels. See SetPixelSize() for more info.
|
||||
@@ -394,6 +394,22 @@ public:
|
||||
const wxString& faceName = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
||||
|
||||
/**
|
||||
Creates a font object using font flags.
|
||||
|
||||
This constructor is similar to the constructors above except it
|
||||
specifies the font styles such as underlined, italic, bold, ... in a
|
||||
single @a flags argument instead of using separate arguments for them.
|
||||
This parameter can be a combination of ::wxFontFlag enum elements.
|
||||
The meaning of the remaining arguments is the same as in the other
|
||||
constructors, please see their documentation for details.
|
||||
|
||||
@since 2.9.4
|
||||
*/
|
||||
wxFont(int pointSize, wxFontFamily family, int flags,
|
||||
const wxString& faceName = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
||||
|
||||
/**
|
||||
Constructor from font description string.
|
||||
|
||||
|
@@ -128,33 +128,6 @@ wxEMPTY_HANDLERS_TABLE(wxFont)
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// helper functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static inline int flags2Style(int flags)
|
||||
{
|
||||
return flags & wxFONTFLAG_ITALIC
|
||||
? wxFONTSTYLE_ITALIC
|
||||
: flags & wxFONTFLAG_SLANT
|
||||
? wxFONTSTYLE_SLANT
|
||||
: wxFONTSTYLE_NORMAL;
|
||||
}
|
||||
|
||||
static inline int flags2Weight(int flags)
|
||||
{
|
||||
return flags & wxFONTFLAG_LIGHT
|
||||
? wxFONTWEIGHT_LIGHT
|
||||
: flags & wxFONTFLAG_BOLD
|
||||
? wxFONTWEIGHT_BOLD
|
||||
: wxFONTWEIGHT_NORMAL;
|
||||
}
|
||||
|
||||
static inline bool flags2Underlined(int flags)
|
||||
{
|
||||
return (flags & wxFONTFLAG_UNDERLINED) != 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontBase
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -209,8 +182,11 @@ wxFont *wxFontBase::New(int pointSize,
|
||||
const wxString& face,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
return New(pointSize, family, flags2Style(flags), flags2Weight(flags),
|
||||
flags2Underlined(flags), face, encoding);
|
||||
return New(pointSize, family,
|
||||
GetStyleFromFlags(flags),
|
||||
GetWeightFromFlags(flags),
|
||||
GetUnderlinedFromFlags(flags),
|
||||
face, encoding);
|
||||
}
|
||||
|
||||
/* static */
|
||||
@@ -220,8 +196,11 @@ wxFont *wxFontBase::New(const wxSize& pixelSize,
|
||||
const wxString& face,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
return New(pixelSize, family, flags2Style(flags), flags2Weight(flags),
|
||||
flags2Underlined(flags), face, encoding);
|
||||
return New(pixelSize, family,
|
||||
GetStyleFromFlags(flags),
|
||||
GetWeightFromFlags(flags),
|
||||
GetUnderlinedFromFlags(flags),
|
||||
face, encoding);
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@@ -277,6 +277,19 @@ wxFont::wxFont(const wxNativeFontInfo& info)
|
||||
info.GetEncoding() );
|
||||
}
|
||||
|
||||
wxFont::wxFont(int pointSize,
|
||||
wxFontFamily family,
|
||||
int flags,
|
||||
const wxString& face,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
m_refData = new wxFontRefData(pointSize, family,
|
||||
GetStyleFromFlags(flags),
|
||||
GetWeightFromFlags(flags),
|
||||
GetUnderlinedFromFlags(flags),
|
||||
face, encoding);
|
||||
}
|
||||
|
||||
bool wxFont::Create( int pointSize,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
|
@@ -778,6 +778,20 @@ wxFont::wxFont(const wxString& fontdesc)
|
||||
(void)Create(info);
|
||||
}
|
||||
|
||||
wxFont::wxFont(int pointSize,
|
||||
wxFontFamily family,
|
||||
int flags,
|
||||
const wxString& face,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
m_refData = new wxFontRefData(pointSize, wxDefaultSize, false,
|
||||
family,
|
||||
GetStyleFromFlags(flags),
|
||||
GetWeightFromFlags(flags),
|
||||
GetUnderlinedFromFlags(flags),
|
||||
face, encoding);
|
||||
}
|
||||
|
||||
bool wxFont::Create(const wxNativeFontInfo& info, WXHFONT hFont)
|
||||
{
|
||||
UnRef();
|
||||
|
Reference in New Issue
Block a user