diff --git a/include/wx/msw/control.h b/include/wx/msw/control.h index c7c692c58e..cf754e9ffe 100644 --- a/include/wx/msw/control.h +++ b/include/wx/msw/control.h @@ -70,6 +70,12 @@ public: virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const wxOVERRIDE; protected: + // Hook for common controls for which we don't want to set the default font + // as if we do set it, the controls don't update their font size + // automatically in response to WM_SETTINGCHANGE if it's changed in the + // display properties in the control panel, so avoid doing this for them. + virtual bool MSWShouldSetDefaultFont() const { return true; } + // choose the default border for this window virtual wxBorder GetDefaultBorder() const wxOVERRIDE; diff --git a/include/wx/msw/listctrl.h b/include/wx/msw/listctrl.h index c8b833419c..78010b212e 100644 --- a/include/wx/msw/listctrl.h +++ b/include/wx/msw/listctrl.h @@ -380,6 +380,8 @@ protected: // common part of all ctors void Init(); + virtual bool MSWShouldSetDefaultFont() const wxOVERRIDE { return false; } + // Implement constrained best size calculation. virtual int DoGetBestClientHeight(int width) const wxOVERRIDE { return MSWGetBestViewRect(width, -1).y; } diff --git a/include/wx/msw/treectrl.h b/include/wx/msw/treectrl.h index 7eff5430d0..4a5eb1ea57 100644 --- a/include/wx/msw/treectrl.h +++ b/include/wx/msw/treectrl.h @@ -211,6 +211,8 @@ protected: int width, int height, int sizeFlags = wxSIZE_AUTO) wxOVERRIDE; + virtual bool MSWShouldSetDefaultFont() const wxOVERRIDE { return false; } + // SetImageList helper void SetAnyImageList(wxImageList *imageList, int which); diff --git a/src/msw/control.cpp b/src/msw/control.cpp index becfab0140..2f1dcc62a9 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -184,39 +184,7 @@ bool wxControl::MSWCreateControl(const wxChar *classname, InheritAttributes(); if ( !m_hasFont ) { - bool setFont = true; - - wxFont font = GetDefaultAttributes().font; - - // if we set a font for {list,tree}ctrls and the font size is changed in - // the display properties then the font size for these controls doesn't - // automatically adjust when they receive WM_SETTINGCHANGE - - // FIXME: replace the dynamic casts with virtual function calls!! -#if wxUSE_LISTCTRL || wxUSE_TREECTRL - bool testFont = false; -#if wxUSE_LISTCTRL - if ( wxDynamicCastThis(wxListCtrl) ) - testFont = true; -#endif // wxUSE_LISTCTRL -#if wxUSE_TREECTRL - if ( wxDynamicCastThis(wxTreeCtrl) ) - testFont = true; -#endif // wxUSE_TREECTRL - - if ( testFont ) - { - // we can't explicitly set the font here - // see wxGetCCDefaultFont() in src/msw/settings.cpp for explanation - // of why this test works - if ( font != wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) ) - { - setFont = false; - } - } -#endif // wxUSE_LISTCTRL || wxUSE_TREECTRL - - if ( setFont ) + if ( MSWShouldSetDefaultFont() ) { SetFont(GetDefaultAttributes().font); }