X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/73deed44e63d9d8d21a2ef6182bc685edc2bb0f9..dd23c25cde86903f2a4115e4a24e891e80d477e4:/src/common/fontmap.cpp?ds=inline diff --git a/src/common/fontmap.cpp b/src/common/fontmap.cpp index 022d92d0e3..6c591571f0 100644 --- a/src/common/fontmap.cpp +++ b/src/common/fontmap.cpp @@ -36,6 +36,7 @@ #include "wx/intl.h" #endif // PCH +#include "wx/module.h" #include "wx/fontmap.h" #if wxUSE_CONFIG @@ -177,15 +178,6 @@ static const wxChar* gs_encodingNames[] = wxT( "utf-8" ), }; -// ---------------------------------------------------------------------------- -// global data -// ---------------------------------------------------------------------------- - -// private object -static wxFontMapper gs_fontMapper; - -// and public pointer -wxFontMapper * wxTheFontMapper = &gs_fontMapper; // ---------------------------------------------------------------------------- // private classes @@ -243,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 // ---------------------------------------------------------------------------- @@ -862,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();