]>
Commit | Line | Data |
---|---|---|
68bc8549 RD |
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> | |
68bc8549 RD |
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 | ||
9cbf6f6e | 77 | |
68bc8549 RD |
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) | |
9cbf6f6e | 119 | wxFONTENCODING_CP936, // Chinese simplified (GB) |
68bc8549 RD |
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 | ||
1e4a197e RD |
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 | |
9cbf6f6e RD |
142 | wxFONTENCODING_EUC_JP = wxFONTENCODING_UTF8 + 1, // Extended Unix Codepage |
143 | // for Japanese | |
1e4a197e | 144 | |
9cbf6f6e | 145 | wxFONTENCODING_UNICODE, // Unicode (for wxEncodingConverter only) |
68bc8549 RD |
146 | |
147 | wxFONTENCODING_MAX | |
148 | }; | |
149 | ||
150 | ||
68bc8549 RD |
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 | { | |
1e4a197e | 159 | wxNativeFontInfo(); |
68bc8549 RD |
160 | |
161 | // reset to the default state | |
162 | void Init(); | |
163 | ||
68bc8549 RD |
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); | |
68bc8549 RD |
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 | ||
1e4a197e RD |
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 | ||
68bc8549 RD |
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 | ||
db0ff83e RD |
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 | ||
68bc8549 RD |
251 | |
252 | // find an alternative for the given encoding (which is supposed to not be | |
253 | // available on this system). If successful, return TRUE and rwxFontEcoding | |
254 | // that can be used it wxFont ctor otherwise return FALSE | |
255 | //bool GetAltForEncoding(wxFontEncoding encoding, | |
256 | // wxFontEncoding *alt_encoding, | |
257 | // const wxString& facename = wxPyEmptyString, | |
258 | // bool interactive = TRUE); | |
259 | ||
260 | ||
261 | // Find an alternative for the given encoding (which is supposed to not be | |
262 | // available on this system). If successful, returns the encoding otherwise | |
263 | // returns None. | |
264 | %addmethods { | |
265 | PyObject* GetAltForEncoding(wxFontEncoding encoding, | |
266 | const wxString& facename = wxPyEmptyString, | |
267 | bool interactive = TRUE) { | |
268 | wxFontEncoding alt_enc; | |
269 | if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive)) | |
270 | return PyInt_FromLong(alt_enc); | |
271 | else { | |
272 | Py_INCREF(Py_None); | |
273 | return Py_None; | |
274 | } | |
275 | } | |
276 | } | |
277 | ||
278 | ||
279 | // checks whether given encoding is available in given face or not. | |
280 | // If no facename is given, | |
281 | bool IsEncodingAvailable(wxFontEncoding encoding, | |
282 | const wxString& facename = wxPyEmptyString); | |
283 | ||
284 | // returns the encoding for the given charset (in the form of RFC 2046) or | |
285 | // wxFONTENCODING_SYSTEM if couldn't decode it | |
286 | wxFontEncoding CharsetToEncoding(const wxString& charset, | |
287 | bool interactive = TRUE); | |
288 | ||
289 | // return internal string identifier for the encoding (see also | |
290 | // GetEncodingDescription()) | |
291 | static wxString GetEncodingName(wxFontEncoding encoding); | |
292 | ||
293 | // return user-readable string describing the given encoding | |
294 | // | |
295 | // NB: hard-coded now, but might change later (read it from config?) | |
296 | static wxString GetEncodingDescription(wxFontEncoding encoding); | |
297 | ||
298 | // the parent window for modal dialogs | |
299 | void SetDialogParent(wxWindow *parent); | |
300 | ||
301 | // the title for the dialogs (note that default is quite reasonable) | |
302 | void SetDialogTitle(const wxString& title); | |
303 | ||
304 | // functions which allow to configure the config object used: by default, | |
305 | // the global one (from wxConfigBase::Get() will be used) and the default | |
306 | // root path for the config settings is the string returned by | |
307 | // GetDefaultConfigPath() | |
308 | ||
309 | ||
310 | // set the config object to use (may be NULL to use default) | |
311 | void SetConfig(wxConfigBase *config); | |
312 | ||
313 | // set the root config path to use (should be an absolute path) | |
314 | void SetConfigPath(const wxString& prefix); | |
315 | ||
316 | // return default config path | |
317 | static wxString GetDefaultConfigPath(); | |
318 | }; | |
319 | ||
320 | ||
321 | ||
322 | //--------------------------------------------------------------------------- | |
323 | ||
324 | class wxFont : public wxObject { | |
325 | public: | |
326 | wxFont( int pointSize, int family, int style, int weight, | |
327 | int underline=FALSE, const wxString& faceName = wxPyEmptyString, | |
328 | wxFontEncoding encoding=wxFONTENCODING_DEFAULT); | |
329 | ||
330 | %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info); | |
1e4a197e RD |
331 | %addmethods { |
332 | %new wxFont* wxFontFromNativeInfoString(const wxString& info) { | |
333 | wxNativeFontInfo nfi; | |
334 | nfi.FromString(info); | |
335 | return new wxFont(nfi); | |
336 | } | |
337 | } | |
68bc8549 RD |
338 | |
339 | ~wxFont(); | |
340 | ||
341 | bool Ok() const; | |
342 | int GetPointSize() const; | |
343 | int GetFamily() const; | |
344 | int GetStyle() const; | |
345 | int GetWeight() const; | |
346 | bool GetUnderlined() const; | |
347 | wxString GetFaceName() const; | |
348 | wxFontEncoding GetEncoding() const; | |
349 | ||
350 | bool IsFixedWidth(); | |
351 | ||
352 | wxNativeFontInfo* GetNativeFontInfo() const; | |
353 | wxString GetNativeFontInfoDesc() const; | |
354 | wxString GetNativeFontInfoUserDesc() const; | |
355 | ||
356 | void SetPointSize(int pointSize); | |
357 | void SetFamily(int family); | |
358 | void SetStyle(int style); | |
359 | void SetWeight(int weight); | |
360 | void SetFaceName(const wxString& faceName); | |
361 | void SetUnderlined(bool underlined); | |
362 | void SetEncoding(wxFontEncoding encoding); | |
363 | void SetNativeFontInfo(const wxNativeFontInfo& info); | |
364 | // void SetNativeFontInfo(const wxString& info); | |
365 | void SetNativeFontInfoUserDesc(const wxString& info); | |
366 | ||
367 | wxString GetFamilyString() const; | |
368 | wxString GetStyleString() const; | |
369 | wxString GetWeightString() const; | |
370 | ||
1e4a197e RD |
371 | void SetNoAntiAliasing( bool no = TRUE ); |
372 | bool GetNoAntiAliasing(); | |
373 | ||
68bc8549 RD |
374 | static wxFontEncoding GetDefaultEncoding(); |
375 | static void SetDefaultEncoding(wxFontEncoding encoding); | |
376 | ||
1fded56b | 377 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" |
68bc8549 RD |
378 | }; |
379 | ||
380 | ||
381 | class wxFontList : public wxObject { | |
382 | public: | |
383 | ||
384 | void AddFont(wxFont* font); | |
385 | wxFont * FindOrCreateFont(int point_size, int family, int style, int weight, | |
386 | bool underline = FALSE, const wxString& facename = wxPyEmptyString, | |
387 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
388 | void RemoveFont(wxFont *font); | |
389 | ||
390 | int GetCount(); | |
391 | }; | |
392 | ||
393 | ||
394 | //---------------------------------------------------------------------- | |
395 | // wxFontEnumerator | |
396 | ||
397 | %{ | |
398 | class wxPyFontEnumerator : public wxFontEnumerator { | |
399 | public: | |
400 | wxPyFontEnumerator() {} | |
401 | ~wxPyFontEnumerator() {} | |
402 | ||
403 | DEC_PYCALLBACK_BOOL_STRING(OnFacename); | |
404 | DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding); | |
405 | ||
406 | PYPRIVATE; | |
407 | }; | |
408 | ||
409 | IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename); | |
410 | IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding); | |
411 | ||
412 | %} | |
413 | ||
414 | %name(wxFontEnumerator) class wxPyFontEnumerator { | |
415 | public: | |
416 | wxPyFontEnumerator(); | |
417 | ~wxPyFontEnumerator(); | |
418 | void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref); | |
419 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFontEnumerator, 0)" | |
420 | ||
421 | bool EnumerateFacenames( | |
422 | wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all | |
423 | bool fixedWidthOnly = FALSE); | |
424 | bool EnumerateEncodings(const wxString& facename = wxPyEmptyString); | |
425 | ||
426 | //wxArrayString* GetEncodings(); | |
427 | //wxArrayString* GetFacenames(); | |
428 | %addmethods { | |
429 | PyObject* GetEncodings() { | |
430 | wxArrayString* arr = self->GetEncodings(); | |
431 | return wxArrayString2PyList_helper(*arr); | |
432 | } | |
433 | ||
434 | PyObject* GetFacenames() { | |
435 | wxArrayString* arr = self->GetFacenames(); | |
436 | return wxArrayString2PyList_helper(*arr); | |
437 | } | |
438 | } | |
439 | }; | |
440 | ||
441 | //--------------------------------------------------------------------------- | |
442 | // wxLocale. Not really font related, but close enough | |
443 | ||
444 | ||
445 | enum wxLanguage | |
446 | { | |
1e4a197e | 447 | // user's default/preffered language as got from OS: |
68bc8549 | 448 | wxLANGUAGE_DEFAULT, |
1e4a197e | 449 | // unknown language, if wxLocale::GetSystemLanguage fails: |
68bc8549 RD |
450 | wxLANGUAGE_UNKNOWN, |
451 | ||
452 | wxLANGUAGE_ABKHAZIAN, | |
453 | wxLANGUAGE_AFAR, | |
454 | wxLANGUAGE_AFRIKAANS, | |
455 | wxLANGUAGE_ALBANIAN, | |
456 | wxLANGUAGE_AMHARIC, | |
457 | wxLANGUAGE_ARABIC, | |
458 | wxLANGUAGE_ARABIC_ALGERIA, | |
459 | wxLANGUAGE_ARABIC_BAHRAIN, | |
460 | wxLANGUAGE_ARABIC_EGYPT, | |
461 | wxLANGUAGE_ARABIC_IRAQ, | |
462 | wxLANGUAGE_ARABIC_JORDAN, | |
463 | wxLANGUAGE_ARABIC_KUWAIT, | |
464 | wxLANGUAGE_ARABIC_LEBANON, | |
465 | wxLANGUAGE_ARABIC_LIBYA, | |
466 | wxLANGUAGE_ARABIC_MOROCCO, | |
467 | wxLANGUAGE_ARABIC_OMAN, | |
468 | wxLANGUAGE_ARABIC_QATAR, | |
469 | wxLANGUAGE_ARABIC_SAUDI_ARABIA, | |
470 | wxLANGUAGE_ARABIC_SUDAN, | |
471 | wxLANGUAGE_ARABIC_SYRIA, | |
472 | wxLANGUAGE_ARABIC_TUNISIA, | |
473 | wxLANGUAGE_ARABIC_UAE, | |
474 | wxLANGUAGE_ARABIC_YEMEN, | |
475 | wxLANGUAGE_ARMENIAN, | |
476 | wxLANGUAGE_ASSAMESE, | |
477 | wxLANGUAGE_AYMARA, | |
478 | wxLANGUAGE_AZERI, | |
479 | wxLANGUAGE_AZERI_CYRILLIC, | |
480 | wxLANGUAGE_AZERI_LATIN, | |
481 | wxLANGUAGE_BASHKIR, | |
482 | wxLANGUAGE_BASQUE, | |
483 | wxLANGUAGE_BELARUSIAN, | |
484 | wxLANGUAGE_BENGALI, | |
485 | wxLANGUAGE_BHUTANI, | |
486 | wxLANGUAGE_BIHARI, | |
487 | wxLANGUAGE_BISLAMA, | |
488 | wxLANGUAGE_BRETON, | |
489 | wxLANGUAGE_BULGARIAN, | |
490 | wxLANGUAGE_BURMESE, | |
491 | wxLANGUAGE_CAMBODIAN, | |
492 | wxLANGUAGE_CATALAN, | |
493 | wxLANGUAGE_CHINESE, | |
494 | wxLANGUAGE_CHINESE_SIMPLIFIED, | |
495 | wxLANGUAGE_CHINESE_TRADITIONAL, | |
496 | wxLANGUAGE_CHINESE_HONGKONG, | |
497 | wxLANGUAGE_CHINESE_MACAU, | |
498 | wxLANGUAGE_CHINESE_SINGAPORE, | |
499 | wxLANGUAGE_CHINESE_TAIWAN, | |
500 | wxLANGUAGE_CORSICAN, | |
501 | wxLANGUAGE_CROATIAN, | |
502 | wxLANGUAGE_CZECH, | |
503 | wxLANGUAGE_DANISH, | |
504 | wxLANGUAGE_DUTCH, | |
505 | wxLANGUAGE_DUTCH_BELGIAN, | |
506 | wxLANGUAGE_ENGLISH, | |
507 | wxLANGUAGE_ENGLISH_UK, | |
508 | wxLANGUAGE_ENGLISH_US, | |
509 | wxLANGUAGE_ENGLISH_AUSTRALIA, | |
510 | wxLANGUAGE_ENGLISH_BELIZE, | |
511 | wxLANGUAGE_ENGLISH_BOTSWANA, | |
512 | wxLANGUAGE_ENGLISH_CANADA, | |
513 | wxLANGUAGE_ENGLISH_CARIBBEAN, | |
514 | wxLANGUAGE_ENGLISH_DENMARK, | |
515 | wxLANGUAGE_ENGLISH_EIRE, | |
516 | wxLANGUAGE_ENGLISH_JAMAICA, | |
517 | wxLANGUAGE_ENGLISH_NEW_ZEALAND, | |
518 | wxLANGUAGE_ENGLISH_PHILIPPINES, | |
519 | wxLANGUAGE_ENGLISH_SOUTH_AFRICA, | |
520 | wxLANGUAGE_ENGLISH_TRINIDAD, | |
521 | wxLANGUAGE_ENGLISH_ZIMBABWE, | |
522 | wxLANGUAGE_ESPERANTO, | |
523 | wxLANGUAGE_ESTONIAN, | |
524 | wxLANGUAGE_FAEROESE, | |
525 | wxLANGUAGE_FARSI, | |
526 | wxLANGUAGE_FIJI, | |
527 | wxLANGUAGE_FINNISH, | |
528 | wxLANGUAGE_FRENCH, | |
529 | wxLANGUAGE_FRENCH_BELGIAN, | |
530 | wxLANGUAGE_FRENCH_CANADIAN, | |
531 | wxLANGUAGE_FRENCH_LUXEMBOURG, | |
532 | wxLANGUAGE_FRENCH_MONACO, | |
533 | wxLANGUAGE_FRENCH_SWISS, | |
534 | wxLANGUAGE_FRISIAN, | |
535 | wxLANGUAGE_GALICIAN, | |
536 | wxLANGUAGE_GEORGIAN, | |
537 | wxLANGUAGE_GERMAN, | |
538 | wxLANGUAGE_GERMAN_AUSTRIAN, | |
539 | wxLANGUAGE_GERMAN_BELGIUM, | |
540 | wxLANGUAGE_GERMAN_LIECHTENSTEIN, | |
541 | wxLANGUAGE_GERMAN_LUXEMBOURG, | |
542 | wxLANGUAGE_GERMAN_SWISS, | |
543 | wxLANGUAGE_GREEK, | |
544 | wxLANGUAGE_GREENLANDIC, | |
545 | wxLANGUAGE_GUARANI, | |
546 | wxLANGUAGE_GUJARATI, | |
547 | wxLANGUAGE_HAUSA, | |
548 | wxLANGUAGE_HEBREW, | |
549 | wxLANGUAGE_HINDI, | |
550 | wxLANGUAGE_HUNGARIAN, | |
551 | wxLANGUAGE_ICELANDIC, | |
552 | wxLANGUAGE_INDONESIAN, | |
553 | wxLANGUAGE_INTERLINGUA, | |
554 | wxLANGUAGE_INTERLINGUE, | |
555 | wxLANGUAGE_INUKTITUT, | |
556 | wxLANGUAGE_INUPIAK, | |
557 | wxLANGUAGE_IRISH, | |
558 | wxLANGUAGE_ITALIAN, | |
559 | wxLANGUAGE_ITALIAN_SWISS, | |
560 | wxLANGUAGE_JAPANESE, | |
561 | wxLANGUAGE_JAVANESE, | |
562 | wxLANGUAGE_KANNADA, | |
563 | wxLANGUAGE_KASHMIRI, | |
564 | wxLANGUAGE_KASHMIRI_INDIA, | |
565 | wxLANGUAGE_KAZAKH, | |
566 | wxLANGUAGE_KERNEWEK, | |
567 | wxLANGUAGE_KINYARWANDA, | |
568 | wxLANGUAGE_KIRGHIZ, | |
569 | wxLANGUAGE_KIRUNDI, | |
570 | wxLANGUAGE_KONKANI, | |
571 | wxLANGUAGE_KOREAN, | |
572 | wxLANGUAGE_KURDISH, | |
573 | wxLANGUAGE_LAOTHIAN, | |
574 | wxLANGUAGE_LATIN, | |
575 | wxLANGUAGE_LATVIAN, | |
576 | wxLANGUAGE_LINGALA, | |
577 | wxLANGUAGE_LITHUANIAN, | |
578 | wxLANGUAGE_MACEDONIAN, | |
579 | wxLANGUAGE_MALAGASY, | |
580 | wxLANGUAGE_MALAY, | |
581 | wxLANGUAGE_MALAYALAM, | |
582 | wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM, | |
583 | wxLANGUAGE_MALAY_MALAYSIA, | |
584 | wxLANGUAGE_MALTESE, | |
585 | wxLANGUAGE_MANIPURI, | |
586 | wxLANGUAGE_MAORI, | |
587 | wxLANGUAGE_MARATHI, | |
588 | wxLANGUAGE_MOLDAVIAN, | |
589 | wxLANGUAGE_MONGOLIAN, | |
590 | wxLANGUAGE_NAURU, | |
591 | wxLANGUAGE_NEPALI, | |
592 | wxLANGUAGE_NEPALI_INDIA, | |
593 | wxLANGUAGE_NORWEGIAN_BOKMAL, | |
594 | wxLANGUAGE_NORWEGIAN_NYNORSK, | |
595 | wxLANGUAGE_OCCITAN, | |
596 | wxLANGUAGE_ORIYA, | |
597 | wxLANGUAGE_OROMO, | |
598 | wxLANGUAGE_PASHTO, | |
599 | wxLANGUAGE_POLISH, | |
600 | wxLANGUAGE_PORTUGUESE, | |
601 | wxLANGUAGE_PORTUGUESE_BRAZILIAN, | |
602 | wxLANGUAGE_PUNJABI, | |
603 | wxLANGUAGE_QUECHUA, | |
604 | wxLANGUAGE_RHAETO_ROMANCE, | |
605 | wxLANGUAGE_ROMANIAN, | |
606 | wxLANGUAGE_RUSSIAN, | |
607 | wxLANGUAGE_RUSSIAN_UKRAINE, | |
608 | wxLANGUAGE_SAMOAN, | |
609 | wxLANGUAGE_SANGHO, | |
610 | wxLANGUAGE_SANSKRIT, | |
611 | wxLANGUAGE_SCOTS_GAELIC, | |
612 | wxLANGUAGE_SERBIAN, | |
613 | wxLANGUAGE_SERBIAN_CYRILLIC, | |
614 | wxLANGUAGE_SERBIAN_LATIN, | |
615 | wxLANGUAGE_SERBO_CROATIAN, | |
616 | wxLANGUAGE_SESOTHO, | |
617 | wxLANGUAGE_SETSWANA, | |
618 | wxLANGUAGE_SHONA, | |
619 | wxLANGUAGE_SINDHI, | |
620 | wxLANGUAGE_SINHALESE, | |
621 | wxLANGUAGE_SISWATI, | |
622 | wxLANGUAGE_SLOVAK, | |
623 | wxLANGUAGE_SLOVENIAN, | |
624 | wxLANGUAGE_SOMALI, | |
625 | wxLANGUAGE_SPANISH, | |
626 | wxLANGUAGE_SPANISH_ARGENTINA, | |
627 | wxLANGUAGE_SPANISH_BOLIVIA, | |
628 | wxLANGUAGE_SPANISH_CHILE, | |
629 | wxLANGUAGE_SPANISH_COLOMBIA, | |
630 | wxLANGUAGE_SPANISH_COSTA_RICA, | |
631 | wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC, | |
632 | wxLANGUAGE_SPANISH_ECUADOR, | |
633 | wxLANGUAGE_SPANISH_EL_SALVADOR, | |
634 | wxLANGUAGE_SPANISH_GUATEMALA, | |
635 | wxLANGUAGE_SPANISH_HONDURAS, | |
636 | wxLANGUAGE_SPANISH_MEXICAN, | |
637 | wxLANGUAGE_SPANISH_MODERN, | |
638 | wxLANGUAGE_SPANISH_NICARAGUA, | |
639 | wxLANGUAGE_SPANISH_PANAMA, | |
640 | wxLANGUAGE_SPANISH_PARAGUAY, | |
641 | wxLANGUAGE_SPANISH_PERU, | |
642 | wxLANGUAGE_SPANISH_PUERTO_RICO, | |
643 | wxLANGUAGE_SPANISH_URUGUAY, | |
644 | wxLANGUAGE_SPANISH_US, | |
645 | wxLANGUAGE_SPANISH_VENEZUELA, | |
646 | wxLANGUAGE_SUNDANESE, | |
647 | wxLANGUAGE_SWAHILI, | |
648 | wxLANGUAGE_SWEDISH, | |
649 | wxLANGUAGE_SWEDISH_FINLAND, | |
650 | wxLANGUAGE_TAGALOG, | |
651 | wxLANGUAGE_TAJIK, | |
652 | wxLANGUAGE_TAMIL, | |
653 | wxLANGUAGE_TATAR, | |
654 | wxLANGUAGE_TELUGU, | |
655 | wxLANGUAGE_THAI, | |
656 | wxLANGUAGE_TIBETAN, | |
657 | wxLANGUAGE_TIGRINYA, | |
658 | wxLANGUAGE_TONGA, | |
659 | wxLANGUAGE_TSONGA, | |
660 | wxLANGUAGE_TURKISH, | |
661 | wxLANGUAGE_TURKMEN, | |
662 | wxLANGUAGE_TWI, | |
663 | wxLANGUAGE_UIGHUR, | |
664 | wxLANGUAGE_UKRAINIAN, | |
665 | wxLANGUAGE_URDU, | |
666 | wxLANGUAGE_URDU_INDIA, | |
667 | wxLANGUAGE_URDU_PAKISTAN, | |
668 | wxLANGUAGE_UZBEK, | |
669 | wxLANGUAGE_UZBEK_CYRILLIC, | |
670 | wxLANGUAGE_UZBEK_LATIN, | |
671 | wxLANGUAGE_VIETNAMESE, | |
672 | wxLANGUAGE_VOLAPUK, | |
673 | wxLANGUAGE_WELSH, | |
674 | wxLANGUAGE_WOLOF, | |
675 | wxLANGUAGE_XHOSA, | |
676 | wxLANGUAGE_YIDDISH, | |
677 | wxLANGUAGE_YORUBA, | |
678 | wxLANGUAGE_ZHUANG, | |
679 | wxLANGUAGE_ZULU, | |
680 | ||
681 | // for custom, user-defined languages: | |
682 | wxLANGUAGE_USER_DEFINED | |
683 | }; | |
684 | ||
685 | // wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc. | |
686 | // translation information | |
687 | class wxLanguageInfo | |
688 | { | |
689 | public: | |
690 | int Language; // wxLanguage id | |
691 | wxString CanonicalName; // Canonical name, e.g. fr_FR | |
692 | wxString Description; // human-readable name of the language | |
693 | }; | |
694 | ||
695 | // wxLocaleCategory: the category of locale settings | |
696 | enum wxLocaleCategory | |
697 | { | |
698 | wxLOCALE_CAT_NUMBER, | |
699 | wxLOCALE_CAT_DATE, | |
700 | wxLOCALE_CAT_MONEY, | |
701 | wxLOCALE_CAT_MAX | |
702 | }; | |
703 | ||
704 | // wxLocaleInfo: the items understood by wxLocale::GetInfo() | |
705 | enum wxLocaleInfo | |
706 | { | |
707 | wxLOCALE_THOUSANDS_SEP, | |
708 | wxLOCALE_DECIMAL_POINT | |
709 | ||
710 | }; | |
711 | ||
712 | // wxLocale: encapsulates all language dependent settings, including current | |
713 | // message catalogs, date, time and currency formats (TODO) &c | |
714 | enum wxLocaleInitFlags | |
715 | { | |
716 | wxLOCALE_LOAD_DEFAULT = 0x0001, // load wxwin.mo? | |
717 | wxLOCALE_CONV_ENCODING = 0x0002 // convert encoding on the fly? | |
718 | }; | |
719 | ||
720 | class wxLocale | |
721 | { | |
722 | public: | |
723 | // ctor & dtor | |
724 | // ----------- | |
725 | wxLocale(int language = wxLANGUAGE_DEFAULT, | |
726 | int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING); | |
727 | ||
68bc8549 RD |
728 | // restores old locale |
729 | ~wxLocale(); | |
730 | ||
1e4a197e RD |
731 | %name(Init1)bool Init(const wxString& szName, |
732 | const wxString& szShort = wxPyEmptyString, | |
733 | const wxString& szLocale = wxPyEmptyString, | |
734 | bool bLoadDefault = TRUE, | |
735 | bool bConvertEncoding = FALSE); | |
736 | ||
737 | %name(Init2) bool Init(int language = wxLANGUAGE_DEFAULT, | |
738 | int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING); | |
739 | ||
740 | %pragma(python) addtoclass = " | |
741 | def Init(self, *_args, **_kwargs): | |
742 | if type(_args[0]) in [type(''), type(u'')]: | |
1fded56b | 743 | val = self.Init1(*_args, **_kwargs) |
1e4a197e | 744 | else: |
1fded56b | 745 | val = self.Init2(*_args, **_kwargs) |
1e4a197e RD |
746 | return val |
747 | " | |
748 | ||
749 | ||
68bc8549 RD |
750 | // Try to get user's (or OS's) prefered language setting. |
751 | // Return wxLANGUAGE_UNKNOWN if language-guessing algorithm failed | |
752 | static int GetSystemLanguage(); | |
753 | ||
754 | // get the encoding used by default for text on this system, returns | |
755 | // wxFONTENCODING_SYSTEM if it couldn't be determined | |
756 | static wxFontEncoding GetSystemEncoding(); | |
757 | ||
758 | // get the string describing the system encoding, return empty string if | |
759 | // couldn't be determined | |
760 | static wxString GetSystemEncodingName(); | |
761 | ||
762 | ||
763 | // THIS ONE IS COMMENTED OUT IN src/common/intl.cpp | |
764 | // get the values of the given locale-dependent datum: the current locale | |
765 | // is used, the US default value is returned if everything else fails | |
766 | // static wxString GetInfo(wxLocaleInfo index, wxLocaleCategory cat); | |
767 | ||
768 | // return TRUE if the locale was set successfully | |
769 | bool IsOk() const; | |
770 | ||
771 | // returns locale name | |
772 | wxString GetLocale() const; | |
773 | ||
774 | // return current locale wxLanguage value | |
775 | int GetLanguage() const; | |
776 | ||
777 | // return locale name to be passed to setlocale() | |
778 | wxString GetSysName() const; | |
779 | ||
780 | // return 'canonical' name, i.e. in the form of xx[_YY], where xx is | |
781 | // language code according to ISO 639 and YY is country name | |
782 | // as specified by ISO 3166. | |
783 | wxString GetCanonicalName() const; | |
784 | ||
785 | // add a prefix to the catalog lookup path: the message catalog files will be | |
786 | // looked up under prefix/<lang>/LC_MESSAGES, prefix/LC_MESSAGES and prefix | |
787 | // (in this order). | |
788 | // | |
789 | // This only applies to subsequent invocations of AddCatalog()! | |
790 | static void AddCatalogLookupPathPrefix(const wxString& prefix); | |
791 | ||
792 | // add a catalog: it's searched for in standard places (current directory | |
793 | // first, system one after), but the you may prepend additional directories to | |
794 | // the search path with AddCatalogLookupPathPrefix(). | |
795 | // | |
796 | // The loaded catalog will be used for message lookup by GetString(). | |
797 | // | |
798 | // Returns 'true' if it was successfully loaded | |
799 | bool AddCatalog(const wxString& szDomain); | |
800 | ||
801 | // check if the given catalog is loaded | |
802 | bool IsLoaded(const wxString& szDomain) const; | |
803 | ||
923e5f56 RD |
804 | // Retrieve the language info struct for the given language |
805 | // | |
806 | // Returns NULL if no info found, pointer must *not* be deleted by caller | |
807 | static const wxLanguageInfo *GetLanguageInfo(int lang); | |
808 | ||
9cbf6f6e RD |
809 | // Find the language for the given locale string which may be either a |
810 | // canonical ISO 2 letter language code ("xx"), a language code followed by | |
811 | // the country code ("xx_XX") or a Windows full language name ("Xxxxx...") | |
812 | // | |
813 | // Returns NULL if no info found, pointer must *not* be deleted by caller | |
814 | static const wxLanguageInfo *FindLanguageInfo(const wxString& locale); | |
815 | ||
6789bce9 | 816 | // Add custom language to the list of known languages. |
68bc8549 RD |
817 | // Notes: 1) wxLanguageInfo contains platform-specific data |
818 | // 2) must be called before Init to have effect | |
819 | static void AddLanguage(const wxLanguageInfo& info); | |
820 | ||
821 | // retrieve the translation for a string in all loaded domains unless | |
822 | // the szDomain parameter is specified (and then only this domain is | |
823 | // searched) | |
824 | // | |
825 | // return original string if translation is not available | |
826 | // (in this case an error message is generated the first time | |
827 | // a string is not found; use wxLogNull to suppress it) | |
828 | // | |
829 | // domains are searched in the last to first order, i.e. catalogs | |
830 | // added later override those added before. | |
831 | wxString GetString(const wxString& szOrigString, | |
832 | const wxString& szDomain = wxPyEmptyString) const; | |
833 | ||
834 | // Returns the current short name for the locale | |
835 | const wxString& GetName() const; | |
836 | ||
837 | }; | |
838 | ||
839 | ||
840 | ||
841 | // get the current locale object (note that it may be NULL!) | |
842 | wxLocale* wxGetLocale(); | |
843 | ||
844 | // get the translation of the string in the current locale | |
845 | wxString wxGetTranslation(const wxString& sz); | |
846 | ||
847 | ||
848 | //---------------------------------------------------------------------- | |
849 | // wxEncodingConverter | |
850 | // This class is capable of converting strings between any two | |
851 | // 8bit encodings/charsets. It can also convert from/to Unicode | |
852 | ||
853 | ||
854 | %typemap(python, out) wxFontEncodingArray { | |
855 | $target = PyList_New(0); | |
856 | for (size_t i=0; i < $source->GetCount(); i++) { | |
857 | PyObject* number = PyInt_FromLong($source->Item(i)); | |
858 | PyList_Append($target, number); | |
859 | Py_DECREF(number); | |
860 | } | |
861 | } | |
862 | ||
863 | ||
864 | enum | |
865 | { | |
866 | wxCONVERT_STRICT, | |
867 | wxCONVERT_SUBSTITUTE | |
868 | }; | |
869 | ||
870 | ||
871 | enum | |
872 | { | |
873 | wxPLATFORM_CURRENT = -1, | |
874 | ||
875 | wxPLATFORM_UNIX = 0, | |
876 | wxPLATFORM_WINDOWS, | |
877 | wxPLATFORM_OS2, | |
878 | wxPLATFORM_MAC | |
879 | }; | |
880 | ||
881 | ||
882 | class wxEncodingConverter : public wxObject | |
883 | { | |
884 | public: | |
885 | ||
886 | wxEncodingConverter(); | |
887 | ~wxEncodingConverter(); | |
888 | ||
889 | ||
890 | // Initialize convertion. Both output or input encoding may | |
891 | // be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1. | |
892 | // | |
893 | // All subsequent calls to Convert() will interpret it's argument | |
894 | // as a string in input_enc encoding and will output string in | |
895 | // output_enc encoding. | |
896 | // | |
897 | // You must call this method before calling Convert. You may call | |
898 | // it more than once in order to switch to another conversion | |
899 | // | |
900 | // Method affects behaviour of Convert() in case input character | |
901 | // cannot be converted because it does not exist in output encoding: | |
902 | // wxCONVERT_STRICT -- | |
903 | // follow behaviour of GNU Recode - just copy unconvertable | |
904 | // characters to output and don't change them (it's integer | |
905 | // value will stay the same) | |
906 | // wxCONVERT_SUBSTITUTE -- | |
907 | // try some (lossy) substitutions - e.g. replace | |
908 | // unconvertable latin capitals with acute by ordinary | |
909 | // capitals, replace en-dash or em-dash by '-' etc. | |
910 | // both modes gurantee that output string will have same length | |
911 | // as input string | |
912 | // | |
913 | // Returns FALSE if given conversion is impossible, TRUE otherwise | |
914 | // (conversion may be impossible either if you try to convert | |
915 | // to Unicode with non-Unicode build of wxWindows or if input | |
916 | // or output encoding is not supported.) | |
917 | bool Init(wxFontEncoding input_enc, wxFontEncoding output_enc, int method = wxCONVERT_STRICT); | |
918 | ||
f60765b0 RD |
919 | |
920 | // TODO: Need to do something about unicode mode... | |
921 | ||
68bc8549 RD |
922 | // Convert input string according to settings passed to Init. |
923 | // Note that you must call Init before using Convert! | |
924 | wxString Convert(const wxString& input); | |
925 | ||
926 | // void Convert(const char* input, char* output); | |
927 | ||
928 | // #if wxUSE_WCHAR_T | |
929 | // void Convert(const char* input, wchar_t* output); | |
930 | // void Convert(const wchar_t* input, char* output); | |
931 | // void Convert(const wchar_t* input, wchar_t* output); | |
932 | // void Convert(wchar_t* str) { Convert(str, str); } | |
933 | // #endif | |
934 | ||
935 | ||
f60765b0 | 936 | |
68bc8549 RD |
937 | // Return equivalent(s) for given font that are used |
938 | // under given platform. wxPLATFORM_CURRENT means the plaform | |
939 | // this binary was compiled for | |
940 | // | |
941 | // Examples: | |
942 | // current platform enc returned value | |
943 | // ----------------------------------------------------- | |
944 | // unix CP1250 {ISO8859_2} | |
945 | // unix ISO8859_2 {} | |
946 | // windows ISO8859_2 {CP1250} | |
947 | // | |
948 | // Equivalence is defined in terms of convertibility: | |
949 | // 2 encodings are equivalent if you can convert text between | |
950 | // then without loosing information (it may - and will - happen | |
951 | // that you loose special chars like quotation marks or em-dashes | |
952 | // but you shouldn't loose any diacritics and language-specific | |
953 | // characters when converting between equivalent encodings). | |
954 | // | |
955 | // Convert() method is not limited to converting between | |
956 | // equivalent encodings, it can convert between arbitrary | |
957 | // two encodings! | |
958 | // | |
959 | // Remember that this function does _NOT_ check for presence of | |
960 | // fonts in system. It only tells you what are most suitable | |
961 | // encodings. (It usually returns only one encoding) | |
962 | // | |
963 | // Note that argument enc itself may be present in returned array! | |
964 | // (so that you can -- as a side effect -- detect whether the | |
965 | // encoding is native for this platform or not) | |
966 | static wxFontEncodingArray GetPlatformEquivalents(wxFontEncoding enc, | |
967 | int platform = wxPLATFORM_CURRENT); | |
968 | ||
969 | // Similar to GetPlatformEquivalent, but this one will return ALL | |
970 | // equivalent encodings, regardless the platform, including itself. | |
971 | static wxFontEncodingArray GetAllEquivalents(wxFontEncoding enc); | |
972 | ||
1fded56b | 973 | %pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()" |
68bc8549 RD |
974 | }; |
975 | ||
976 | ||
977 | //---------------------------------------------------------------------- | |
978 | //---------------------------------------------------------------------- | |
979 | ||
980 | %init %{ | |
981 | wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator"); | |
982 | %} | |
983 | ||
984 | //---------------------------------------------------------------------- | |
985 |