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;
|
||||
wxFontFamily GetFamily() const;
|
||||
virtual wxFontStyle GetStyle() const = 0;
|
||||
virtual wxFontWeight GetWeight() const = 0;
|
||||
virtual int GetNumericWeight() const = 0;
|
||||
virtual bool GetUnderlined() const = 0;
|
||||
virtual bool GetStrikethrough() const { return false; }
|
||||
@@ -360,6 +359,9 @@ public:
|
||||
virtual wxFontEncoding GetEncoding() 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;
|
||||
|
||||
wxString GetNativeFontInfoDesc() const;
|
||||
@@ -370,7 +372,6 @@ public:
|
||||
virtual void SetPixelSize( const wxSize& pixelSize );
|
||||
virtual void SetFamily( wxFontFamily family ) = 0;
|
||||
virtual void SetStyle( wxFontStyle style ) = 0;
|
||||
virtual void SetWeight( wxFontWeight weight ) = 0;
|
||||
virtual void SetNumericWeight( int weight ) = 0;
|
||||
|
||||
virtual void SetUnderlined( bool underlined ) = 0;
|
||||
@@ -380,6 +381,10 @@ public:
|
||||
void SetNativeFontInfo(const wxNativeFontInfo& 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 SetNativeFontInfoUserDesc(const wxString& info);
|
||||
|
||||
@@ -413,6 +418,14 @@ public:
|
||||
wxDEPRECATED_INLINE(bool GetNoAntiAliasing() const, return false;)
|
||||
#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
|
||||
wxDEPRECATED_MSG("use wxFONT{FAMILY,STYLE,WEIGHT}_XXX constants")
|
||||
static wxFont *New(
|
||||
@@ -500,18 +513,12 @@ WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxFontBase* font);
|
||||
wxDEPRECATED_MSG("use wxFONTSTYLE_XXX constants") \
|
||||
void SetStyle(int style) \
|
||||
{ SetStyle((wxFontStyle)style); } \
|
||||
wxDEPRECATED_MSG("use wxFONTWEIGHT_XXX constants") \
|
||||
void SetWeight(int weight) \
|
||||
{ SetWeight((wxFontWeight)weight); } \
|
||||
wxDEPRECATED_MSG("use wxFONTFAMILY_XXX constants") \
|
||||
void SetFamily(wxDeprecatedGUIConstants family) \
|
||||
{ SetFamily((wxFontFamily)family); } \
|
||||
wxDEPRECATED_MSG("use wxFONTSTYLE_XXX constants") \
|
||||
void SetStyle(wxDeprecatedGUIConstants style) \
|
||||
{ SetStyle((wxFontStyle)style); } \
|
||||
wxDEPRECATED_MSG("use wxFONTWEIGHT_XXX constants") \
|
||||
void SetWeight(wxDeprecatedGUIConstants weight) \
|
||||
{ SetWeight((wxFontWeight)weight); } \
|
||||
\
|
||||
/* functions for modifying font in place */ \
|
||||
wxFont& MakeBold(); \
|
||||
|
@@ -66,7 +66,6 @@ public:
|
||||
// implement base class pure virtuals
|
||||
virtual float GetFractionalPointSize() const wxOVERRIDE;
|
||||
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
||||
virtual wxFontWeight GetWeight() const wxOVERRIDE;
|
||||
virtual int GetNumericWeight() const wxOVERRIDE;
|
||||
virtual wxString GetFaceName() const wxOVERRIDE;
|
||||
virtual bool GetUnderlined() const wxOVERRIDE;
|
||||
@@ -78,7 +77,6 @@ public:
|
||||
virtual void SetPointSize(float pointSize) wxOVERRIDE;
|
||||
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
||||
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
||||
virtual void SetWeight(wxFontWeight weight) wxOVERRIDE;
|
||||
virtual void SetNumericWeight(int weight) wxOVERRIDE;
|
||||
virtual bool SetFaceName( const wxString& faceName ) wxOVERRIDE;
|
||||
virtual void SetUnderlined( bool underlined ) wxOVERRIDE;
|
||||
|
@@ -89,7 +89,6 @@ public:
|
||||
virtual wxSize GetPixelSize() const wxOVERRIDE;
|
||||
virtual bool IsUsingSizeInPixels() const wxOVERRIDE;
|
||||
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
||||
virtual wxFontWeight GetWeight() const wxOVERRIDE;
|
||||
virtual int GetNumericWeight() const wxOVERRIDE;
|
||||
virtual bool GetUnderlined() const wxOVERRIDE;
|
||||
virtual bool GetStrikethrough() const wxOVERRIDE;
|
||||
@@ -101,7 +100,6 @@ public:
|
||||
virtual void SetPixelSize(const wxSize& pixelSize) wxOVERRIDE;
|
||||
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
||||
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
||||
virtual void SetWeight(wxFontWeight weight) wxOVERRIDE;
|
||||
virtual void SetNumericWeight(int weight) wxOVERRIDE;
|
||||
virtual bool SetFaceName(const wxString& faceName) wxOVERRIDE;
|
||||
virtual void SetUnderlined(bool underlined) wxOVERRIDE;
|
||||
|
@@ -122,7 +122,6 @@ public:
|
||||
virtual float GetFractionalPointSize() const wxOVERRIDE;
|
||||
virtual wxSize GetPixelSize() const wxOVERRIDE;
|
||||
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
||||
virtual wxFontWeight GetWeight() const wxOVERRIDE;
|
||||
virtual int GetNumericWeight() const wxOVERRIDE;
|
||||
virtual bool GetUnderlined() const wxOVERRIDE;
|
||||
virtual bool GetStrikethrough() const wxOVERRIDE;
|
||||
@@ -135,7 +134,6 @@ public:
|
||||
virtual void SetPointSize(float pointSize) wxOVERRIDE;
|
||||
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
||||
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
||||
virtual void SetWeight(wxFontWeight weight) wxOVERRIDE;
|
||||
virtual void SetNumericWeight(int weight) wxOVERRIDE;
|
||||
virtual bool SetFaceName(const wxString& faceName) wxOVERRIDE;
|
||||
virtual void SetUnderlined(bool underlined) wxOVERRIDE;
|
||||
|
@@ -294,6 +294,13 @@ wxSize wxFontBase::GetPixelSize() const
|
||||
return wxSize(dc.GetCharWidth(), dc.GetCharHeight());
|
||||
}
|
||||
|
||||
wxFontWeight wxFontBase::GetWeight() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, "invalid font" );
|
||||
|
||||
return GetWeightClosestToNumericValue(GetNumericWeight());
|
||||
}
|
||||
|
||||
bool wxFontBase::IsUsingSizeInPixels() const
|
||||
{
|
||||
return false;
|
||||
@@ -362,6 +369,11 @@ void wxFontBase::SetPixelSize( const wxSize& pixelSize )
|
||||
SetPointSize(largestGood);
|
||||
}
|
||||
|
||||
void wxFontBase::SetWeight(wxFontWeight weight)
|
||||
{
|
||||
SetNumericWeight(GetNumericWeightOf(weight));
|
||||
}
|
||||
|
||||
void wxFontBase::DoSetNativeFontInfo(const wxNativeFontInfo& info)
|
||||
{
|
||||
#ifdef wxNO_NATIVE_FONTINFO
|
||||
|
@@ -372,13 +372,6 @@ wxFontStyle wxFont::GetStyle() const
|
||||
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
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, "invalid font" );
|
||||
@@ -447,13 +440,6 @@ void wxFont::SetStyle(wxFontStyle style)
|
||||
M_FONTDATA->SetStyle(style);
|
||||
}
|
||||
|
||||
void wxFont::SetWeight(wxFontWeight weight)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->SetWeight(weight);
|
||||
}
|
||||
|
||||
void wxFont::SetNumericWeight(int weight)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
@@ -123,11 +123,6 @@ public:
|
||||
return m_nativeFontInfo.GetStyle();
|
||||
}
|
||||
|
||||
wxFontWeight GetWeight() const
|
||||
{
|
||||
return m_nativeFontInfo.GetWeight();
|
||||
}
|
||||
|
||||
int GetNumericWeight() const
|
||||
{
|
||||
return m_nativeFontInfo.GetNumericWeight();
|
||||
@@ -214,13 +209,6 @@ public:
|
||||
m_nativeFontInfo.SetStyle(style);
|
||||
}
|
||||
|
||||
void SetWeight(wxFontWeight weight)
|
||||
{
|
||||
Free();
|
||||
|
||||
m_nativeFontInfo.SetWeight(weight);
|
||||
}
|
||||
|
||||
void SetNumericWeight(int weight)
|
||||
{
|
||||
Free();
|
||||
@@ -374,7 +362,7 @@ void wxFontRefData::Init(int pointSize,
|
||||
SetPointSize(pointSize == -1 ? wxNORMAL_FONT->GetPointSize() : pointSize);
|
||||
|
||||
SetStyle(style);
|
||||
SetWeight(weight);
|
||||
m_nativeFontInfo.SetWeight(weight);
|
||||
SetUnderlined(underlined);
|
||||
SetStrikethrough(strikethrough);
|
||||
|
||||
@@ -929,13 +917,6 @@ void wxFont::SetStyle(wxFontStyle style)
|
||||
M_FONTDATA->SetStyle(style);
|
||||
}
|
||||
|
||||
void wxFont::SetWeight(wxFontWeight weight)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->SetWeight(weight);
|
||||
}
|
||||
|
||||
void wxFont::SetNumericWeight(int weight)
|
||||
{
|
||||
AllocExclusive();
|
||||
@@ -1025,13 +1006,6 @@ wxFontStyle wxFont::GetStyle() const
|
||||
return M_FONTDATA->GetStyle();
|
||||
}
|
||||
|
||||
wxFontWeight wxFont::GetWeight() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, "invalid font" );
|
||||
|
||||
return M_FONTDATA->GetWeight();
|
||||
}
|
||||
|
||||
int wxFont::GetNumericWeight() const
|
||||
{
|
||||
wxCHECK_MSG(IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font"));
|
||||
|
@@ -72,8 +72,6 @@ public:
|
||||
|
||||
wxFontStyle GetStyle() const { return m_info.GetStyle(); }
|
||||
|
||||
wxFontWeight GetWeight() const { return m_info.GetWeight(); }
|
||||
|
||||
int GetNumericWeight() const { return m_info.GetNumericWeight(); }
|
||||
|
||||
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)
|
||||
{
|
||||
if (m_info.GetNumericWeight() != weight)
|
||||
@@ -312,7 +301,7 @@ void wxFontRefData::Init(float size,
|
||||
else
|
||||
SetFamily(family);
|
||||
SetPointSize(size < 0 ? wxNORMAL_FONT->GetFractionalPointSize() : size);
|
||||
SetWeight(weight);
|
||||
SetNumericWeight(weight);
|
||||
SetStyle(style);
|
||||
SetUnderlined(underlined);
|
||||
SetStrikethrough(strikethrough);
|
||||
@@ -651,13 +640,6 @@ void wxFont::SetStyle(wxFontStyle style)
|
||||
M_FONTDATA->SetStyle(style);
|
||||
}
|
||||
|
||||
void wxFont::SetWeight(wxFontWeight weight)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->SetWeight(weight);
|
||||
}
|
||||
|
||||
void wxFont::SetNumericWeight(int weight)
|
||||
{
|
||||
AllocExclusive();
|
||||
@@ -738,13 +720,6 @@ wxFontStyle wxFont::GetStyle() const
|
||||
return M_FONTDATA->GetStyle();
|
||||
}
|
||||
|
||||
wxFontWeight wxFont::GetWeight() const
|
||||
{
|
||||
wxCHECK_MSG(IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font"));
|
||||
|
||||
return M_FONTDATA->GetWeight();
|
||||
}
|
||||
|
||||
int wxFont::GetNumericWeight() const
|
||||
{
|
||||
wxCHECK_MSG(IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font"));
|
||||
|
Reference in New Issue
Block a user