Move GetWeightClosestToNumericValue() to wxFontInfo too

This is similar to a recent commit which moved float to int point size
conversions to wxFontInfo and is done for the same reasons: wxFont and
wxNativeFontInfo can depend on wxFontInfo, but the converse is not true.

No real changes.
This commit is contained in:
Vadim Zeitlin
2018-09-12 14:46:00 +02:00
parent 0a23e8dfbe
commit ff5766a8fb
4 changed files with 36 additions and 36 deletions

View File

@@ -246,6 +246,27 @@ public:
return f;
}
// Another helper for converting arbitrary numeric weight to the closest
// value of wxFontWeight enum. It should be avoided in the new code (also
// note that the function for the conversion in the other direction is
// trivial and so is not provided, we only have GetNumericWeightOf() which
// contains backwards compatibility hacks, but we don't need it here).
static wxFontWeight GetWeightClosestToNumericValue(int numWeight)
{
wxASSERT(numWeight > 0);
wxASSERT(numWeight <= 1000);
// round to nearest hundredth = wxFONTWEIGHT_ constant
int weight = ((numWeight + 50) / 100) * 100;
if (weight < wxFONTWEIGHT_THIN)
weight = wxFONTWEIGHT_THIN;
if (weight > wxFONTWEIGHT_MAX)
weight = wxFONTWEIGHT_MAX;
return static_cast<wxFontWeight>(weight);
}
private:
void Init()
{
@@ -444,7 +465,6 @@ public:
// Convert between symbolic and numeric font weights.
static int GetNumericWeightOf(wxFontWeight weight);
static wxFontWeight GetWeightClosestToNumericValue(int numWeight);
// this doesn't do anything and is kept for compatibility only
#if WXWIN_COMPATIBILITY_2_8