]>
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 #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::Unshare()
154 // Don't change shared data
157 m_refData
= new wxFontRefData();
161 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
167 void wxFont::SetPointSize(int pointSize
)
171 M_FONTDATA
->m_pointSize
= pointSize
;
176 void wxFont::SetFamily(int family
)
180 M_FONTDATA
->m_family
= family
;
185 void wxFont::SetStyle(int style
)
189 M_FONTDATA
->m_style
= style
;
194 void wxFont::SetWeight(int weight
)
198 M_FONTDATA
->m_weight
= weight
;
203 void wxFont::SetFaceName(const wxString
& faceName
)
207 M_FONTDATA
->m_faceName
= faceName
;
212 void wxFont::SetUnderlined(bool underlined
)
216 M_FONTDATA
->m_underlined
= underlined
;
221 // ----------------------------------------------------------------------------
223 // ----------------------------------------------------------------------------
225 int wxFont::GetPointSize() const
227 return M_FONTDATA
->m_pointSize
;
230 int wxFont::GetFamily() const
232 return M_FONTDATA
->m_family
;
235 int wxFont::GetFontId() const
237 return M_FONTDATA
->m_fontId
;
240 int wxFont::GetStyle() const
242 return M_FONTDATA
->m_style
;
245 int wxFont::GetWeight() const
247 return M_FONTDATA
->m_weight
;
250 bool wxFont::GetUnderlined() const
252 return M_FONTDATA
->m_underlined
;
255 wxString
wxFont::GetFaceName() const
259 str
= M_FONTDATA
->m_faceName
;
263 wxFontEncoding
wxFont::GetEncoding() const
265 return M_FONTDATA
->m_encoding
;