]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/fontmap.cpp
Committing in .
[wxWidgets.git] / src / common / fontmap.cpp
index 022d92d0e3925707e5beec033e65b2f4cf27401a..c976d72af6b753263a543c1e352f7f7225d8bf99 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
 // ----------------------------------------------------------------------------