X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/32b8ec418aee4e38877d4cb79e2984c766dcc358..b6a20a20d010d643e52914f51aa0700df0da925f:/src/mgl/font.cpp?ds=sidebyside diff --git a/src/mgl/font.cpp b/src/mgl/font.cpp index 26456824c7..06d972feee 100644 --- a/src/mgl/font.cpp +++ b/src/mgl/font.cpp @@ -2,7 +2,7 @@ // Name: font.cpp // Author: Vaclav Slavik // Id: $Id$ -// Copyright: (c) 2001, Vaclav Slavik +// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com) // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -14,10 +14,17 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "font.h" #endif +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + #include "wx/font.h" #include "wx/fontutil.h" #include "wx/cmndata.h" @@ -26,8 +33,7 @@ #include "wx/gdicmn.h" #include "wx/tokenzr.h" #include "wx/settings.h" - -#include +#include "wx/mgl/private.h" // ---------------------------------------------------------------------------- // wxFontRefData @@ -68,6 +74,8 @@ private: wxMGLFontLibrary *m_library; bool m_valid; + wxNativeFontInfo m_info; + friend class wxFont; }; @@ -125,6 +133,7 @@ wxFontRefData::wxFontRefData(const wxFontRefData& data) m_valid = data.m_valid; if ( m_library ) m_library->IncRef(); + wxLogTrace("mgl_font", "created fntrefdata %p, library is %p", this, m_library); } wxFontRefData::wxFontRefData(int size, int family, int style, @@ -133,10 +142,12 @@ wxFontRefData::wxFontRefData(int size, int family, int style, wxFontEncoding encoding) { Init(size, family, style, weight, underlined, faceName, encoding); + wxLogTrace("mgl_font", "created fntrefdata %p, library is %p", this, m_library); } wxFontRefData::~wxFontRefData() { + wxLogTrace("mgl_font", "destructing fntrefdata %p, library is %p", this, m_library); if ( m_library ) m_library->DecRef(); } @@ -147,12 +158,6 @@ wxFontRefData::~wxFontRefData() IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) -void wxFont::Init() -{ - if (wxTheFontList) - wxTheFontList->Append(this); -} - bool wxFont::Create(const wxNativeFontInfo& info) { return Create(info.pointSize, info.family, info.style, info.weight, @@ -189,26 +194,17 @@ struct font_t *wxFont::GetMGLfont_t(float scale, bool antialiased) return instance->GetMGLfont_t(); } -void wxFont::Unshare() +wxObjectRefData *wxFont::CreateRefData() const { - if ( !m_refData ) - { - m_refData = new wxFontRefData(); - } - else - { - wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); - UnRef(); - m_refData = ref; - } + return new wxFontRefData; } -wxFont::~wxFont() +wxObjectRefData *wxFont::CloneRefData(const wxObjectRefData *data) const { - if (wxTheFontList) - wxTheFontList->DeleteObject(this); + return new wxFontRefData(*(wxFontRefData *)data); } + // ---------------------------------------------------------------------------- // accessors // ---------------------------------------------------------------------------- @@ -263,6 +259,21 @@ wxFontEncoding wxFont::GetEncoding() const return M_FONTDATA->m_encoding; } +bool wxFont::IsFixedWidth() const +{ + wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") ); + + return (bool)(M_FONTDATA->m_library->GetFamily()->GetInfo()->isFixed); +} + +const wxNativeFontInfo *wxFont::GetNativeFontInfo() const +{ + wxCHECK_MSG( Ok(), NULL, wxT("invalid font") ); + + M_FONTDATA->m_info.InitFromFont(*this); + + return &(M_FONTDATA->m_info); +} // ---------------------------------------------------------------------------- // change font attributes @@ -270,7 +281,7 @@ wxFontEncoding wxFont::GetEncoding() const void wxFont::SetPointSize(int pointSize) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_pointSize = pointSize; M_FONTDATA->m_valid = FALSE; @@ -278,7 +289,7 @@ void wxFont::SetPointSize(int pointSize) void wxFont::SetFamily(int family) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_family = family; M_FONTDATA->m_valid = FALSE; @@ -286,7 +297,7 @@ void wxFont::SetFamily(int family) void wxFont::SetStyle(int style) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_style = style; M_FONTDATA->m_valid = FALSE; @@ -294,7 +305,7 @@ void wxFont::SetStyle(int style) void wxFont::SetWeight(int weight) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_weight = weight; M_FONTDATA->m_valid = FALSE; @@ -302,7 +313,7 @@ void wxFont::SetWeight(int weight) void wxFont::SetFaceName(const wxString& faceName) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_faceName = faceName; M_FONTDATA->m_valid = FALSE; @@ -310,14 +321,14 @@ void wxFont::SetFaceName(const wxString& faceName) void wxFont::SetUnderlined(bool underlined) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_underlined = underlined; } void wxFont::SetEncoding(wxFontEncoding encoding) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_encoding = encoding; M_FONTDATA->m_valid = FALSE;