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