]>
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/gdicmn.h"
21 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
26 // ============================================================================
28 // ============================================================================
30 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
34 void wxFontRefData::Init(int pointSize
,
39 const wxString
& faceName
,
40 wxFontEncoding encoding
)
43 m_pointSize
= pointSize
;
47 m_underlined
= underlined
;
48 m_faceName
= faceName
;
49 m_encoding
= encoding
;
57 wxFontRefData::~wxFontRefData()
61 void wxFontRefData::MacFindFont()
63 if( m_faceName
== "" )
68 m_macFontNum
= ::GetAppFont() ;
71 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
74 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
77 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
80 ::GetFNum( "\pHelvetica" , &m_macFontNum
) ;
83 ::GetFNum( "\pMonaco" , &m_macFontNum
) ;
89 if ( m_faceName
== "systemfont" )
90 m_macFontNum
= ::GetSysFont() ;
91 else if ( m_faceName
== "applicationfont" )
92 m_macFontNum
= ::GetAppFont() ;
95 strcpy(wxBuffer
, m_faceName
);
97 ::GetFNum( (unsigned char*) wxBuffer
, &m_macFontNum
);
102 if (m_weight
== wxBOLD
)
103 m_macFontStyle
|= bold
;
104 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
105 m_macFontStyle
|= italic
;
107 m_macFontStyle
|= underline
;
108 m_macFontSize
= m_pointSize
;
111 // ----------------------------------------------------------------------------
113 // ----------------------------------------------------------------------------
118 wxTheFontList
->Append(this);
121 bool wxFont::Create(int pointSize
,
126 const wxString
& faceName
,
127 wxFontEncoding encoding
)
130 m_refData
= new wxFontRefData(pointSize
, family
, style
, weight
,
131 underlined
, faceName
, encoding
);
141 wxTheFontList
->DeleteObject(this);
144 bool wxFont::RealizeResource()
146 M_FONTDATA
->MacFindFont() ;
150 void wxFont::SetEncoding(wxFontEncoding encoding
)
154 M_FONTDATA
->m_encoding
= encoding
;
159 void wxFont::Unshare()
161 // Don't change shared data
164 m_refData
= new wxFontRefData();
168 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
174 void wxFont::SetPointSize(int pointSize
)
178 M_FONTDATA
->m_pointSize
= pointSize
;
183 void wxFont::SetFamily(int family
)
187 M_FONTDATA
->m_family
= family
;
192 void wxFont::SetStyle(int style
)
196 M_FONTDATA
->m_style
= style
;
201 void wxFont::SetWeight(int weight
)
205 M_FONTDATA
->m_weight
= weight
;
210 void wxFont::SetFaceName(const wxString
& faceName
)
214 M_FONTDATA
->m_faceName
= faceName
;
219 void wxFont::SetUnderlined(bool underlined
)
223 M_FONTDATA
->m_underlined
= underlined
;
228 // ----------------------------------------------------------------------------
230 // ----------------------------------------------------------------------------
232 int wxFont::GetPointSize() const
234 return M_FONTDATA
->m_pointSize
;
237 int wxFont::GetFamily() const
239 return M_FONTDATA
->m_family
;
242 int wxFont::GetStyle() const
244 return M_FONTDATA
->m_style
;
247 int wxFont::GetWeight() const
249 return M_FONTDATA
->m_weight
;
252 bool wxFont::GetUnderlined() const
254 return M_FONTDATA
->m_underlined
;
257 wxString
wxFont::GetFaceName() const
261 str
= M_FONTDATA
->m_faceName
;
265 wxFontEncoding
wxFont::GetEncoding() const
267 return M_FONTDATA
->m_encoding
;