X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d3211838bf578eb8ada5a608b66626a6bde6846a..e6adf05834e880312efa3d59914ecc1d4f5f78a6:/src/msw/settings.cpp?ds=sidebyside diff --git a/src/msw/settings.cpp b/src/msw/settings.cpp index 133c23ab95..360e8a2fc3 100644 --- a/src/msw/settings.cpp +++ b/src/msw/settings.cpp @@ -40,6 +40,7 @@ #include "wx/window.h" #include "wx/msw/private.h" #include "wx/module.h" +#include "wx/fontutil.h" // ---------------------------------------------------------------------------- // private classes @@ -56,9 +57,6 @@ public: private: DECLARE_DYNAMIC_CLASS(wxSystemSettingsModule) - - static wxArrayString sm_optionNames; - static wxArrayString sm_optionValues; }; // ---------------------------------------------------------------------------- @@ -77,9 +75,6 @@ static wxFont *gs_fontDefault = NULL; IMPLEMENT_DYNAMIC_CLASS(wxSystemSettingsModule, wxModule) -wxArrayString wxSystemSettingsModule::sm_optionNames; -wxArrayString wxSystemSettingsModule::sm_optionValues; - bool wxSystemSettingsModule::OnInit() { return TRUE; @@ -87,9 +82,8 @@ bool wxSystemSettingsModule::OnInit() void wxSystemSettingsModule::OnExit() { - sm_optionNames.Clear(); - sm_optionValues.Clear(); delete gs_fontDefault; + gs_fontDefault = NULL; } // ---------------------------------------------------------------------------- @@ -117,16 +111,8 @@ wxColour wxSystemSettings::GetSystemColour(int index) } } -wxFont wxSystemSettings::GetSystemFont(int index) +wxFont wxCreateFontFromStockObject(int index) { - // wxWindow ctor calls GetSystemFont(wxSYS_DEFAULT_GUI_FONT) so we're - // called fairly often - this is why we cache this particular font - bool isDefaultRequested = index == wxSYS_DEFAULT_GUI_FONT; - if ( isDefaultRequested && gs_fontDefault ) - { - return *gs_fontDefault; - } - wxFont font; HFONT hFont = (HFONT) ::GetStockObject(index); @@ -135,7 +121,16 @@ wxFont wxSystemSettings::GetSystemFont(int index) LOGFONT lf; if ( ::GetObject(hFont, sizeof(LOGFONT), &lf) != 0 ) { - font = wxCreateFontFromLogFont(&lf); + wxNativeFontInfo info; + info.lf = lf; + // Under MicroWindows we pass the HFONT as well + // because it's hard to convert HFONT -> LOGFONT -> HFONT + // It's OK to delete stock objects, the delete will be ignored. +#ifdef __WXMICROWIN__ + font.Create(info, (WXHFONT) hFont); +#else + font.Create(info); +#endif } else { @@ -146,6 +141,20 @@ wxFont wxSystemSettings::GetSystemFont(int index) { wxFAIL_MSG( _T("stock font not found") ); } + return font; +} + +wxFont wxSystemSettings::GetSystemFont(int index) +{ + // wxWindow ctor calls GetSystemFont(wxSYS_DEFAULT_GUI_FONT) so we're + // called fairly often - this is why we cache this particular font + bool isDefaultRequested = index == wxSYS_DEFAULT_GUI_FONT; + if ( isDefaultRequested && gs_fontDefault ) + { + return *gs_fontDefault; + } + + wxFont font = wxCreateFontFromStockObject(index); if ( isDefaultRequested ) { @@ -159,6 +168,10 @@ wxFont wxSystemSettings::GetSystemFont(int index) // Get a system metric, e.g. scrollbar size int wxSystemSettings::GetSystemMetric(int index) { +#ifdef __WXMICROWIN__ + // TODO: probably use wxUniv themes functionality + return 0; +#else switch ( index) { #ifdef __WIN32__ @@ -250,47 +263,7 @@ int wxSystemSettings::GetSystemMetric(int index) default: return 0; } -} - -// 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); +#endif + // __WXMICROWIN__ }