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_UTF16, // UTF-16 Unicode encoding
135 wxFONTENCODING_UTF16BE, // UTF-16 Big Endian Unicode encoding
136 wxFONTENCODING_UTF16LE, // UTF-16 Little Endian Unicode encoding
137 wxFONTENCODING_UTF32, // UTF-32 Unicode encoding
138 wxFONTENCODING_UTF32BE, // UTF-32 Big Endian Unicode encoding
139 wxFONTENCODING_UTF32LE, // UTF-32 Little Endian Unicode encoding
141 // Far Eastern encodings
143 wxFONTENCODING_GB2312 = wxFONTENCODING_CP936, // Simplified Chinese
144 wxFONTENCODING_BIG5 = wxFONTENCODING_CP950, // Traditional Chinese
146 // Japanese (see http://zsigri.tripod.com/fontboard/cjk/jis.html)
147 wxFONTENCODING_SHIFT_JIS = wxFONTENCODING_CP932, // Shift JIS
148 wxFONTENCODING_EUC_JP = wxFONTENCODING_UTF8 + 1, // Extended Unix Codepage
151 wxFONTENCODING_UNICODE, // Unicode (for wxEncodingConverter only)
157 //---------------------------------------------------------------------------
158 // wxNativeFontInfo is platform-specific font representation: this struct
159 // should be considered as opaque font description only used by the native
160 // functions, the user code can only get the objects of this type from
161 // somewhere and pass it somewhere else (possibly save them somewhere using
162 // ToString() and restore them using FromString())
163 struct wxNativeFontInfo
167 // reset to the default state
170 // init with the parameters of the given font
171 void InitFromFont(const wxFont& font);
173 // accessors and modifiers for the font elements
174 int GetPointSize() const;
175 wxFontStyle GetStyle() const;
176 wxFontWeight GetWeight() const;
177 bool GetUnderlined() const;
178 wxString GetFaceName() const;
179 wxFontFamily GetFamily() const;
180 wxFontEncoding GetEncoding() const;
182 void SetPointSize(int pointsize);
183 void SetStyle(wxFontStyle style);
184 void SetWeight(wxFontWeight weight);
185 void SetUnderlined(bool underlined);
186 void SetFaceName(wxString facename);
187 void SetFamily(wxFontFamily family);
188 void SetEncoding(wxFontEncoding encoding);
190 // it is important to be able to serialize wxNativeFontInfo objects to be
191 // able to store them (in config file, for example)
192 bool FromString(const wxString& s);
193 wxString ToString() const;
197 return self->ToString();
201 // we also want to present the native font descriptions to the user in some
202 // human-readable form (it is not platform independent neither, but can
203 // hopefully be understood by the user)
204 bool FromUserString(const wxString& s);
205 wxString ToUserString() const;
210 // Fix some link errors... Remove this when these methods get real implementations...
211 // #if defined(__WXGTK__) || defined(__WXX11__)
213 // void wxNativeFontInfo::SetPointSize(int pointsize)
214 // { wxFAIL_MSG( _T("not implemented") ); }
216 // void wxNativeFontInfo::SetStyle(wxFontStyle style)
217 // { wxFAIL_MSG( _T("not implemented") ); }
219 // void wxNativeFontInfo::SetWeight(wxFontWeight weight)
220 // { wxFAIL_MSG( _T("not implemented") ); }
222 // void wxNativeFontInfo::SetUnderlined(bool WXUNUSED(underlined))
223 // { wxFAIL_MSG( _T("not implemented") ); }
225 // void wxNativeFontInfo::SetFaceName(wxString facename)
226 // { wxFAIL_MSG( _T("not implemented") ); }
228 // void wxNativeFontInfo::SetFamily(wxFontFamily family)
229 // { wxFAIL_MSG( _T("not implemented") ); }
231 // void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding)
232 // { wxFAIL_MSG( _T("not implemented") ); }
237 //---------------------------------------------------------------------------
238 // wxFontMapper manages user-definable correspondence between logical font
239 // names and the fonts present on the machine.
241 // The default implementations of all functions will ask the user if they are
242 // not capable of finding the answer themselves and store the answer in a
243 // config file (configurable via SetConfigXXX functions). This behaviour may
244 // be disabled by giving the value of FALSE to "interactive" parameter.
245 // However, the functions will always consult the config file to allow the
246 // user-defined values override the default logic and there is no way to
247 // disable this - which shouldn't be ever needed because if "interactive" was
248 // never TRUE, the config file is never created anyhow.
255 // return instance of the wxFontMapper singleton
256 static wxFontMapper *Get();
257 // set the sigleton to 'mapper' instance and return previous one
258 static wxFontMapper *Set(wxFontMapper *mapper);
261 // returns the encoding for the given charset (in the form of RFC 2046) or
262 // wxFONTENCODING_SYSTEM if couldn't decode it
264 // interactive parameter is ignored in the base class, we behave as if it
266 virtual wxFontEncoding CharsetToEncoding(const wxString& charset,
267 bool interactive = true);
270 // get the number of font encodings we know about
271 static size_t GetSupportedEncodingsCount();
273 // get the n-th supported encoding
274 static wxFontEncoding GetEncoding(size_t n);
276 // return internal string identifier for the encoding (see also
277 // GetEncodingDescription())
278 static wxString GetEncodingName(wxFontEncoding encoding);
280 // return user-readable string describing the given encoding
282 // NB: hard-coded now, but might change later (read it from config?)
283 static wxString GetEncodingDescription(wxFontEncoding encoding);
286 // set the config object to use (may be NULL to use default)
287 void SetConfig(wxConfigBase *config);
289 // set the root config path to use (should be an absolute path)
290 void SetConfigPath(const wxString& prefix);
292 // return default config path
293 static const wxChar *GetDefaultConfigPath();
297 // Find an alternative for the given encoding (which is supposed to not be
298 // available on this system). If successful, returns the encoding otherwise
301 PyObject* GetAltForEncoding(wxFontEncoding encoding,
302 const wxString& facename = wxPyEmptyString,
303 bool interactive = TRUE) {
304 wxFontEncoding alt_enc;
305 if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive))
306 return PyInt_FromLong(alt_enc);
315 // checks whether given encoding is available in given face or not.
316 // If no facename is given,
317 bool IsEncodingAvailable(wxFontEncoding encoding,
318 const wxString& facename = wxPyEmptyString);
320 // the parent window for modal dialogs
321 void SetDialogParent(wxWindow *parent) { m_windowParent = parent; }
323 // the title for the dialogs (note that default is quite reasonable)
324 void SetDialogTitle(const wxString& title) { m_titleDialog = title; }
330 //---------------------------------------------------------------------------
332 class wxFont : public wxObject {
334 wxFont( int pointSize, int family, int style, int weight,
335 int underline=FALSE, const wxString& faceName = wxPyEmptyString,
336 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
338 %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
340 %new wxFont* wxFontFromNativeInfoString(const wxString& info) {
341 wxNativeFontInfo nfi;
342 nfi.FromString(info);
343 return new wxFont(nfi);
350 int GetPointSize() const;
351 int GetFamily() const;
352 int GetStyle() const;
353 int GetWeight() const;
354 bool GetUnderlined() const;
355 wxString GetFaceName() const;
356 wxFontEncoding GetEncoding() const;
360 const wxNativeFontInfo* GetNativeFontInfo() const;
361 wxString GetNativeFontInfoDesc() const;
362 wxString GetNativeFontInfoUserDesc() const;
364 void SetPointSize(int pointSize);
365 void SetFamily(int family);
366 void SetStyle(int style);
367 void SetWeight(int weight);
368 void SetFaceName(const wxString& faceName);
369 void SetUnderlined(bool underlined);
370 void SetEncoding(wxFontEncoding encoding);
371 void SetNativeFontInfo(const wxNativeFontInfo& info);
372 // void SetNativeFontInfo(const wxString& info);
373 void SetNativeFontInfoUserDesc(const wxString& info);
375 wxString GetFamilyString() const;
376 wxString GetStyleString() const;
377 wxString GetWeightString() const;
379 void SetNoAntiAliasing( bool no = TRUE );
380 bool GetNoAntiAliasing();
382 static wxFontEncoding GetDefaultEncoding();
383 static void SetDefaultEncoding(wxFontEncoding encoding);
385 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
389 class wxFontList : public wxObject {
392 void AddFont(wxFont* font);
393 wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
394 bool underline = FALSE, const wxString& facename = wxPyEmptyString,
395 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
396 void RemoveFont(wxFont *font);
402 //----------------------------------------------------------------------
406 class wxPyFontEnumerator : public wxFontEnumerator {
408 wxPyFontEnumerator() {}
409 ~wxPyFontEnumerator() {}
411 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
412 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
417 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
418 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
422 %name(wxFontEnumerator) class wxPyFontEnumerator {
424 wxPyFontEnumerator();
425 ~wxPyFontEnumerator();
426 void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref);
427 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFontEnumerator, 0)"
429 bool EnumerateFacenames(
430 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
431 bool fixedWidthOnly = FALSE);
432 bool EnumerateEncodings(const wxString& facename = wxPyEmptyString);
434 //wxArrayString* GetEncodings();
435 //wxArrayString* GetFacenames();
437 PyObject* GetEncodings() {
438 wxArrayString* arr = self->GetEncodings();
439 return wxArrayString2PyList_helper(*arr);
442 PyObject* GetFacenames() {
443 wxArrayString* arr = self->GetFacenames();
444 return wxArrayString2PyList_helper(*arr);
449 //---------------------------------------------------------------------------
450 // wxLocale. Not really font related, but close enough
455 // user's default/preffered language as got from OS:
457 // unknown language, if wxLocale::GetSystemLanguage fails:
460 wxLANGUAGE_ABKHAZIAN,
462 wxLANGUAGE_AFRIKAANS,
466 wxLANGUAGE_ARABIC_ALGERIA,
467 wxLANGUAGE_ARABIC_BAHRAIN,
468 wxLANGUAGE_ARABIC_EGYPT,
469 wxLANGUAGE_ARABIC_IRAQ,
470 wxLANGUAGE_ARABIC_JORDAN,
471 wxLANGUAGE_ARABIC_KUWAIT,
472 wxLANGUAGE_ARABIC_LEBANON,
473 wxLANGUAGE_ARABIC_LIBYA,
474 wxLANGUAGE_ARABIC_MOROCCO,
475 wxLANGUAGE_ARABIC_OMAN,
476 wxLANGUAGE_ARABIC_QATAR,
477 wxLANGUAGE_ARABIC_SAUDI_ARABIA,
478 wxLANGUAGE_ARABIC_SUDAN,
479 wxLANGUAGE_ARABIC_SYRIA,
480 wxLANGUAGE_ARABIC_TUNISIA,
481 wxLANGUAGE_ARABIC_UAE,
482 wxLANGUAGE_ARABIC_YEMEN,
487 wxLANGUAGE_AZERI_CYRILLIC,
488 wxLANGUAGE_AZERI_LATIN,
491 wxLANGUAGE_BELARUSIAN,
497 wxLANGUAGE_BULGARIAN,
499 wxLANGUAGE_CAMBODIAN,
502 wxLANGUAGE_CHINESE_SIMPLIFIED,
503 wxLANGUAGE_CHINESE_TRADITIONAL,
504 wxLANGUAGE_CHINESE_HONGKONG,
505 wxLANGUAGE_CHINESE_MACAU,
506 wxLANGUAGE_CHINESE_SINGAPORE,
507 wxLANGUAGE_CHINESE_TAIWAN,
513 wxLANGUAGE_DUTCH_BELGIAN,
515 wxLANGUAGE_ENGLISH_UK,
516 wxLANGUAGE_ENGLISH_US,
517 wxLANGUAGE_ENGLISH_AUSTRALIA,
518 wxLANGUAGE_ENGLISH_BELIZE,
519 wxLANGUAGE_ENGLISH_BOTSWANA,
520 wxLANGUAGE_ENGLISH_CANADA,
521 wxLANGUAGE_ENGLISH_CARIBBEAN,
522 wxLANGUAGE_ENGLISH_DENMARK,
523 wxLANGUAGE_ENGLISH_EIRE,
524 wxLANGUAGE_ENGLISH_JAMAICA,
525 wxLANGUAGE_ENGLISH_NEW_ZEALAND,
526 wxLANGUAGE_ENGLISH_PHILIPPINES,
527 wxLANGUAGE_ENGLISH_SOUTH_AFRICA,
528 wxLANGUAGE_ENGLISH_TRINIDAD,
529 wxLANGUAGE_ENGLISH_ZIMBABWE,
530 wxLANGUAGE_ESPERANTO,
537 wxLANGUAGE_FRENCH_BELGIAN,
538 wxLANGUAGE_FRENCH_CANADIAN,
539 wxLANGUAGE_FRENCH_LUXEMBOURG,
540 wxLANGUAGE_FRENCH_MONACO,
541 wxLANGUAGE_FRENCH_SWISS,
546 wxLANGUAGE_GERMAN_AUSTRIAN,
547 wxLANGUAGE_GERMAN_BELGIUM,
548 wxLANGUAGE_GERMAN_LIECHTENSTEIN,
549 wxLANGUAGE_GERMAN_LUXEMBOURG,
550 wxLANGUAGE_GERMAN_SWISS,
552 wxLANGUAGE_GREENLANDIC,
558 wxLANGUAGE_HUNGARIAN,
559 wxLANGUAGE_ICELANDIC,
560 wxLANGUAGE_INDONESIAN,
561 wxLANGUAGE_INTERLINGUA,
562 wxLANGUAGE_INTERLINGUE,
563 wxLANGUAGE_INUKTITUT,
567 wxLANGUAGE_ITALIAN_SWISS,
572 wxLANGUAGE_KASHMIRI_INDIA,
575 wxLANGUAGE_KINYARWANDA,
585 wxLANGUAGE_LITHUANIAN,
586 wxLANGUAGE_MACEDONIAN,
589 wxLANGUAGE_MALAYALAM,
590 wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM,
591 wxLANGUAGE_MALAY_MALAYSIA,
596 wxLANGUAGE_MOLDAVIAN,
597 wxLANGUAGE_MONGOLIAN,
600 wxLANGUAGE_NEPALI_INDIA,
601 wxLANGUAGE_NORWEGIAN_BOKMAL,
602 wxLANGUAGE_NORWEGIAN_NYNORSK,
608 wxLANGUAGE_PORTUGUESE,
609 wxLANGUAGE_PORTUGUESE_BRAZILIAN,
612 wxLANGUAGE_RHAETO_ROMANCE,
615 wxLANGUAGE_RUSSIAN_UKRAINE,
619 wxLANGUAGE_SCOTS_GAELIC,
621 wxLANGUAGE_SERBIAN_CYRILLIC,
622 wxLANGUAGE_SERBIAN_LATIN,
623 wxLANGUAGE_SERBO_CROATIAN,
628 wxLANGUAGE_SINHALESE,
631 wxLANGUAGE_SLOVENIAN,
634 wxLANGUAGE_SPANISH_ARGENTINA,
635 wxLANGUAGE_SPANISH_BOLIVIA,
636 wxLANGUAGE_SPANISH_CHILE,
637 wxLANGUAGE_SPANISH_COLOMBIA,
638 wxLANGUAGE_SPANISH_COSTA_RICA,
639 wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC,
640 wxLANGUAGE_SPANISH_ECUADOR,
641 wxLANGUAGE_SPANISH_EL_SALVADOR,
642 wxLANGUAGE_SPANISH_GUATEMALA,
643 wxLANGUAGE_SPANISH_HONDURAS,
644 wxLANGUAGE_SPANISH_MEXICAN,
645 wxLANGUAGE_SPANISH_MODERN,
646 wxLANGUAGE_SPANISH_NICARAGUA,
647 wxLANGUAGE_SPANISH_PANAMA,
648 wxLANGUAGE_SPANISH_PARAGUAY,
649 wxLANGUAGE_SPANISH_PERU,
650 wxLANGUAGE_SPANISH_PUERTO_RICO,
651 wxLANGUAGE_SPANISH_URUGUAY,
652 wxLANGUAGE_SPANISH_US,
653 wxLANGUAGE_SPANISH_VENEZUELA,
654 wxLANGUAGE_SUNDANESE,
657 wxLANGUAGE_SWEDISH_FINLAND,
672 wxLANGUAGE_UKRAINIAN,
674 wxLANGUAGE_URDU_INDIA,
675 wxLANGUAGE_URDU_PAKISTAN,
677 wxLANGUAGE_UZBEK_CYRILLIC,
678 wxLANGUAGE_UZBEK_LATIN,
679 wxLANGUAGE_VIETNAMESE,
689 // for custom, user-defined languages:
690 wxLANGUAGE_USER_DEFINED
693 // wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc.
694 // translation information
698 int Language; // wxLanguage id
699 wxString CanonicalName; // Canonical name, e.g. fr_FR
700 wxString Description; // human-readable name of the language
703 // wxLocaleCategory: the category of locale settings
704 enum wxLocaleCategory
712 // wxLocaleInfo: the items understood by wxLocale::GetInfo()
715 wxLOCALE_THOUSANDS_SEP,
716 wxLOCALE_DECIMAL_POINT
720 // wxLocale: encapsulates all language dependent settings, including current
721 // message catalogs, date, time and currency formats (TODO) &c
722 enum wxLocaleInitFlags
724 wxLOCALE_LOAD_DEFAULT = 0x0001, // load wxwin.mo?
725 wxLOCALE_CONV_ENCODING = 0x0002 // convert encoding on the fly?
733 wxLocale(int language = wxLANGUAGE_DEFAULT,
734 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
736 // restores old locale
739 %name(Init1)bool Init(const wxString& szName,
740 const wxString& szShort = wxPyEmptyString,
741 const wxString& szLocale = wxPyEmptyString,
742 bool bLoadDefault = TRUE,
743 bool bConvertEncoding = FALSE);
745 %name(Init2) bool Init(int language = wxLANGUAGE_DEFAULT,
746 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
748 %pragma(python) addtoclass = "
749 def Init(self, *_args, **_kwargs):
750 if type(_args[0]) in [type(''), type(u'')]:
751 val = self.Init1(*_args, **_kwargs)
753 val = self.Init2(*_args, **_kwargs)
758 // Try to get user's (or OS's) prefered language setting.
759 // Return wxLANGUAGE_UNKNOWN if language-guessing algorithm failed
760 static int GetSystemLanguage();
762 // get the encoding used by default for text on this system, returns
763 // wxFONTENCODING_SYSTEM if it couldn't be determined
764 static wxFontEncoding GetSystemEncoding();
766 // get the string describing the system encoding, return empty string if
767 // couldn't be determined
768 static wxString GetSystemEncodingName();
771 // THIS ONE IS COMMENTED OUT IN src/common/intl.cpp
772 // get the values of the given locale-dependent datum: the current locale
773 // is used, the US default value is returned if everything else fails
774 // static wxString GetInfo(wxLocaleInfo index, wxLocaleCategory cat);
776 // return TRUE if the locale was set successfully
779 // returns locale name
780 wxString GetLocale() const;
782 // return current locale wxLanguage value
783 int GetLanguage() const;
785 // return locale name to be passed to setlocale()
786 wxString GetSysName() const;
788 // return 'canonical' name, i.e. in the form of xx[_YY], where xx is
789 // language code according to ISO 639 and YY is country name
790 // as specified by ISO 3166.
791 wxString GetCanonicalName() const;
793 // add a prefix to the catalog lookup path: the message catalog files will be
794 // looked up under prefix/<lang>/LC_MESSAGES, prefix/LC_MESSAGES and prefix
797 // This only applies to subsequent invocations of AddCatalog()!
798 static void AddCatalogLookupPathPrefix(const wxString& prefix);
800 // add a catalog: it's searched for in standard places (current directory
801 // first, system one after), but the you may prepend additional directories to
802 // the search path with AddCatalogLookupPathPrefix().
804 // The loaded catalog will be used for message lookup by GetString().
806 // Returns 'true' if it was successfully loaded
807 bool AddCatalog(const wxString& szDomain);
809 // check if the given catalog is loaded
810 bool IsLoaded(const wxString& szDomain) const;
812 // Retrieve the language info struct for the given language
814 // Returns NULL if no info found, pointer must *not* be deleted by caller
815 static const wxLanguageInfo *GetLanguageInfo(int lang);
817 // Returns language name in English or empty string if the language
818 // is not in database
819 static wxString GetLanguageName(int lang);
821 // Find the language for the given locale string which may be either a
822 // canonical ISO 2 letter language code ("xx"), a language code followed by
823 // the country code ("xx_XX") or a Windows full language name ("Xxxxx...")
825 // Returns NULL if no info found, pointer must *not* be deleted by caller
826 static const wxLanguageInfo *FindLanguageInfo(const wxString& locale);
828 // Add custom language to the list of known languages.
829 // Notes: 1) wxLanguageInfo contains platform-specific data
830 // 2) must be called before Init to have effect
831 static void AddLanguage(const wxLanguageInfo& info);
833 // retrieve the translation for a string in all loaded domains unless
834 // the szDomain parameter is specified (and then only this domain is
837 // return original string if translation is not available
838 // (in this case an error message is generated the first time
839 // a string is not found; use wxLogNull to suppress it)
841 // domains are searched in the last to first order, i.e. catalogs
842 // added later override those added before.
843 wxString GetString(const wxString& szOrigString,
844 const wxString& szDomain = wxPyEmptyString) const;
846 // Returns the current short name for the locale
847 const wxString& GetName() const;
853 // get the current locale object (note that it may be NULL!)
854 wxLocale* wxGetLocale();
856 // get the translation of the string in the current locale
857 wxString wxGetTranslation(const wxString& sz);
860 //----------------------------------------------------------------------
861 // wxEncodingConverter
862 // This class is capable of converting strings between any two
863 // 8bit encodings/charsets. It can also convert from/to Unicode
866 %typemap(python, out) wxFontEncodingArray {
867 $target = PyList_New(0);
868 for (size_t i=0; i < $source->GetCount(); i++) {
869 PyObject* number = PyInt_FromLong($source->Item(i));
870 PyList_Append($target, number);
885 wxPLATFORM_CURRENT = -1,
894 class wxEncodingConverter : public wxObject
898 wxEncodingConverter();
899 ~wxEncodingConverter();
902 // Initialize convertion. Both output or input encoding may
903 // be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1.
905 // All subsequent calls to Convert() will interpret it's argument
906 // as a string in input_enc encoding and will output string in
907 // output_enc encoding.
909 // You must call this method before calling Convert. You may call
910 // it more than once in order to switch to another conversion
912 // Method affects behaviour of Convert() in case input character
913 // cannot be converted because it does not exist in output encoding:
914 // wxCONVERT_STRICT --
915 // follow behaviour of GNU Recode - just copy unconvertable
916 // characters to output and don't change them (it's integer
917 // value will stay the same)
918 // wxCONVERT_SUBSTITUTE --
919 // try some (lossy) substitutions - e.g. replace
920 // unconvertable latin capitals with acute by ordinary
921 // capitals, replace en-dash or em-dash by '-' etc.
922 // both modes gurantee that output string will have same length
925 // Returns FALSE if given conversion is impossible, TRUE otherwise
926 // (conversion may be impossible either if you try to convert
927 // to Unicode with non-Unicode build of wxWindows or if input
928 // or output encoding is not supported.)
929 bool Init(wxFontEncoding input_enc, wxFontEncoding output_enc, int method = wxCONVERT_STRICT);
932 // TODO: Need to do something about unicode mode...
934 // Convert input string according to settings passed to Init.
935 // Note that you must call Init before using Convert!
936 wxString Convert(const wxString& input);
938 // void Convert(const char* input, char* output);
941 // void Convert(const char* input, wchar_t* output);
942 // void Convert(const wchar_t* input, char* output);
943 // void Convert(const wchar_t* input, wchar_t* output);
944 // void Convert(wchar_t* str) { Convert(str, str); }
949 // Return equivalent(s) for given font that are used
950 // under given platform. wxPLATFORM_CURRENT means the plaform
951 // this binary was compiled for
954 // current platform enc returned value
955 // -----------------------------------------------------
956 // unix CP1250 {ISO8859_2}
958 // windows ISO8859_2 {CP1250}
960 // Equivalence is defined in terms of convertibility:
961 // 2 encodings are equivalent if you can convert text between
962 // then without loosing information (it may - and will - happen
963 // that you loose special chars like quotation marks or em-dashes
964 // but you shouldn't loose any diacritics and language-specific
965 // characters when converting between equivalent encodings).
967 // Convert() method is not limited to converting between
968 // equivalent encodings, it can convert between arbitrary
971 // Remember that this function does _NOT_ check for presence of
972 // fonts in system. It only tells you what are most suitable
973 // encodings. (It usually returns only one encoding)
975 // Note that argument enc itself may be present in returned array!
976 // (so that you can -- as a side effect -- detect whether the
977 // encoding is native for this platform or not)
978 static wxFontEncodingArray GetPlatformEquivalents(wxFontEncoding enc,
979 int platform = wxPLATFORM_CURRENT);
981 // Similar to GetPlatformEquivalent, but this one will return ALL
982 // equivalent encodings, regardless the platform, including itself.
983 static wxFontEncodingArray GetAllEquivalents(wxFontEncoding enc);
985 %pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
989 //----------------------------------------------------------------------
990 //----------------------------------------------------------------------
993 wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator");
996 //----------------------------------------------------------------------