]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/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 #if !USE_SHARED_LIBRARIES
22 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
28 // ============================================================================
30 // ============================================================================
32 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
36 void wxFontRefData::Init(int pointSize
,
41 const wxString
& faceName
,
42 wxFontEncoding encoding
)
45 m_pointSize
= pointSize
;
49 m_underlined
= underlined
;
50 m_faceName
= faceName
;
51 m_encoding
= encoding
;
59 wxFontRefData::~wxFontRefData()
63 void wxFontRefData::MacFindFont()
65 if( m_faceName
== "" )
70 m_macFontNum
= ::GetAppFont() ;
73 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
76 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
79 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
82 ::GetFNum( "\pHelvetica" , &m_macFontNum
) ;
85 ::GetFNum( "\pMonaco" , &m_macFontNum
) ;
91 if ( m_faceName
== "systemfont" )
92 m_macFontNum
= ::GetSysFont() ;
93 else if ( m_faceName
== "applicationfont" )
94 m_macFontNum
= ::GetAppFont() ;
97 strcpy(wxBuffer
, m_faceName
);
99 ::GetFNum( (unsigned char*) wxBuffer
, &m_macFontNum
);
104 if (m_weight
== wxBOLD
)
105 m_macFontStyle
|= bold
;
106 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
107 m_macFontStyle
|= italic
;
109 m_macFontStyle
|= underline
;
110 m_macFontSize
= m_pointSize
;
113 // ----------------------------------------------------------------------------
115 // ----------------------------------------------------------------------------
120 wxTheFontList
->Append(this);
123 bool wxFont::Create(int pointSize
,
128 const wxString
& faceName
,
129 wxFontEncoding encoding
)
132 m_refData
= new wxFontRefData(pointSize
, family
, style
, weight
,
133 underlined
, faceName
, encoding
);
143 wxTheFontList
->DeleteObject(this);
146 bool wxFont::RealizeResource()
148 M_FONTDATA
->MacFindFont() ;
152 void wxFont::SetEncoding(wxFontEncoding encoding
)
156 M_FONTDATA
->m_encoding
= encoding
;
161 void wxFont::Unshare()
163 // Don't change shared data
166 m_refData
= new wxFontRefData();
170 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
176 void wxFont::SetPointSize(int pointSize
)
180 M_FONTDATA
->m_pointSize
= pointSize
;
185 void wxFont::SetFamily(int family
)
189 M_FONTDATA
->m_family
= family
;
194 void wxFont::SetStyle(int style
)
198 M_FONTDATA
->m_style
= style
;
203 void wxFont::SetWeight(int weight
)
207 M_FONTDATA
->m_weight
= weight
;
212 void wxFont::SetFaceName(const wxString
& faceName
)
216 M_FONTDATA
->m_faceName
= faceName
;
221 void wxFont::SetUnderlined(bool underlined
)
225 M_FONTDATA
->m_underlined
= underlined
;
230 // ----------------------------------------------------------------------------
232 // ----------------------------------------------------------------------------
234 int wxFont::GetPointSize() const
236 return M_FONTDATA
->m_pointSize
;
239 int wxFont::GetFamily() const
241 return M_FONTDATA
->m_family
;
244 int wxFont::GetStyle() const
246 return M_FONTDATA
->m_style
;
249 int wxFont::GetWeight() const
251 return M_FONTDATA
->m_weight
;
254 bool wxFont::GetUnderlined() const
256 return M_FONTDATA
->m_underlined
;
259 wxString
wxFont::GetFaceName() const
263 str
= M_FONTDATA
->m_faceName
;
267 wxFontEncoding
wxFont::GetEncoding() const
269 return M_FONTDATA
->m_encoding
;