Add wxHAS_CONFIG_AS_{REG,FILE}CONFIG symbols
Sometimes it's useful to have some code used only if wxConfig is defined as wxRegConfig or only if it is defined as wxFileConfig and testing for these symbols is more clear than testing for the platform (and more correct, considering that setting wxUSE_CONFIG_NATIVE to 0 may result in wxFileConfig being used even under Windows).
This commit is contained in:
parent
055c4cbed5
commit
ebe0847932
4 changed files with 16 additions and 7 deletions
|
|
@ -168,6 +168,10 @@ Currently the following symbols exist:
|
||||||
implemented in a generic way, using a critical section.}
|
implemented in a generic way, using a critical section.}
|
||||||
@itemdef{wxHAS_BITMAPTOGGLEBUTTON, Defined in @c wx/tglbtn.h if
|
@itemdef{wxHAS_BITMAPTOGGLEBUTTON, Defined in @c wx/tglbtn.h if
|
||||||
wxBitmapToggleButton class is available in addition to wxToggleButton.}
|
wxBitmapToggleButton class is available in addition to wxToggleButton.}
|
||||||
|
@itemdef{wxHAS_CONFIG_AS_FILECONFIG, Defined if wxConfig is defined as
|
||||||
|
wxFileConfig. This constant is available since wxWidgets 3.3.0.}
|
||||||
|
@itemdef{wxHAS_CONFIG_AS_REGCONFIG, Defined if wxConfig is defined as
|
||||||
|
wxRegConfig. This constant is available since wxWidgets 3.3.0.}
|
||||||
@itemdef{wxHAS_CONFIG_TEMPLATE_RW, Defined if the currently used compiler
|
@itemdef{wxHAS_CONFIG_TEMPLATE_RW, Defined if the currently used compiler
|
||||||
supports template Read() and Write() methods in wxConfig.}
|
supports template Read() and Write() methods in wxConfig.}
|
||||||
@itemdef{wxHAS_DEPRECATED_ATTR, Defined if C++14 @c [[deprecated]] attribute is
|
@itemdef{wxHAS_DEPRECATED_ATTR, Defined if C++14 @c [[deprecated]] attribute is
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,11 @@
|
||||||
#if defined(__WINDOWS__) && wxUSE_CONFIG_NATIVE
|
#if defined(__WINDOWS__) && wxUSE_CONFIG_NATIVE
|
||||||
#include "wx/msw/regconf.h"
|
#include "wx/msw/regconf.h"
|
||||||
#define wxConfig wxRegConfig
|
#define wxConfig wxRegConfig
|
||||||
|
#define wxHAS_CONFIG_AS_REGCONFIG
|
||||||
#else // either we're under Unix or wish to always use config files
|
#else // either we're under Unix or wish to always use config files
|
||||||
#include "wx/fileconf.h"
|
#include "wx/fileconf.h"
|
||||||
#define wxConfig wxFileConfig
|
#define wxConfig wxFileConfig
|
||||||
|
#define wxHAS_CONFIG_AS_FILECONFIG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // wxUSE_CONFIG
|
#endif // wxUSE_CONFIG
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,9 @@ enum
|
||||||
with the registry under Windows or text-based config files under Unix.
|
with the registry under Windows or text-based config files under Unix.
|
||||||
To make writing the portable code even easier, wxWidgets provides a typedef
|
To make writing the portable code even easier, wxWidgets provides a typedef
|
||||||
wxConfig which is mapped onto the native wxConfigBase implementation on the
|
wxConfig which is mapped onto the native wxConfigBase implementation on the
|
||||||
given platform: i.e. wxRegConfig under Windows and wxFileConfig otherwise.
|
given platform: i.e. wxRegConfig under Windows (in this case
|
||||||
|
`wxHAS_CONFIG_AS_REGCONFIG` preprocessor symbol is defined) and
|
||||||
|
wxFileConfig otherwise (in this case `wxHAS_CONFIG_AS_FILECONFIG` is).
|
||||||
|
|
||||||
See @ref overview_config for a description of all features of this class.
|
See @ref overview_config for a description of all features of this class.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,12 +56,13 @@ bool wxConfigBase::ms_bAutoCreate = true;
|
||||||
|
|
||||||
wxConfigBase *wxAppTraitsBase::CreateConfig()
|
wxConfigBase *wxAppTraitsBase::CreateConfig()
|
||||||
{
|
{
|
||||||
return new
|
#if defined(wxHAS_CONFIG_AS_REGCONFIG)
|
||||||
#if defined(__WINDOWS__) && wxUSE_CONFIG_NATIVE
|
return new wxRegConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName());
|
||||||
wxRegConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName());
|
#elif defined(wxHAS_CONFIG_AS_FILECONFIG)
|
||||||
#else // either we're under Unix or wish to use files even under Windows
|
return new wxFileConfig(wxTheApp->GetAppName());
|
||||||
wxFileConfig(wxTheApp->GetAppName());
|
#else
|
||||||
#endif
|
#error No wxConfig implementation defined.
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue