Change wxFontRefData ctor to take wxFontInfo in wxMSW
Apply the same change as was done for wxGTK in the previous commit to wxMSW too, for the same reasons.
This commit is contained in:
@@ -44,8 +44,10 @@ public:
|
|||||||
const wxString& face = wxEmptyString,
|
const wxString& face = wxEmptyString,
|
||||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
||||||
{
|
{
|
||||||
return DoCreate(size, wxDefaultSize, false, family, style,
|
AccountForCompatValues(size, style, weight);
|
||||||
weight, underlined, face, encoding);
|
|
||||||
|
wxFontInfo info(size);
|
||||||
|
return DoCreate(info, family, style, weight, underlined, face, encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFont(const wxSize& pixelSize,
|
wxFont(const wxSize& pixelSize,
|
||||||
@@ -76,8 +78,8 @@ public:
|
|||||||
const wxString& face = wxEmptyString,
|
const wxString& face = wxEmptyString,
|
||||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
||||||
{
|
{
|
||||||
return DoCreate(-1, pixelSize, true, family, style,
|
wxFontInfo info(pixelSize);
|
||||||
weight, underlined, face, encoding);
|
return DoCreate(info, family, style, weight, underlined, face, encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Create(const wxNativeFontInfo& info, WXHFONT hFont = 0);
|
bool Create(const wxNativeFontInfo& info, WXHFONT hFont = 0);
|
||||||
@@ -147,10 +149,8 @@ public:
|
|||||||
WXHFONT GetHFONT() const;
|
WXHFONT GetHFONT() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// real font creation function, used in all cases
|
// Common helper of overloaded Create() methods.
|
||||||
bool DoCreate(int size,
|
bool DoCreate(wxFontInfo& info,
|
||||||
const wxSize& pixelSize,
|
|
||||||
bool sizeUsingPixels,
|
|
||||||
wxFontFamily family,
|
wxFontFamily family,
|
||||||
wxFontStyle style,
|
wxFontStyle style,
|
||||||
wxFontWeight weight,
|
wxFontWeight weight,
|
||||||
|
@@ -57,28 +57,7 @@ static const int PITCH_MASK = FIXED_PITCH | VARIABLE_PITCH;
|
|||||||
class WXDLLEXPORT wxFontRefData: public wxGDIRefData
|
class WXDLLEXPORT wxFontRefData: public wxGDIRefData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// constructors
|
wxFontRefData(const wxFontInfo& info = wxFontInfo());
|
||||||
wxFontRefData()
|
|
||||||
{
|
|
||||||
Init(-1.0f, wxSize(0,0), false, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
|
|
||||||
wxFONTWEIGHT_NORMAL, false, false, wxEmptyString,
|
|
||||||
wxFONTENCODING_DEFAULT);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxFontRefData(float size,
|
|
||||||
const wxSize& pixelSize,
|
|
||||||
bool sizeUsingPixels,
|
|
||||||
wxFontFamily family,
|
|
||||||
wxFontStyle style,
|
|
||||||
int weight,
|
|
||||||
bool underlined,
|
|
||||||
bool strikethrough,
|
|
||||||
const wxString& faceName,
|
|
||||||
wxFontEncoding encoding)
|
|
||||||
{
|
|
||||||
Init(size, pixelSize, sizeUsingPixels, family, style, weight,
|
|
||||||
underlined, strikethrough, faceName, encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxFontRefData(const wxNativeFontInfo& info, WXHFONT hFont = 0)
|
wxFontRefData(const wxNativeFontInfo& info, WXHFONT hFont = 0)
|
||||||
{
|
{
|
||||||
@@ -266,18 +245,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// common part of all ctors
|
|
||||||
void Init(float size,
|
|
||||||
const wxSize& pixelSize,
|
|
||||||
bool sizeUsingPixels,
|
|
||||||
wxFontFamily family,
|
|
||||||
wxFontStyle style,
|
|
||||||
int weight,
|
|
||||||
bool underlined,
|
|
||||||
bool strikethrough,
|
|
||||||
const wxString& faceName,
|
|
||||||
wxFontEncoding encoding);
|
|
||||||
|
|
||||||
void Init(const wxNativeFontInfo& info, WXHFONT hFont = 0);
|
void Init(const wxNativeFontInfo& info, WXHFONT hFont = 0);
|
||||||
|
|
||||||
void AllocIfNeeded() const
|
void AllocIfNeeded() const
|
||||||
@@ -342,42 +309,33 @@ protected:
|
|||||||
// wxFontRefData
|
// wxFontRefData
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxFontRefData::Init(float pointSize,
|
wxFontRefData::wxFontRefData(const wxFontInfo& info)
|
||||||
const wxSize& pixelSize,
|
|
||||||
bool sizeUsingPixels,
|
|
||||||
wxFontFamily family,
|
|
||||||
wxFontStyle style,
|
|
||||||
int weight,
|
|
||||||
bool underlined,
|
|
||||||
bool strikethrough,
|
|
||||||
const wxString& faceName,
|
|
||||||
wxFontEncoding encoding)
|
|
||||||
{
|
{
|
||||||
m_hFont = NULL;
|
m_hFont = NULL;
|
||||||
|
|
||||||
m_sizeUsingPixels = sizeUsingPixels;
|
m_sizeUsingPixels = info.IsUsingSizeInPixels();
|
||||||
if ( m_sizeUsingPixels )
|
if ( m_sizeUsingPixels )
|
||||||
{
|
{
|
||||||
m_nativeFontInfo.SetPixelSize(pixelSize);
|
m_nativeFontInfo.SetPixelSize(info.GetPixelSize());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_nativeFontInfo.SetSizeOrDefault(pointSize);
|
m_nativeFontInfo.SetSizeOrDefault(info.GetFractionalPointSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
SetStyle(style);
|
SetStyle(info.GetStyle());
|
||||||
SetNumericWeight(weight);
|
SetNumericWeight(info.GetNumericWeight());
|
||||||
SetUnderlined(underlined);
|
SetUnderlined(info.IsUnderlined());
|
||||||
SetStrikethrough(strikethrough);
|
SetStrikethrough(info.IsStrikethrough());
|
||||||
|
|
||||||
// set the family/facename
|
// set the family/facename
|
||||||
SetFamily(family);
|
SetFamily(info.GetFamily());
|
||||||
if ( !faceName.empty() )
|
if ( !info.GetFaceName().empty() )
|
||||||
SetFaceName(faceName);
|
SetFaceName(info.GetFaceName());
|
||||||
|
|
||||||
// deal with encoding now (it may override the font family and facename
|
// deal with encoding now (it may override the font family and facename
|
||||||
// so do it after setting them)
|
// so do it after setting them)
|
||||||
SetEncoding(encoding);
|
SetEncoding(info.GetEncoding());
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFontRefData::Init(const wxNativeFontInfo& info, WXHFONT hFont)
|
void wxFontRefData::Init(const wxNativeFontInfo& info, WXHFONT hFont)
|
||||||
@@ -791,16 +749,7 @@ wxFont::wxFont(const wxString& fontdesc)
|
|||||||
|
|
||||||
wxFont::wxFont(const wxFontInfo& info)
|
wxFont::wxFont(const wxFontInfo& info)
|
||||||
{
|
{
|
||||||
m_refData = new wxFontRefData(info.GetFractionalPointSize(),
|
m_refData = new wxFontRefData(info);
|
||||||
info.GetPixelSize(),
|
|
||||||
info.IsUsingSizeInPixels(),
|
|
||||||
info.GetFamily(),
|
|
||||||
info.GetStyle(),
|
|
||||||
info.GetNumericWeight(),
|
|
||||||
info.IsUnderlined(),
|
|
||||||
info.IsStrikethrough(),
|
|
||||||
info.GetFaceName(),
|
|
||||||
info.GetEncoding());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFont::Create(const wxNativeFontInfo& info, WXHFONT hFont)
|
bool wxFont::Create(const wxNativeFontInfo& info, WXHFONT hFont)
|
||||||
@@ -812,9 +761,7 @@ bool wxFont::Create(const wxNativeFontInfo& info, WXHFONT hFont)
|
|||||||
return RealizeResource();
|
return RealizeResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFont::DoCreate(int pointSize,
|
bool wxFont::DoCreate(wxFontInfo& info,
|
||||||
const wxSize& pixelSize,
|
|
||||||
bool sizeUsingPixels,
|
|
||||||
wxFontFamily family,
|
wxFontFamily family,
|
||||||
wxFontStyle style,
|
wxFontStyle style,
|
||||||
wxFontWeight weight,
|
wxFontWeight weight,
|
||||||
@@ -824,13 +771,13 @@ bool wxFont::DoCreate(int pointSize,
|
|||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
|
|
||||||
AccountForCompatValues(pointSize, style, weight);
|
m_refData = new wxFontRefData(info.
|
||||||
|
Family(family).
|
||||||
m_refData = new wxFontRefData(wxFontInfo::ToFloatPointSize(pointSize),
|
Style(style).
|
||||||
pixelSize, sizeUsingPixels,
|
Weight(GetNumericWeightOf(weight)).
|
||||||
family, style,
|
Underlined(underlined).
|
||||||
GetNumericWeightOf(weight),
|
FaceName(faceName).
|
||||||
underlined, false, faceName, encoding);
|
Encoding(encoding));
|
||||||
|
|
||||||
return RealizeResource();
|
return RealizeResource();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user