X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/66160760e1b333dd73f4c32cb6549bbc0461b67e..1afe8c83072c52d957db8a9877ca28011258ecac:/src/msw/font.cpp?ds=sidebyside diff --git a/src/msw/font.cpp b/src/msw/font.cpp index 8023ed0e3d..ed8728be50 100644 --- a/src/msw/font.cpp +++ b/src/msw/font.cpp @@ -116,9 +116,9 @@ public: wxFontRefData(int size, const wxSize& pixelSize, bool sizeUsingPixels, - int family, - int style, - int weight, + wxFontFamily family, + wxFontStyle style, + wxFontWeight weight, bool underlined, const wxString& faceName, wxFontEncoding encoding) @@ -171,18 +171,18 @@ public: return m_nativeFontInfoOk ? true : m_sizeUsingPixels; } - int GetFamily() const + wxFontFamily GetFamily() const { return m_family; } - int GetStyle() const + wxFontStyle GetStyle() const { return m_nativeFontInfoOk ? m_nativeFontInfo.GetStyle() : m_style; } - int GetWeight() const + wxFontWeight GetWeight() const { return m_nativeFontInfoOk ? m_nativeFontInfo.GetWeight() : m_weight; @@ -214,7 +214,7 @@ public: WXHFONT GetHFONT(const wxFont *font) const { if ( !m_hFont ) - wx_const_cast(wxFontRefData *, this)->Alloc(font); + const_cast(this)->Alloc(font); return (WXHFONT)m_hFont; } @@ -257,14 +257,14 @@ public: } } - void SetFamily(int family) + void SetFamily(wxFontFamily family) { Free(); m_family = family; } - void SetStyle(int style) + void SetStyle(wxFontStyle style) { Free(); @@ -274,7 +274,7 @@ public: m_style = style; } - void SetWeight(int weight) + void SetWeight(wxFontWeight weight) { Free(); @@ -334,9 +334,9 @@ protected: void Init(int size, const wxSize& pixelSize, bool sizeUsingPixels, - int family, - int style, - int weight, + wxFontFamily family, + wxFontStyle style, + wxFontWeight weight, bool underlined, const wxString& faceName, wxFontEncoding encoding); @@ -347,9 +347,9 @@ protected: int m_pointSize; wxSize m_pixelSize; bool m_sizeUsingPixels; - int m_family; - int m_style; - int m_weight; + wxFontFamily m_family; + wxFontStyle m_style; + wxFontWeight m_weight; bool m_underlined; wxString m_faceName; wxFontEncoding m_encoding; @@ -375,9 +375,9 @@ protected: void wxFontRefData::Init(int pointSize, const wxSize& pixelSize, bool sizeUsingPixels, - int family, - int style, - int weight, + wxFontFamily family, + wxFontStyle style, + wxFontWeight weight, bool underlined, const wxString& faceName, wxFontEncoding encoding) @@ -410,7 +410,7 @@ void wxFontRefData::Init(const wxNativeFontInfo& info, WXHFONT hFont) m_nativeFontInfo = info; // This is the best we can do since we don't have the // correct information at this point. - m_family = wxSWISS; + m_family = wxFONTFAMILY_SWISS; } wxFontRefData::~wxFontRefData() @@ -476,13 +476,14 @@ int wxNativeFontInfo::GetPointSize() const // for printing! const int ppInch = ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY); - return (int) (((72.0*(double)abs(lf.lfHeight)) / (double) ppInch) + 0.5); + // BC++ 2007 doesn't provide abs(long) overload, hence the cast + return (int) (((72.0*abs((int)lf.lfHeight)) / (double) ppInch) + 0.5); } wxSize wxNativeFontInfo::GetPixelSize() const { wxSize ret; - ret.SetHeight(lf.lfHeight); + ret.SetHeight(abs((int)lf.lfHeight)); ret.SetWidth(lf.lfWidth); return ret; } @@ -617,9 +618,7 @@ void wxNativeFontInfo::SetUnderlined(bool underlined) bool wxNativeFontInfo::SetFaceName(const wxString& facename) { - size_t len = WXSIZEOF(lf.lfFaceName); - wxStrncpy(lf.lfFaceName, facename, len); - lf.lfFaceName[len - 1] = '\0'; // truncate the face name + wxStrlcpy(lf.lfFaceName, facename.c_str(), WXSIZEOF(lf.lfFaceName)); return true; } @@ -863,9 +862,9 @@ wxFont::wxFont(const wxString& fontdesc) bool wxFont::DoCreate(int pointSize, const wxSize& pixelSize, bool sizeUsingPixels, - int family, - int style, - int weight, + wxFontFamily family, + wxFontStyle style, + wxFontWeight weight, bool underlined, const wxString& faceName, wxFontEncoding encoding) @@ -894,14 +893,14 @@ wxFont::~wxFont() // real implementation // ---------------------------------------------------------------------------- -wxObjectRefData *wxFont::CreateRefData() const +wxGDIRefData *wxFont::CreateGDIRefData() const { return new wxFontRefData(); } -wxObjectRefData *wxFont::CloneRefData(const wxObjectRefData *data) const +wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const { - return new wxFontRefData(*wx_static_cast(const wxFontRefData *, data)); + return new wxFontRefData(*static_cast(data)); } bool wxFont::RealizeResource() @@ -957,21 +956,21 @@ void wxFont::SetPixelSize(const wxSize& pixelSize) M_FONTDATA->SetPixelSize(pixelSize); } -void wxFont::SetFamily(int family) +void wxFont::SetFamily(wxFontFamily family) { AllocExclusive(); M_FONTDATA->SetFamily(family); } -void wxFont::SetStyle(int style) +void wxFont::SetStyle(wxFontStyle style) { AllocExclusive(); M_FONTDATA->SetStyle(style); } -void wxFont::SetWeight(int weight) +void wxFont::SetWeight(wxFontWeight weight) { AllocExclusive(); @@ -1041,23 +1040,23 @@ bool wxFont::IsUsingSizeInPixels() const return M_FONTDATA->IsUsingSizeInPixels(); } -int wxFont::GetFamily() const +wxFontFamily wxFont::GetFamily() const { - wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); + wxCHECK_MSG( Ok(), wxFONTFAMILY_MAX, wxT("invalid font") ); return M_FONTDATA->GetFamily(); } -int wxFont::GetStyle() const +wxFontStyle wxFont::GetStyle() const { - wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); + wxCHECK_MSG( Ok(), wxFONTSTYLE_MAX, wxT("invalid font") ); return M_FONTDATA->GetStyle(); } -int wxFont::GetWeight() const +wxFontWeight wxFont::GetWeight() const { - wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); + wxCHECK_MSG( Ok(), wxFONTWEIGHT_MAX, wxT("invalid font") ); return M_FONTDATA->GetWeight(); }