added wxAppTraits::CreateConfig() (patch 1721149)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46189 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-05-24 00:50:54 +00:00
parent d71a2d7863
commit 84281b92d5
2 changed files with 31 additions and 12 deletions

View File

@@ -16,15 +16,16 @@
#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;

View 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;