X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/655719367ac5e131d9642e5783f3ecf64d1a3385..b9eb3d9de670bdeb0b6c2500b43bb74bc3807bd9:/src/mac/classic/font.cpp diff --git a/src/mac/classic/font.cpp b/src/mac/classic/font.cpp index ef0ecc73b6..e2757af968 100644 --- a/src/mac/classic/font.cpp +++ b/src/mac/classic/font.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: font.cpp +// Name: src/mac/classic/font.cpp // Purpose: wxFont class // Author: Stefan Csomor // Modified by: @@ -9,25 +9,28 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "font.h" +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop #endif -#include "wx/defs.h" -#include "wx/string.h" #include "wx/font.h" + +#ifndef WX_PRECOMP + #include "wx/string.h" + #include "wx/utils.h" + #include "wx/gdicmn.h" +#endif + #include "wx/fontutil.h" -#include "wx/gdicmn.h" -#include "wx/utils.h" #include "wx/fontutil.h" #include "wx/mac/private.h" #include -#if !USE_SHARED_LIBRARIES IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) -#endif class WXDLLEXPORT wxFontRefData: public wxGDIRefData { @@ -39,7 +42,7 @@ public: , m_family(wxDEFAULT) , m_style(wxNORMAL) , m_weight(wxNORMAL) - , m_underlined(FALSE) + , m_underlined(false) , m_faceName(wxT("Geneva")) , m_encoding(wxFONTENCODING_DEFAULT) , m_macFontNum(0) @@ -47,7 +50,7 @@ public: , m_macFontStyle(0) , m_macATSUFontID() { - Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE, + Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, false, wxT("Geneva"), wxFONTENCODING_DEFAULT); } @@ -94,9 +97,9 @@ public: } virtual ~wxFontRefData(); - void SetNoAntiAliasing( bool no = TRUE ) { m_noAA = no; } - bool GetNoAntiAliasing() { return m_noAA; } - + void SetNoAntiAliasing( bool no = true ) { m_noAA = no; } + bool GetNoAntiAliasing() const { return m_noAA; } + protected: // common part of all ctors void Init(int size, @@ -116,8 +119,8 @@ protected: bool m_underlined; wxString m_faceName; wxFontEncoding m_encoding; - bool m_noAA; // No anti-aliasing - + bool m_noAA; // No anti-aliasing + public: short m_macFontNum; short m_macFontSize; @@ -158,7 +161,7 @@ void wxFontRefData::Init(int pointSize, m_macFontSize = 0; m_macFontStyle = 0; m_fontId = 0; - m_noAA = FALSE; + m_noAA = false; } wxFontRefData::~wxFontRefData() @@ -167,7 +170,7 @@ wxFontRefData::~wxFontRefData() void wxFontRefData::MacFindFont() { - if( m_faceName.Length() == 0 ) + if( m_faceName.empty() ) { switch( m_family ) { @@ -211,19 +214,19 @@ void wxFontRefData::MacFindFont() m_macFontStyle = 0; if (m_weight == wxBOLD) m_macFontStyle |= bold; - if (m_style == wxITALIC || m_style == wxSLANT) + if (m_style == wxITALIC || m_style == wxSLANT) m_macFontStyle |= italic; - if (m_underlined) + if (m_underlined) m_macFontStyle |= underline; m_macFontSize = m_pointSize ; - + //TODO:if we supply the style as an additional parameter we must make a testing //sequence in order to degrade gracefully while trying to maintain most of the style //information, meanwhile we just take the normal font and apply the features after #ifdef __WXDEBUG__ OSStatus status = #endif // __WXDEBUG__ - ::ATSUFONDtoFontID(m_macFontNum, normal /*qdStyle*/, (UInt32*)&m_macATSUFontID); + ::ATSUFONDtoFontID(m_macFontNum, normal /*qdStyle*/, (UInt32*)&m_macATSUFontID); /* status = ATSUFindFontFromName ( (Ptr) m_faceName , strlen( m_faceName ) , kFontFullName, kFontMacintoshPlatform, kFontRomanScript , kFontNoLanguage , (UInt32*)&m_macATSUFontID ) ; @@ -234,9 +237,6 @@ void wxFontRefData::MacFindFont() // ---------------------------------------------------------------------------- // wxFont // ---------------------------------------------------------------------------- - -void wxFont::Init() -{ } bool wxFont::Create(const wxNativeFontInfo& info) @@ -266,7 +266,7 @@ bool wxFont::Create(int pointSize, RealizeResource(); - return TRUE; + return true; } wxFont::~wxFont() @@ -276,7 +276,7 @@ wxFont::~wxFont() bool wxFont::RealizeResource() { M_FONTDATA->MacFindFont() ; - return TRUE; + return true; } void wxFont::SetEncoding(wxFontEncoding encoding) @@ -339,13 +339,15 @@ void wxFont::SetWeight(int weight) RealizeResource(); } -void wxFont::SetFaceName(const wxString& faceName) +bool wxFont::SetFaceName(const wxString& faceName) { Unshare(); M_FONTDATA->m_faceName = faceName; RealizeResource(); + + return wxFontBase::SetFaceName(faceName); } void wxFont::SetUnderlined(bool underlined) @@ -410,7 +412,7 @@ wxFontEncoding wxFont::GetEncoding() const return M_FONTDATA->m_encoding; } -bool wxFont::GetNoAntiAliasing() +bool wxFont::GetNoAntiAliasing() const { return M_FONTDATA->m_noAA; } @@ -443,4 +445,3 @@ const wxNativeFontInfo *wxFont::GetNativeFontInfo() const return &(M_FONTDATA->m_info); } -