X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1ac162ad06ea4f97a768a9d0adaf3abbcf6e5f10..d35ad26eee38a8d71efde5a6e7f7f28f4b7df1bd:/src/mgl/font.cpp?ds=sidebyside diff --git a/src/mgl/font.cpp b/src/mgl/font.cpp index 4deda242cf..6bb8af4e47 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 SciTech Software, Inc. (www.scitechsoft.com) +// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com) // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -14,8 +14,11 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ - #pragma implementation "font.h" +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop #endif #include "wx/font.h" @@ -26,8 +29,7 @@ #include "wx/gdicmn.h" #include "wx/tokenzr.h" #include "wx/settings.h" - -#include +#include "wx/mgl/private.h" // ---------------------------------------------------------------------------- // wxFontRefData @@ -68,6 +70,8 @@ private: wxMGLFontLibrary *m_library; bool m_valid; + wxNativeFontInfo m_info; + friend class wxFont; }; @@ -150,12 +154,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, @@ -177,7 +175,6 @@ bool wxFont::Create(int pointSize, struct font_t *wxFont::GetMGLfont_t(float scale, bool antialiased) { - // FIXME_MGL -- no antialiasing for fonts smaller than certain treshold! if ( !M_FONTDATA->m_valid ) { wxMGLFontLibrary *old = M_FONTDATA->m_library; @@ -193,26 +190,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 // ---------------------------------------------------------------------------- @@ -267,6 +255,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 @@ -274,7 +277,7 @@ wxFontEncoding wxFont::GetEncoding() const void wxFont::SetPointSize(int pointSize) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_pointSize = pointSize; M_FONTDATA->m_valid = FALSE; @@ -282,7 +285,7 @@ void wxFont::SetPointSize(int pointSize) void wxFont::SetFamily(int family) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_family = family; M_FONTDATA->m_valid = FALSE; @@ -290,7 +293,7 @@ void wxFont::SetFamily(int family) void wxFont::SetStyle(int style) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_style = style; M_FONTDATA->m_valid = FALSE; @@ -298,7 +301,7 @@ void wxFont::SetStyle(int style) void wxFont::SetWeight(int weight) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_weight = weight; M_FONTDATA->m_valid = FALSE; @@ -306,7 +309,7 @@ void wxFont::SetWeight(int weight) void wxFont::SetFaceName(const wxString& faceName) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_faceName = faceName; M_FONTDATA->m_valid = FALSE; @@ -314,14 +317,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;