]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/fontmap.cpp
Applied patch [ 605189 ] add edit cancel notify to wxTreeEvent
[wxWidgets.git] / src / common / fontmap.cpp
index 022d92d0e3925707e5beec033e65b2f4cf27401a..6c591571f0a68feef889f96a2f88ec71c291f008 100644 (file)
@@ -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();