Move {Get,Set}Weight() implementations to wxFontBase
Implement these methods in the base class in terms of {Get,Set}NumericWeight() in order to avoid having to do it for each platform. No real changes.
This commit is contained in:
@@ -352,7 +352,6 @@ public:
|
|||||||
virtual bool IsUsingSizeInPixels() const;
|
virtual bool IsUsingSizeInPixels() const;
|
||||||
wxFontFamily GetFamily() const;
|
wxFontFamily GetFamily() const;
|
||||||
virtual wxFontStyle GetStyle() const = 0;
|
virtual wxFontStyle GetStyle() const = 0;
|
||||||
virtual wxFontWeight GetWeight() const = 0;
|
|
||||||
virtual int GetNumericWeight() const = 0;
|
virtual int GetNumericWeight() const = 0;
|
||||||
virtual bool GetUnderlined() const = 0;
|
virtual bool GetUnderlined() const = 0;
|
||||||
virtual bool GetStrikethrough() const { return false; }
|
virtual bool GetStrikethrough() const { return false; }
|
||||||
@@ -360,6 +359,9 @@ public:
|
|||||||
virtual wxFontEncoding GetEncoding() const = 0;
|
virtual wxFontEncoding GetEncoding() const = 0;
|
||||||
virtual const wxNativeFontInfo *GetNativeFontInfo() const = 0;
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const = 0;
|
||||||
|
|
||||||
|
// Accessors that can be overridden in the platform-specific code but for
|
||||||
|
// which we provide a reasonable default implementation in the base class.
|
||||||
|
virtual wxFontWeight GetWeight() const;
|
||||||
virtual bool IsFixedWidth() const;
|
virtual bool IsFixedWidth() const;
|
||||||
|
|
||||||
wxString GetNativeFontInfoDesc() const;
|
wxString GetNativeFontInfoDesc() const;
|
||||||
@@ -370,7 +372,6 @@ public:
|
|||||||
virtual void SetPixelSize( const wxSize& pixelSize );
|
virtual void SetPixelSize( const wxSize& pixelSize );
|
||||||
virtual void SetFamily( wxFontFamily family ) = 0;
|
virtual void SetFamily( wxFontFamily family ) = 0;
|
||||||
virtual void SetStyle( wxFontStyle style ) = 0;
|
virtual void SetStyle( wxFontStyle style ) = 0;
|
||||||
virtual void SetWeight( wxFontWeight weight ) = 0;
|
|
||||||
virtual void SetNumericWeight( int weight ) = 0;
|
virtual void SetNumericWeight( int weight ) = 0;
|
||||||
|
|
||||||
virtual void SetUnderlined( bool underlined ) = 0;
|
virtual void SetUnderlined( bool underlined ) = 0;
|
||||||
@@ -380,6 +381,10 @@ public:
|
|||||||
void SetNativeFontInfo(const wxNativeFontInfo& info)
|
void SetNativeFontInfo(const wxNativeFontInfo& info)
|
||||||
{ DoSetNativeFontInfo(info); }
|
{ DoSetNativeFontInfo(info); }
|
||||||
|
|
||||||
|
// Similarly to the accessors above, the functions in this group have a
|
||||||
|
// reasonable default implementation in the base class.
|
||||||
|
virtual void SetWeight( wxFontWeight weight );
|
||||||
|
|
||||||
bool SetNativeFontInfo(const wxString& info);
|
bool SetNativeFontInfo(const wxString& info);
|
||||||
bool SetNativeFontInfoUserDesc(const wxString& info);
|
bool SetNativeFontInfoUserDesc(const wxString& info);
|
||||||
|
|
||||||
@@ -413,6 +418,14 @@ public:
|
|||||||
wxDEPRECATED_INLINE(bool GetNoAntiAliasing() const, return false;)
|
wxDEPRECATED_INLINE(bool GetNoAntiAliasing() const, return false;)
|
||||||
#endif // WXWIN_COMPATIBILITY_2_8
|
#endif // WXWIN_COMPATIBILITY_2_8
|
||||||
|
|
||||||
|
wxDEPRECATED_MSG("use wxFONTWEIGHT_XXX constants instead of raw values")
|
||||||
|
void SetWeight(int weight)
|
||||||
|
{ SetWeight(static_cast<wxFontWeight>(weight)); }
|
||||||
|
|
||||||
|
wxDEPRECATED_MSG("use wxFONTWEIGHT_XXX constants instead of wxLIGHT/wxNORMAL/wxBOLD")
|
||||||
|
void SetWeight(wxDeprecatedGUIConstants weight)
|
||||||
|
{ SetWeight(static_cast<wxFontWeight>(weight)); }
|
||||||
|
|
||||||
// from the font components
|
// from the font components
|
||||||
wxDEPRECATED_MSG("use wxFONT{FAMILY,STYLE,WEIGHT}_XXX constants")
|
wxDEPRECATED_MSG("use wxFONT{FAMILY,STYLE,WEIGHT}_XXX constants")
|
||||||
static wxFont *New(
|
static wxFont *New(
|
||||||
@@ -500,18 +513,12 @@ WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxFontBase* font);
|
|||||||
wxDEPRECATED_MSG("use wxFONTSTYLE_XXX constants") \
|
wxDEPRECATED_MSG("use wxFONTSTYLE_XXX constants") \
|
||||||
void SetStyle(int style) \
|
void SetStyle(int style) \
|
||||||
{ SetStyle((wxFontStyle)style); } \
|
{ SetStyle((wxFontStyle)style); } \
|
||||||
wxDEPRECATED_MSG("use wxFONTWEIGHT_XXX constants") \
|
|
||||||
void SetWeight(int weight) \
|
|
||||||
{ SetWeight((wxFontWeight)weight); } \
|
|
||||||
wxDEPRECATED_MSG("use wxFONTFAMILY_XXX constants") \
|
wxDEPRECATED_MSG("use wxFONTFAMILY_XXX constants") \
|
||||||
void SetFamily(wxDeprecatedGUIConstants family) \
|
void SetFamily(wxDeprecatedGUIConstants family) \
|
||||||
{ SetFamily((wxFontFamily)family); } \
|
{ SetFamily((wxFontFamily)family); } \
|
||||||
wxDEPRECATED_MSG("use wxFONTSTYLE_XXX constants") \
|
wxDEPRECATED_MSG("use wxFONTSTYLE_XXX constants") \
|
||||||
void SetStyle(wxDeprecatedGUIConstants style) \
|
void SetStyle(wxDeprecatedGUIConstants style) \
|
||||||
{ SetStyle((wxFontStyle)style); } \
|
{ SetStyle((wxFontStyle)style); } \
|
||||||
wxDEPRECATED_MSG("use wxFONTWEIGHT_XXX constants") \
|
|
||||||
void SetWeight(wxDeprecatedGUIConstants weight) \
|
|
||||||
{ SetWeight((wxFontWeight)weight); } \
|
|
||||||
\
|
\
|
||||||
/* functions for modifying font in place */ \
|
/* functions for modifying font in place */ \
|
||||||
wxFont& MakeBold(); \
|
wxFont& MakeBold(); \
|
||||||
|
@@ -66,7 +66,6 @@ public:
|
|||||||
// implement base class pure virtuals
|
// implement base class pure virtuals
|
||||||
virtual float GetFractionalPointSize() const wxOVERRIDE;
|
virtual float GetFractionalPointSize() const wxOVERRIDE;
|
||||||
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
||||||
virtual wxFontWeight GetWeight() const wxOVERRIDE;
|
|
||||||
virtual int GetNumericWeight() const wxOVERRIDE;
|
virtual int GetNumericWeight() const wxOVERRIDE;
|
||||||
virtual wxString GetFaceName() const wxOVERRIDE;
|
virtual wxString GetFaceName() const wxOVERRIDE;
|
||||||
virtual bool GetUnderlined() const wxOVERRIDE;
|
virtual bool GetUnderlined() const wxOVERRIDE;
|
||||||
@@ -78,7 +77,6 @@ public:
|
|||||||
virtual void SetPointSize(float pointSize) wxOVERRIDE;
|
virtual void SetPointSize(float pointSize) wxOVERRIDE;
|
||||||
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
||||||
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
||||||
virtual void SetWeight(wxFontWeight weight) wxOVERRIDE;
|
|
||||||
virtual void SetNumericWeight(int weight) wxOVERRIDE;
|
virtual void SetNumericWeight(int weight) wxOVERRIDE;
|
||||||
virtual bool SetFaceName( const wxString& faceName ) wxOVERRIDE;
|
virtual bool SetFaceName( const wxString& faceName ) wxOVERRIDE;
|
||||||
virtual void SetUnderlined( bool underlined ) wxOVERRIDE;
|
virtual void SetUnderlined( bool underlined ) wxOVERRIDE;
|
||||||
|
@@ -89,7 +89,6 @@ public:
|
|||||||
virtual wxSize GetPixelSize() const wxOVERRIDE;
|
virtual wxSize GetPixelSize() const wxOVERRIDE;
|
||||||
virtual bool IsUsingSizeInPixels() const wxOVERRIDE;
|
virtual bool IsUsingSizeInPixels() const wxOVERRIDE;
|
||||||
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
||||||
virtual wxFontWeight GetWeight() const wxOVERRIDE;
|
|
||||||
virtual int GetNumericWeight() const wxOVERRIDE;
|
virtual int GetNumericWeight() const wxOVERRIDE;
|
||||||
virtual bool GetUnderlined() const wxOVERRIDE;
|
virtual bool GetUnderlined() const wxOVERRIDE;
|
||||||
virtual bool GetStrikethrough() const wxOVERRIDE;
|
virtual bool GetStrikethrough() const wxOVERRIDE;
|
||||||
@@ -101,7 +100,6 @@ public:
|
|||||||
virtual void SetPixelSize(const wxSize& pixelSize) wxOVERRIDE;
|
virtual void SetPixelSize(const wxSize& pixelSize) wxOVERRIDE;
|
||||||
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
||||||
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
||||||
virtual void SetWeight(wxFontWeight weight) wxOVERRIDE;
|
|
||||||
virtual void SetNumericWeight(int weight) wxOVERRIDE;
|
virtual void SetNumericWeight(int weight) wxOVERRIDE;
|
||||||
virtual bool SetFaceName(const wxString& faceName) wxOVERRIDE;
|
virtual bool SetFaceName(const wxString& faceName) wxOVERRIDE;
|
||||||
virtual void SetUnderlined(bool underlined) wxOVERRIDE;
|
virtual void SetUnderlined(bool underlined) wxOVERRIDE;
|
||||||
|
@@ -122,7 +122,6 @@ public:
|
|||||||
virtual float GetFractionalPointSize() const wxOVERRIDE;
|
virtual float GetFractionalPointSize() const wxOVERRIDE;
|
||||||
virtual wxSize GetPixelSize() const wxOVERRIDE;
|
virtual wxSize GetPixelSize() const wxOVERRIDE;
|
||||||
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
||||||
virtual wxFontWeight GetWeight() const wxOVERRIDE;
|
|
||||||
virtual int GetNumericWeight() const wxOVERRIDE;
|
virtual int GetNumericWeight() const wxOVERRIDE;
|
||||||
virtual bool GetUnderlined() const wxOVERRIDE;
|
virtual bool GetUnderlined() const wxOVERRIDE;
|
||||||
virtual bool GetStrikethrough() const wxOVERRIDE;
|
virtual bool GetStrikethrough() const wxOVERRIDE;
|
||||||
@@ -135,7 +134,6 @@ public:
|
|||||||
virtual void SetPointSize(float pointSize) wxOVERRIDE;
|
virtual void SetPointSize(float pointSize) wxOVERRIDE;
|
||||||
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
||||||
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
||||||
virtual void SetWeight(wxFontWeight weight) wxOVERRIDE;
|
|
||||||
virtual void SetNumericWeight(int weight) wxOVERRIDE;
|
virtual void SetNumericWeight(int weight) wxOVERRIDE;
|
||||||
virtual bool SetFaceName(const wxString& faceName) wxOVERRIDE;
|
virtual bool SetFaceName(const wxString& faceName) wxOVERRIDE;
|
||||||
virtual void SetUnderlined(bool underlined) wxOVERRIDE;
|
virtual void SetUnderlined(bool underlined) wxOVERRIDE;
|
||||||
|
@@ -294,6 +294,13 @@ wxSize wxFontBase::GetPixelSize() const
|
|||||||
return wxSize(dc.GetCharWidth(), dc.GetCharHeight());
|
return wxSize(dc.GetCharWidth(), dc.GetCharHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxFontWeight wxFontBase::GetWeight() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, "invalid font" );
|
||||||
|
|
||||||
|
return GetWeightClosestToNumericValue(GetNumericWeight());
|
||||||
|
}
|
||||||
|
|
||||||
bool wxFontBase::IsUsingSizeInPixels() const
|
bool wxFontBase::IsUsingSizeInPixels() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -362,6 +369,11 @@ void wxFontBase::SetPixelSize( const wxSize& pixelSize )
|
|||||||
SetPointSize(largestGood);
|
SetPointSize(largestGood);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxFontBase::SetWeight(wxFontWeight weight)
|
||||||
|
{
|
||||||
|
SetNumericWeight(GetNumericWeightOf(weight));
|
||||||
|
}
|
||||||
|
|
||||||
void wxFontBase::DoSetNativeFontInfo(const wxNativeFontInfo& info)
|
void wxFontBase::DoSetNativeFontInfo(const wxNativeFontInfo& info)
|
||||||
{
|
{
|
||||||
#ifdef wxNO_NATIVE_FONTINFO
|
#ifdef wxNO_NATIVE_FONTINFO
|
||||||
|
@@ -372,13 +372,6 @@ wxFontStyle wxFont::GetStyle() const
|
|||||||
return M_FONTDATA->m_nativeFontInfo.GetStyle();
|
return M_FONTDATA->m_nativeFontInfo.GetStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFontWeight wxFont::GetWeight() const
|
|
||||||
{
|
|
||||||
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, "invalid font" );
|
|
||||||
|
|
||||||
return M_FONTDATA->m_nativeFontInfo.GetWeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxFont::GetNumericWeight() const
|
int wxFont::GetNumericWeight() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, "invalid font" );
|
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, "invalid font" );
|
||||||
@@ -447,13 +440,6 @@ void wxFont::SetStyle(wxFontStyle style)
|
|||||||
M_FONTDATA->SetStyle(style);
|
M_FONTDATA->SetStyle(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFont::SetWeight(wxFontWeight weight)
|
|
||||||
{
|
|
||||||
AllocExclusive();
|
|
||||||
|
|
||||||
M_FONTDATA->SetWeight(weight);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxFont::SetNumericWeight(int weight)
|
void wxFont::SetNumericWeight(int weight)
|
||||||
{
|
{
|
||||||
AllocExclusive();
|
AllocExclusive();
|
||||||
|
@@ -123,11 +123,6 @@ public:
|
|||||||
return m_nativeFontInfo.GetStyle();
|
return m_nativeFontInfo.GetStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFontWeight GetWeight() const
|
|
||||||
{
|
|
||||||
return m_nativeFontInfo.GetWeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
int GetNumericWeight() const
|
int GetNumericWeight() const
|
||||||
{
|
{
|
||||||
return m_nativeFontInfo.GetNumericWeight();
|
return m_nativeFontInfo.GetNumericWeight();
|
||||||
@@ -214,13 +209,6 @@ public:
|
|||||||
m_nativeFontInfo.SetStyle(style);
|
m_nativeFontInfo.SetStyle(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetWeight(wxFontWeight weight)
|
|
||||||
{
|
|
||||||
Free();
|
|
||||||
|
|
||||||
m_nativeFontInfo.SetWeight(weight);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetNumericWeight(int weight)
|
void SetNumericWeight(int weight)
|
||||||
{
|
{
|
||||||
Free();
|
Free();
|
||||||
@@ -374,7 +362,7 @@ void wxFontRefData::Init(int pointSize,
|
|||||||
SetPointSize(pointSize == -1 ? wxNORMAL_FONT->GetPointSize() : pointSize);
|
SetPointSize(pointSize == -1 ? wxNORMAL_FONT->GetPointSize() : pointSize);
|
||||||
|
|
||||||
SetStyle(style);
|
SetStyle(style);
|
||||||
SetWeight(weight);
|
m_nativeFontInfo.SetWeight(weight);
|
||||||
SetUnderlined(underlined);
|
SetUnderlined(underlined);
|
||||||
SetStrikethrough(strikethrough);
|
SetStrikethrough(strikethrough);
|
||||||
|
|
||||||
@@ -929,13 +917,6 @@ void wxFont::SetStyle(wxFontStyle style)
|
|||||||
M_FONTDATA->SetStyle(style);
|
M_FONTDATA->SetStyle(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFont::SetWeight(wxFontWeight weight)
|
|
||||||
{
|
|
||||||
AllocExclusive();
|
|
||||||
|
|
||||||
M_FONTDATA->SetWeight(weight);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxFont::SetNumericWeight(int weight)
|
void wxFont::SetNumericWeight(int weight)
|
||||||
{
|
{
|
||||||
AllocExclusive();
|
AllocExclusive();
|
||||||
@@ -1025,13 +1006,6 @@ wxFontStyle wxFont::GetStyle() const
|
|||||||
return M_FONTDATA->GetStyle();
|
return M_FONTDATA->GetStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFontWeight wxFont::GetWeight() const
|
|
||||||
{
|
|
||||||
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, "invalid font" );
|
|
||||||
|
|
||||||
return M_FONTDATA->GetWeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxFont::GetNumericWeight() const
|
int wxFont::GetNumericWeight() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG(IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font"));
|
wxCHECK_MSG(IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font"));
|
||||||
|
@@ -72,8 +72,6 @@ public:
|
|||||||
|
|
||||||
wxFontStyle GetStyle() const { return m_info.GetStyle(); }
|
wxFontStyle GetStyle() const { return m_info.GetStyle(); }
|
||||||
|
|
||||||
wxFontWeight GetWeight() const { return m_info.GetWeight(); }
|
|
||||||
|
|
||||||
int GetNumericWeight() const { return m_info.GetNumericWeight(); }
|
int GetNumericWeight() const { return m_info.GetNumericWeight(); }
|
||||||
|
|
||||||
bool GetUnderlined() const { return m_info.GetUnderlined(); }
|
bool GetUnderlined() const { return m_info.GetUnderlined(); }
|
||||||
@@ -121,15 +119,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetWeight(wxFontWeight weight)
|
|
||||||
{
|
|
||||||
if (m_info.GetWeight() != weight)
|
|
||||||
{
|
|
||||||
m_info.SetWeight(weight);
|
|
||||||
Free();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetNumericWeight(int weight)
|
void SetNumericWeight(int weight)
|
||||||
{
|
{
|
||||||
if (m_info.GetNumericWeight() != weight)
|
if (m_info.GetNumericWeight() != weight)
|
||||||
@@ -312,7 +301,7 @@ void wxFontRefData::Init(float size,
|
|||||||
else
|
else
|
||||||
SetFamily(family);
|
SetFamily(family);
|
||||||
SetPointSize(size < 0 ? wxNORMAL_FONT->GetFractionalPointSize() : size);
|
SetPointSize(size < 0 ? wxNORMAL_FONT->GetFractionalPointSize() : size);
|
||||||
SetWeight(weight);
|
SetNumericWeight(weight);
|
||||||
SetStyle(style);
|
SetStyle(style);
|
||||||
SetUnderlined(underlined);
|
SetUnderlined(underlined);
|
||||||
SetStrikethrough(strikethrough);
|
SetStrikethrough(strikethrough);
|
||||||
@@ -651,13 +640,6 @@ void wxFont::SetStyle(wxFontStyle style)
|
|||||||
M_FONTDATA->SetStyle(style);
|
M_FONTDATA->SetStyle(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFont::SetWeight(wxFontWeight weight)
|
|
||||||
{
|
|
||||||
AllocExclusive();
|
|
||||||
|
|
||||||
M_FONTDATA->SetWeight(weight);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxFont::SetNumericWeight(int weight)
|
void wxFont::SetNumericWeight(int weight)
|
||||||
{
|
{
|
||||||
AllocExclusive();
|
AllocExclusive();
|
||||||
@@ -738,13 +720,6 @@ wxFontStyle wxFont::GetStyle() const
|
|||||||
return M_FONTDATA->GetStyle();
|
return M_FONTDATA->GetStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFontWeight wxFont::GetWeight() const
|
|
||||||
{
|
|
||||||
wxCHECK_MSG(IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font"));
|
|
||||||
|
|
||||||
return M_FONTDATA->GetWeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxFont::GetNumericWeight() const
|
int wxFont::GetNumericWeight() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG(IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font"));
|
wxCHECK_MSG(IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font"));
|
||||||
|
Reference in New Issue
Block a user