]> git.saurik.com Git - wxWidgets.git/blob - src/qt/font.cpp
Since wxREADONLY has disappeared, I had to change to wxTE_READONLY
[wxWidgets.git] / src / qt / font.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: font.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Created: 01/02/97
6 // Id:
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifdef __GNUG__
12 #pragma implementation "font.h"
13 #endif
14
15 #include "wx/font.h"
16 #include "wx/utils.h"
17 #include <strings.h>
18
19 //-----------------------------------------------------------------------------
20 // local data
21 //-----------------------------------------------------------------------------
22
23 static char *wx_font_family [] = {
24 "wxDEFAULT", "wxDECORATIVE", "wxMODERN", "wxROMAN", "wxSCRIPT",
25 "wxSWISS", "wxTELETYPE",
26 };
27 static char *wx_font_style [] = {
28 "wxDEFAULT", "wxNORMAL", "wxSLANT", "wxITALIC",
29 };
30 static char *wx_font_weight [] = {
31 "wxDEFAULT", "wxNORMAL", "wxBOLD", "wxLIGHT",
32 };
33
34 extern wxFontNameDirectory wxTheFontNameDirectory;
35
36 //-----------------------------------------------------------------------------
37 // wxFont
38 //-----------------------------------------------------------------------------
39
40 class wxFontRefData: public wxObjectRefData
41 {
42 public:
43
44 wxFontRefData(void);
45 ~wxFontRefData(void);
46
47 wxList m_scaled_xfonts;
48 int m_pointSize;
49 int m_family, m_style, m_weight;
50 bool m_underlined;
51 int m_fontId;
52 char* m_faceName;
53
54 };
55
56 wxFontRefData::wxFontRefData(void) : m_scaled_xfonts(wxKEY_INTEGER)
57 {
58 m_pointSize = -1;
59 m_family = -1;
60 m_style = -1;
61 m_weight = -1;
62 m_underlined = FALSE;
63 m_fontId = 0;
64 m_faceName = NULL;
65 };
66
67 wxFontRefData::~wxFontRefData(void)
68 {
69 wxNode *node = m_scaled_xfonts.First();
70 while (node)
71 {
72 wxNode *next = node->Next();
73 node = next;
74 };
75 if (m_faceName)
76 {
77 delete m_faceName;
78 m_faceName = NULL;
79 };
80 };
81
82 //-----------------------------------------------------------------------------
83
84 #define M_FONTDATA ((wxFontRefData *)m_refData)
85
86 IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
87
88 wxFont::wxFont(void)
89 {
90 if (wxTheFontList) wxTheFontList->Append( this );
91 };
92
93 wxFont::wxFont( char *xFontName )
94 {
95 if (!xFontName) return;
96
97 m_refData = new wxFontRefData();
98
99 };
100
101 wxFont::wxFont(int PointSize, int FontIdOrFamily, int Style, int Weight,
102 bool Underlined, const char* Face)
103 {
104 m_refData = new wxFontRefData();
105
106
107 if (wxTheFontList) wxTheFontList->Append( this );
108 };
109
110 wxFont::wxFont(int PointSize, const char *Face, int Family, int Style,
111 int Weight, bool Underlined)
112 {
113 m_refData = new wxFontRefData();
114
115
116 if (wxTheFontList) wxTheFontList->Append( this );
117 };
118
119 wxFont::wxFont( const wxFont& font )
120 {
121 Ref( font );
122 };
123
124 wxFont::wxFont( const wxFont* font )
125 {
126 UnRef();
127 if (font) Ref( *font );
128 };
129
130 wxFont::~wxFont(void)
131 {
132 if (wxTheFontList) wxTheFontList->DeleteObject( this );
133 };
134
135 wxFont& wxFont::operator = ( const wxFont& font )
136 {
137 if (*this == font) return (*this);
138 Ref( font );
139 return *this;
140 };
141
142 bool wxFont::operator == ( const wxFont& font )
143 {
144 return m_refData == font.m_refData;
145 };
146
147 bool wxFont::operator != ( const wxFont& font )
148 {
149 return m_refData != font.m_refData;
150 };
151
152 bool wxFont::Ok()
153 {
154 return (m_refData != NULL);
155 };
156
157 int wxFont::GetPointSize(void) const
158 {
159 return M_FONTDATA->m_pointSize;
160 };
161
162 wxString wxFont::GetFaceString(void) const
163 {
164 return "";
165 };
166
167 wxString wxFont::GetFaceName(void) const
168 {
169 return "";
170 };
171
172 int wxFont::GetFamily(void) const
173 {
174 return M_FONTDATA->m_family;
175 };
176
177 wxString wxFont::GetFamilyString(void) const
178 {
179 wxString s = wx_font_family[M_FONTDATA->m_family];
180 return s;
181 };
182
183 int wxFont::GetFontId(void) const
184 {
185 return M_FONTDATA->m_fontId; // stub
186 };
187
188 int wxFont::GetStyle(void) const
189 {
190 return M_FONTDATA->m_style;
191 };
192
193 wxString wxFont::GetStyleString(void) const
194 {
195 wxString s = wx_font_style[M_FONTDATA->m_style];
196 return s;
197 };
198
199 int wxFont::GetWeight(void) const
200 {
201 return M_FONTDATA->m_weight;
202 };
203
204 wxString wxFont::GetWeightString(void) const
205 {
206 wxString s = wx_font_weight[M_FONTDATA->m_weight];
207 return s;
208 };
209
210 bool wxFont::GetUnderlined(void) const
211 {
212 return M_FONTDATA->m_underlined;
213 };