Change wxFontRefData ctor to take wxFontInfo in wxOSX too
Change wxOSX similarly to wxGTK and wxMSW in the two previous commits.
This commit is contained in:
@@ -36,29 +36,12 @@
|
|||||||
class WXDLLEXPORT wxFontRefData : public wxGDIRefData
|
class WXDLLEXPORT wxFontRefData : public wxGDIRefData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxFontRefData()
|
wxFontRefData(const wxFontInfo& info = wxFontInfo());
|
||||||
{
|
|
||||||
Init(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL,
|
|
||||||
false, false, wxEmptyString, wxFONTENCODING_DEFAULT);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxFontRefData(float size,
|
|
||||||
wxFontFamily family,
|
|
||||||
wxFontStyle style,
|
|
||||||
int weight,
|
|
||||||
bool underlined,
|
|
||||||
bool strikethrough,
|
|
||||||
const wxString& faceName,
|
|
||||||
wxFontEncoding encoding)
|
|
||||||
{
|
|
||||||
Init(size, family, style, weight, underlined, strikethrough, faceName, encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxFontRefData(const wxFontRefData& data);
|
wxFontRefData(const wxFontRefData& data);
|
||||||
|
|
||||||
wxFontRefData(const wxNativeFontInfo& info)
|
wxFontRefData(const wxNativeFontInfo& info)
|
||||||
{
|
{
|
||||||
Init();
|
|
||||||
m_info.Init(info);
|
m_info.Init(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,16 +151,6 @@ public:
|
|||||||
|
|
||||||
void Alloc();
|
void Alloc();
|
||||||
protected:
|
protected:
|
||||||
// common part of all ctors
|
|
||||||
void Init();
|
|
||||||
void Init(float size,
|
|
||||||
wxFontFamily family,
|
|
||||||
wxFontStyle style,
|
|
||||||
int weight,
|
|
||||||
bool underlined,
|
|
||||||
bool strikethrough,
|
|
||||||
const wxString& faceName,
|
|
||||||
wxFontEncoding encoding);
|
|
||||||
void SetFont(CTFontRef font);
|
void SetFont(CTFontRef font);
|
||||||
void AllocIfNeeded() const;
|
void AllocIfNeeded() const;
|
||||||
|
|
||||||
@@ -274,39 +247,28 @@ namespace
|
|||||||
wxFontRefData::wxFontRefData(const wxFontRefData& data)
|
wxFontRefData::wxFontRefData(const wxFontRefData& data)
|
||||||
: wxGDIRefData()
|
: wxGDIRefData()
|
||||||
{
|
{
|
||||||
Init();
|
|
||||||
m_info = data.m_info;
|
m_info = data.m_info;
|
||||||
m_ctFont = data.m_ctFont;
|
m_ctFont = data.m_ctFont;
|
||||||
m_ctFontAttributes = data.m_ctFontAttributes;
|
m_ctFontAttributes = data.m_ctFontAttributes;
|
||||||
m_cgFont = data.m_cgFont;
|
m_cgFont = data.m_cgFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFontRefData::Init()
|
wxFontRefData::wxFontRefData(const wxFontInfo& info)
|
||||||
{
|
{
|
||||||
m_info.Init();
|
m_info.Init();
|
||||||
}
|
|
||||||
|
|
||||||
void wxFontRefData::Init(float size,
|
const wxString& faceName = info.GetFaceName();
|
||||||
wxFontFamily family,
|
|
||||||
wxFontStyle style,
|
|
||||||
int weight,
|
|
||||||
bool underlined,
|
|
||||||
bool strikethrough,
|
|
||||||
const wxString& faceName,
|
|
||||||
wxFontEncoding encoding)
|
|
||||||
{
|
|
||||||
m_info.Init();
|
|
||||||
if ( !faceName.empty() )
|
if ( !faceName.empty() )
|
||||||
SetFaceName(faceName);
|
SetFaceName(faceName);
|
||||||
else
|
else
|
||||||
SetFamily(family);
|
SetFamily(info.GetFamily());
|
||||||
|
|
||||||
m_info.SetSizeOrDefault(size);
|
m_info.SetSizeOrDefault(info.GetFractionalPointSize());
|
||||||
SetNumericWeight(weight);
|
SetNumericWeight(info.GetNumericWeight());
|
||||||
SetStyle(style);
|
SetStyle(info.GetStyle());
|
||||||
SetUnderlined(underlined);
|
SetUnderlined(info.IsUnderlined());
|
||||||
SetStrikethrough(strikethrough);
|
SetStrikethrough(info.IsStrikethrough());
|
||||||
SetEncoding(encoding);
|
SetEncoding(info.GetEncoding());
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFontRefData::~wxFontRefData()
|
wxFontRefData::~wxFontRefData()
|
||||||
@@ -323,7 +285,6 @@ void wxFontRefData::Free()
|
|||||||
|
|
||||||
wxFontRefData::wxFontRefData(CTFontRef font)
|
wxFontRefData::wxFontRefData(CTFontRef font)
|
||||||
{
|
{
|
||||||
Init();
|
|
||||||
SetFont(font);
|
SetFont(font);
|
||||||
m_info.InitFromFont(font);
|
m_info.InitFromFont(font);
|
||||||
}
|
}
|
||||||
@@ -542,17 +503,7 @@ wxFont::wxFont(const wxString& fontdesc)
|
|||||||
|
|
||||||
wxFont::wxFont(const wxFontInfo& info)
|
wxFont::wxFont(const wxFontInfo& info)
|
||||||
{
|
{
|
||||||
m_refData = new wxFontRefData
|
m_refData = new wxFontRefData(info);
|
||||||
(
|
|
||||||
info.GetFractionalPointSize(),
|
|
||||||
info.GetFamily(),
|
|
||||||
info.GetStyle(),
|
|
||||||
info.GetNumericWeight(),
|
|
||||||
info.IsUnderlined(),
|
|
||||||
info.IsStrikethrough(),
|
|
||||||
info.GetFaceName(),
|
|
||||||
info.GetEncoding()
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( info.IsUsingSizeInPixels() )
|
if ( info.IsUsingSizeInPixels() )
|
||||||
SetPixelSize(info.GetPixelSize());
|
SetPixelSize(info.GetPixelSize());
|
||||||
@@ -580,13 +531,13 @@ bool wxFont::Create(int pointSize,
|
|||||||
{
|
{
|
||||||
AccountForCompatValues(pointSize, style, weight);
|
AccountForCompatValues(pointSize, style, weight);
|
||||||
|
|
||||||
m_refData = new wxFontRefData
|
m_refData = new wxFontRefData(wxFontInfo(pointSize).
|
||||||
(
|
Family(family).
|
||||||
wxFontInfo::ToFloatPointSize(pointSize),
|
Style(style).
|
||||||
family, style,
|
Weight(GetNumericWeightOf(weight)).
|
||||||
GetNumericWeightOf(weight),
|
Underlined(underlined).
|
||||||
underlined, false, faceName, encoding
|
FaceName(faceName).
|
||||||
);
|
Encoding(encoding));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user