]>
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 // ----------------------------------------------------------------------------
126 bool wxFont::Create(const wxNativeFontInfo
& info
)
128 return Create(info
.pointSize
, info
.family
, info
.style
, info
.weight
,
129 info
.underlined
, info
.faceName
, info
.encoding
);
132 wxFont::wxFont(const wxString
& fontdesc
)
134 wxNativeFontInfo info
;
135 if ( info
.FromString(fontdesc
) )
139 bool wxFont::Create(int pointSize
,
144 const wxString
& faceName
,
145 wxFontEncoding encoding
)
148 m_refData
= new wxFontRefData(pointSize
, family
, style
, weight
,
149 underlined
, faceName
, encoding
);
160 bool wxFont::RealizeResource()
162 M_FONTDATA
->MacFindFont() ;
166 void wxFont::SetEncoding(wxFontEncoding encoding
)
170 M_FONTDATA
->m_encoding
= encoding
;
175 void wxFont::Unshare()
177 // Don't change shared data
180 m_refData
= new wxFontRefData();
184 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
190 void wxFont::SetPointSize(int pointSize
)
194 M_FONTDATA
->m_pointSize
= pointSize
;
199 void wxFont::SetFamily(int family
)
203 M_FONTDATA
->m_family
= family
;
208 void wxFont::SetStyle(int style
)
212 M_FONTDATA
->m_style
= style
;
217 void wxFont::SetWeight(int weight
)
221 M_FONTDATA
->m_weight
= weight
;
226 void wxFont::SetFaceName(const wxString
& faceName
)
230 M_FONTDATA
->m_faceName
= faceName
;
235 void wxFont::SetUnderlined(bool underlined
)
239 M_FONTDATA
->m_underlined
= underlined
;
244 // ----------------------------------------------------------------------------
246 // ----------------------------------------------------------------------------
248 int wxFont::GetPointSize() const
250 return M_FONTDATA
->m_pointSize
;
253 int wxFont::GetFamily() const
255 return M_FONTDATA
->m_family
;
258 int wxFont::GetStyle() const
260 return M_FONTDATA
->m_style
;
263 int wxFont::GetWeight() const
265 return M_FONTDATA
->m_weight
;
268 bool wxFont::GetUnderlined() const
270 return M_FONTDATA
->m_underlined
;
273 wxString
wxFont::GetFaceName() const
277 str
= M_FONTDATA
->m_faceName
;
281 wxFontEncoding
wxFont::GetEncoding() const
283 return M_FONTDATA
->m_encoding
;