]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/font.cpp
2409e1a38b170a92c1b809aaeb10d25bd079cd4d
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
)
25 wxFontRefData::wxFontRefData()
35 m_macFontSize
= m_pointSize
;
36 m_macFontNum
= systemFont
;
37 m_macFontStyle
= normal
;
40 wxFontRefData::wxFontRefData(const wxFontRefData
& data
)
42 m_style
= data
.m_style
;
43 m_pointSize
= data
.m_pointSize
;
44 m_family
= data
.m_family
;
45 m_style
= data
.m_style
;
46 m_weight
= data
.m_weight
;
47 m_underlined
= data
.m_underlined
;
48 m_faceName
= data
.m_faceName
;
50 m_macFontSize
= m_pointSize
;
51 m_macFontNum
= systemFont
;
52 m_macFontStyle
= normal
;
55 wxFontRefData::~wxFontRefData()
57 // TODO: delete font data
60 void wxFontRefData::MacFindFont()
62 if( m_faceName
== "" )
67 m_macFontNum
= ::GetAppFont() ;
70 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
73 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
76 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
79 ::GetFNum( "\pHelvetica" , &m_macFontNum
) ;
82 ::GetFNum( "\pMonaco" , &m_macFontNum
) ;
88 if ( m_faceName
== "systemfont" )
89 m_macFontNum
= ::GetSysFont() ;
90 else if ( m_faceName
== "applicationfont" )
91 m_macFontNum
= ::GetAppFont() ;
94 strcpy(wxBuffer
, m_faceName
);
96 ::GetFNum( (unsigned char*) wxBuffer
, &m_macFontNum
);
101 if (m_weight
== wxBOLD
)
102 m_macFontStyle
|= bold
;
103 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
104 m_macFontStyle
|= italic
;
106 m_macFontStyle
|= underline
;
107 m_macFontSize
= m_pointSize
;
113 wxTheFontList
->Append(this);
116 wxFont::wxFont(int pointSize
, int family
, int style
, int weight
, bool underlined
, const wxString
& faceName
)
118 Create(pointSize
, family
, style
, weight
, underlined
, faceName
);
121 wxTheFontList
->Append(this);
124 bool wxFont::Create(int pointSize
, int family
, int style
, int weight
, bool underlined
, const wxString
& faceName
)
127 m_refData
= new wxFontRefData
;
129 M_FONTDATA
->m_family
= family
;
130 M_FONTDATA
->m_style
= style
;
131 M_FONTDATA
->m_weight
= weight
;
132 M_FONTDATA
->m_pointSize
= pointSize
;
133 M_FONTDATA
->m_underlined
= underlined
;
134 M_FONTDATA
->m_faceName
= faceName
;
144 wxTheFontList
->DeleteObject(this);
147 bool wxFont::RealizeResource()
149 M_FONTDATA
->MacFindFont() ;
153 void wxFont::Unshare()
155 // Don't change shared data
158 m_refData
= new wxFontRefData();
162 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
168 void wxFont::SetPointSize(int pointSize
)
172 M_FONTDATA
->m_pointSize
= pointSize
;
177 void wxFont::SetFamily(int family
)
181 M_FONTDATA
->m_family
= family
;
186 void wxFont::SetStyle(int style
)
190 M_FONTDATA
->m_style
= style
;
195 void wxFont::SetWeight(int weight
)
199 M_FONTDATA
->m_weight
= weight
;
204 void wxFont::SetFaceName(const wxString
& faceName
)
208 M_FONTDATA
->m_faceName
= faceName
;
213 void wxFont::SetUnderlined(bool underlined
)
217 M_FONTDATA
->m_underlined
= underlined
;
222 wxString
wxFont::GetFamilyString() const
228 fam
= "wxDECORATIVE";
252 /* New font system */
253 wxString
wxFont::GetFaceName() const
257 str
= M_FONTDATA
->m_faceName
;
261 wxString
wxFont::GetStyleString() const
279 wxString
wxFont::GetWeightString() const