]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: fonts.i | |
3 | // Purpose: SWIG interface file wxFont, local, converters, etc. | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 1-Apr-2002 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2002 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | ||
14 | %module fonts | |
15 | ||
16 | %{ | |
17 | #include "helpers.h" | |
18 | #include <wx/fontmap.h> | |
19 | #include <wx/fontenc.h> | |
20 | #include <wx/fontutil.h> | |
21 | #include <wx/fontenum.h> | |
22 | #include <wx/intl.h> | |
23 | #include <wx/encconv.h> | |
24 | %} | |
25 | ||
26 | //---------------------------------------------------------------------- | |
27 | ||
28 | %include typemaps.i | |
29 | %include my_typemaps.i | |
30 | ||
31 | // Import some definitions of other classes, etc. | |
32 | %import _defs.i | |
33 | %import misc.i | |
34 | ||
35 | ||
36 | //--------------------------------------------------------------------------- | |
37 | %{ | |
38 | // Put some wx default wxChar* values into wxStrings. | |
39 | static const wxString wxPyEmptyString(wxT("")); | |
40 | %} | |
41 | //--------------------------------------------------------------------------- | |
42 | ||
43 | ||
44 | ||
45 | enum wxFontFamily | |
46 | { | |
47 | wxFONTFAMILY_DEFAULT = wxDEFAULT, | |
48 | wxFONTFAMILY_DECORATIVE = wxDECORATIVE, | |
49 | wxFONTFAMILY_ROMAN = wxROMAN, | |
50 | wxFONTFAMILY_SCRIPT = wxSCRIPT, | |
51 | wxFONTFAMILY_SWISS = wxSWISS, | |
52 | wxFONTFAMILY_MODERN = wxMODERN, | |
53 | wxFONTFAMILY_TELETYPE = wxTELETYPE, | |
54 | wxFONTFAMILY_MAX, | |
55 | wxFONTFAMILY_UNKNOWN | |
56 | }; | |
57 | ||
58 | // font styles | |
59 | enum wxFontStyle | |
60 | { | |
61 | wxFONTSTYLE_NORMAL = wxNORMAL, | |
62 | wxFONTSTYLE_ITALIC = wxITALIC, | |
63 | wxFONTSTYLE_SLANT = wxSLANT, | |
64 | wxFONTSTYLE_MAX | |
65 | }; | |
66 | ||
67 | // font weights | |
68 | enum wxFontWeight | |
69 | { | |
70 | wxFONTWEIGHT_NORMAL = wxNORMAL, | |
71 | wxFONTWEIGHT_LIGHT = wxLIGHT, | |
72 | wxFONTWEIGHT_BOLD = wxBOLD, | |
73 | wxFONTWEIGHT_MAX | |
74 | }; | |
75 | ||
76 | ||
77 | ||
78 | // font encodings | |
79 | enum wxFontEncoding | |
80 | { | |
81 | wxFONTENCODING_SYSTEM = -1, // system default | |
82 | wxFONTENCODING_DEFAULT, // current default encoding | |
83 | ||
84 | // ISO8859 standard defines a number of single-byte charsets | |
85 | wxFONTENCODING_ISO8859_1, // West European (Latin1) | |
86 | wxFONTENCODING_ISO8859_2, // Central and East European (Latin2) | |
87 | wxFONTENCODING_ISO8859_3, // Esperanto (Latin3) | |
88 | wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4) | |
89 | wxFONTENCODING_ISO8859_5, // Cyrillic | |
90 | wxFONTENCODING_ISO8859_6, // Arabic | |
91 | wxFONTENCODING_ISO8859_7, // Greek | |
92 | wxFONTENCODING_ISO8859_8, // Hebrew | |
93 | wxFONTENCODING_ISO8859_9, // Turkish (Latin5) | |
94 | wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6) | |
95 | wxFONTENCODING_ISO8859_11, // Thai | |
96 | wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it | |
97 | // here anyhow to make all ISO8859 | |
98 | // consecutive numbers | |
99 | wxFONTENCODING_ISO8859_13, // Baltic (Latin7) | |
100 | wxFONTENCODING_ISO8859_14, // Latin8 | |
101 | wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro) | |
102 | wxFONTENCODING_ISO8859_MAX, | |
103 | ||
104 | // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html) | |
105 | wxFONTENCODING_KOI8, // we don't support any of KOI8 variants | |
106 | wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866 | |
107 | wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria | |
108 | ||
109 | // what would we do without Microsoft? They have their own encodings | |
110 | // for DOS | |
111 | wxFONTENCODING_CP437, // original MS-DOS codepage | |
112 | wxFONTENCODING_CP850, // CP437 merged with Latin1 | |
113 | wxFONTENCODING_CP852, // CP437 merged with Latin2 | |
114 | wxFONTENCODING_CP855, // another cyrillic encoding | |
115 | wxFONTENCODING_CP866, // and another one | |
116 | // and for Windows | |
117 | wxFONTENCODING_CP874, // WinThai | |
118 | wxFONTENCODING_CP932, // Japanese (shift-JIS) | |
119 | wxFONTENCODING_CP936, // Chinese simplified (GB) | |
120 | wxFONTENCODING_CP949, // Korean (Hangul charset) | |
121 | wxFONTENCODING_CP950, // Chinese (traditional - Big5) | |
122 | wxFONTENCODING_CP1250, // WinLatin2 | |
123 | wxFONTENCODING_CP1251, // WinCyrillic | |
124 | wxFONTENCODING_CP1252, // WinLatin1 | |
125 | wxFONTENCODING_CP1253, // WinGreek (8859-7) | |
126 | wxFONTENCODING_CP1254, // WinTurkish | |
127 | wxFONTENCODING_CP1255, // WinHebrew | |
128 | wxFONTENCODING_CP1256, // WinArabic | |
129 | wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7) | |
130 | wxFONTENCODING_CP12_MAX, | |
131 | ||
132 | wxFONTENCODING_UTF7, // UTF-7 Unicode encoding | |
133 | wxFONTENCODING_UTF8, // UTF-8 Unicode encoding | |
134 | ||
135 | // Far Eastern encodings | |
136 | // Chinese | |
137 | wxFONTENCODING_GB2312 = wxFONTENCODING_CP936, // Simplified Chinese | |
138 | wxFONTENCODING_BIG5 = wxFONTENCODING_CP950, // Traditional Chinese | |
139 | ||
140 | // Japanese (see http://zsigri.tripod.com/fontboard/cjk/jis.html) | |
141 | wxFONTENCODING_SHIFT_JIS = wxFONTENCODING_CP932, // Shift JIS | |
142 | wxFONTENCODING_EUC_JP = wxFONTENCODING_UTF8 + 1, // Extended Unix Codepage | |
143 | // for Japanese | |
144 | ||
145 | wxFONTENCODING_UNICODE, // Unicode (for wxEncodingConverter only) | |
146 | ||
147 | wxFONTENCODING_MAX | |
148 | }; | |
149 | ||
150 | ||
151 | //--------------------------------------------------------------------------- | |
152 | // wxNativeFontInfo is platform-specific font representation: this struct | |
153 | // should be considered as opaque font description only used by the native | |
154 | // functions, the user code can only get the objects of this type from | |
155 | // somewhere and pass it somewhere else (possibly save them somewhere using | |
156 | // ToString() and restore them using FromString()) | |
157 | struct wxNativeFontInfo | |
158 | { | |
159 | wxNativeFontInfo(); | |
160 | ||
161 | // reset to the default state | |
162 | void Init(); | |
163 | ||
164 | // accessors and modifiers for the font elements | |
165 | int GetPointSize() const; | |
166 | wxFontStyle GetStyle() const; | |
167 | wxFontWeight GetWeight() const; | |
168 | bool GetUnderlined() const; | |
169 | wxString GetFaceName() const; | |
170 | wxFontFamily GetFamily() const; | |
171 | wxFontEncoding GetEncoding() const; | |
172 | ||
173 | void SetPointSize(int pointsize); | |
174 | void SetStyle(wxFontStyle style); | |
175 | void SetWeight(wxFontWeight weight); | |
176 | void SetUnderlined(bool underlined); | |
177 | void SetFaceName(wxString facename); | |
178 | void SetFamily(wxFontFamily family); | |
179 | void SetEncoding(wxFontEncoding encoding); | |
180 | ||
181 | // it is important to be able to serialize wxNativeFontInfo objects to be | |
182 | // able to store them (in config file, for example) | |
183 | bool FromString(const wxString& s); | |
184 | wxString ToString() const; | |
185 | ||
186 | %addmethods { | |
187 | wxString __str__() { | |
188 | return self->ToString(); | |
189 | } | |
190 | } | |
191 | ||
192 | // we also want to present the native font descriptions to the user in some | |
193 | // human-readable form (it is not platform independent neither, but can | |
194 | // hopefully be understood by the user) | |
195 | bool FromUserString(const wxString& s); | |
196 | wxString ToUserString() const; | |
197 | }; | |
198 | ||
199 | ||
200 | %{ | |
201 | // Fix some link errors... Remove this when these methods get real implementations... | |
202 | #if defined(__WXGTK__) || defined(__WXX11__) | |
203 | #if wxUSE_PANGO | |
204 | void wxNativeFontInfo::SetPointSize(int pointsize) | |
205 | { wxFAIL_MSG( _T("not implemented") ); } | |
206 | ||
207 | void wxNativeFontInfo::SetStyle(wxFontStyle style) | |
208 | { wxFAIL_MSG( _T("not implemented") ); } | |
209 | ||
210 | void wxNativeFontInfo::SetWeight(wxFontWeight weight) | |
211 | { wxFAIL_MSG( _T("not implemented") ); } | |
212 | ||
213 | void wxNativeFontInfo::SetUnderlined(bool WXUNUSED(underlined)) | |
214 | { wxFAIL_MSG( _T("not implemented") ); } | |
215 | ||
216 | void wxNativeFontInfo::SetFaceName(wxString facename) | |
217 | { wxFAIL_MSG( _T("not implemented") ); } | |
218 | ||
219 | void wxNativeFontInfo::SetFamily(wxFontFamily family) | |
220 | { wxFAIL_MSG( _T("not implemented") ); } | |
221 | ||
222 | void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding) | |
223 | { wxFAIL_MSG( _T("not implemented") ); } | |
224 | #endif | |
225 | #endif | |
226 | %} | |
227 | ||
228 | //--------------------------------------------------------------------------- | |
229 | // wxFontMapper manages user-definable correspondence between logical font | |
230 | // names and the fonts present on the machine. | |
231 | // | |
232 | // The default implementations of all functions will ask the user if they are | |
233 | // not capable of finding the answer themselves and store the answer in a | |
234 | // config file (configurable via SetConfigXXX functions). This behaviour may | |
235 | // be disabled by giving the value of FALSE to "interactive" parameter. | |
236 | // However, the functions will always consult the config file to allow the | |
237 | // user-defined values override the default logic and there is no way to | |
238 | // disable this - which shouldn't be ever needed because if "interactive" was | |
239 | // never TRUE, the config file is never created anyhow. | |
240 | class wxFontMapper | |
241 | { | |
242 | public: | |
243 | wxFontMapper(); | |
244 | ~wxFontMapper(); | |
245 | ||
246 | // return instance of the wxFontMapper singleton | |
247 | static wxFontMapper *Get(); | |
248 | // set the sigleton to 'mapper' instance and return previous one | |
249 | static wxFontMapper *Set(wxFontMapper *mapper); | |
250 | ||
251 | ||
252 | // returns the encoding for the given charset (in the form of RFC 2046) or | |
253 | // wxFONTENCODING_SYSTEM if couldn't decode it | |
254 | // | |
255 | // interactive parameter is ignored in the base class, we behave as if it | |
256 | // were always false | |
257 | virtual wxFontEncoding CharsetToEncoding(const wxString& charset, | |
258 | bool interactive = true); | |
259 | ||
260 | ||
261 | // get the number of font encodings we know about | |
262 | static size_t GetSupportedEncodingsCount(); | |
263 | ||
264 | // get the n-th supported encoding | |
265 | static wxFontEncoding GetEncoding(size_t n); | |
266 | ||
267 | // return internal string identifier for the encoding (see also | |
268 | // GetEncodingDescription()) | |
269 | static wxString GetEncodingName(wxFontEncoding encoding); | |
270 | ||
271 | // return user-readable string describing the given encoding | |
272 | // | |
273 | // NB: hard-coded now, but might change later (read it from config?) | |
274 | static wxString GetEncodingDescription(wxFontEncoding encoding); | |
275 | ||
276 | ||
277 | // set the config object to use (may be NULL to use default) | |
278 | void SetConfig(wxConfigBase *config); | |
279 | ||
280 | // set the root config path to use (should be an absolute path) | |
281 | void SetConfigPath(const wxString& prefix); | |
282 | ||
283 | // return default config path | |
284 | static const wxChar *GetDefaultConfigPath(); | |
285 | ||
286 | ||
287 | ||
288 | // Find an alternative for the given encoding (which is supposed to not be | |
289 | // available on this system). If successful, returns the encoding otherwise | |
290 | // returns None. | |
291 | %addmethods { | |
292 | PyObject* GetAltForEncoding(wxFontEncoding encoding, | |
293 | const wxString& facename = wxPyEmptyString, | |
294 | bool interactive = TRUE) { | |
295 | wxFontEncoding alt_enc; | |
296 | if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive)) | |
297 | return PyInt_FromLong(alt_enc); | |
298 | else { | |
299 | Py_INCREF(Py_None); | |
300 | return Py_None; | |
301 | } | |
302 | } | |
303 | } | |
304 | ||
305 | ||
306 | // checks whether given encoding is available in given face or not. | |
307 | // If no facename is given, | |
308 | bool IsEncodingAvailable(wxFontEncoding encoding, | |
309 | const wxString& facename = wxPyEmptyString); | |
310 | ||
311 | // the parent window for modal dialogs | |
312 | void SetDialogParent(wxWindow *parent) { m_windowParent = parent; } | |
313 | ||
314 | // the title for the dialogs (note that default is quite reasonable) | |
315 | void SetDialogTitle(const wxString& title) { m_titleDialog = title; } | |
316 | ||
317 | }; | |
318 | ||
319 | ||
320 | ||
321 | //--------------------------------------------------------------------------- | |
322 | ||
323 | class wxFont : public wxObject { | |
324 | public: | |
325 | wxFont( int pointSize, int family, int style, int weight, | |
326 | int underline=FALSE, const wxString& faceName = wxPyEmptyString, | |
327 | wxFontEncoding encoding=wxFONTENCODING_DEFAULT); | |
328 | ||
329 | %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info); | |
330 | %addmethods { | |
331 | %new wxFont* wxFontFromNativeInfoString(const wxString& info) { | |
332 | wxNativeFontInfo nfi; | |
333 | nfi.FromString(info); | |
334 | return new wxFont(nfi); | |
335 | } | |
336 | } | |
337 | ||
338 | ~wxFont(); | |
339 | ||
340 | bool Ok() const; | |
341 | int GetPointSize() const; | |
342 | int GetFamily() const; | |
343 | int GetStyle() const; | |
344 | int GetWeight() const; | |
345 | bool GetUnderlined() const; | |
346 | wxString GetFaceName() const; | |
347 | wxFontEncoding GetEncoding() const; | |
348 | ||
349 | bool IsFixedWidth(); | |
350 | ||
351 | wxNativeFontInfo* GetNativeFontInfo() const; | |
352 | wxString GetNativeFontInfoDesc() const; | |
353 | wxString GetNativeFontInfoUserDesc() const; | |
354 | ||
355 | void SetPointSize(int pointSize); | |
356 | void SetFamily(int family); | |
357 | void SetStyle(int style); | |
358 | void SetWeight(int weight); | |
359 | void SetFaceName(const wxString& faceName); | |
360 | void SetUnderlined(bool underlined); | |
361 | void SetEncoding(wxFontEncoding encoding); | |
362 | void SetNativeFontInfo(const wxNativeFontInfo& info); | |
363 | // void SetNativeFontInfo(const wxString& info); | |
364 | void SetNativeFontInfoUserDesc(const wxString& info); | |
365 | ||
366 | wxString GetFamilyString() const; | |
367 | wxString GetStyleString() const; | |
368 | wxString GetWeightString() const; | |
369 | ||
370 | void SetNoAntiAliasing( bool no = TRUE ); | |
371 | bool GetNoAntiAliasing(); | |
372 | ||
373 | static wxFontEncoding GetDefaultEncoding(); | |
374 | static void SetDefaultEncoding(wxFontEncoding encoding); | |
375 | ||
376 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" | |
377 | }; | |
378 | ||
379 | ||
380 | class wxFontList : public wxObject { | |
381 | public: | |
382 | ||
383 | void AddFont(wxFont* font); | |
384 | wxFont * FindOrCreateFont(int point_size, int family, int style, int weight, | |
385 | bool underline = FALSE, const wxString& facename = wxPyEmptyString, | |
386 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
387 | void RemoveFont(wxFont *font); | |
388 | ||
389 | int GetCount(); | |
390 | }; | |
391 | ||
392 | ||
393 | //---------------------------------------------------------------------- | |
394 | // wxFontEnumerator | |
395 | ||
396 | %{ | |
397 | class wxPyFontEnumerator : public wxFontEnumerator { | |
398 | public: | |
399 | wxPyFontEnumerator() {} | |
400 | ~wxPyFontEnumerator() {} | |
401 | ||
402 | DEC_PYCALLBACK_BOOL_STRING(OnFacename); | |
403 | DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding); | |
404 | ||
405 | PYPRIVATE; | |
406 | }; | |
407 | ||
408 | IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename); | |
409 | IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding); | |
410 | ||
411 | %} | |
412 | ||
413 | %name(wxFontEnumerator) class wxPyFontEnumerator { | |
414 | public: | |
415 | wxPyFontEnumerator(); | |
416 | ~wxPyFontEnumerator(); | |
417 | void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref); | |
418 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFontEnumerator, 0)" | |
419 | ||
420 | bool EnumerateFacenames( | |
421 | wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all | |
422 | bool fixedWidthOnly = FALSE); | |
423 | bool EnumerateEncodings(const wxString& facename = wxPyEmptyString); | |
424 | ||
425 | //wxArrayString* GetEncodings(); | |
426 | //wxArrayString* GetFacenames(); | |
427 | %addmethods { | |
428 | PyObject* GetEncodings() { | |
429 | wxArrayString* arr = self->GetEncodings(); | |
430 | return wxArrayString2PyList_helper(*arr); | |
431 | } | |
432 | ||
433 | PyObject* GetFacenames() { | |
434 | wxArrayString* arr = self->GetFacenames(); | |
435 | return wxArrayString2PyList_helper(*arr); | |
436 | } | |
437 | } | |
438 | }; | |
439 | ||
440 | //--------------------------------------------------------------------------- | |
441 | // wxLocale. Not really font related, but close enough | |
442 | ||
443 | ||
444 | enum wxLanguage | |
445 | { | |
446 | // user's default/preffered language as got from OS: | |
447 | wxLANGUAGE_DEFAULT, | |
448 | // unknown language, if wxLocale::GetSystemLanguage fails: | |
449 | wxLANGUAGE_UNKNOWN, | |
450 | ||
451 | wxLANGUAGE_ABKHAZIAN, | |
452 | wxLANGUAGE_AFAR, | |
453 | wxLANGUAGE_AFRIKAANS, | |
454 | wxLANGUAGE_ALBANIAN, | |
455 | wxLANGUAGE_AMHARIC, | |
456 | wxLANGUAGE_ARABIC, | |
457 | wxLANGUAGE_ARABIC_ALGERIA, | |
458 | wxLANGUAGE_ARABIC_BAHRAIN, | |
459 | wxLANGUAGE_ARABIC_EGYPT, | |
460 | wxLANGUAGE_ARABIC_IRAQ, | |
461 | wxLANGUAGE_ARABIC_JORDAN, | |
462 | wxLANGUAGE_ARABIC_KUWAIT, | |
463 | wxLANGUAGE_ARABIC_LEBANON, | |
464 | wxLANGUAGE_ARABIC_LIBYA, | |
465 | wxLANGUAGE_ARABIC_MOROCCO, | |
466 | wxLANGUAGE_ARABIC_OMAN, | |
467 | wxLANGUAGE_ARABIC_QATAR, | |
468 | wxLANGUAGE_ARABIC_SAUDI_ARABIA, | |
469 | wxLANGUAGE_ARABIC_SUDAN, | |
470 | wxLANGUAGE_ARABIC_SYRIA, | |
471 | wxLANGUAGE_ARABIC_TUNISIA, | |
472 | wxLANGUAGE_ARABIC_UAE, | |
473 | wxLANGUAGE_ARABIC_YEMEN, | |
474 | wxLANGUAGE_ARMENIAN, | |
475 | wxLANGUAGE_ASSAMESE, | |
476 | wxLANGUAGE_AYMARA, | |
477 | wxLANGUAGE_AZERI, | |
478 | wxLANGUAGE_AZERI_CYRILLIC, | |
479 | wxLANGUAGE_AZERI_LATIN, | |
480 | wxLANGUAGE_BASHKIR, | |
481 | wxLANGUAGE_BASQUE, | |
482 | wxLANGUAGE_BELARUSIAN, | |
483 | wxLANGUAGE_BENGALI, | |
484 | wxLANGUAGE_BHUTANI, | |
485 | wxLANGUAGE_BIHARI, | |
486 | wxLANGUAGE_BISLAMA, | |
487 | wxLANGUAGE_BRETON, | |
488 | wxLANGUAGE_BULGARIAN, | |
489 | wxLANGUAGE_BURMESE, | |
490 | wxLANGUAGE_CAMBODIAN, | |
491 | wxLANGUAGE_CATALAN, | |
492 | wxLANGUAGE_CHINESE, | |
493 | wxLANGUAGE_CHINESE_SIMPLIFIED, | |
494 | wxLANGUAGE_CHINESE_TRADITIONAL, | |
495 | wxLANGUAGE_CHINESE_HONGKONG, | |
496 | wxLANGUAGE_CHINESE_MACAU, | |
497 | wxLANGUAGE_CHINESE_SINGAPORE, | |
498 | wxLANGUAGE_CHINESE_TAIWAN, | |
499 | wxLANGUAGE_CORSICAN, | |
500 | wxLANGUAGE_CROATIAN, | |
501 | wxLANGUAGE_CZECH, | |
502 | wxLANGUAGE_DANISH, | |
503 | wxLANGUAGE_DUTCH, | |
504 | wxLANGUAGE_DUTCH_BELGIAN, | |
505 | wxLANGUAGE_ENGLISH, | |
506 | wxLANGUAGE_ENGLISH_UK, | |
507 | wxLANGUAGE_ENGLISH_US, | |
508 | wxLANGUAGE_ENGLISH_AUSTRALIA, | |
509 | wxLANGUAGE_ENGLISH_BELIZE, | |
510 | wxLANGUAGE_ENGLISH_BOTSWANA, | |
511 | wxLANGUAGE_ENGLISH_CANADA, | |
512 | wxLANGUAGE_ENGLISH_CARIBBEAN, | |
513 | wxLANGUAGE_ENGLISH_DENMARK, | |
514 | wxLANGUAGE_ENGLISH_EIRE, | |
515 | wxLANGUAGE_ENGLISH_JAMAICA, | |
516 | wxLANGUAGE_ENGLISH_NEW_ZEALAND, | |
517 | wxLANGUAGE_ENGLISH_PHILIPPINES, | |
518 | wxLANGUAGE_ENGLISH_SOUTH_AFRICA, | |
519 | wxLANGUAGE_ENGLISH_TRINIDAD, | |
520 | wxLANGUAGE_ENGLISH_ZIMBABWE, | |
521 | wxLANGUAGE_ESPERANTO, | |
522 | wxLANGUAGE_ESTONIAN, | |
523 | wxLANGUAGE_FAEROESE, | |
524 | wxLANGUAGE_FARSI, | |
525 | wxLANGUAGE_FIJI, | |
526 | wxLANGUAGE_FINNISH, | |
527 | wxLANGUAGE_FRENCH, | |
528 | wxLANGUAGE_FRENCH_BELGIAN, | |
529 | wxLANGUAGE_FRENCH_CANADIAN, | |
530 | wxLANGUAGE_FRENCH_LUXEMBOURG, | |
531 | wxLANGUAGE_FRENCH_MONACO, | |
532 | wxLANGUAGE_FRENCH_SWISS, | |
533 | wxLANGUAGE_FRISIAN, | |
534 | wxLANGUAGE_GALICIAN, | |
535 | wxLANGUAGE_GEORGIAN, | |
536 | wxLANGUAGE_GERMAN, | |
537 | wxLANGUAGE_GERMAN_AUSTRIAN, | |
538 | wxLANGUAGE_GERMAN_BELGIUM, | |
539 | wxLANGUAGE_GERMAN_LIECHTENSTEIN, | |
540 | wxLANGUAGE_GERMAN_LUXEMBOURG, | |
541 | wxLANGUAGE_GERMAN_SWISS, | |
542 | wxLANGUAGE_GREEK, | |
543 | wxLANGUAGE_GREENLANDIC, | |
544 | wxLANGUAGE_GUARANI, | |
545 | wxLANGUAGE_GUJARATI, | |
546 | wxLANGUAGE_HAUSA, | |
547 | wxLANGUAGE_HEBREW, | |
548 | wxLANGUAGE_HINDI, | |
549 | wxLANGUAGE_HUNGARIAN, | |
550 | wxLANGUAGE_ICELANDIC, | |
551 | wxLANGUAGE_INDONESIAN, | |
552 | wxLANGUAGE_INTERLINGUA, | |
553 | wxLANGUAGE_INTERLINGUE, | |
554 | wxLANGUAGE_INUKTITUT, | |
555 | wxLANGUAGE_INUPIAK, | |
556 | wxLANGUAGE_IRISH, | |
557 | wxLANGUAGE_ITALIAN, | |
558 | wxLANGUAGE_ITALIAN_SWISS, | |
559 | wxLANGUAGE_JAPANESE, | |
560 | wxLANGUAGE_JAVANESE, | |
561 | wxLANGUAGE_KANNADA, | |
562 | wxLANGUAGE_KASHMIRI, | |
563 | wxLANGUAGE_KASHMIRI_INDIA, | |
564 | wxLANGUAGE_KAZAKH, | |
565 | wxLANGUAGE_KERNEWEK, | |
566 | wxLANGUAGE_KINYARWANDA, | |
567 | wxLANGUAGE_KIRGHIZ, | |
568 | wxLANGUAGE_KIRUNDI, | |
569 | wxLANGUAGE_KONKANI, | |
570 | wxLANGUAGE_KOREAN, | |
571 | wxLANGUAGE_KURDISH, | |
572 | wxLANGUAGE_LAOTHIAN, | |
573 | wxLANGUAGE_LATIN, | |
574 | wxLANGUAGE_LATVIAN, | |
575 | wxLANGUAGE_LINGALA, | |
576 | wxLANGUAGE_LITHUANIAN, | |
577 | wxLANGUAGE_MACEDONIAN, | |
578 | wxLANGUAGE_MALAGASY, | |
579 | wxLANGUAGE_MALAY, | |
580 | wxLANGUAGE_MALAYALAM, | |
581 | wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM, | |
582 | wxLANGUAGE_MALAY_MALAYSIA, | |
583 | wxLANGUAGE_MALTESE, | |
584 | wxLANGUAGE_MANIPURI, | |
585 | wxLANGUAGE_MAORI, | |
586 | wxLANGUAGE_MARATHI, | |
587 | wxLANGUAGE_MOLDAVIAN, | |
588 | wxLANGUAGE_MONGOLIAN, | |
589 | wxLANGUAGE_NAURU, | |
590 | wxLANGUAGE_NEPALI, | |
591 | wxLANGUAGE_NEPALI_INDIA, | |
592 | wxLANGUAGE_NORWEGIAN_BOKMAL, | |
593 | wxLANGUAGE_NORWEGIAN_NYNORSK, | |
594 | wxLANGUAGE_OCCITAN, | |
595 | wxLANGUAGE_ORIYA, | |
596 | wxLANGUAGE_OROMO, | |
597 | wxLANGUAGE_PASHTO, | |
598 | wxLANGUAGE_POLISH, | |
599 | wxLANGUAGE_PORTUGUESE, | |
600 | wxLANGUAGE_PORTUGUESE_BRAZILIAN, | |
601 | wxLANGUAGE_PUNJABI, | |
602 | wxLANGUAGE_QUECHUA, | |
603 | wxLANGUAGE_RHAETO_ROMANCE, | |
604 | wxLANGUAGE_ROMANIAN, | |
605 | wxLANGUAGE_RUSSIAN, | |
606 | wxLANGUAGE_RUSSIAN_UKRAINE, | |
607 | wxLANGUAGE_SAMOAN, | |
608 | wxLANGUAGE_SANGHO, | |
609 | wxLANGUAGE_SANSKRIT, | |
610 | wxLANGUAGE_SCOTS_GAELIC, | |
611 | wxLANGUAGE_SERBIAN, | |
612 | wxLANGUAGE_SERBIAN_CYRILLIC, | |
613 | wxLANGUAGE_SERBIAN_LATIN, | |
614 | wxLANGUAGE_SERBO_CROATIAN, | |
615 | wxLANGUAGE_SESOTHO, | |
616 | wxLANGUAGE_SETSWANA, | |
617 | wxLANGUAGE_SHONA, | |
618 | wxLANGUAGE_SINDHI, | |
619 | wxLANGUAGE_SINHALESE, | |
620 | wxLANGUAGE_SISWATI, | |
621 | wxLANGUAGE_SLOVAK, | |
622 | wxLANGUAGE_SLOVENIAN, | |
623 | wxLANGUAGE_SOMALI, | |
624 | wxLANGUAGE_SPANISH, | |
625 | wxLANGUAGE_SPANISH_ARGENTINA, | |
626 | wxLANGUAGE_SPANISH_BOLIVIA, | |
627 | wxLANGUAGE_SPANISH_CHILE, | |
628 | wxLANGUAGE_SPANISH_COLOMBIA, | |
629 | wxLANGUAGE_SPANISH_COSTA_RICA, | |
630 | wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC, | |
631 | wxLANGUAGE_SPANISH_ECUADOR, | |
632 | wxLANGUAGE_SPANISH_EL_SALVADOR, | |
633 | wxLANGUAGE_SPANISH_GUATEMALA, | |
634 | wxLANGUAGE_SPANISH_HONDURAS, | |
635 | wxLANGUAGE_SPANISH_MEXICAN, | |
636 | wxLANGUAGE_SPANISH_MODERN, | |
637 | wxLANGUAGE_SPANISH_NICARAGUA, | |
638 | wxLANGUAGE_SPANISH_PANAMA, | |
639 | wxLANGUAGE_SPANISH_PARAGUAY, | |
640 | wxLANGUAGE_SPANISH_PERU, | |
641 | wxLANGUAGE_SPANISH_PUERTO_RICO, | |
642 | wxLANGUAGE_SPANISH_URUGUAY, | |
643 | wxLANGUAGE_SPANISH_US, | |
644 | wxLANGUAGE_SPANISH_VENEZUELA, | |
645 | wxLANGUAGE_SUNDANESE, | |
646 | wxLANGUAGE_SWAHILI, | |
647 | wxLANGUAGE_SWEDISH, | |
648 | wxLANGUAGE_SWEDISH_FINLAND, | |
649 | wxLANGUAGE_TAGALOG, | |
650 | wxLANGUAGE_TAJIK, | |
651 | wxLANGUAGE_TAMIL, | |
652 | wxLANGUAGE_TATAR, | |
653 | wxLANGUAGE_TELUGU, | |
654 | wxLANGUAGE_THAI, | |
655 | wxLANGUAGE_TIBETAN, | |
656 | wxLANGUAGE_TIGRINYA, | |
657 | wxLANGUAGE_TONGA, | |
658 | wxLANGUAGE_TSONGA, | |
659 | wxLANGUAGE_TURKISH, | |
660 | wxLANGUAGE_TURKMEN, | |
661 | wxLANGUAGE_TWI, | |
662 | wxLANGUAGE_UIGHUR, | |
663 | wxLANGUAGE_UKRAINIAN, | |
664 | wxLANGUAGE_URDU, | |
665 | wxLANGUAGE_URDU_INDIA, | |
666 | wxLANGUAGE_URDU_PAKISTAN, | |
667 | wxLANGUAGE_UZBEK, | |
668 | wxLANGUAGE_UZBEK_CYRILLIC, | |
669 | wxLANGUAGE_UZBEK_LATIN, | |
670 | wxLANGUAGE_VIETNAMESE, | |
671 | wxLANGUAGE_VOLAPUK, | |
672 | wxLANGUAGE_WELSH, | |
673 | wxLANGUAGE_WOLOF, | |
674 | wxLANGUAGE_XHOSA, | |
675 | wxLANGUAGE_YIDDISH, | |
676 | wxLANGUAGE_YORUBA, | |
677 | wxLANGUAGE_ZHUANG, | |
678 | wxLANGUAGE_ZULU, | |
679 | ||
680 | // for custom, user-defined languages: | |
681 | wxLANGUAGE_USER_DEFINED | |
682 | }; | |
683 | ||
684 | // wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc. | |
685 | // translation information | |
686 | class wxLanguageInfo | |
687 | { | |
688 | public: | |
689 | int Language; // wxLanguage id | |
690 | wxString CanonicalName; // Canonical name, e.g. fr_FR | |
691 | wxString Description; // human-readable name of the language | |
692 | }; | |
693 | ||
694 | // wxLocaleCategory: the category of locale settings | |
695 | enum wxLocaleCategory | |
696 | { | |
697 | wxLOCALE_CAT_NUMBER, | |
698 | wxLOCALE_CAT_DATE, | |
699 | wxLOCALE_CAT_MONEY, | |
700 | wxLOCALE_CAT_MAX | |
701 | }; | |
702 | ||
703 | // wxLocaleInfo: the items understood by wxLocale::GetInfo() | |
704 | enum wxLocaleInfo | |
705 | { | |
706 | wxLOCALE_THOUSANDS_SEP, | |
707 | wxLOCALE_DECIMAL_POINT | |
708 | ||
709 | }; | |
710 | ||
711 | // wxLocale: encapsulates all language dependent settings, including current | |
712 | // message catalogs, date, time and currency formats (TODO) &c | |
713 | enum wxLocaleInitFlags | |
714 | { | |
715 | wxLOCALE_LOAD_DEFAULT = 0x0001, // load wxwin.mo? | |
716 | wxLOCALE_CONV_ENCODING = 0x0002 // convert encoding on the fly? | |
717 | }; | |
718 | ||
719 | class wxLocale | |
720 | { | |
721 | public: | |
722 | // ctor & dtor | |
723 | // ----------- | |
724 | wxLocale(int language = wxLANGUAGE_DEFAULT, | |
725 | int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING); | |
726 | ||
727 | // restores old locale | |
728 | ~wxLocale(); | |
729 | ||
730 | %name(Init1)bool Init(const wxString& szName, | |
731 | const wxString& szShort = wxPyEmptyString, | |
732 | const wxString& szLocale = wxPyEmptyString, | |
733 | bool bLoadDefault = TRUE, | |
734 | bool bConvertEncoding = FALSE); | |
735 | ||
736 | %name(Init2) bool Init(int language = wxLANGUAGE_DEFAULT, | |
737 | int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING); | |
738 | ||
739 | %pragma(python) addtoclass = " | |
740 | def Init(self, *_args, **_kwargs): | |
741 | if type(_args[0]) in [type(''), type(u'')]: | |
742 | val = self.Init1(*_args, **_kwargs) | |
743 | else: | |
744 | val = self.Init2(*_args, **_kwargs) | |
745 | return val | |
746 | " | |
747 | ||
748 | ||
749 | // Try to get user's (or OS's) prefered language setting. | |
750 | // Return wxLANGUAGE_UNKNOWN if language-guessing algorithm failed | |
751 | static int GetSystemLanguage(); | |
752 | ||
753 | // get the encoding used by default for text on this system, returns | |
754 | // wxFONTENCODING_SYSTEM if it couldn't be determined | |
755 | static wxFontEncoding GetSystemEncoding(); | |
756 | ||
757 | // get the string describing the system encoding, return empty string if | |
758 | // couldn't be determined | |
759 | static wxString GetSystemEncodingName(); | |
760 | ||
761 | ||
762 | // THIS ONE IS COMMENTED OUT IN src/common/intl.cpp | |
763 | // get the values of the given locale-dependent datum: the current locale | |
764 | // is used, the US default value is returned if everything else fails | |
765 | // static wxString GetInfo(wxLocaleInfo index, wxLocaleCategory cat); | |
766 | ||
767 | // return TRUE if the locale was set successfully | |
768 | bool IsOk() const; | |
769 | ||
770 | // returns locale name | |
771 | wxString GetLocale() const; | |
772 | ||
773 | // return current locale wxLanguage value | |
774 | int GetLanguage() const; | |
775 | ||
776 | // return locale name to be passed to setlocale() | |
777 | wxString GetSysName() const; | |
778 | ||
779 | // return 'canonical' name, i.e. in the form of xx[_YY], where xx is | |
780 | // language code according to ISO 639 and YY is country name | |
781 | // as specified by ISO 3166. | |
782 | wxString GetCanonicalName() const; | |
783 | ||
784 | // add a prefix to the catalog lookup path: the message catalog files will be | |
785 | // looked up under prefix/<lang>/LC_MESSAGES, prefix/LC_MESSAGES and prefix | |
786 | // (in this order). | |
787 | // | |
788 | // This only applies to subsequent invocations of AddCatalog()! | |
789 | static void AddCatalogLookupPathPrefix(const wxString& prefix); | |
790 | ||
791 | // add a catalog: it's searched for in standard places (current directory | |
792 | // first, system one after), but the you may prepend additional directories to | |
793 | // the search path with AddCatalogLookupPathPrefix(). | |
794 | // | |
795 | // The loaded catalog will be used for message lookup by GetString(). | |
796 | // | |
797 | // Returns 'true' if it was successfully loaded | |
798 | bool AddCatalog(const wxString& szDomain); | |
799 | ||
800 | // check if the given catalog is loaded | |
801 | bool IsLoaded(const wxString& szDomain) const; | |
802 | ||
803 | // Retrieve the language info struct for the given language | |
804 | // | |
805 | // Returns NULL if no info found, pointer must *not* be deleted by caller | |
806 | static const wxLanguageInfo *GetLanguageInfo(int lang); | |
807 | ||
808 | // Returns language name in English or empty string if the language | |
809 | // is not in database | |
810 | static wxString GetLanguageName(int lang); | |
811 | ||
812 | // Find the language for the given locale string which may be either a | |
813 | // canonical ISO 2 letter language code ("xx"), a language code followed by | |
814 | // the country code ("xx_XX") or a Windows full language name ("Xxxxx...") | |
815 | // | |
816 | // Returns NULL if no info found, pointer must *not* be deleted by caller | |
817 | static const wxLanguageInfo *FindLanguageInfo(const wxString& locale); | |
818 | ||
819 | // Add custom language to the list of known languages. | |
820 | // Notes: 1) wxLanguageInfo contains platform-specific data | |
821 | // 2) must be called before Init to have effect | |
822 | static void AddLanguage(const wxLanguageInfo& info); | |
823 | ||
824 | // retrieve the translation for a string in all loaded domains unless | |
825 | // the szDomain parameter is specified (and then only this domain is | |
826 | // searched) | |
827 | // | |
828 | // return original string if translation is not available | |
829 | // (in this case an error message is generated the first time | |
830 | // a string is not found; use wxLogNull to suppress it) | |
831 | // | |
832 | // domains are searched in the last to first order, i.e. catalogs | |
833 | // added later override those added before. | |
834 | wxString GetString(const wxString& szOrigString, | |
835 | const wxString& szDomain = wxPyEmptyString) const; | |
836 | ||
837 | // Returns the current short name for the locale | |
838 | const wxString& GetName() const; | |
839 | ||
840 | }; | |
841 | ||
842 | ||
843 | ||
844 | // get the current locale object (note that it may be NULL!) | |
845 | wxLocale* wxGetLocale(); | |
846 | ||
847 | // get the translation of the string in the current locale | |
848 | wxString wxGetTranslation(const wxString& sz); | |
849 | ||
850 | ||
851 | //---------------------------------------------------------------------- | |
852 | // wxEncodingConverter | |
853 | // This class is capable of converting strings between any two | |
854 | // 8bit encodings/charsets. It can also convert from/to Unicode | |
855 | ||
856 | ||
857 | %typemap(python, out) wxFontEncodingArray { | |
858 | $target = PyList_New(0); | |
859 | for (size_t i=0; i < $source->GetCount(); i++) { | |
860 | PyObject* number = PyInt_FromLong($source->Item(i)); | |
861 | PyList_Append($target, number); | |
862 | Py_DECREF(number); | |
863 | } | |
864 | } | |
865 | ||
866 | ||
867 | enum | |
868 | { | |
869 | wxCONVERT_STRICT, | |
870 | wxCONVERT_SUBSTITUTE | |
871 | }; | |
872 | ||
873 | ||
874 | enum | |
875 | { | |
876 | wxPLATFORM_CURRENT = -1, | |
877 | ||
878 | wxPLATFORM_UNIX = 0, | |
879 | wxPLATFORM_WINDOWS, | |
880 | wxPLATFORM_OS2, | |
881 | wxPLATFORM_MAC | |
882 | }; | |
883 | ||
884 | ||
885 | class wxEncodingConverter : public wxObject | |
886 | { | |
887 | public: | |
888 | ||
889 | wxEncodingConverter(); | |
890 | ~wxEncodingConverter(); | |
891 | ||
892 | ||
893 | // Initialize convertion. Both output or input encoding may | |
894 | // be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1. | |
895 | // | |
896 | // All subsequent calls to Convert() will interpret it's argument | |
897 | // as a string in input_enc encoding and will output string in | |
898 | // output_enc encoding. | |
899 | // | |
900 | // You must call this method before calling Convert. You may call | |
901 | // it more than once in order to switch to another conversion | |
902 | // | |
903 | // Method affects behaviour of Convert() in case input character | |
904 | // cannot be converted because it does not exist in output encoding: | |
905 | // wxCONVERT_STRICT -- | |
906 | // follow behaviour of GNU Recode - just copy unconvertable | |
907 | // characters to output and don't change them (it's integer | |
908 | // value will stay the same) | |
909 | // wxCONVERT_SUBSTITUTE -- | |
910 | // try some (lossy) substitutions - e.g. replace | |
911 | // unconvertable latin capitals with acute by ordinary | |
912 | // capitals, replace en-dash or em-dash by '-' etc. | |
913 | // both modes gurantee that output string will have same length | |
914 | // as input string | |
915 | // | |
916 | // Returns FALSE if given conversion is impossible, TRUE otherwise | |
917 | // (conversion may be impossible either if you try to convert | |
918 | // to Unicode with non-Unicode build of wxWindows or if input | |
919 | // or output encoding is not supported.) | |
920 | bool Init(wxFontEncoding input_enc, wxFontEncoding output_enc, int method = wxCONVERT_STRICT); | |
921 | ||
922 | ||
923 | // TODO: Need to do something about unicode mode... | |
924 | ||
925 | // Convert input string according to settings passed to Init. | |
926 | // Note that you must call Init before using Convert! | |
927 | wxString Convert(const wxString& input); | |
928 | ||
929 | // void Convert(const char* input, char* output); | |
930 | ||
931 | // #if wxUSE_WCHAR_T | |
932 | // void Convert(const char* input, wchar_t* output); | |
933 | // void Convert(const wchar_t* input, char* output); | |
934 | // void Convert(const wchar_t* input, wchar_t* output); | |
935 | // void Convert(wchar_t* str) { Convert(str, str); } | |
936 | // #endif | |
937 | ||
938 | ||
939 | ||
940 | // Return equivalent(s) for given font that are used | |
941 | // under given platform. wxPLATFORM_CURRENT means the plaform | |
942 | // this binary was compiled for | |
943 | // | |
944 | // Examples: | |
945 | // current platform enc returned value | |
946 | // ----------------------------------------------------- | |
947 | // unix CP1250 {ISO8859_2} | |
948 | // unix ISO8859_2 {} | |
949 | // windows ISO8859_2 {CP1250} | |
950 | // | |
951 | // Equivalence is defined in terms of convertibility: | |
952 | // 2 encodings are equivalent if you can convert text between | |
953 | // then without loosing information (it may - and will - happen | |
954 | // that you loose special chars like quotation marks or em-dashes | |
955 | // but you shouldn't loose any diacritics and language-specific | |
956 | // characters when converting between equivalent encodings). | |
957 | // | |
958 | // Convert() method is not limited to converting between | |
959 | // equivalent encodings, it can convert between arbitrary | |
960 | // two encodings! | |
961 | // | |
962 | // Remember that this function does _NOT_ check for presence of | |
963 | // fonts in system. It only tells you what are most suitable | |
964 | // encodings. (It usually returns only one encoding) | |
965 | // | |
966 | // Note that argument enc itself may be present in returned array! | |
967 | // (so that you can -- as a side effect -- detect whether the | |
968 | // encoding is native for this platform or not) | |
969 | static wxFontEncodingArray GetPlatformEquivalents(wxFontEncoding enc, | |
970 | int platform = wxPLATFORM_CURRENT); | |
971 | ||
972 | // Similar to GetPlatformEquivalent, but this one will return ALL | |
973 | // equivalent encodings, regardless the platform, including itself. | |
974 | static wxFontEncodingArray GetAllEquivalents(wxFontEncoding enc); | |
975 | ||
976 | %pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()" | |
977 | }; | |
978 | ||
979 | ||
980 | //---------------------------------------------------------------------- | |
981 | //---------------------------------------------------------------------- | |
982 | ||
983 | %init %{ | |
984 | wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator"); | |
985 | %} | |
986 | ||
987 | //---------------------------------------------------------------------- | |
988 |