X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/85ab460e7d62b52b105b3dc0bbdd36cebc14fb4b..9a6d14383a57771a334f6d0b6376dd47bf24049d:/src/os2/font.cpp diff --git a/src/os2/font.cpp b/src/os2/font.cpp index 9871769c77..4a97f97c28 100644 --- a/src/os2/font.cpp +++ b/src/os2/font.cpp @@ -20,12 +20,13 @@ // headers // ---------------------------------------------------------------------------- +#include "wx/font.h" + #ifndef WX_PRECOMP #include #include "wx/list.h" #include "wx/utils.h" #include "wx/app.h" - #include "wx/font.h" #include "wx/log.h" #endif // WX_PRECOMP @@ -50,7 +51,7 @@ class WXDLLEXPORT wxFontRefData: public wxGDIRefData public: wxFontRefData() { - Init(-1, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, FALSE, + Init(-1, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString, wxFONTENCODING_DEFAULT); } @@ -296,6 +297,8 @@ protected: bool m_bInternalPS; // Internally generated PS? }; // end of CLASS wxFontRefData +#define M_FONTDATA ((wxFontRefData*)m_refData) + // ============================================================================ // implementation // ============================================================================ @@ -854,7 +857,7 @@ wxString wxNativeFontInfo::ToString() const fa.usCodePage, fa.lMatch, fn.usWeightClass, - fa.szFacename); + (char *)fa.szFacename); return sStr; } // end of wxNativeFontInfo::ToString @@ -928,6 +931,16 @@ wxFont::~wxFont() // here, but we may check that font definition is true // ---------------------------------------------------------------------------- +wxGDIRefData *wxFont::CreateGDIRefData() const +{ + return new wxFontRefData(); +} + +wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const +{ + return new wxFontRefData(*wx_static_cast(const wxFontRefData *, data)); +} + bool wxFont::RealizeResource() { if ( GetResourceHandle() ) @@ -947,7 +960,7 @@ bool wxFont::FreeResource( bool WXUNUSED(bForce) ) return false; } // end of wxFont::FreeResource -WXHANDLE wxFont::GetResourceHandle() +WXHANDLE wxFont::GetResourceHandle() const { return GetHFONT(); } // end of wxFont::GetResourceHandle @@ -962,21 +975,6 @@ bool wxFont::IsFree() const return M_FONTDATA && (M_FONTDATA->GetHFONT() == 0); } // end of wxFont::IsFree -void wxFont::Unshare() -{ - // Don't change shared data - if ( !m_refData ) - { - m_refData = new wxFontRefData(); - } - else - { - wxFontRefData* ref = new wxFontRefData(*M_FONTDATA); - UnRef(); - m_refData = ref; - } -} // end of wxFont::Unshare - // ---------------------------------------------------------------------------- // change font attribute: we recreate font when doing it // ---------------------------------------------------------------------------- @@ -985,7 +983,7 @@ void wxFont::SetPointSize( int nPointSize ) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetPointSize(nPointSize); @@ -996,7 +994,7 @@ void wxFont::SetFamily( int nFamily ) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetFamily(nFamily); @@ -1007,7 +1005,7 @@ void wxFont::SetStyle( int nStyle ) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetStyle(nStyle); @@ -1018,7 +1016,7 @@ void wxFont::SetWeight( int nWeight ) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetWeight(nWeight); @@ -1029,7 +1027,7 @@ bool wxFont::SetFaceName( const wxString& rsFaceName ) { - Unshare(); + AllocExclusive(); bool refdataok = M_FONTDATA->SetFaceName(rsFaceName); @@ -1042,7 +1040,7 @@ void wxFont::SetUnderlined( bool bUnderlined ) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetUnderlined(bUnderlined); @@ -1053,7 +1051,7 @@ void wxFont::SetEncoding( wxFontEncoding vEncoding ) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetEncoding(vEncoding); @@ -1064,7 +1062,7 @@ void wxFont::DoSetNativeFontInfo( const wxNativeFontInfo& rInfo ) { - Unshare(); + AllocExclusive(); FreeResource(); @@ -1135,21 +1133,16 @@ const wxNativeFontInfo* wxFont::GetNativeFontInfo() const // // Internal use only method to set the FONTMETRICS array // -void wxFont::SetFM( - PFONTMETRICS pFM -, int nNumFonts -) +void wxFont::SetFM( PFONTMETRICS pFM, int nNumFonts ) { M_FONTDATA->SetFM(pFM); M_FONTDATA->SetNumFonts(nNumFonts); } // end of wxFont::SetFM -void wxFont::SetPS( - HPS hPS -) +void wxFont::SetPS( HPS hPS ) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetPS(hPS);