X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8bf30fe9b0b40d1a6f54608588121212c2c4e037..606b005fb2b535b34d1ca45d2d06ee86718e8b1c:/src/msw/settings.cpp?ds=sidebyside diff --git a/src/msw/settings.cpp b/src/msw/settings.cpp index b636a80883..133c23ab95 100644 --- a/src/msw/settings.cpp +++ b/src/msw/settings.cpp @@ -39,6 +39,7 @@ #include "wx/settings.h" #include "wx/window.h" #include "wx/msw/private.h" +#include "wx/module.h" // ---------------------------------------------------------------------------- // private classes @@ -48,12 +49,16 @@ // singleton class so it can't be done in the dtor) class wxSystemSettingsModule : public wxModule { + friend class wxSystemSettings; public: virtual bool OnInit(); virtual void OnExit(); private: DECLARE_DYNAMIC_CLASS(wxSystemSettingsModule) + + static wxArrayString sm_optionNames; + static wxArrayString sm_optionValues; }; // ---------------------------------------------------------------------------- @@ -72,6 +77,9 @@ static wxFont *gs_fontDefault = NULL; IMPLEMENT_DYNAMIC_CLASS(wxSystemSettingsModule, wxModule) +wxArrayString wxSystemSettingsModule::sm_optionNames; +wxArrayString wxSystemSettingsModule::sm_optionValues; + bool wxSystemSettingsModule::OnInit() { return TRUE; @@ -79,6 +87,8 @@ bool wxSystemSettingsModule::OnInit() void wxSystemSettingsModule::OnExit() { + sm_optionNames.Clear(); + sm_optionValues.Clear(); delete gs_fontDefault; } @@ -242,3 +252,45 @@ int wxSystemSettings::GetSystemMetric(int index) } } +// Option functions (arbitrary name/value mapping) +void wxSystemSettings::SetOption(const wxString& name, const wxString& value) +{ + int idx = wxSystemSettingsModule::sm_optionNames.Index(name, FALSE); + if (idx == wxNOT_FOUND) + { + wxSystemSettingsModule::sm_optionNames.Add(name); + wxSystemSettingsModule::sm_optionValues.Add(value); + } + else + { + wxSystemSettingsModule::sm_optionNames[idx] = name; + wxSystemSettingsModule::sm_optionValues[idx] = value; + } +} + +void wxSystemSettings::SetOption(const wxString& name, int value) +{ + wxString valStr; + valStr.Printf(wxT("%d"), value); + SetOption(name, valStr); +} + +wxString wxSystemSettings::GetOption(const wxString& name) +{ + int idx = wxSystemSettingsModule::sm_optionNames.Index(name, FALSE); + if (idx == wxNOT_FOUND) + return wxEmptyString; + else + return wxSystemSettingsModule::sm_optionValues[idx]; +} + +int wxSystemSettings::GetOptionInt(const wxString& name) +{ + return wxAtoi(GetOption(name)); +} + +bool wxSystemSettings::HasOption(const wxString& name) +{ + return (wxSystemSettingsModule::sm_optionNames.Index(name, FALSE) != wxNOT_FOUND); +} +