- wxLocale now works in Unicode mode
- wxLocale can now load message catalogs in arbitrary encoding
- fixed the bug related to the redrawing on resize introduced in 2.3.2
+- added static wxFontMapper::Get() accessor (use of wxTheFontMapper is now
+ deprecated)
Unix (Base/GUI):
\membersection{wxConfigBase::Get}\label{wxconfigbaseget}
-\func{wxConfigBase *}{Get}{\param{bool }{CreateOnDemand = TRUE}}
+\func{static wxConfigBase *}{Get}{\param{bool }{CreateOnDemand = TRUE}}
Get the current config object. If there is no current object and
{\it CreateOnDemand} is TRUE, creates one
\membersection{wxConfigBase::Set}\label{wxconfigbaseset}
-\func{wxConfigBase *}{Set}{\param{wxConfigBase *}{pConfig}}
+\func{static wxConfigBase *}{Set}{\param{wxConfigBase *}{pConfig}}
Sets the config object as the current one, returns the pointer to the previous
current object (both the parameter and returned value may be NULL)
the class queries \helpref{wxEncodingConverter}{wxencodingconverter}
for "equivalent" encodings (e.g. iso8859-2 and cp1250) and tries them.
-\wxheading{Global variables}
-
-{\tt wxFontMapper *wxTheFontMapper} is defined.
-
\wxheading{Using wxFontMapper in conjunction with wxEncodingConverter}
If you need to display text in encoding which is not available at
Following code snippet demonstrates it:
\begin{verbatim}
-if (!wxTheFontMapper->IsEncodingAvailable(enc, facename))
+if (!wxFontMapper::Get()->IsEncodingAvailable(enc, facename))
{
wxFontEncoding alternative;
- if (wxTheFontMapper->GetAltForEncoding(enc, &alternative,
- facename, FALSE))
+ if (wxFontMapper::Get()->GetAltForEncoding(enc, &alternative,
+ facename, FALSE))
{
wxEncodingConverter encconv;
if (!encconv.Init(enc, alternative))
Default ctor.
+\wxheading{Note}
+
+The preferred way of creating a wxFontMapper instance is to call
+\helpref{wxFontMapper::Get}{wxfontmapperget}.
+
\membersection{wxFontMapper::\destruct{wxFontMapper}}\label{wxfontmapperdtor}
\func{}{\destruct{wxFontMapper}}{\void}
Virtual dtor for a base class.
+\membersection{wxFontMapper::Get}\label{wxfontmapperget}
+
+\func{static wxFontMapper *}{Get}{\void}
+
+Get the current font mapper object. If there is no current object, creates
+one.
+
+\wxheading{See also}
+
+\helpref{wxFontMapper::Set}{wxfontmapperset}
+
\membersection{wxFontMapper::GetAltForEncoding}\label{wxfontmappergetaltforencoding}
\func{bool}{GetAltForEncoding}{\param{wxFontEncoding }{encoding}, \param{wxNativeEncodingInfo* }{info}, \param{const wxString\& }{facename = wxEmptyString}, \param{bool }{interactive = TRUE}}
The title for the dialogs (note that default is quite reasonable).
+\membersection{wxFontMapper::Set}\label{wxfontmapperset}
+
+\func{static wxFontMapper *}{Set}{\param{wxFontMapper *}{mapper}}
+
+Set the current font mapper object and return previous one (may be NULL).
+This method is only useful if you want to plug-in an alternative font mapper
+into wxWindows.
+
+\wxheading{See also}
+
+\helpref{wxFontMapper::Get}{wxfontmapperget}
+
\membersection{wxFontMapper::SetConfig}\label{wxfontmappersetconfig}
\func{void}{SetConfig}{\param{wxConfigBase* }{config}}
\helpref{wxFontMapper}{wxfontmapper} to display text:
\begin{verbatim}
-if (!wxTheFontMapper->IsEncodingAvailable(enc, facename))
+if (!wxFontMapper::Get()->IsEncodingAvailable(enc, facename))
{
wxFontEncoding alternative;
if (wxTheFontMapper->GetAltForEncoding(enc, &alternative,
// virtual dtor for a base class
virtual ~wxFontMapper();
+ // return instance of the wxFontMapper singleton
+ static wxFontMapper *Get();
+ // set the sigleton to 'mapper' instance and return previous one
+ static wxFontMapper *Set(wxFontMapper *mapper);
+
#if wxUSE_GUI
// find an alternative for the given encoding (which is supposed to not be
// available on this system). If successful, return TRUE and fill info
#endif // wxUSE_GUI
friend class wxFontMapperPathChanger;
+
+private:
+ static wxFontMapper *sm_instance;
};
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// the default font mapper for wxWindows programs
-WXDLLEXPORT_DATA(extern wxFontMapper *) wxTheFontMapper;
+// do NOT use! This is for backward compatibility, use wxFontMapper::Get() instead
+#define wxTheFontMapper (wxFontMapper::Get())
#endif // wxUSE_FONTMAP
for ( size_t n = 0; n < WXSIZEOF(charsets); n++ )
{
- wxFontEncoding enc = wxTheFontMapper->CharsetToEncoding(charsets[n]);
+ wxFontEncoding enc = wxFontMapper::Get()->CharsetToEncoding(charsets[n]);
wxPrintf(_T("Charset: %s\tEncoding: %s (%s)\n"),
charsets[n],
- wxTheFontMapper->GetEncodingName(enc).c_str(),
- wxTheFontMapper->GetEncodingDescription(enc).c_str());
+ wxFontMapper::Get()->GetEncodingName(enc).c_str(),
+ wxFontMapper::Get()->GetEncodingDescription(enc).c_str());
}
}
}
// ok, now get the corresponding encoding
- wxFontEncoding fontenc = wxTheFontMapper->CharsetToEncoding(charset);
+ wxFontEncoding fontenc = wxFontMapper::Get()->CharsetToEncoding(charset);
if ( fontenc == wxFONTENCODING_SYSTEM )
{
wxLogError(wxT("Charset '%s' is unsupported."), charset.c_str());
m_textctrl->LoadFile(filename);
if ( fontenc == wxFONTENCODING_UTF8 ||
- !wxTheFontMapper->IsEncodingAvailable(fontenc) )
+ !wxFontMapper::Get()->IsEncodingAvailable(fontenc) )
{
// try to find some similar encoding:
wxFontEncoding encAlt;
- if ( wxTheFontMapper->GetAltForEncoding(fontenc, &encAlt) )
+ if ( wxFontMapper::Get()->GetAltForEncoding(fontenc, &encAlt) )
{
wxEncodingConverter conv;
fontInfo.Printf(wxT("Font size is %d points, family: %s, encoding: %s"),
m_font.GetPointSize(),
m_font.GetFamilyString().c_str(),
- wxTheFontMapper->
+ wxFontMapper::Get()->
GetEncodingDescription(m_font.GetEncoding()).c_str());
dc.DrawText(fontInfo, x, y);
wxFontEncoding enc = GetEncoding();
if ( enc != wxFONTENCODING_DEFAULT && enc != wxFONTENCODING_SYSTEM )
{
- desc << _T(' ') << wxTheFontMapper->GetEncodingName(enc);
+ desc << _T(' ') << wxFontMapper::Get()->GetEncodingName(enc);
}
#endif // wxUSE_FONTMAP
SetPointSize(size);
}
#if wxUSE_FONTMAP
- else if ( (encoding = wxTheFontMapper->CharsetToEncoding(token, FALSE))
+ else if ( (encoding = wxFontMapper::Get()->CharsetToEncoding(token, FALSE))
!= wxFONTENCODING_DEFAULT )
{
SetEncoding(encoding);
wxT( "utf-8" ),
};
-// ----------------------------------------------------------------------------
-// global data
-// ----------------------------------------------------------------------------
-
-wxFontMapper * wxTheFontMapper = NULL;
-
-class wxFontMapperModule: public wxModule
-{
-public:
- wxFontMapperModule() : wxModule() { }
- virtual bool OnInit() { wxTheFontMapper = new wxFontMapper; return TRUE; }
- virtual void OnExit()
- {
- delete wxTheFontMapper;
- wxTheFontMapper = NULL;
- }
-
- DECLARE_DYNAMIC_CLASS(wxFontMapperModule)
-};
-
-IMPLEMENT_DYNAMIC_CLASS(wxFontMapperModule, wxModule)
// ----------------------------------------------------------------------------
// private classes
#endif // wxUSE_CONFIG
}
+wxFontMapper *wxFontMapper::sm_instance = NULL;
+
+/*static*/ wxFontMapper *wxFontMapper::Get()
+{
+ if ( !sm_instance )
+ sm_instance = new wxFontMapper;
+ return sm_instance;
+}
+
+/*static*/ wxFontMapper *wxFontMapper::Set(wxFontMapper *mapper)
+{
+ wxFontMapper *old = sm_instance;
+ sm_instance = mapper;
+ return old;
+}
+
+class wxFontMapperModule: public wxModule
+{
+public:
+ wxFontMapperModule() : wxModule() {}
+ virtual bool OnInit() { return TRUE; }
+ virtual void OnExit() { delete wxFontMapper::Set(NULL); }
+
+ DECLARE_DYNAMIC_CLASS(wxFontMapperModule)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxFontMapperModule, wxModule)
+
// ----------------------------------------------------------------------------
// customisation
// ----------------------------------------------------------------------------
if ( convertEncoding )
{
wxFontEncoding targetEnc = wxFONTENCODING_SYSTEM;
- wxFontEncoding enc = wxTheFontMapper->CharsetToEncoding(charset, FALSE);
+ wxFontEncoding enc = wxFontMapper::Get()->CharsetToEncoding(charset, FALSE);
if ( enc == wxFONTENCODING_SYSTEM )
{
convertEncoding = FALSE; // unknown encoding
wxString encname = GetSystemEncodingName();
if ( !encname.empty() )
{
- wxFontEncoding enc = wxTheFontMapper->
+ wxFontEncoding enc = wxFontMapper::Get()->
CharsetToEncoding(encname, FALSE /* not interactive */);
// this should probably be considered as a bug in CharsetToEncoding():
enc(wxFONTENCODING_SYSTEM)
{
if (name)
- enc = wxTheFontMapper->CharsetToEncoding(name, FALSE);
+ enc = wxFontMapper::Get()->CharsetToEncoding(name, FALSE);
m_ok = m2w.Init(enc, wxFONTENCODING_UNICODE) &&
w2m.Init(wxFONTENCODING_UNICODE, enc);
{
// check for the special case of ASCII charset
#if wxUSE_FONTMAP
- if ( wxTheFontMapper->CharsetToEncoding(name) == wxFONTENCODING_DEFAULT )
+ if ( wxFontMapper::Get()->CharsetToEncoding(name) == wxFONTENCODING_DEFAULT )
#else // wxUSE_FONTMAP
if ( !name )
#endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
wxFontEncoding enc;
if (charset == wxEmptyString) enc = wxFONTENCODING_SYSTEM;
- else enc = wxTheFontMapper->CharsetToEncoding(charset);
+ else enc = wxFontMapper::Get()->CharsetToEncoding(charset);
bool rtval = AddBookParam(*fi, enc,
title, contents, index, start, fsys.GetPath());
delete fi;
if (content.Left(19) == _T("text/html; charset="))
{
wxFontEncoding enc =
- wxTheFontMapper->CharsetToEncoding(content.Mid(19));
+ wxFontMapper::Get()->CharsetToEncoding(content.Mid(19));
if (enc == wxFONTENCODING_SYSTEM) return FALSE;
if (enc == m_WParser->GetInputEncoding()) return FALSE;
bool availfix, availnorm;
// exact match?
- availnorm = wxTheFontMapper->IsEncodingAvailable(enc, m_FontFaceNormal);
- availfix = wxTheFontMapper->IsEncodingAvailable(enc, m_FontFaceFixed);
+ availnorm = wxFontMapper::Get()->IsEncodingAvailable(enc, m_FontFaceNormal);
+ availfix = wxFontMapper::Get()->IsEncodingAvailable(enc, m_FontFaceFixed);
if (availnorm && availfix)
m_OutputEnc = enc;
// alternatives?
- else if (wxTheFontMapper->GetAltForEncoding(enc, &altnorm, m_FontFaceNormal, FALSE) &&
- wxTheFontMapper->GetAltForEncoding(enc, &altfix, m_FontFaceFixed, FALSE) &&
+ else if (wxFontMapper::Get()->GetAltForEncoding(enc, &altnorm, m_FontFaceNormal, FALSE) &&
+ wxFontMapper::Get()->GetAltForEncoding(enc, &altfix, m_FontFaceFixed, FALSE) &&
altnorm == altfix)
m_OutputEnc = altnorm;
// at least normal face?
else if (availnorm)
m_OutputEnc = enc;
- else if (wxTheFontMapper->GetAltForEncoding(enc, &altnorm, m_FontFaceNormal, FALSE))
+ else if (wxFontMapper::Get()->GetAltForEncoding(enc, &altnorm, m_FontFaceNormal, FALSE))
m_OutputEnc = altnorm;
// okay, let convert to ISO_8859-1, available always
wxNativeEncodingInfo info;
if ( !wxGetNativeFontEncoding(encoding, &info) )
{
- if ( !wxTheFontMapper->GetAltForEncoding(encoding, &info) )
+ if ( !wxFontMapper::Get()->GetAltForEncoding(encoding, &info) )
{
// no such encodings at all
return FALSE;
wxNativeEncodingInfo info;
if ( !wxGetNativeFontEncoding(encoding, &info) )
{
- if ( !wxTheFontMapper->GetAltForEncoding(encoding, &info) )
+ if ( !wxFontMapper::Get()->GetAltForEncoding(encoding, &info) )
{
// no such encodings at all
return FALSE;
!wxTestFontEncoding(nativeEnc) )
{
#if wxUSE_FONTMAP
- if ( !wxTheFontMapper->GetAltForEncoding(encoding, &nativeEnc) )
+ if ( !wxFontMapper::Get()->GetAltForEncoding(encoding, &nativeEnc) )
#endif
{
nativeEnc.mglEncoding = MGL_ENCODING_ASCII;
if ( !wxGetNativeFontEncoding(encoding, &info) )
{
#if wxUSE_FONTMAP
- if ( wxTheFontMapper->GetAltForEncoding(encoding, &info) )
+ if ( wxFontMapper::Get()->GetAltForEncoding(encoding, &info) )
{
if ( !info.facename.empty() )
{
if ( !wxGetNativeFontEncoding(encoding, &info) )
{
#if wxUSE_FONTMAP
- if ( !wxTheFontMapper->GetAltForEncoding(encoding, &info) )
+ if ( !wxFontMapper::Get()->GetAltForEncoding(encoding, &info) )
#endif // wxUSE_FONTMAP
{
// no such encodings at all
if ( !name )
return -1;
- wxFontEncoding enc = wxTheFontMapper->CharsetToEncoding(name, FALSE);
+ wxFontEncoding enc = wxFontMapper::Get()->CharsetToEncoding(name, FALSE);
if ( enc == wxFONTENCODING_SYSTEM )
return -1;
))
{
#if wxUSE_FONTMAP
- if (wxTheFontMapper->GetAltForEncoding( eEncoding
+ if (wxFontMapper::Get()->GetAltForEncoding( eEncoding
,&vInfo
))
{
wxNativeEncodingInfo info;
if ( !wxGetNativeFontEncoding(encoding, &info) )
{
- if ( !wxTheFontMapper->GetAltForEncoding(encoding, &info) )
+ if ( !wxFontMapper::Get()->GetAltForEncoding(encoding, &info) )
{
// no such encodings at all
return FALSE;
GetEncodingName__12wxFontMapperF14wxFontEncoding
;wxFontMapper::~wxFontMapper()
__dt__12wxFontMapperFv
- wxTheFontMapper
;wxFontMapper::GetDefaultConfigPath()
GetDefaultConfigPath__12wxFontMapperFv
;wxFontMapper::GetEncodingDescription(wxFontEncoding)
if ( !wxTestFontEncoding(info) )
{
// ask font mapper for a replacement
- (void)wxTheFontMapper->GetAltForEncoding(encoding, &info);
+ (void)wxFontMapper::Get()->GetAltForEncoding(encoding, &info);
}
#endif // wxUSE_FONTMAP
!wxTestFontEncoding(info) )
{
#if wxUSE_FONTMAP
- if ( !wxTheFontMapper->GetAltForEncoding(encoding, &info) )
+ if ( !wxFontMapper::Get()->GetAltForEncoding(encoding, &info) )
#endif // wxUSE_FONTMAP
{
// unspported encoding - replace it with the default