X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77ffb5937e89927b621128789401db8921fe580f..5d1b49193b778e39901b83097a34429db2e5b47b:/src/common/fmapbase.cpp diff --git a/src/common/fmapbase.cpp b/src/common/fmapbase.cpp index a926d8e1d7..2358475b48 100644 --- a/src/common/fmapbase.cpp +++ b/src/common/fmapbase.cpp @@ -6,7 +6,7 @@ // Created: 21.06.2003 (extracted from common/fontmap.cpp) // RCS-ID: $Id$ // Copyright: (c) 1999-2003 Vadim Zeitlin -// License: wxWidgets license +// License: wxWindows license /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -73,6 +73,7 @@ static wxFontEncoding gs_encodings[] = wxFONTENCODING_ISO8859_15, wxFONTENCODING_KOI8, wxFONTENCODING_KOI8_U, + wxFONTENCODING_CP874, wxFONTENCODING_CP932, wxFONTENCODING_CP936, wxFONTENCODING_CP949, @@ -117,6 +118,7 @@ static const wxChar* gs_encodingDescs[] = wxTRANSLATE( "Western European with Euro (ISO-8859-15)" ), wxTRANSLATE( "KOI8-R" ), wxTRANSLATE( "KOI8-U" ), + wxTRANSLATE( "Windows Thai (CP 874)" ), wxTRANSLATE( "Windows Japanese (CP 932)" ), wxTRANSLATE( "Windows Chinese Simplified (CP 936)" ), wxTRANSLATE( "Windows Korean (CP 949)" ), @@ -161,6 +163,7 @@ static const wxChar* gs_encodingNames[] = wxT( "iso-8859-15" ), wxT( "koi8-r" ), wxT( "koi8-u" ), + wxT( "windows-874" ), wxT( "windows-932" ), wxT( "windows-936" ), wxT( "windows-949" ), @@ -198,8 +201,8 @@ class wxFontMapperModule : public wxModule { public: wxFontMapperModule() : wxModule() { } - virtual bool OnInit() { return TRUE; } - virtual void OnExit() { delete wxFontMapper::Set(NULL); } + virtual bool OnInit() { return true; } + virtual void OnExit() { delete (wxFontMapperBase*)wxFontMapperBase::Set(NULL); } DECLARE_DYNAMIC_CLASS(wxFontMapperModule) }; @@ -221,7 +224,7 @@ wxFontMapperBase::wxFontMapperBase() { #if wxUSE_CONFIG && wxUSE_FILECONFIG m_config = NULL; - m_configIsDummy = FALSE; + m_configIsDummy = false; #endif // wxUSE_CONFIG } @@ -233,8 +236,11 @@ wxFontMapperBase::~wxFontMapperBase() #endif // wxUSE_CONFIG } +bool wxFontMapperBase::IsWxFontMapper() +{ return false; } + /* static */ -wxFontMapper *wxFontMapperBase::Get() +wxFontMapperBase *wxFontMapperBase::Get() { if ( !sm_instance ) { @@ -255,7 +261,7 @@ wxFontMapper *wxFontMapperBase::Get() } } - return sm_instance; + return (wxFontMapperBase*)sm_instance; } /* static */ @@ -295,7 +301,7 @@ wxConfigBase *wxFontMapperBase::GetConfig() if ( !m_config ) { // try the default - m_config = wxConfig::Get(FALSE /*don't create on demand*/ ); + m_config = wxConfig::Get(false /*don't create on demand*/ ); if ( !m_config ) { @@ -305,7 +311,7 @@ wxConfigBase *wxFontMapperBase::GetConfig() // but will allow us to remember the results of the questions at // least during this run m_config = new wxMemoryConfig; - m_configIsDummy = TRUE; + m_configIsDummy = true; // VS: we can't call wxConfig::Set(m_config) here because that would // disable automatic wxConfig instance creation if this code was // called before wxApp::OnInit (this happens in wxGTK -- it sets @@ -313,13 +319,13 @@ wxConfigBase *wxFontMapperBase::GetConfig() } } - if ( m_configIsDummy && wxConfig::Get(FALSE) != NULL ) + if ( m_configIsDummy && wxConfig::Get(false) != NULL ) { // VS: in case we created dummy m_config (see above), we want to switch back // to the real one as soon as one becomes available. delete m_config; - m_config = wxConfig::Get(FALSE); - m_configIsDummy = FALSE; + m_config = wxConfig::Get(false); + m_configIsDummy = false; // FIXME: ideally, we should add keys from dummy config to the real one now, // but it is a low-priority task because typical wxWin application // either doesn't use wxConfig at all or creates wxConfig object in @@ -349,7 +355,7 @@ bool wxFontMapperBase::ChangePath(const wxString& pathNew, wxString *pathOld) { wxConfigBase *config = GetConfig(); if ( !config ) - return FALSE; + return false; *pathOld = config->GetPath(); @@ -366,7 +372,7 @@ bool wxFontMapperBase::ChangePath(const wxString& pathNew, wxString *pathOld) config->SetPath(path); - return TRUE; + return true; } void wxFontMapperBase::RestorePath(const wxString& pathOld) @@ -437,7 +443,7 @@ wxFontMapperBase::NonInteractiveCharsetToEncoding(const wxString& charset) config->SetPath(FONTMAPPER_CHARSET_ALIAS_PATH); wxString alias = config->Read(charset); - if ( !!alias ) + if ( !alias.IsEmpty() ) { // yes, we do - use it instead cs = alias; @@ -519,6 +525,11 @@ wxFontMapperBase::NonInteractiveCharsetToEncoding(const wxString& charset) { encoding = wxFONTENCODING_EUC_JP; } + else if ( cs == wxT("EUC-KR") || + cs == wxT("EUC_KR") ) + { + encoding = wxFONTENCODING_CP949; + } else if ( cs == wxT("KOI8-R") || cs == wxT("KOI8-RU") ) { @@ -538,14 +549,14 @@ wxFontMapperBase::NonInteractiveCharsetToEncoding(const wxString& charset) const wxChar *p = cs.c_str() + 3; if ( *p == wxT('-') ) p++; - + // printf( "iso %s\n", (const char*) cs.ToAscii() ); unsigned int value; if ( wxSscanf(p, wxT("8859-%u"), &value) == 1 ) { // printf( "value %d\n", (int)value ); - + // make it 0 based and check that it is strictly positive in // the process (no such thing as iso8859-0 encoding) if ( (value-- > 0) && @@ -561,12 +572,12 @@ wxFontMapperBase::NonInteractiveCharsetToEncoding(const wxString& charset) else if ( cs.Left(4) == wxT("8859") ) { const wxChar *p = cs.c_str(); - + unsigned int value; if ( wxSscanf(p, wxT("8859-%u"), &value) == 1 ) { // printf( "value %d\n", (int)value ); - + // make it 0 based and check that it is strictly positive in // the process (no such thing as iso8859-0 encoding) if ( (value-- > 0) && @@ -618,6 +629,10 @@ wxFontMapperBase::NonInteractiveCharsetToEncoding(const wxString& charset) switch ( value ) { + case 874: + encoding = wxFONTENCODING_CP874; + break; + case 932: encoding = wxFONTENCODING_CP932; break;