Add wxFont::SetFractionalPointSize()

Changing SetPointSize() argument type from int to float wasn't 100%
backwards-compatible as it notably started resulting in warnings (from
at least MSVC) about conversions from int to float in the existing code.

To avoid these warnings and for symmetry with GetFractionalPointSize(),
add SetFractionalPointSize() taking float argument and preserve the
argument of type int in SetPointSize() for compatibility.

SetPointSize() is now just a wrapper forwarding to the more general
SetFractionalPointSize().

Notice that the other ports still remain broken, this commit only
updates the currently working wxGTK, wxMac and wxMSW.
This commit is contained in:
Vadim Zeitlin
2018-09-06 01:40:47 +02:00
parent e05a732666
commit c98879e379
9 changed files with 52 additions and 26 deletions

View File

@@ -92,7 +92,7 @@ public:
const wxNativeFontInfo& GetNativeFontInfo() const;
void SetPointSize(float size)
void SetFractionalPointSize(float size)
{
if (GetFractionalPointSize() != size)
{
@@ -300,7 +300,8 @@ void wxFontRefData::Init(float size,
SetFaceName(faceName);
else
SetFamily(family);
SetPointSize(size < 0 ? wxNORMAL_FONT->GetFractionalPointSize() : size);
SetFractionalPointSize(size < 0 ? wxNORMAL_FONT->GetFractionalPointSize() : size);
SetNumericWeight(weight);
SetStyle(style);
SetUnderlined(underlined);
@@ -613,14 +614,11 @@ wxGDIRefData* wxFont::CloneGDIRefData(const wxGDIRefData* data) const
return new wxFontRefData(*static_cast<const wxFontRefData*>(data));
}
void wxFont::SetPointSize(float pointSize)
void wxFont::SetFractionalPointSize(float pointSize)
{
if (IsOk() && M_FONTDATA->GetFractionalPointSize() == pointSize)
return;
AllocExclusive();
M_FONTDATA->SetPointSize(pointSize);
M_FONTDATA->SetFractionalPointSize(pointSize);
}
void wxFont::SetFamily(wxFontFamily family)