]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: unix/fontutil.cpp | |
3 | // Purpose: Font helper functions for X11 (GDK/X) | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 05.11.99 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Vadim Zeitlin | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | #ifdef __GNUG__ | |
21 | #pragma implementation "fontutil.h" | |
22 | #endif | |
23 | ||
24 | // For compilers that support precompilation, includes "wx.h". | |
25 | #include "wx/wxprec.h" | |
26 | ||
27 | #ifdef __BORLANDC__ | |
28 | #pragma hdrstop | |
29 | #endif | |
30 | ||
31 | #ifndef WX_PRECOMP | |
32 | #endif // PCH | |
33 | ||
34 | #include "wx/fontutil.h" | |
35 | #include "wx/fontmap.h" | |
36 | #include "wx/tokenzr.h" | |
37 | #include "wx/hash.h" | |
38 | #include "wx/module.h" | |
39 | ||
40 | #ifdef __WXGTK20__ | |
41 | ||
42 | #include "wx/gtk/private.h" | |
43 | ||
44 | // ---------------------------------------------------------------------------- | |
45 | // wxNativeFontInfo | |
46 | // ---------------------------------------------------------------------------- | |
47 | ||
48 | void wxNativeFontInfo::Init() | |
49 | { | |
50 | description = NULL; | |
51 | } | |
52 | ||
53 | int wxNativeFontInfo::GetPointSize() const | |
54 | { | |
55 | return pango_font_description_get_size( description ) / PANGO_SCALE; | |
56 | } | |
57 | ||
58 | wxFontStyle wxNativeFontInfo::GetStyle() const | |
59 | { | |
60 | wxFontStyle m_style = wxFONTSTYLE_NORMAL; | |
61 | ||
62 | switch (pango_font_description_get_style( description )) | |
63 | { | |
64 | case PANGO_STYLE_NORMAL: | |
65 | m_style = wxFONTSTYLE_NORMAL; | |
66 | break; | |
67 | case PANGO_STYLE_ITALIC: | |
68 | m_style = wxFONTSTYLE_ITALIC; | |
69 | break; | |
70 | case PANGO_STYLE_OBLIQUE: | |
71 | m_style = wxFONTSTYLE_SLANT; | |
72 | break; | |
73 | } | |
74 | ||
75 | return m_style; | |
76 | } | |
77 | ||
78 | wxFontWeight wxNativeFontInfo::GetWeight() const | |
79 | { | |
80 | wxFontWeight m_weight = wxFONTWEIGHT_NORMAL; | |
81 | ||
82 | switch (pango_font_description_get_weight( description )) | |
83 | { | |
84 | case PANGO_WEIGHT_ULTRALIGHT: | |
85 | m_weight = wxFONTWEIGHT_LIGHT; | |
86 | break; | |
87 | case PANGO_WEIGHT_LIGHT: | |
88 | m_weight = wxFONTWEIGHT_LIGHT; | |
89 | break; | |
90 | case PANGO_WEIGHT_NORMAL: | |
91 | m_weight = wxFONTWEIGHT_NORMAL; | |
92 | break; | |
93 | case PANGO_WEIGHT_BOLD: | |
94 | m_weight = wxFONTWEIGHT_BOLD; | |
95 | break; | |
96 | case PANGO_WEIGHT_ULTRABOLD: | |
97 | m_weight = wxFONTWEIGHT_BOLD; | |
98 | break; | |
99 | case PANGO_WEIGHT_HEAVY: | |
100 | m_weight = wxFONTWEIGHT_BOLD; | |
101 | break; | |
102 | } | |
103 | ||
104 | return m_weight; | |
105 | } | |
106 | ||
107 | bool wxNativeFontInfo::GetUnderlined() const | |
108 | { | |
109 | return FALSE; | |
110 | } | |
111 | ||
112 | wxString wxNativeFontInfo::GetFaceName() const | |
113 | { | |
114 | wxString tmp = wxGTK_CONV_BACK( pango_font_description_get_family( description ) ); | |
115 | ||
116 | return tmp; | |
117 | } | |
118 | ||
119 | wxFontFamily wxNativeFontInfo::GetFamily() const | |
120 | { | |
121 | return wxFONTFAMILY_SWISS; | |
122 | } | |
123 | ||
124 | wxFontEncoding wxNativeFontInfo::GetEncoding() const | |
125 | { | |
126 | return wxFONTENCODING_SYSTEM; | |
127 | } | |
128 | ||
129 | // ---------------------------------------------------------------------------- | |
130 | // wxNativeEncodingInfo | |
131 | // ---------------------------------------------------------------------------- | |
132 | ||
133 | bool wxNativeEncodingInfo::FromString(const wxString& s) | |
134 | { | |
135 | return FALSE; | |
136 | } | |
137 | ||
138 | wxString wxNativeEncodingInfo::ToString() const | |
139 | { | |
140 | return wxEmptyString; | |
141 | } | |
142 | ||
143 | bool wxTestFontEncoding(const wxNativeEncodingInfo& info) | |
144 | { | |
145 | return TRUE; | |
146 | } | |
147 | ||
148 | bool wxGetNativeFontEncoding(wxFontEncoding encoding, | |
149 | wxNativeEncodingInfo *info) | |
150 | { | |
151 | return FALSE; | |
152 | } | |
153 | ||
154 | #else | |
155 | // __WXGTK20__ | |
156 | ||
157 | #ifdef __X__ | |
158 | #ifdef __VMS__ | |
159 | #pragma message disable nosimpint | |
160 | #endif | |
161 | ||
162 | #include <X11/Xlib.h> | |
163 | ||
164 | #ifdef __VMS__ | |
165 | #pragma message enable nosimpint | |
166 | #endif | |
167 | ||
168 | #include "wx/utils.h" // for wxGetDisplay() | |
169 | #elif defined(__WXGTK__) | |
170 | // we have to declare struct tm to avoid problems with first forward | |
171 | // declaring it in C code (glib.h included from gdk.h does it) and then | |
172 | // defining it when time.h is included from the headers below - this is | |
173 | // known not to work at least with Sun CC 6.01 | |
174 | #include <time.h> | |
175 | ||
176 | #include <gdk/gdk.h> | |
177 | #endif | |
178 | ||
179 | ||
180 | // ---------------------------------------------------------------------------- | |
181 | // private data | |
182 | // ---------------------------------------------------------------------------- | |
183 | ||
184 | static wxHashTable *g_fontHash = (wxHashTable*) NULL; | |
185 | ||
186 | // ---------------------------------------------------------------------------- | |
187 | // private functions | |
188 | // ---------------------------------------------------------------------------- | |
189 | ||
190 | // ============================================================================ | |
191 | // implementation | |
192 | // ============================================================================ | |
193 | ||
194 | // ---------------------------------------------------------------------------- | |
195 | // wxNativeEncodingInfo | |
196 | // ---------------------------------------------------------------------------- | |
197 | ||
198 | // convert to/from the string representation: format is | |
199 | // encodingid;registry;encoding[;facename] | |
200 | bool wxNativeEncodingInfo::FromString(const wxString& s) | |
201 | { | |
202 | return false; | |
203 | } | |
204 | ||
205 | wxString wxNativeEncodingInfo::ToString() const | |
206 | { | |
207 | return wxEmptyString; | |
208 | } | |
209 | ||
210 | // ---------------------------------------------------------------------------- | |
211 | // common functions | |
212 | // ---------------------------------------------------------------------------- | |
213 | ||
214 | bool wxGetNativeFontEncoding(wxFontEncoding encoding, | |
215 | wxNativeEncodingInfo *info) | |
216 | { | |
217 | return FALSE; | |
218 | } | |
219 | ||
220 | bool wxTestFontEncoding(const wxNativeEncodingInfo& info) | |
221 | { | |
222 | return false; | |
223 | } | |
224 | ||
225 | // ---------------------------------------------------------------------------- | |
226 | // private functions | |
227 | // ---------------------------------------------------------------------------- | |
228 | ||
229 | // ---------------------------------------------------------------------------- | |
230 | // wxFontModule | |
231 | // ---------------------------------------------------------------------------- | |
232 | ||
233 | class wxFontModule : public wxModule | |
234 | { | |
235 | public: | |
236 | bool OnInit(); | |
237 | void OnExit(); | |
238 | ||
239 | private: | |
240 | DECLARE_DYNAMIC_CLASS(wxFontModule) | |
241 | }; | |
242 | ||
243 | IMPLEMENT_DYNAMIC_CLASS(wxFontModule, wxModule) | |
244 | ||
245 | bool wxFontModule::OnInit() | |
246 | { | |
247 | g_fontHash = new wxHashTable( wxKEY_STRING ); | |
248 | ||
249 | return TRUE; | |
250 | } | |
251 | ||
252 | void wxFontModule::OnExit() | |
253 | { | |
254 | delete g_fontHash; | |
255 | ||
256 | g_fontHash = (wxHashTable *)NULL; | |
257 | } | |
258 | ||
259 | #endif | |
260 | // not GTK 2.0 |