]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/font.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     wxFont class 
   8 // Copyright:   (c) AUTHOR 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  13 #pragma implementation "font.h" 
  17 #include "wx/string.h" 
  19 #include "wx/fontutil.h" 
  20 #include "wx/gdicmn.h" 
  23 #include "wx/fontutil.h" 
  25 #if !USE_SHARED_LIBRARIES 
  26 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
) 
  29 // ============================================================================ 
  31 // ============================================================================ 
  33 // ---------------------------------------------------------------------------- 
  35 // ---------------------------------------------------------------------------- 
  37 void wxFontRefData::Init(int pointSize
, 
  42                          const wxString
& faceName
, 
  43                          wxFontEncoding encoding
) 
  46     m_pointSize 
= pointSize
; 
  50     m_underlined 
= underlined
; 
  51     m_faceName 
= faceName
; 
  52     m_encoding 
= encoding
; 
  60 wxFontRefData::~wxFontRefData() 
  64 void wxFontRefData::MacFindFont() 
  66         if( m_faceName 
== "" ) 
  71                                 m_macFontNum 
= ::GetAppFont() ; 
  74                                 ::GetFNum( "\pTimes" , &m_macFontNum
) ; 
  77                                 ::GetFNum( "\pTimes" , &m_macFontNum
) ; 
  80                                 ::GetFNum( "\pTimes" , &m_macFontNum
) ; 
  83                                 ::GetFNum( "\pGeneva" , &m_macFontNum
) ; 
  86                                 ::GetFNum( "\pMonaco" , &m_macFontNum
) ; 
  92                 if ( m_faceName 
== "systemfont" ) 
  93                         m_macFontNum 
= ::GetSysFont() ; 
  94                 else if ( m_faceName 
== "applicationfont" ) 
  95                         m_macFontNum 
= ::GetAppFont() ; 
  99                         c2pstrcpy( (StringPtr
) wxBuffer
, m_faceName 
) ; 
 101                         strcpy( (char *) wxBuffer
, m_faceName 
) ; 
 102                         c2pstr( (char *) wxBuffer 
) ; 
 104                         ::GetFNum( (StringPtr
) wxBuffer
, &m_macFontNum
); 
 109         if (m_weight 
== wxBOLD
) 
 110                  m_macFontStyle 
|= bold
; 
 111         if (m_style 
== wxITALIC 
|| m_style 
== wxSLANT
)  
 112                 m_macFontStyle 
|= italic
; 
 114                 m_macFontStyle 
|= underline
; 
 115         m_macFontSize 
= m_pointSize 
; 
 118 // ---------------------------------------------------------------------------- 
 120 // ---------------------------------------------------------------------------- 
 125         wxTheFontList
->Append(this); 
 128 bool wxFont::Create(const wxNativeFontInfo
& info
) 
 130     return Create(info
.pointSize
, info
.family
, info
.style
, info
.weight
, 
 131                   info
.underlined
, info
.faceName
, info
.encoding
); 
 134 wxFont::wxFont(const wxString
& fontdesc
) 
 136     wxNativeFontInfo info
; 
 137     if ( info
.FromString(fontdesc
) ) 
 141 bool wxFont::Create(int pointSize
, 
 146                     const wxString
& faceName
, 
 147                     wxFontEncoding encoding
) 
 150     m_refData 
= new wxFontRefData(pointSize
, family
, style
, weight
, 
 151                                   underlined
, faceName
, encoding
); 
 161         wxTheFontList
->DeleteObject(this); 
 164 bool wxFont::RealizeResource() 
 166         M_FONTDATA
->MacFindFont() ; 
 170 void wxFont::SetEncoding(wxFontEncoding encoding
) 
 174     M_FONTDATA
->m_encoding 
= encoding
; 
 179 void wxFont::Unshare() 
 181         // Don't change shared data 
 184                 m_refData 
= new wxFontRefData(); 
 188                 wxFontRefData
* ref 
= new wxFontRefData(*(wxFontRefData
*)m_refData
); 
 194 void wxFont::SetPointSize(int pointSize
) 
 198     M_FONTDATA
->m_pointSize 
= pointSize
; 
 203 void wxFont::SetFamily(int family
) 
 207     M_FONTDATA
->m_family 
= family
; 
 212 void wxFont::SetStyle(int style
) 
 216     M_FONTDATA
->m_style 
= style
; 
 221 void wxFont::SetWeight(int weight
) 
 225     M_FONTDATA
->m_weight 
= weight
; 
 230 void wxFont::SetFaceName(const wxString
& faceName
) 
 234     M_FONTDATA
->m_faceName 
= faceName
; 
 239 void wxFont::SetUnderlined(bool underlined
) 
 243     M_FONTDATA
->m_underlined 
= underlined
; 
 248 // ---------------------------------------------------------------------------- 
 250 // ---------------------------------------------------------------------------- 
 252 int wxFont::GetPointSize() const 
 254     return M_FONTDATA
->m_pointSize
; 
 257 int wxFont::GetFamily() const 
 259     return M_FONTDATA
->m_family
; 
 262 int wxFont::GetStyle() const 
 264     return M_FONTDATA
->m_style
; 
 267 int wxFont::GetWeight() const 
 269     return M_FONTDATA
->m_weight
; 
 272 bool wxFont::GetUnderlined() const 
 274     return M_FONTDATA
->m_underlined
; 
 277 wxString 
wxFont::GetFaceName() const 
 281         str 
= M_FONTDATA
->m_faceName 
; 
 285 wxFontEncoding 
wxFont::GetEncoding() const 
 287     return M_FONTDATA
->m_encoding
;