Replace dynamic casts with MSWShouldSetDefaultFont() virtual method
Get rid of ugly wxDynamicCastThis()s in wxMSW wxControl code and add a new virtual method overridden in wx{Tree,List}Ctrl instead. Also stop comparing the font with wxSYS_DEFAULT_GUI_FONT, there doesn't seem to be any good reason to set this particular font for these controls neither. In addition to simplifying and de-ugligying the code, this commit incidentally fixes -Wnonnull-compare warnings in this code from gcc6 too.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user