From 892def066cd9c35fc1f2d894ed2ba315b5e9ba0f Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 18 Oct 2017 22:58:21 +0200 Subject: [PATCH] Pass only relevant extra style bits to wxPropertyGrid When extra style bits are set with the call to wxPropertyGridManager::SetExtraStyle(), only those which are relevant to wxPropertyGrid should be passed to the underlying property grid object. Because it can happen that not all extra style bits of the underlying wxPropertyGrid have been effectively changed by call to SetExtraStyle() (e.g. wxPG_EX_NATIVE_DOUBLE_BUFFERING), we have to get the actual style bits prior to storing them. --- include/wx/propgrid/propgrid.h | 16 +++++++++++----- src/propgrid/manager.cpp | 9 ++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index f6f56d9d13..5c5508601f 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -303,12 +303,18 @@ wxPG_EX_TOOLBAR_SEPARATOR = 0x10000000, // even if wxPropertyGrid is not a standalone control. wxPG_EX_ALWAYS_ALLOW_FOCUS = 0x00100000, + +// A mask which can be used to filter (out) all extra styles applicable to wxPropertyGrid. +wxPG_EX_WINDOW_PG_STYLE_MASK = wxPG_EX_INIT_NOCAT|wxPG_EX_HELP_AS_TOOLTIPS|wxPG_EX_NATIVE_DOUBLE_BUFFERING| + wxPG_EX_AUTO_UNSPECIFIED_VALUES|wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES| + wxPG_EX_MULTIPLE_SELECTION|wxPG_EX_ENABLE_TLP_TRACKING|wxPG_EX_ALWAYS_ALLOW_FOCUS, + +// A mask which can be used to filter (out) all extra styles applicable to wxPropertyGridManager. +wxPG_EX_WINDOW_PGMAN_STYLE_MASK = wxPG_EX_NO_FLAT_TOOLBAR|wxPG_EX_MODE_BUTTONS|wxPG_EX_HIDE_PAGE_BUTTONS| + wxPG_EX_NO_TOOLBAR_DIVIDER|wxPG_EX_TOOLBAR_SEPARATOR, + // A mask which can be used to filter (out) all extra styles. -wxPG_EX_WINDOW_STYLE_MASK = wxPG_EX_INIT_NOCAT|wxPG_EX_NO_FLAT_TOOLBAR|wxPG_EX_MODE_BUTTONS| - wxPG_EX_HELP_AS_TOOLTIPS|wxPG_EX_NATIVE_DOUBLE_BUFFERING|wxPG_EX_AUTO_UNSPECIFIED_VALUES| - wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES|wxPG_EX_HIDE_PAGE_BUTTONS|wxPG_EX_MULTIPLE_SELECTION| - wxPG_EX_ENABLE_TLP_TRACKING|wxPG_EX_NO_TOOLBAR_DIVIDER|wxPG_EX_TOOLBAR_SEPARATOR| - wxPG_EX_ALWAYS_ALLOW_FOCUS +wxPG_EX_WINDOW_STYLE_MASK = wxPG_EX_WINDOW_PG_STYLE_MASK|wxPG_EX_WINDOW_PGMAN_STYLE_MASK }; #if wxPG_COMPATIBILITY_1_4 diff --git a/src/propgrid/manager.cpp b/src/propgrid/manager.cpp index 7bd7358d99..6683ac502e 100644 --- a/src/propgrid/manager.cpp +++ b/src/propgrid/manager.cpp @@ -675,8 +675,15 @@ bool wxPropertyGridManager::SetFont( const wxFont& font ) void wxPropertyGridManager::SetExtraStyle( long exStyle ) { + // Pass only relevant flags to wxPropertyGrid. + m_pPropGrid->SetExtraStyle(exStyle & wxPG_EX_WINDOW_PG_STYLE_MASK); + // Because it can happen that not all flags are actually changed + // by call to SetExtraStyle() (e.g. wxPG_EX_NATIVE_DOUBLE_BUFFERING), + // we have to get the actual style flags prior to storing them. + exStyle &= ~wxPG_EX_WINDOW_PG_STYLE_MASK; + exStyle |= m_pPropGrid->GetExtraStyle() & wxPG_EX_WINDOW_PG_STYLE_MASK; + wxWindow::SetExtraStyle( exStyle ); - m_pPropGrid->SetExtraStyle( exStyle & wxPG_EX_WINDOW_STYLE_MASK ); #if wxUSE_TOOLBAR if ( (exStyle & (wxPG_EX_NO_FLAT_TOOLBAR|wxPG_EX_MODE_BUTTONS)) && m_pToolbar ) RecreateControls();