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
)
23 wxFontRefData
::wxFontRefData()
37 wxFontRefData
::wxFontRefData(const wxFontRefData
& data
)
39 m_style
= data
.m_style
;
40 m_pointSize
= data
.m_pointSize
;
41 m_family
= data
.m_family
;
42 m_style
= data
.m_style
;
43 m_weight
= data
.m_weight
;
44 m_underlined
= data
.m_underlined
;
45 m_faceName
= data
.m_faceName
;
51 wxFontRefData
::~wxFontRefData()
53 // TODO: delete font data
59 wxTheFontList
->Append(this);
62 wxFont
::wxFont(int pointSize
, int family
, int style
, int weight
, bool underlined
, const wxString
& faceName
)
64 Create(pointSize
, family
, style
, weight
, underlined
, faceName
);
67 wxTheFontList
->Append(this);
70 bool wxFont
::Create(int pointSize
, int family
, int style
, int weight
, bool underlined
, const wxString
& faceName
)
73 m_refData
= new wxFontRefData
;
75 M_FONTDATA
->m_family
= family
;
76 M_FONTDATA
->m_style
= style
;
77 M_FONTDATA
->m_weight
= weight
;
78 M_FONTDATA
->m_pointSize
= pointSize
;
79 M_FONTDATA
->m_underlined
= underlined
;
80 M_FONTDATA
->m_faceName
= faceName
;
90 wxTheFontList
->DeleteObject(this);
93 bool wxFont
::RealizeResource()
95 // TODO: create the font (if there is a native font object)
99 void wxFont
::Unshare()
101 // Don't change shared data
104 m_refData
= new wxFontRefData();
108 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
114 void wxFont
::SetPointSize(int pointSize
)
118 M_FONTDATA
->m_pointSize
= pointSize
;
123 void wxFont
::SetFamily(int family
)
127 M_FONTDATA
->m_family
= family
;
132 void wxFont
::SetStyle(int style
)
136 M_FONTDATA
->m_style
= style
;
141 void wxFont
::SetWeight(int weight
)
145 M_FONTDATA
->m_weight
= weight
;
150 void wxFont
::SetFaceName(const wxString
& faceName
)
154 M_FONTDATA
->m_faceName
= faceName
;
159 void wxFont
::SetUnderlined(bool underlined
)
163 M_FONTDATA
->m_underlined
= underlined
;
168 wxString wxFont
::GetFamilyString() const
174 fam
= "wxDECORATIVE";
198 /* New font system */
199 wxString wxFont
::GetFaceName() const
203 str
= M_FONTDATA
->m_faceName
;
207 wxString wxFont
::GetStyleString() const
225 wxString wxFont
::GetWeightString() const