Extract ConvertFromLegacyWeightIfNecessary() function
Make it possible to reuse just this part of GetNumericWeightOf() in the upcoming commit.
This commit is contained in:
@@ -491,7 +491,14 @@ public:
|
|||||||
static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; }
|
static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; }
|
||||||
static void SetDefaultEncoding(wxFontEncoding encoding);
|
static void SetDefaultEncoding(wxFontEncoding encoding);
|
||||||
|
|
||||||
// Convert between symbolic and numeric font weights.
|
// Account for legacy font weight values: if the argument is one of
|
||||||
|
// wxNORMAL, wxLIGHT or wxBOLD, return the corresponding wxFONTWEIGHT_XXX
|
||||||
|
// enum value. Otherwise just return it unchanged.
|
||||||
|
static int ConvertFromLegacyWeightIfNecessary(int weight);
|
||||||
|
|
||||||
|
// Convert between symbolic and numeric font weights. This function uses
|
||||||
|
// ConvertFromLegacyWeightIfNecessary(), so takes legacy values into
|
||||||
|
// account as well.
|
||||||
static int GetNumericWeightOf(wxFontWeight weight);
|
static int GetNumericWeightOf(wxFontWeight weight);
|
||||||
|
|
||||||
// this doesn't do anything and is kept for compatibility only
|
// this doesn't do anything and is kept for compatibility only
|
||||||
|
@@ -226,22 +226,22 @@ bool wxFontBase::IsFixedWidth() const
|
|||||||
|
|
||||||
// Convert to/from wxFontWeight enum elements and numeric weight values.
|
// Convert to/from wxFontWeight enum elements and numeric weight values.
|
||||||
|
|
||||||
// This function interprets wxNORMAL, wxLIGHT and wxBOLD values in addition to
|
|
||||||
// the actual wxFontWeight enum element values for compatibility. It does check
|
|
||||||
// that it gets either the one or the other.
|
|
||||||
/* static */
|
/* static */
|
||||||
int wxFontBase::GetNumericWeightOf(wxFontWeight weight)
|
int wxFontBase::ConvertFromLegacyWeightIfNecessary(int weight)
|
||||||
{
|
{
|
||||||
// deal with compatibility constants
|
switch ( weight )
|
||||||
if (weight >= 90 && weight <= 92)
|
|
||||||
{
|
{
|
||||||
if (weight == 90 /* wxNORMAL */)
|
case 90: return wxFONTWEIGHT_NORMAL;
|
||||||
weight = wxFONTWEIGHT_NORMAL;
|
case 91: return wxFONTWEIGHT_LIGHT;
|
||||||
else if (weight == 91 /* wxLIGHT */)
|
case 92: return wxFONTWEIGHT_BOLD;
|
||||||
weight = wxFONTWEIGHT_LIGHT;
|
default: return weight;
|
||||||
else if (weight == 92 /* wxBOLD */)
|
|
||||||
weight = wxFONTWEIGHT_BOLD;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
int wxFontBase::GetNumericWeightOf(wxFontWeight weight_)
|
||||||
|
{
|
||||||
|
const int weight = ConvertFromLegacyWeightIfNecessary(weight_);
|
||||||
|
|
||||||
wxASSERT(weight > wxFONTWEIGHT_INVALID);
|
wxASSERT(weight > wxFONTWEIGHT_INVALID);
|
||||||
wxASSERT(weight <= wxFONTWEIGHT_MAX);
|
wxASSERT(weight <= wxFONTWEIGHT_MAX);
|
||||||
|
Reference in New Issue
Block a user