]>
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 #include "wx/mac/private.h"
28 #if !USE_SHARED_LIBRARIES
29 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
32 // ============================================================================
34 // ============================================================================
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 void wxFontRefData::Init(int pointSize
,
45 const wxString
& faceName
,
46 wxFontEncoding encoding
)
49 m_pointSize
= pointSize
;
53 m_underlined
= underlined
;
54 m_faceName
= faceName
;
55 m_encoding
= encoding
;
63 wxFontRefData::~wxFontRefData()
67 void wxFontRefData::MacFindFont()
69 if( m_faceName
== "" )
74 m_macFontNum
= ::GetAppFont() ;
77 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
80 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
83 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
86 ::GetFNum( "\pGeneva" , &m_macFontNum
) ;
89 ::GetFNum( "\pMonaco" , &m_macFontNum
) ;
95 if ( m_faceName
== "systemfont" )
96 m_macFontNum
= ::GetSysFont() ;
97 else if ( m_faceName
== "applicationfont" )
98 m_macFontNum
= ::GetAppFont() ;
102 c2pstrcpy( (StringPtr
) wxBuffer
, m_faceName
) ;
104 strcpy( (char *) wxBuffer
, m_faceName
) ;
105 c2pstr( (char *) wxBuffer
) ;
107 ::GetFNum( (StringPtr
) wxBuffer
, &m_macFontNum
);
112 if (m_weight
== wxBOLD
)
113 m_macFontStyle
|= bold
;
114 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
115 m_macFontStyle
|= italic
;
117 m_macFontStyle
|= underline
;
118 m_macFontSize
= m_pointSize
;
121 // ----------------------------------------------------------------------------
123 // ----------------------------------------------------------------------------
129 bool wxFont::Create(const wxNativeFontInfo
& info
)
131 return Create(info
.pointSize
, info
.family
, info
.style
, info
.weight
,
132 info
.underlined
, info
.faceName
, info
.encoding
);
135 wxFont::wxFont(const wxString
& fontdesc
)
137 wxNativeFontInfo info
;
138 if ( info
.FromString(fontdesc
) )
142 bool wxFont::Create(int pointSize
,
147 const wxString
& faceName
,
148 wxFontEncoding encoding
)
151 m_refData
= new wxFontRefData(pointSize
, family
, style
, weight
,
152 underlined
, faceName
, encoding
);
163 bool wxFont::RealizeResource()
165 M_FONTDATA
->MacFindFont() ;
169 void wxFont::SetEncoding(wxFontEncoding encoding
)
173 M_FONTDATA
->m_encoding
= encoding
;
178 void wxFont::Unshare()
180 // Don't change shared data
183 m_refData
= new wxFontRefData();
187 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
193 void wxFont::SetPointSize(int pointSize
)
197 M_FONTDATA
->m_pointSize
= pointSize
;
202 void wxFont::SetFamily(int family
)
206 M_FONTDATA
->m_family
= family
;
211 void wxFont::SetStyle(int style
)
215 M_FONTDATA
->m_style
= style
;
220 void wxFont::SetWeight(int weight
)
224 M_FONTDATA
->m_weight
= weight
;
229 void wxFont::SetFaceName(const wxString
& faceName
)
233 M_FONTDATA
->m_faceName
= faceName
;
238 void wxFont::SetUnderlined(bool underlined
)
242 M_FONTDATA
->m_underlined
= underlined
;
247 // ----------------------------------------------------------------------------
249 // ----------------------------------------------------------------------------
251 int wxFont::GetPointSize() const
253 return M_FONTDATA
->m_pointSize
;
256 int wxFont::GetFamily() const
258 return M_FONTDATA
->m_family
;
261 int wxFont::GetStyle() const
263 return M_FONTDATA
->m_style
;
266 int wxFont::GetWeight() const
268 return M_FONTDATA
->m_weight
;
271 bool wxFont::GetUnderlined() const
273 return M_FONTDATA
->m_underlined
;
276 wxString
wxFont::GetFaceName() const
280 str
= M_FONTDATA
->m_faceName
;
284 wxFontEncoding
wxFont::GetEncoding() const
286 return M_FONTDATA
->m_encoding
;