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     // returns the encoding for the given charset (in the form of RFC 2046) or
 
 253     // wxFONTENCODING_SYSTEM if couldn't decode it
 
 255     // interactive parameter is ignored in the base class, we behave as if it
 
 257     virtual wxFontEncoding CharsetToEncoding(const wxString& charset,
 
 258                                              bool interactive = true);
 
 261     // get the number of font encodings we know about
 
 262     static size_t GetSupportedEncodingsCount();
 
 264     // get the n-th supported encoding
 
 265     static wxFontEncoding GetEncoding(size_t n);
 
 267     // return internal string identifier for the encoding (see also
 
 268     // GetEncodingDescription())
 
 269     static wxString GetEncodingName(wxFontEncoding encoding);
 
 271     // return user-readable string describing the given encoding
 
 273     // NB: hard-coded now, but might change later (read it from config?)
 
 274     static wxString GetEncodingDescription(wxFontEncoding encoding);
 
 277     // set the config object to use (may be NULL to use default)
 
 278     void SetConfig(wxConfigBase *config);
 
 280     // set the root config path to use (should be an absolute path)
 
 281     void SetConfigPath(const wxString& prefix);
 
 283     // return default config path
 
 284     static const wxChar *GetDefaultConfigPath();
 
 288     // Find an alternative for the given encoding (which is supposed to not be
 
 289     // available on this system). If successful, returns the encoding otherwise
 
 292         PyObject* GetAltForEncoding(wxFontEncoding encoding,
 
 293                                     const wxString& facename = wxPyEmptyString,
 
 294                                     bool interactive = TRUE) {
 
 295             wxFontEncoding alt_enc;
 
 296             if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive))
 
 297                 return PyInt_FromLong(alt_enc);
 
 306     // checks whether given encoding is available in given face or not.
 
 307     // If no facename is given,
 
 308     bool IsEncodingAvailable(wxFontEncoding encoding,
 
 309                              const wxString& facename = wxPyEmptyString);
 
 311     // the parent window for modal dialogs
 
 312     void SetDialogParent(wxWindow *parent) { m_windowParent = parent; }
 
 314     // the title for the dialogs (note that default is quite reasonable)
 
 315     void SetDialogTitle(const wxString& title) { m_titleDialog = title; }
 
 321 //---------------------------------------------------------------------------
 
 323 class wxFont : public wxObject {
 
 325     wxFont( int pointSize, int family, int style, int weight,
 
 326             int underline=FALSE, const wxString& faceName = wxPyEmptyString,
 
 327             wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
 
 329     %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
 
 331         %new wxFont* wxFontFromNativeInfoString(const wxString& info) {
 
 332             wxNativeFontInfo nfi;
 
 333             nfi.FromString(info);
 
 334             return new wxFont(nfi);
 
 341     int GetPointSize() const;
 
 342     int GetFamily() const;
 
 343     int GetStyle() const;
 
 344     int GetWeight() const;
 
 345     bool GetUnderlined() const;
 
 346     wxString GetFaceName() const;
 
 347     wxFontEncoding GetEncoding() const;
 
 351     wxNativeFontInfo* GetNativeFontInfo() const;
 
 352     wxString GetNativeFontInfoDesc() const;
 
 353     wxString GetNativeFontInfoUserDesc() const;
 
 355     void SetPointSize(int pointSize);
 
 356     void SetFamily(int family);
 
 357     void SetStyle(int style);
 
 358     void SetWeight(int weight);
 
 359     void SetFaceName(const wxString& faceName);
 
 360     void SetUnderlined(bool underlined);
 
 361     void SetEncoding(wxFontEncoding encoding);
 
 362     void SetNativeFontInfo(const wxNativeFontInfo& info);
 
 363     // void SetNativeFontInfo(const wxString& info);
 
 364     void SetNativeFontInfoUserDesc(const wxString& info);
 
 366     wxString GetFamilyString() const;
 
 367     wxString GetStyleString() const;
 
 368     wxString GetWeightString() const;
 
 370     void SetNoAntiAliasing( bool no = TRUE );
 
 371     bool GetNoAntiAliasing();
 
 373     static wxFontEncoding GetDefaultEncoding();
 
 374     static void SetDefaultEncoding(wxFontEncoding encoding);
 
 376     %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
 
 380 class wxFontList : public wxObject {
 
 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);
 
 393 //----------------------------------------------------------------------
 
 397 class wxPyFontEnumerator : public wxFontEnumerator {
 
 399     wxPyFontEnumerator() {}
 
 400     ~wxPyFontEnumerator() {}
 
 402     DEC_PYCALLBACK_BOOL_STRING(OnFacename);
 
 403     DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
 
 408 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
 
 409 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
 
 413 %name(wxFontEnumerator) class wxPyFontEnumerator {
 
 415     wxPyFontEnumerator();
 
 416     ~wxPyFontEnumerator();
 
 417     void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref);
 
 418     %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFontEnumerator, 0)"
 
 420     bool EnumerateFacenames(
 
 421         wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
 
 422         bool fixedWidthOnly = FALSE);
 
 423     bool EnumerateEncodings(const wxString& facename = wxPyEmptyString);
 
 425     //wxArrayString* GetEncodings();
 
 426     //wxArrayString* GetFacenames();
 
 428         PyObject* GetEncodings() {
 
 429             wxArrayString* arr = self->GetEncodings();
 
 430             return wxArrayString2PyList_helper(*arr);
 
 433         PyObject* GetFacenames() {
 
 434             wxArrayString* arr = self->GetFacenames();
 
 435             return wxArrayString2PyList_helper(*arr);
 
 440 //---------------------------------------------------------------------------
 
 441 // wxLocale.  Not really font related, but close enough
 
 446     // user's default/preffered language as got from OS:
 
 448     // unknown language, if wxLocale::GetSystemLanguage fails:
 
 451     wxLANGUAGE_ABKHAZIAN,
 
 453     wxLANGUAGE_AFRIKAANS,
 
 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,
 
 478     wxLANGUAGE_AZERI_CYRILLIC,
 
 479     wxLANGUAGE_AZERI_LATIN,
 
 482     wxLANGUAGE_BELARUSIAN,
 
 488     wxLANGUAGE_BULGARIAN,
 
 490     wxLANGUAGE_CAMBODIAN,
 
 493     wxLANGUAGE_CHINESE_SIMPLIFIED,
 
 494     wxLANGUAGE_CHINESE_TRADITIONAL,
 
 495     wxLANGUAGE_CHINESE_HONGKONG,
 
 496     wxLANGUAGE_CHINESE_MACAU,
 
 497     wxLANGUAGE_CHINESE_SINGAPORE,
 
 498     wxLANGUAGE_CHINESE_TAIWAN,
 
 504     wxLANGUAGE_DUTCH_BELGIAN,
 
 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,
 
 528     wxLANGUAGE_FRENCH_BELGIAN,
 
 529     wxLANGUAGE_FRENCH_CANADIAN,
 
 530     wxLANGUAGE_FRENCH_LUXEMBOURG,
 
 531     wxLANGUAGE_FRENCH_MONACO,
 
 532     wxLANGUAGE_FRENCH_SWISS,
 
 537     wxLANGUAGE_GERMAN_AUSTRIAN,
 
 538     wxLANGUAGE_GERMAN_BELGIUM,
 
 539     wxLANGUAGE_GERMAN_LIECHTENSTEIN,
 
 540     wxLANGUAGE_GERMAN_LUXEMBOURG,
 
 541     wxLANGUAGE_GERMAN_SWISS,
 
 543     wxLANGUAGE_GREENLANDIC,
 
 549     wxLANGUAGE_HUNGARIAN,
 
 550     wxLANGUAGE_ICELANDIC,
 
 551     wxLANGUAGE_INDONESIAN,
 
 552     wxLANGUAGE_INTERLINGUA,
 
 553     wxLANGUAGE_INTERLINGUE,
 
 554     wxLANGUAGE_INUKTITUT,
 
 558     wxLANGUAGE_ITALIAN_SWISS,
 
 563     wxLANGUAGE_KASHMIRI_INDIA,
 
 566     wxLANGUAGE_KINYARWANDA,
 
 576     wxLANGUAGE_LITHUANIAN,
 
 577     wxLANGUAGE_MACEDONIAN,
 
 580     wxLANGUAGE_MALAYALAM,
 
 581     wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM,
 
 582     wxLANGUAGE_MALAY_MALAYSIA,
 
 587     wxLANGUAGE_MOLDAVIAN,
 
 588     wxLANGUAGE_MONGOLIAN,
 
 591     wxLANGUAGE_NEPALI_INDIA,
 
 592     wxLANGUAGE_NORWEGIAN_BOKMAL,
 
 593     wxLANGUAGE_NORWEGIAN_NYNORSK,
 
 599     wxLANGUAGE_PORTUGUESE,
 
 600     wxLANGUAGE_PORTUGUESE_BRAZILIAN,
 
 603     wxLANGUAGE_RHAETO_ROMANCE,
 
 606     wxLANGUAGE_RUSSIAN_UKRAINE,
 
 610     wxLANGUAGE_SCOTS_GAELIC,
 
 612     wxLANGUAGE_SERBIAN_CYRILLIC,
 
 613     wxLANGUAGE_SERBIAN_LATIN,
 
 614     wxLANGUAGE_SERBO_CROATIAN,
 
 619     wxLANGUAGE_SINHALESE,
 
 622     wxLANGUAGE_SLOVENIAN,
 
 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,
 
 648     wxLANGUAGE_SWEDISH_FINLAND,
 
 663     wxLANGUAGE_UKRAINIAN,
 
 665     wxLANGUAGE_URDU_INDIA,
 
 666     wxLANGUAGE_URDU_PAKISTAN,
 
 668     wxLANGUAGE_UZBEK_CYRILLIC,
 
 669     wxLANGUAGE_UZBEK_LATIN,
 
 670     wxLANGUAGE_VIETNAMESE,
 
 680     // for custom, user-defined languages:
 
 681     wxLANGUAGE_USER_DEFINED
 
 684 // wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc.
 
 685 //                 translation information
 
 689     int Language;                   // wxLanguage id
 
 690     wxString CanonicalName;         // Canonical name, e.g. fr_FR
 
 691     wxString Description;           // human-readable name of the language
 
 694 // wxLocaleCategory: the category of locale settings
 
 695 enum wxLocaleCategory
 
 703 // wxLocaleInfo: the items understood by wxLocale::GetInfo()
 
 706     wxLOCALE_THOUSANDS_SEP,
 
 707     wxLOCALE_DECIMAL_POINT
 
 711 // wxLocale: encapsulates all language dependent settings, including current
 
 712 //           message catalogs, date, time and currency formats (TODO) &c
 
 713 enum wxLocaleInitFlags
 
 715     wxLOCALE_LOAD_DEFAULT  = 0x0001,     // load wxwin.mo?
 
 716     wxLOCALE_CONV_ENCODING = 0x0002      // convert encoding on the fly?
 
 724     wxLocale(int language = wxLANGUAGE_DEFAULT,
 
 725              int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
 
 727         // restores old locale
 
 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);
 
 736     %name(Init2) bool Init(int language = wxLANGUAGE_DEFAULT,
 
 737                            int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
 
 739     %pragma(python) addtoclass = "
 
 740     def Init(self, *_args, **_kwargs):
 
 741         if type(_args[0]) in [type(''), type(u'')]:
 
 742             val = self.Init1(*_args, **_kwargs)
 
 744             val = self.Init2(*_args, **_kwargs)
 
 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();
 
 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();
 
 757     // get the string describing the system encoding, return empty string if
 
 758     // couldn't be determined
 
 759     static wxString GetSystemEncodingName();
 
 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);
 
 767     // return TRUE if the locale was set successfully
 
 770     // returns locale name
 
 771     wxString GetLocale() const;
 
 773     // return current locale wxLanguage value
 
 774     int GetLanguage() const;
 
 776     // return locale name to be passed to setlocale()
 
 777     wxString GetSysName() const;
 
 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;
 
 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
 
 788     // This only applies to subsequent invocations of AddCatalog()!
 
 789     static void AddCatalogLookupPathPrefix(const wxString& prefix);
 
 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().
 
 795     // The loaded catalog will be used for message lookup by GetString().
 
 797     // Returns 'true' if it was successfully loaded
 
 798     bool AddCatalog(const wxString& szDomain);
 
 800     // check if the given catalog is loaded
 
 801     bool IsLoaded(const wxString& szDomain) const;
 
 803     // Retrieve the language info struct for the given language
 
 805     // Returns NULL if no info found, pointer must *not* be deleted by caller
 
 806     static const wxLanguageInfo *GetLanguageInfo(int lang);
 
 808     // Returns language name in English or empty string if the language
 
 809     // is not in database
 
 810     static wxString GetLanguageName(int lang);
 
 812     // Find the language for the given locale string which may be either a
 
 813     // canonical ISO 2 letter language code ("xx"), a language code followed by
 
 814     // the country code ("xx_XX") or a Windows full language name ("Xxxxx...")
 
 816     // Returns NULL if no info found, pointer must *not* be deleted by caller
 
 817     static const wxLanguageInfo *FindLanguageInfo(const wxString& locale);
 
 819     // Add custom language to the list of known languages.
 
 820     // Notes: 1) wxLanguageInfo contains platform-specific data
 
 821     //        2) must be called before Init to have effect
 
 822     static void AddLanguage(const wxLanguageInfo& info);
 
 824     // retrieve the translation for a string in all loaded domains unless
 
 825     // the szDomain parameter is specified (and then only this domain is
 
 828     // return original string if translation is not available
 
 829     // (in this case an error message is generated the first time
 
 830     //  a string is not found; use wxLogNull to suppress it)
 
 832     // domains are searched in the last to first order, i.e. catalogs
 
 833     // added later override those added before.
 
 834     wxString GetString(const wxString& szOrigString,
 
 835                        const wxString& szDomain = wxPyEmptyString) const;
 
 837     // Returns the current short name for the locale
 
 838     const wxString& GetName() const;
 
 844 // get the current locale object (note that it may be NULL!)
 
 845 wxLocale* wxGetLocale();
 
 847 // get the translation of the string in the current locale
 
 848 wxString wxGetTranslation(const wxString& sz);
 
 851 //----------------------------------------------------------------------
 
 852 // wxEncodingConverter
 
 853 //                  This class is capable of converting strings between any two
 
 854 //                  8bit encodings/charsets. It can also convert from/to Unicode
 
 857 %typemap(python, out) wxFontEncodingArray {
 
 858     $target = PyList_New(0);
 
 859     for (size_t i=0; i < $source->GetCount(); i++) {
 
 860         PyObject* number = PyInt_FromLong($source->Item(i));
 
 861         PyList_Append($target, number);
 
 876     wxPLATFORM_CURRENT = -1,
 
 885 class wxEncodingConverter : public wxObject
 
 889     wxEncodingConverter();
 
 890     ~wxEncodingConverter();
 
 893     // Initialize convertion. Both output or input encoding may
 
 894     // be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1.
 
 896     // All subsequent calls to Convert() will interpret it's argument
 
 897     // as a string in input_enc encoding and will output string in
 
 898     // output_enc encoding.
 
 900     // You must call this method before calling Convert. You may call
 
 901     // it more than once in order to switch to another conversion
 
 903     // Method affects behaviour of Convert() in case input character
 
 904     // cannot be converted because it does not exist in output encoding:
 
 905     //     wxCONVERT_STRICT --
 
 906     //              follow behaviour of GNU Recode - just copy unconvertable
 
 907     //              characters to output and don't change them (it's integer
 
 908     //              value will stay the same)
 
 909     //     wxCONVERT_SUBSTITUTE --
 
 910     //              try some (lossy) substitutions - e.g. replace
 
 911     //              unconvertable latin capitals with acute by ordinary
 
 912     //              capitals, replace en-dash or em-dash by '-' etc.
 
 913     //     both modes gurantee that output string will have same length
 
 916     // Returns FALSE if given conversion is impossible, TRUE otherwise
 
 917     // (conversion may be impossible either if you try to convert
 
 918     // to Unicode with non-Unicode build of wxWindows or if input
 
 919     // or output encoding is not supported.)
 
 920     bool Init(wxFontEncoding input_enc, wxFontEncoding output_enc, int method = wxCONVERT_STRICT);
 
 923     // TODO:  Need to do something about unicode mode...
 
 925     // Convert input string according to settings passed to Init.
 
 926     // Note that you must call Init before using Convert!
 
 927     wxString Convert(const wxString& input);
 
 929     // void Convert(const char* input, char* output);
 
 932 //              void Convert(const char* input, wchar_t* output);
 
 933 //              void Convert(const wchar_t* input, char* output);
 
 934 //              void Convert(const wchar_t* input, wchar_t* output);
 
 935 //              void Convert(wchar_t* str) { Convert(str, str); }
 
 940     // Return equivalent(s) for given font that are used
 
 941     // under given platform. wxPLATFORM_CURRENT means the plaform
 
 942     // this binary was compiled for
 
 945     //     current platform          enc    returned value
 
 946     // -----------------------------------------------------
 
 947     //     unix                   CP1250         {ISO8859_2}
 
 949     //     windows             ISO8859_2            {CP1250}
 
 951     // Equivalence is defined in terms of convertibility:
 
 952     // 2 encodings are equivalent if you can convert text between
 
 953     // then without loosing information (it may - and will - happen
 
 954     // that you loose special chars like quotation marks or em-dashes
 
 955     // but you shouldn't loose any diacritics and language-specific
 
 956     // characters when converting between equivalent encodings).
 
 958     // Convert() method is not limited to converting between
 
 959     // equivalent encodings, it can convert between arbitrary
 
 962     // Remember that this function does _NOT_ check for presence of
 
 963     // fonts in system. It only tells you what are most suitable
 
 964     // encodings. (It usually returns only one encoding)
 
 966     // Note that argument enc itself may be present in returned array!
 
 967     // (so that you can -- as a side effect -- detect whether the
 
 968     // encoding is native for this platform or not)
 
 969     static wxFontEncodingArray GetPlatformEquivalents(wxFontEncoding enc,
 
 970                                                       int platform = wxPLATFORM_CURRENT);
 
 972     // Similar to GetPlatformEquivalent, but this one will return ALL
 
 973     // equivalent encodings, regardless the platform, including itself.
 
 974     static wxFontEncodingArray GetAllEquivalents(wxFontEncoding enc);
 
 976     %pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
 
 980 //----------------------------------------------------------------------
 
 981 //----------------------------------------------------------------------
 
 984     wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator");
 
 987 //----------------------------------------------------------------------