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
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
142 // Far Eastern encodings
143 wxFONTENCODING_GB2312, // Simplified Chinese
144 wxFONTENCODING_BIG5, // Traditional Chinese
146 wxFONTENCODING_SHIFT_JIS, // Shift JIS
150 wxFONTENCODING_UTF16,
151 wxFONTENCODING_UTF32,
152 wxFONTENCODING_UNICODE,
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
166 // reset to the default state
169 // init with the parameters of the given font
170 void InitFromFont(const wxFont& font);
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;
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);
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;
196 return self->ToString();
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;
209 // Fix some link errors... Remove this when these methods get real implementations...
210 // #if defined(__WXGTK__) || defined(__WXX11__)
212 // void wxNativeFontInfo::SetPointSize(int pointsize)
213 // { wxFAIL_MSG( _T("not implemented") ); }
215 // void wxNativeFontInfo::SetStyle(wxFontStyle style)
216 // { wxFAIL_MSG( _T("not implemented") ); }
218 // void wxNativeFontInfo::SetWeight(wxFontWeight weight)
219 // { wxFAIL_MSG( _T("not implemented") ); }
221 // void wxNativeFontInfo::SetUnderlined(bool WXUNUSED(underlined))
222 // { wxFAIL_MSG( _T("not implemented") ); }
224 // void wxNativeFontInfo::SetFaceName(wxString facename)
225 // { wxFAIL_MSG( _T("not implemented") ); }
227 // void wxNativeFontInfo::SetFamily(wxFontFamily family)
228 // { wxFAIL_MSG( _T("not implemented") ); }
230 // void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding)
231 // { wxFAIL_MSG( _T("not implemented") ); }
236 //---------------------------------------------------------------------------
237 // wxFontMapper manages user-definable correspondence between logical font
238 // names and the fonts present on the machine.
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.
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);
260 // returns the encoding for the given charset (in the form of RFC 2046) or
261 // wxFONTENCODING_SYSTEM if couldn't decode it
263 // interactive parameter is ignored in the base class, we behave as if it
265 virtual wxFontEncoding CharsetToEncoding(const wxString& charset,
266 bool interactive = true);
269 // get the number of font encodings we know about
270 static size_t GetSupportedEncodingsCount();
272 // get the n-th supported encoding
273 static wxFontEncoding GetEncoding(size_t n);
275 // return internal string identifier for the encoding (see also
276 // GetEncodingDescription())
277 static wxString GetEncodingName(wxFontEncoding encoding);
279 // return user-readable string describing the given encoding
281 // NB: hard-coded now, but might change later (read it from config?)
282 static wxString GetEncodingDescription(wxFontEncoding encoding);
285 // set the config object to use (may be NULL to use default)
286 void SetConfig(wxConfigBase *config);
288 // set the root config path to use (should be an absolute path)
289 void SetConfigPath(const wxString& prefix);
291 // return default config path
292 static const wxChar *GetDefaultConfigPath();
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
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);
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);
319 // the parent window for modal dialogs
320 void SetDialogParent(wxWindow *parent) { m_windowParent = parent; }
322 // the title for the dialogs (note that default is quite reasonable)
323 void SetDialogTitle(const wxString& title) { m_titleDialog = title; }
329 //---------------------------------------------------------------------------
331 class wxFont : public wxObject {
333 wxFont( int pointSize, int family, int style, int weight,
334 int underline=FALSE, const wxString& faceName = wxPyEmptyString,
335 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
337 %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
339 %new wxFont* wxFontFromNativeInfoString(const wxString& info) {
340 wxNativeFontInfo nfi;
341 nfi.FromString(info);
342 return new wxFont(nfi);
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;
359 const wxNativeFontInfo* GetNativeFontInfo() const;
360 wxString GetNativeFontInfoDesc() const;
361 wxString GetNativeFontInfoUserDesc() const;
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);
374 wxString GetFamilyString() const;
375 wxString GetStyleString() const;
376 wxString GetWeightString() const;
378 void SetNoAntiAliasing( bool no = TRUE );
379 bool GetNoAntiAliasing();
381 static wxFontEncoding GetDefaultEncoding();
382 static void SetDefaultEncoding(wxFontEncoding encoding);
384 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
388 class wxFontList : public wxObject {
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);
401 //----------------------------------------------------------------------
405 class wxPyFontEnumerator : public wxFontEnumerator {
407 wxPyFontEnumerator() {}
408 ~wxPyFontEnumerator() {}
410 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
411 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
416 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
417 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
421 %name(wxFontEnumerator) class wxPyFontEnumerator {
423 wxPyFontEnumerator();
424 ~wxPyFontEnumerator();
425 void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref);
426 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFontEnumerator, 0)"
428 bool EnumerateFacenames(
429 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
430 bool fixedWidthOnly = FALSE);
431 bool EnumerateEncodings(const wxString& facename = wxPyEmptyString);
433 //wxArrayString* GetEncodings();
434 //wxArrayString* GetFacenames();
436 PyObject* GetEncodings() {
437 wxArrayString* arr = self->GetEncodings();
438 return wxArrayString2PyList_helper(*arr);
441 PyObject* GetFacenames() {
442 wxArrayString* arr = self->GetFacenames();
443 return wxArrayString2PyList_helper(*arr);
448 //---------------------------------------------------------------------------
449 // wxLocale. Not really font related, but close enough
454 // user's default/preffered language as got from OS:
456 // unknown language, if wxLocale::GetSystemLanguage fails:
459 wxLANGUAGE_ABKHAZIAN,
461 wxLANGUAGE_AFRIKAANS,
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,
486 wxLANGUAGE_AZERI_CYRILLIC,
487 wxLANGUAGE_AZERI_LATIN,
490 wxLANGUAGE_BELARUSIAN,
496 wxLANGUAGE_BULGARIAN,
498 wxLANGUAGE_CAMBODIAN,
501 wxLANGUAGE_CHINESE_SIMPLIFIED,
502 wxLANGUAGE_CHINESE_TRADITIONAL,
503 wxLANGUAGE_CHINESE_HONGKONG,
504 wxLANGUAGE_CHINESE_MACAU,
505 wxLANGUAGE_CHINESE_SINGAPORE,
506 wxLANGUAGE_CHINESE_TAIWAN,
512 wxLANGUAGE_DUTCH_BELGIAN,
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,
536 wxLANGUAGE_FRENCH_BELGIAN,
537 wxLANGUAGE_FRENCH_CANADIAN,
538 wxLANGUAGE_FRENCH_LUXEMBOURG,
539 wxLANGUAGE_FRENCH_MONACO,
540 wxLANGUAGE_FRENCH_SWISS,
545 wxLANGUAGE_GERMAN_AUSTRIAN,
546 wxLANGUAGE_GERMAN_BELGIUM,
547 wxLANGUAGE_GERMAN_LIECHTENSTEIN,
548 wxLANGUAGE_GERMAN_LUXEMBOURG,
549 wxLANGUAGE_GERMAN_SWISS,
551 wxLANGUAGE_GREENLANDIC,
557 wxLANGUAGE_HUNGARIAN,
558 wxLANGUAGE_ICELANDIC,
559 wxLANGUAGE_INDONESIAN,
560 wxLANGUAGE_INTERLINGUA,
561 wxLANGUAGE_INTERLINGUE,
562 wxLANGUAGE_INUKTITUT,
566 wxLANGUAGE_ITALIAN_SWISS,
571 wxLANGUAGE_KASHMIRI_INDIA,
574 wxLANGUAGE_KINYARWANDA,
584 wxLANGUAGE_LITHUANIAN,
585 wxLANGUAGE_MACEDONIAN,
588 wxLANGUAGE_MALAYALAM,
589 wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM,
590 wxLANGUAGE_MALAY_MALAYSIA,
595 wxLANGUAGE_MOLDAVIAN,
596 wxLANGUAGE_MONGOLIAN,
599 wxLANGUAGE_NEPALI_INDIA,
600 wxLANGUAGE_NORWEGIAN_BOKMAL,
601 wxLANGUAGE_NORWEGIAN_NYNORSK,
607 wxLANGUAGE_PORTUGUESE,
608 wxLANGUAGE_PORTUGUESE_BRAZILIAN,
611 wxLANGUAGE_RHAETO_ROMANCE,
614 wxLANGUAGE_RUSSIAN_UKRAINE,
618 wxLANGUAGE_SCOTS_GAELIC,
620 wxLANGUAGE_SERBIAN_CYRILLIC,
621 wxLANGUAGE_SERBIAN_LATIN,
622 wxLANGUAGE_SERBO_CROATIAN,
627 wxLANGUAGE_SINHALESE,
630 wxLANGUAGE_SLOVENIAN,
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,
656 wxLANGUAGE_SWEDISH_FINLAND,
671 wxLANGUAGE_UKRAINIAN,
673 wxLANGUAGE_URDU_INDIA,
674 wxLANGUAGE_URDU_PAKISTAN,
676 wxLANGUAGE_UZBEK_CYRILLIC,
677 wxLANGUAGE_UZBEK_LATIN,
678 wxLANGUAGE_VIETNAMESE,
688 // for custom, user-defined languages:
689 wxLANGUAGE_USER_DEFINED
692 // wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc.
693 // translation information
697 int Language; // wxLanguage id
698 wxString CanonicalName; // Canonical name, e.g. fr_FR
699 wxString Description; // human-readable name of the language
702 // wxLocaleCategory: the category of locale settings
703 enum wxLocaleCategory
711 // wxLocaleInfo: the items understood by wxLocale::GetInfo()
714 wxLOCALE_THOUSANDS_SEP,
715 wxLOCALE_DECIMAL_POINT
719 // wxLocale: encapsulates all language dependent settings, including current
720 // message catalogs, date, time and currency formats (TODO) &c
721 enum wxLocaleInitFlags
723 wxLOCALE_LOAD_DEFAULT = 0x0001, // load wxwin.mo?
724 wxLOCALE_CONV_ENCODING = 0x0002 // convert encoding on the fly?
732 wxLocale(int language = wxLANGUAGE_DEFAULT,
733 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
735 // restores old locale
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);
744 %name(Init2) bool Init(int language = wxLANGUAGE_DEFAULT,
745 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
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)
752 val = self.Init2(*_args, **_kwargs)
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();
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();
765 // get the string describing the system encoding, return empty string if
766 // couldn't be determined
767 static wxString GetSystemEncodingName();
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);
775 // return TRUE if the locale was set successfully
778 // returns locale name
779 wxString GetLocale() const;
781 // return current locale wxLanguage value
782 int GetLanguage() const;
784 // return locale name to be passed to setlocale()
785 wxString GetSysName() const;
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;
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
796 // This only applies to subsequent invocations of AddCatalog()!
797 static void AddCatalogLookupPathPrefix(const wxString& prefix);
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().
803 // The loaded catalog will be used for message lookup by GetString().
805 // Returns 'true' if it was successfully loaded
806 bool AddCatalog(const wxString& szDomain);
808 // check if the given catalog is loaded
809 bool IsLoaded(const wxString& szDomain) const;
811 // Retrieve the language info struct for the given language
813 // Returns NULL if no info found, pointer must *not* be deleted by caller
814 static const wxLanguageInfo *GetLanguageInfo(int lang);
816 // Returns language name in English or empty string if the language
817 // is not in database
818 static wxString GetLanguageName(int lang);
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...")
824 // Returns NULL if no info found, pointer must *not* be deleted by caller
825 static const wxLanguageInfo *FindLanguageInfo(const wxString& locale);
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);
832 // retrieve the translation for a string in all loaded domains unless
833 // the szDomain parameter is specified (and then only this domain is
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)
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;
845 // Returns the current short name for the locale
846 const wxString& GetName() const;
852 // get the current locale object (note that it may be NULL!)
853 wxLocale* wxGetLocale();
855 // get the translation of the string in the current locale
856 wxString wxGetTranslation(const wxString& sz);
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
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);
884 wxPLATFORM_CURRENT = -1,
893 class wxEncodingConverter : public wxObject
897 wxEncodingConverter();
898 ~wxEncodingConverter();
901 // Initialize convertion. Both output or input encoding may
902 // be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1.
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.
908 // You must call this method before calling Convert. You may call
909 // it more than once in order to switch to another conversion
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
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);
931 // TODO: Need to do something about unicode mode...
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);
937 // void Convert(const char* input, char* output);
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); }
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
953 // current platform enc returned value
954 // -----------------------------------------------------
955 // unix CP1250 {ISO8859_2}
957 // windows ISO8859_2 {CP1250}
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).
966 // Convert() method is not limited to converting between
967 // equivalent encodings, it can convert between arbitrary
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)
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);
980 // Similar to GetPlatformEquivalent, but this one will return ALL
981 // equivalent encodings, regardless the platform, including itself.
982 static wxFontEncodingArray GetAllEquivalents(wxFontEncoding enc);
984 %pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
988 //----------------------------------------------------------------------
989 //----------------------------------------------------------------------
992 wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator");
995 //----------------------------------------------------------------------