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