Add wxFontInfo::Weight()
Also add not yet used wxFontInfo::GetNumericWeight().
This commit is contained in:
@@ -96,7 +96,7 @@ enum wxFontFlag
|
||||
wxFONTFLAG_ITALIC = 1 << 0,
|
||||
wxFONTFLAG_SLANT = 1 << 1,
|
||||
|
||||
// weight flags (default: medium)
|
||||
// weight flags (default: medium):
|
||||
wxFONTFLAG_LIGHT = 1 << 2,
|
||||
wxFONTFLAG_BOLD = 1 << 3,
|
||||
|
||||
@@ -153,10 +153,12 @@ public:
|
||||
wxFontInfo& FaceName(const wxString& faceName)
|
||||
{ m_faceName = faceName; return *this; }
|
||||
|
||||
wxFontInfo& Weight(int weight)
|
||||
{ m_weight = weight; return *this; }
|
||||
wxFontInfo& Bold(bool bold = true)
|
||||
{ SetFlag(wxFONTFLAG_BOLD, bold); return *this; }
|
||||
{ return Weight(bold ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL); }
|
||||
wxFontInfo& Light(bool light = true)
|
||||
{ SetFlag(wxFONTFLAG_LIGHT, light); return *this; }
|
||||
{ return Weight(light ? wxFONTWEIGHT_LIGHT : wxFONTWEIGHT_NORMAL); }
|
||||
|
||||
wxFontInfo& Italic(bool italic = true)
|
||||
{ SetFlag(wxFONTFLAG_ITALIC, italic); return *this; }
|
||||
@@ -176,7 +178,17 @@ public:
|
||||
|
||||
// Set all flags at once.
|
||||
wxFontInfo& AllFlags(int flags)
|
||||
{ m_flags = flags; return *this; }
|
||||
{
|
||||
m_flags = flags;
|
||||
|
||||
m_weight = m_flags & wxFONTFLAG_BOLD
|
||||
? wxFONTWEIGHT_BOLD
|
||||
: m_flags & wxFONTFLAG_LIGHT
|
||||
? wxFONTWEIGHT_LIGHT
|
||||
: wxFONTWEIGHT_NORMAL;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// Accessors are mostly meant to be used by wxFont itself to extract the
|
||||
@@ -198,13 +210,14 @@ public:
|
||||
: wxFONTSTYLE_NORMAL;
|
||||
}
|
||||
|
||||
int GetNumericWeight() const
|
||||
{
|
||||
return m_weight;
|
||||
}
|
||||
|
||||
wxFontWeight GetWeight() const
|
||||
{
|
||||
return m_flags & wxFONTFLAG_LIGHT
|
||||
? wxFONTWEIGHT_LIGHT
|
||||
: m_flags & wxFONTFLAG_BOLD
|
||||
? wxFONTWEIGHT_BOLD
|
||||
: wxFONTWEIGHT_NORMAL;
|
||||
return GetWeightClosestToNumericValue(m_weight);
|
||||
}
|
||||
|
||||
bool IsAntiAliased() const
|
||||
@@ -273,6 +286,7 @@ private:
|
||||
m_pointSize = -1;
|
||||
m_family = wxFONTFAMILY_DEFAULT;
|
||||
m_flags = wxFONTFLAG_DEFAULT;
|
||||
m_weight = wxFONTWEIGHT_NORMAL;
|
||||
m_encoding = wxFONTENCODING_DEFAULT;
|
||||
}
|
||||
|
||||
@@ -303,6 +317,7 @@ private:
|
||||
wxFontFamily m_family;
|
||||
wxString m_faceName;
|
||||
int m_flags;
|
||||
int m_weight;
|
||||
wxFontEncoding m_encoding;
|
||||
};
|
||||
|
||||
|
@@ -363,9 +363,24 @@ public:
|
||||
*/
|
||||
wxFontInfo& FaceName(const wxString& faceName);
|
||||
|
||||
/**
|
||||
Specify the weight of the font.
|
||||
|
||||
@param weight
|
||||
A font weight in the range from 1 to 1000, inclusive, with 1 being
|
||||
the thinnest and 1000 the heaviest possible font variant.
|
||||
@c wxFONTWEIGHT_XXX values from wxFontWeight enum can be used here.
|
||||
|
||||
@since 3.1.2
|
||||
*/
|
||||
wxFontInfo& Weight(int weight);
|
||||
|
||||
/**
|
||||
Use a bold version of the font.
|
||||
|
||||
This is a wrapper for Weight() calling it with ::wxFONTWEIGHT_BOLD
|
||||
argument.
|
||||
|
||||
@see ::wxFontWeight, wxFont::SetWeight()
|
||||
*/
|
||||
wxFontInfo& Bold(bool bold = true);
|
||||
@@ -373,6 +388,9 @@ public:
|
||||
/**
|
||||
Use a lighter version of the font.
|
||||
|
||||
This is a wrapper for Weight() calling it with ::wxFONTWEIGHT_LIGHT
|
||||
argument.
|
||||
|
||||
@see ::wxFontWeight, wxFont::SetWeight()
|
||||
*/
|
||||
wxFontInfo& Light(bool light = true);
|
||||
@@ -426,6 +444,11 @@ public:
|
||||
Set all the font attributes at once.
|
||||
|
||||
See ::wxFontFlag for the various flags that can be used.
|
||||
|
||||
Note that calling this method affects the font weight stored in this
|
||||
object: it is set to ::wxFONTWEIGHT_LIGHT or ::wxFONTWEIGHT_BOLD if the
|
||||
corresponding flag is present in @a flags, or ::wxFONTWEIGHT_NORMAL
|
||||
otherwise.
|
||||
*/
|
||||
wxFontInfo& AllFlags(int flags);
|
||||
|
||||
|
Reference in New Issue
Block a user