1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface file wxFont, local, converters, etc.
9 // Copyright: (c) 2002 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
18 #include <wx/fontmap.h>
19 #include <wx/fontenc.h>
20 #include <wx/fontutil.h>
21 #include <wx/fontenum.h>
23 #include <wx/encconv.h>
26 //----------------------------------------------------------------------
29 %include my_typemaps.i
31 // Import some definitions of other classes, etc.
36 //---------------------------------------------------------------------------
38 // Put some wx default wxChar* values into wxStrings.
39 static const wxString wxPyEmptyString(wxT(""));
41 //---------------------------------------------------------------------------
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,
61 wxFONTSTYLE_NORMAL = wxNORMAL,
62 wxFONTSTYLE_ITALIC = wxITALIC,
63 wxFONTSTYLE_SLANT = wxSLANT,
70 wxFONTWEIGHT_NORMAL = wxNORMAL,
71 wxFONTWEIGHT_LIGHT = wxLIGHT,
72 wxFONTWEIGHT_BOLD = wxBOLD,
81 wxFONTENCODING_SYSTEM = -1, // system default
82 wxFONTENCODING_DEFAULT, // current default encoding
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,
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
109 // what would we do without Microsoft? They have their own encodings
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
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,
132 wxFONTENCODING_UTF7, // UTF-7 Unicode encoding
133 wxFONTENCODING_UTF8, // UTF-8 Unicode encoding
135 // Far Eastern encodings
137 wxFONTENCODING_GB2312 = wxFONTENCODING_CP936, // Simplified Chinese
138 wxFONTENCODING_BIG5 = wxFONTENCODING_CP950, // Traditional Chinese
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
145 wxFONTENCODING_UNICODE, // Unicode (for wxEncodingConverter only)
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
161 // reset to the default state
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;
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);
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;
188 return self->ToString();
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;
201 // Fix some link errors... Remove this when these methods get real implementations...
202 #if defined(__WXGTK__) || defined(__WXX11__)
204 void wxNativeFontInfo::SetPointSize(int pointsize)
205 { wxFAIL_MSG( _T("not implemented") ); }
207 void wxNativeFontInfo::SetStyle(wxFontStyle style)
208 { wxFAIL_MSG( _T("not implemented") ); }
210 void wxNativeFontInfo::SetWeight(wxFontWeight weight)
211 { wxFAIL_MSG( _T("not implemented") ); }
213 void wxNativeFontInfo::SetUnderlined(bool WXUNUSED(underlined))
214 { wxFAIL_MSG( _T("not implemented") ); }
216 void wxNativeFontInfo::SetFaceName(wxString facename)
217 { wxFAIL_MSG( _T("not implemented") ); }
219 void wxNativeFontInfo::SetFamily(wxFontFamily family)
220 { wxFAIL_MSG( _T("not implemented") ); }
222 void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding)
223 { wxFAIL_MSG( _T("not implemented") ); }
228 //---------------------------------------------------------------------------
229 // wxFontMapper manages user-definable correspondence between logical font
230 // names and the fonts present on the machine.
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.
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);
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);
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
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);
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);
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);
289 // return internal string identifier for the encoding (see also
290 // GetEncodingDescription())
291 static wxString GetEncodingName(wxFontEncoding encoding);
293 // return user-readable string describing the given encoding
295 // NB: hard-coded now, but might change later (read it from config?)
296 static wxString GetEncodingDescription(wxFontEncoding encoding);
298 // the parent window for modal dialogs
299 void SetDialogParent(wxWindow *parent);
301 // the title for the dialogs (note that default is quite reasonable)
302 void SetDialogTitle(const wxString& title);
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()
310 // set the config object to use (may be NULL to use default)
311 void SetConfig(wxConfigBase *config);
313 // set the root config path to use (should be an absolute path)
314 void SetConfigPath(const wxString& prefix);
316 // return default config path
317 static wxString GetDefaultConfigPath();
322 //---------------------------------------------------------------------------
324 class wxFont : public wxObject {
326 wxFont( int pointSize, int family, int style, int weight,
327 int underline=FALSE, const wxString& faceName = wxPyEmptyString,
328 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
330 %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
332 %new wxFont* wxFontFromNativeInfoString(const wxString& info) {
333 wxNativeFontInfo nfi;
334 nfi.FromString(info);
335 return new wxFont(nfi);
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;
352 wxNativeFontInfo* GetNativeFontInfo() const;
353 wxString GetNativeFontInfoDesc() const;
354 wxString GetNativeFontInfoUserDesc() const;
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);
367 wxString GetFamilyString() const;
368 wxString GetStyleString() const;
369 wxString GetWeightString() const;
371 void SetNoAntiAliasing( bool no = TRUE );
372 bool GetNoAntiAliasing();
374 static wxFontEncoding GetDefaultEncoding();
375 static void SetDefaultEncoding(wxFontEncoding encoding);
377 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
381 class wxFontList : public wxObject {
384 void AddFont(wxFont* font);
385 wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
386 bool underline = FALSE, const wxString& facename = wxPyEmptyString,
387 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
388 void RemoveFont(wxFont *font);
394 //----------------------------------------------------------------------
398 class wxPyFontEnumerator : public wxFontEnumerator {
400 wxPyFontEnumerator() {}
401 ~wxPyFontEnumerator() {}
403 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
404 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
409 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
410 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
414 %name(wxFontEnumerator) class wxPyFontEnumerator {
416 wxPyFontEnumerator();
417 ~wxPyFontEnumerator();
418 void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref);
419 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFontEnumerator, 0)"
421 bool EnumerateFacenames(
422 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
423 bool fixedWidthOnly = FALSE);
424 bool EnumerateEncodings(const wxString& facename = wxPyEmptyString);
426 //wxArrayString* GetEncodings();
427 //wxArrayString* GetFacenames();
429 PyObject* GetEncodings() {
430 wxArrayString* arr = self->GetEncodings();
431 return wxArrayString2PyList_helper(*arr);
434 PyObject* GetFacenames() {
435 wxArrayString* arr = self->GetFacenames();
436 return wxArrayString2PyList_helper(*arr);
441 //---------------------------------------------------------------------------
442 // wxLocale. Not really font related, but close enough
447 // user's default/preffered language as got from OS:
449 // unknown language, if wxLocale::GetSystemLanguage fails:
452 wxLANGUAGE_ABKHAZIAN,
454 wxLANGUAGE_AFRIKAANS,
458 wxLANGUAGE_ARABIC_ALGERIA,
459 wxLANGUAGE_ARABIC_BAHRAIN,
460 wxLANGUAGE_ARABIC_EGYPT,
461 wxLANGUAGE_ARABIC_IRAQ,
462 wxLANGUAGE_ARABIC_JORDAN,
463 wxLANGUAGE_ARABIC_KUWAIT,
464 wxLANGUAGE_ARABIC_LEBANON,
465 wxLANGUAGE_ARABIC_LIBYA,
466 wxLANGUAGE_ARABIC_MOROCCO,
467 wxLANGUAGE_ARABIC_OMAN,
468 wxLANGUAGE_ARABIC_QATAR,
469 wxLANGUAGE_ARABIC_SAUDI_ARABIA,
470 wxLANGUAGE_ARABIC_SUDAN,
471 wxLANGUAGE_ARABIC_SYRIA,
472 wxLANGUAGE_ARABIC_TUNISIA,
473 wxLANGUAGE_ARABIC_UAE,
474 wxLANGUAGE_ARABIC_YEMEN,
479 wxLANGUAGE_AZERI_CYRILLIC,
480 wxLANGUAGE_AZERI_LATIN,
483 wxLANGUAGE_BELARUSIAN,
489 wxLANGUAGE_BULGARIAN,
491 wxLANGUAGE_CAMBODIAN,
494 wxLANGUAGE_CHINESE_SIMPLIFIED,
495 wxLANGUAGE_CHINESE_TRADITIONAL,
496 wxLANGUAGE_CHINESE_HONGKONG,
497 wxLANGUAGE_CHINESE_MACAU,
498 wxLANGUAGE_CHINESE_SINGAPORE,
499 wxLANGUAGE_CHINESE_TAIWAN,
505 wxLANGUAGE_DUTCH_BELGIAN,
507 wxLANGUAGE_ENGLISH_UK,
508 wxLANGUAGE_ENGLISH_US,
509 wxLANGUAGE_ENGLISH_AUSTRALIA,
510 wxLANGUAGE_ENGLISH_BELIZE,
511 wxLANGUAGE_ENGLISH_BOTSWANA,
512 wxLANGUAGE_ENGLISH_CANADA,
513 wxLANGUAGE_ENGLISH_CARIBBEAN,
514 wxLANGUAGE_ENGLISH_DENMARK,
515 wxLANGUAGE_ENGLISH_EIRE,
516 wxLANGUAGE_ENGLISH_JAMAICA,
517 wxLANGUAGE_ENGLISH_NEW_ZEALAND,
518 wxLANGUAGE_ENGLISH_PHILIPPINES,
519 wxLANGUAGE_ENGLISH_SOUTH_AFRICA,
520 wxLANGUAGE_ENGLISH_TRINIDAD,
521 wxLANGUAGE_ENGLISH_ZIMBABWE,
522 wxLANGUAGE_ESPERANTO,
529 wxLANGUAGE_FRENCH_BELGIAN,
530 wxLANGUAGE_FRENCH_CANADIAN,
531 wxLANGUAGE_FRENCH_LUXEMBOURG,
532 wxLANGUAGE_FRENCH_MONACO,
533 wxLANGUAGE_FRENCH_SWISS,
538 wxLANGUAGE_GERMAN_AUSTRIAN,
539 wxLANGUAGE_GERMAN_BELGIUM,
540 wxLANGUAGE_GERMAN_LIECHTENSTEIN,
541 wxLANGUAGE_GERMAN_LUXEMBOURG,
542 wxLANGUAGE_GERMAN_SWISS,
544 wxLANGUAGE_GREENLANDIC,
550 wxLANGUAGE_HUNGARIAN,
551 wxLANGUAGE_ICELANDIC,
552 wxLANGUAGE_INDONESIAN,
553 wxLANGUAGE_INTERLINGUA,
554 wxLANGUAGE_INTERLINGUE,
555 wxLANGUAGE_INUKTITUT,
559 wxLANGUAGE_ITALIAN_SWISS,
564 wxLANGUAGE_KASHMIRI_INDIA,
567 wxLANGUAGE_KINYARWANDA,
577 wxLANGUAGE_LITHUANIAN,
578 wxLANGUAGE_MACEDONIAN,
581 wxLANGUAGE_MALAYALAM,
582 wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM,
583 wxLANGUAGE_MALAY_MALAYSIA,
588 wxLANGUAGE_MOLDAVIAN,
589 wxLANGUAGE_MONGOLIAN,
592 wxLANGUAGE_NEPALI_INDIA,
593 wxLANGUAGE_NORWEGIAN_BOKMAL,
594 wxLANGUAGE_NORWEGIAN_NYNORSK,
600 wxLANGUAGE_PORTUGUESE,
601 wxLANGUAGE_PORTUGUESE_BRAZILIAN,
604 wxLANGUAGE_RHAETO_ROMANCE,
607 wxLANGUAGE_RUSSIAN_UKRAINE,
611 wxLANGUAGE_SCOTS_GAELIC,
613 wxLANGUAGE_SERBIAN_CYRILLIC,
614 wxLANGUAGE_SERBIAN_LATIN,
615 wxLANGUAGE_SERBO_CROATIAN,
620 wxLANGUAGE_SINHALESE,
623 wxLANGUAGE_SLOVENIAN,
626 wxLANGUAGE_SPANISH_ARGENTINA,
627 wxLANGUAGE_SPANISH_BOLIVIA,
628 wxLANGUAGE_SPANISH_CHILE,
629 wxLANGUAGE_SPANISH_COLOMBIA,
630 wxLANGUAGE_SPANISH_COSTA_RICA,
631 wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC,
632 wxLANGUAGE_SPANISH_ECUADOR,
633 wxLANGUAGE_SPANISH_EL_SALVADOR,
634 wxLANGUAGE_SPANISH_GUATEMALA,
635 wxLANGUAGE_SPANISH_HONDURAS,
636 wxLANGUAGE_SPANISH_MEXICAN,
637 wxLANGUAGE_SPANISH_MODERN,
638 wxLANGUAGE_SPANISH_NICARAGUA,
639 wxLANGUAGE_SPANISH_PANAMA,
640 wxLANGUAGE_SPANISH_PARAGUAY,
641 wxLANGUAGE_SPANISH_PERU,
642 wxLANGUAGE_SPANISH_PUERTO_RICO,
643 wxLANGUAGE_SPANISH_URUGUAY,
644 wxLANGUAGE_SPANISH_US,
645 wxLANGUAGE_SPANISH_VENEZUELA,
646 wxLANGUAGE_SUNDANESE,
649 wxLANGUAGE_SWEDISH_FINLAND,
664 wxLANGUAGE_UKRAINIAN,
666 wxLANGUAGE_URDU_INDIA,
667 wxLANGUAGE_URDU_PAKISTAN,
669 wxLANGUAGE_UZBEK_CYRILLIC,
670 wxLANGUAGE_UZBEK_LATIN,
671 wxLANGUAGE_VIETNAMESE,
681 // for custom, user-defined languages:
682 wxLANGUAGE_USER_DEFINED
685 // wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc.
686 // translation information
690 int Language; // wxLanguage id
691 wxString CanonicalName; // Canonical name, e.g. fr_FR
692 wxString Description; // human-readable name of the language
695 // wxLocaleCategory: the category of locale settings
696 enum wxLocaleCategory
704 // wxLocaleInfo: the items understood by wxLocale::GetInfo()
707 wxLOCALE_THOUSANDS_SEP,
708 wxLOCALE_DECIMAL_POINT
712 // wxLocale: encapsulates all language dependent settings, including current
713 // message catalogs, date, time and currency formats (TODO) &c
714 enum wxLocaleInitFlags
716 wxLOCALE_LOAD_DEFAULT = 0x0001, // load wxwin.mo?
717 wxLOCALE_CONV_ENCODING = 0x0002 // convert encoding on the fly?
725 wxLocale(int language = wxLANGUAGE_DEFAULT,
726 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
728 // restores old locale
731 %name(Init1)bool Init(const wxString& szName,
732 const wxString& szShort = wxPyEmptyString,
733 const wxString& szLocale = wxPyEmptyString,
734 bool bLoadDefault = TRUE,
735 bool bConvertEncoding = FALSE);
737 %name(Init2) bool Init(int language = wxLANGUAGE_DEFAULT,
738 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
740 %pragma(python) addtoclass = "
741 def Init(self, *_args, **_kwargs):
742 if type(_args[0]) in [type(''), type(u'')]:
743 val = self.Init1(*_args, **_kwargs)
745 val = self.Init2(*_args, **_kwargs)
750 // Try to get user's (or OS's) prefered language setting.
751 // Return wxLANGUAGE_UNKNOWN if language-guessing algorithm failed
752 static int GetSystemLanguage();
754 // get the encoding used by default for text on this system, returns
755 // wxFONTENCODING_SYSTEM if it couldn't be determined
756 static wxFontEncoding GetSystemEncoding();
758 // get the string describing the system encoding, return empty string if
759 // couldn't be determined
760 static wxString GetSystemEncodingName();
763 // THIS ONE IS COMMENTED OUT IN src/common/intl.cpp
764 // get the values of the given locale-dependent datum: the current locale
765 // is used, the US default value is returned if everything else fails
766 // static wxString GetInfo(wxLocaleInfo index, wxLocaleCategory cat);
768 // return TRUE if the locale was set successfully
771 // returns locale name
772 wxString GetLocale() const;
774 // return current locale wxLanguage value
775 int GetLanguage() const;
777 // return locale name to be passed to setlocale()
778 wxString GetSysName() const;
780 // return 'canonical' name, i.e. in the form of xx[_YY], where xx is
781 // language code according to ISO 639 and YY is country name
782 // as specified by ISO 3166.
783 wxString GetCanonicalName() const;
785 // add a prefix to the catalog lookup path: the message catalog files will be
786 // looked up under prefix/<lang>/LC_MESSAGES, prefix/LC_MESSAGES and prefix
789 // This only applies to subsequent invocations of AddCatalog()!
790 static void AddCatalogLookupPathPrefix(const wxString& prefix);
792 // add a catalog: it's searched for in standard places (current directory
793 // first, system one after), but the you may prepend additional directories to
794 // the search path with AddCatalogLookupPathPrefix().
796 // The loaded catalog will be used for message lookup by GetString().
798 // Returns 'true' if it was successfully loaded
799 bool AddCatalog(const wxString& szDomain);
801 // check if the given catalog is loaded
802 bool IsLoaded(const wxString& szDomain) const;
804 // Retrieve the language info struct for the given language
806 // Returns NULL if no info found, pointer must *not* be deleted by caller
807 static const wxLanguageInfo *GetLanguageInfo(int lang);
809 // Find the language for the given locale string which may be either a
810 // canonical ISO 2 letter language code ("xx"), a language code followed by
811 // the country code ("xx_XX") or a Windows full language name ("Xxxxx...")
813 // Returns NULL if no info found, pointer must *not* be deleted by caller
814 static const wxLanguageInfo *FindLanguageInfo(const wxString& locale);
816 // Add custom language to the list of known languages.
817 // Notes: 1) wxLanguageInfo contains platform-specific data
818 // 2) must be called before Init to have effect
819 static void AddLanguage(const wxLanguageInfo& info);
821 // retrieve the translation for a string in all loaded domains unless
822 // the szDomain parameter is specified (and then only this domain is
825 // return original string if translation is not available
826 // (in this case an error message is generated the first time
827 // a string is not found; use wxLogNull to suppress it)
829 // domains are searched in the last to first order, i.e. catalogs
830 // added later override those added before.
831 wxString GetString(const wxString& szOrigString,
832 const wxString& szDomain = wxPyEmptyString) const;
834 // Returns the current short name for the locale
835 const wxString& GetName() const;
841 // get the current locale object (note that it may be NULL!)
842 wxLocale* wxGetLocale();
844 // get the translation of the string in the current locale
845 wxString wxGetTranslation(const wxString& sz);
848 //----------------------------------------------------------------------
849 // wxEncodingConverter
850 // This class is capable of converting strings between any two
851 // 8bit encodings/charsets. It can also convert from/to Unicode
854 %typemap(python, out) wxFontEncodingArray {
855 $target = PyList_New(0);
856 for (size_t i=0; i < $source->GetCount(); i++) {
857 PyObject* number = PyInt_FromLong($source->Item(i));
858 PyList_Append($target, number);
873 wxPLATFORM_CURRENT = -1,
882 class wxEncodingConverter : public wxObject
886 wxEncodingConverter();
887 ~wxEncodingConverter();
890 // Initialize convertion. Both output or input encoding may
891 // be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1.
893 // All subsequent calls to Convert() will interpret it's argument
894 // as a string in input_enc encoding and will output string in
895 // output_enc encoding.
897 // You must call this method before calling Convert. You may call
898 // it more than once in order to switch to another conversion
900 // Method affects behaviour of Convert() in case input character
901 // cannot be converted because it does not exist in output encoding:
902 // wxCONVERT_STRICT --
903 // follow behaviour of GNU Recode - just copy unconvertable
904 // characters to output and don't change them (it's integer
905 // value will stay the same)
906 // wxCONVERT_SUBSTITUTE --
907 // try some (lossy) substitutions - e.g. replace
908 // unconvertable latin capitals with acute by ordinary
909 // capitals, replace en-dash or em-dash by '-' etc.
910 // both modes gurantee that output string will have same length
913 // Returns FALSE if given conversion is impossible, TRUE otherwise
914 // (conversion may be impossible either if you try to convert
915 // to Unicode with non-Unicode build of wxWindows or if input
916 // or output encoding is not supported.)
917 bool Init(wxFontEncoding input_enc, wxFontEncoding output_enc, int method = wxCONVERT_STRICT);
920 // TODO: Need to do something about unicode mode...
922 // Convert input string according to settings passed to Init.
923 // Note that you must call Init before using Convert!
924 wxString Convert(const wxString& input);
926 // void Convert(const char* input, char* output);
929 // void Convert(const char* input, wchar_t* output);
930 // void Convert(const wchar_t* input, char* output);
931 // void Convert(const wchar_t* input, wchar_t* output);
932 // void Convert(wchar_t* str) { Convert(str, str); }
937 // Return equivalent(s) for given font that are used
938 // under given platform. wxPLATFORM_CURRENT means the plaform
939 // this binary was compiled for
942 // current platform enc returned value
943 // -----------------------------------------------------
944 // unix CP1250 {ISO8859_2}
946 // windows ISO8859_2 {CP1250}
948 // Equivalence is defined in terms of convertibility:
949 // 2 encodings are equivalent if you can convert text between
950 // then without loosing information (it may - and will - happen
951 // that you loose special chars like quotation marks or em-dashes
952 // but you shouldn't loose any diacritics and language-specific
953 // characters when converting between equivalent encodings).
955 // Convert() method is not limited to converting between
956 // equivalent encodings, it can convert between arbitrary
959 // Remember that this function does _NOT_ check for presence of
960 // fonts in system. It only tells you what are most suitable
961 // encodings. (It usually returns only one encoding)
963 // Note that argument enc itself may be present in returned array!
964 // (so that you can -- as a side effect -- detect whether the
965 // encoding is native for this platform or not)
966 static wxFontEncodingArray GetPlatformEquivalents(wxFontEncoding enc,
967 int platform = wxPLATFORM_CURRENT);
969 // Similar to GetPlatformEquivalent, but this one will return ALL
970 // equivalent encodings, regardless the platform, including itself.
971 static wxFontEncodingArray GetAllEquivalents(wxFontEncoding enc);
973 %pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
977 //----------------------------------------------------------------------
978 //----------------------------------------------------------------------
981 wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator");
984 //----------------------------------------------------------------------