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