]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxAppTraits::CreateConfig() (patch 1721149)
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 24 May 2007 00:50:54 +0000 (00:50 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 24 May 2007 00:50:54 +0000 (00:50 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46189 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/apptrait.h
src/common/config.cpp

index d9147fdd24423c113a191f180e816d1e6a2cffa5..b6447ed9656534f9ca384eb73582dc993e51c845 100644 (file)
 #include "wx/platinfo.h"
 
 class WXDLLIMPEXP_BASE wxArrayString;
-class WXDLLIMPEXP_BASE wxObject;
-class WXDLLEXPORT wxAppTraits;
+class WXDLLIMPEXP_BASE wxConfigBase;
 class WXDLLIMPEXP_BASE wxEventLoopBase;
 #if wxUSE_FONTMAP
     class WXDLLEXPORT wxFontMapper;
 #endif // wxUSE_FONTMAP
 class WXDLLIMPEXP_BASE wxLog;
 class WXDLLIMPEXP_BASE wxMessageOutput;
+class WXDLLIMPEXP_BASE wxObject;
 class WXDLLEXPORT wxRendererNative;
+class WXDLLIMPEXP_BASE wxStandardPathsBase;
 class WXDLLIMPEXP_BASE wxString;
 class WXDLLIMPEXP_BASE wxTimer;
 class WXDLLIMPEXP_BASE wxTimerImpl;
@@ -36,8 +37,6 @@ class GSocketGUIFunctionsTable;
 // wxAppTraits: this class defines various configurable aspects of wxApp
 // ----------------------------------------------------------------------------
 
-class WXDLLIMPEXP_BASE wxStandardPathsBase;
-
 class WXDLLIMPEXP_BASE wxAppTraitsBase
 {
 public:
@@ -47,6 +46,13 @@ public:
     // hooks for working with the global objects, may be overridden by the user
     // ------------------------------------------------------------------------
 
+#if wxUSE_CONFIG
+    // create the default configuration object (base class version is
+    // implemented in config.cpp and creates wxRegConfig for wxMSW and
+    // wxFileConfig for all the other platforms)
+    virtual wxConfigBase *CreateConfig();
+#endif // wxUSE_CONFIG
+
 #if wxUSE_LOG
     // create the default log target
     virtual wxLog *CreateLogTarget() = 0;
index 17db0fca5aedaa314917dc19ed1851ac5e2cae8a..e7e62a34bb7897ee5a56f3621265c224f08a8355 100644 (file)
@@ -37,6 +37,7 @@
 
 #if wxUSE_CONFIG && ((wxUSE_FILE && wxUSE_TEXTFILE) || wxUSE_CONFIG_NATIVE)
 
+#include "wx/apptrait.h"
 #include "wx/file.h"
 
 #include <stdlib.h>
@@ -54,6 +55,22 @@ bool          wxConfigBase::ms_bAutoCreate = true;
 // implementation
 // ============================================================================
 
+// ----------------------------------------------------------------------------
+// wxAppTraitsBase
+// ----------------------------------------------------------------------------
+
+wxConfigBase *wxAppTraitsBase::CreateConfig()
+{
+    return new
+    #if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE
+        wxRegConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName());
+    #elif defined(__WXPALMOS__) && wxUSE_CONFIG_NATIVE
+        wxPrefConfig(wxTheApp->GetAppName());
+    #else // either we're under Unix or wish to use files even under Windows
+        wxFileConfig(wxTheApp->GetAppName());
+    #endif
+}
+
 // ----------------------------------------------------------------------------
 // wxConfigBase
 // ----------------------------------------------------------------------------
@@ -87,14 +104,10 @@ wxConfigBase *wxConfigBase::Set(wxConfigBase *pConfig)
 wxConfigBase *wxConfigBase::Create()
 {
   if ( ms_bAutoCreate && ms_pConfig == NULL ) {
-    ms_pConfig =
-    #if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE
-        new wxRegConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName());
-    #elif defined(__WXPALMOS__) && wxUSE_CONFIG_NATIVE
-        new wxPrefConfig(wxTheApp->GetAppName());
-    #else // either we're under Unix or wish to use files even under Windows
-      new wxFileConfig(wxTheApp->GetAppName());
-    #endif
+    wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
+    wxCHECK_MSG( traits, NULL, _T("create wxApp before calling this") );
+
+    ms_pConfig = traits->CreateConfig();
   }
 
   return ms_pConfig;