1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "font.h"
19 //-----------------------------------------------------------------------------
21 //-----------------------------------------------------------------------------
23 static char *wx_font_family
[] = {
24 "wxDEFAULT", "wxDECORATIVE", "wxMODERN", "wxROMAN", "wxSCRIPT",
25 "wxSWISS", "wxTELETYPE",
27 static char *wx_font_style
[] = {
28 "wxDEFAULT", "wxNORMAL", "wxSLANT", "wxITALIC",
30 static char *wx_font_weight
[] = {
31 "wxDEFAULT", "wxNORMAL", "wxBOLD", "wxLIGHT",
34 extern wxFontNameDirectory wxTheFontNameDirectory
;
36 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
40 class wxFontRefData
: public wxObjectRefData
47 wxList m_scaled_xfonts
;
49 int m_family
, m_style
, m_weight
;
56 wxFontRefData::wxFontRefData(void) : m_scaled_xfonts(wxKEY_INTEGER
)
67 wxFontRefData::~wxFontRefData(void)
69 wxNode
*node
= m_scaled_xfonts
.First();
72 wxNode
*next
= node
->Next();
82 //-----------------------------------------------------------------------------
84 #define M_FONTDATA ((wxFontRefData *)m_refData)
86 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
90 if (wxTheFontList
) wxTheFontList
->Append( this );
93 wxFont::wxFont( char *xFontName
)
95 if (!xFontName
) return;
97 m_refData
= new wxFontRefData();
101 wxFont::wxFont(int PointSize
, int FontIdOrFamily
, int Style
, int Weight
,
102 bool Underlined
, const char* Face
)
104 m_refData
= new wxFontRefData();
107 if (wxTheFontList
) wxTheFontList
->Append( this );
110 wxFont::wxFont(int PointSize
, const char *Face
, int Family
, int Style
,
111 int Weight
, bool Underlined
)
113 m_refData
= new wxFontRefData();
116 if (wxTheFontList
) wxTheFontList
->Append( this );
119 wxFont::wxFont( const wxFont
& font
)
124 wxFont::wxFont( const wxFont
* font
)
127 if (font
) Ref( *font
);
130 wxFont::~wxFont(void)
132 if (wxTheFontList
) wxTheFontList
->DeleteObject( this );
135 wxFont
& wxFont::operator = ( const wxFont
& font
)
137 if (*this == font
) return (*this);
142 bool wxFont::operator == ( const wxFont
& font
)
144 return m_refData
== font
.m_refData
;
147 bool wxFont::operator != ( const wxFont
& font
)
149 return m_refData
!= font
.m_refData
;
154 return (m_refData
!= NULL
);
157 int wxFont::GetPointSize(void) const
159 return M_FONTDATA
->m_pointSize
;
162 wxString
wxFont::GetFaceString(void) const
167 wxString
wxFont::GetFaceName(void) const
172 int wxFont::GetFamily(void) const
174 return M_FONTDATA
->m_family
;
177 wxString
wxFont::GetFamilyString(void) const
179 wxString s
= wx_font_family
[M_FONTDATA
->m_family
];
183 int wxFont::GetFontId(void) const
185 return M_FONTDATA
->m_fontId
; // stub
188 int wxFont::GetStyle(void) const
190 return M_FONTDATA
->m_style
;
193 wxString
wxFont::GetStyleString(void) const
195 wxString s
= wx_font_style
[M_FONTDATA
->m_style
];
199 int wxFont::GetWeight(void) const
201 return M_FONTDATA
->m_weight
;
204 wxString
wxFont::GetWeightString(void) const
206 wxString s
= wx_font_weight
[M_FONTDATA
->m_weight
];
210 bool wxFont::GetUnderlined(void) const
212 return M_FONTDATA
->m_underlined
;