X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/65e508482777277c429b8c522e1ff8050ff5cdc7..39d16996b7616bf8090b140db74fd0b52d50d169:/src/common/fontmap.cpp diff --git a/src/common/fontmap.cpp b/src/common/fontmap.cpp index ab990ef8eb..6c591571f0 100644 --- a/src/common/fontmap.cpp +++ b/src/common/fontmap.cpp @@ -178,27 +178,6 @@ static const wxChar* gs_encodingNames[] = 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 @@ -256,6 +235,34 @@ wxFontMapper::~wxFontMapper() #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 // ---------------------------------------------------------------------------- @@ -875,7 +882,7 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding, wxFontData data; data.SetEncoding(encoding); data.EncodingInfo() = *info; - wxFontDialog dialog(m_windowParent, &data); + wxFontDialog dialog(m_windowParent, data); if ( dialog.ShowModal() == wxID_OK ) { wxFontData retData = dialog.GetFontData();