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