X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2e6d38adea820c5628cdc567398fe5c79de1c7d0..df16a53ef9ae506c51023178e4fe45ce45e69447:/src/msw/settings.cpp?ds=sidebyside diff --git a/src/msw/settings.cpp b/src/msw/settings.cpp index 9d868d66b7..7255aad988 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 @@ -49,6 +50,7 @@ // 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(); @@ -81,6 +83,7 @@ bool wxSystemSettingsModule::OnInit() void wxSystemSettingsModule::OnExit() { delete gs_fontDefault; + gs_fontDefault = NULL; } // ---------------------------------------------------------------------------- @@ -108,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); @@ -126,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 { @@ -137,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 ) { @@ -150,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__ @@ -241,5 +263,18 @@ int wxSystemSettings::GetSystemMetric(int index) default: return 0; } +#endif + // __WXMICROWIN__ } +bool wxSystemSettings::GetCapability(int index) +{ + switch (index) + { + case wxSYS_CAN_ICONIZE_FRAME: + case wxSYS_CAN_DRAW_FRAME_DECORATIONS: + return TRUE; + default: + return FALSE; + } +}