From afdfc02a495a2054ca68db68d71c63d47a27a65f Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 21 Oct 2017 22:15:15 +0200 Subject: [PATCH] Allow changing wxPropertyGridManager wxPG_EX_NO_TOOLBAR_DIVIDER style Currently this style can be set only at toolbar creation and cannot be changed afterwards. --- interface/wx/propgrid/propgrid.h | 27 ++++++++++++++++++--------- src/propgrid/manager.cpp | 22 +++++++++++++++++----- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/interface/wx/propgrid/propgrid.h b/interface/wx/propgrid/propgrid.h index 6b55041c29..226533c21c 100644 --- a/interface/wx/propgrid/propgrid.h +++ b/interface/wx/propgrid/propgrid.h @@ -146,7 +146,7 @@ wxPG_EX_INIT_NOCAT = 0x00001000, wxPG_EX_NO_FLAT_TOOLBAR = 0x00002000, /** - Shows alphabetic/categoric mode buttons from tool bar. + Shows alphabetic/categoric mode buttons on wxPropertyGridManager tool bar. @hideinitializer */ wxPG_EX_MODE_BUTTONS = 0x00008000, @@ -185,7 +185,7 @@ wxPG_EX_AUTO_UNSPECIFIED_VALUES = 0x00200000, wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES = 0x00400000, /** - Hides page selection buttons from tool bar. + Hides page selection buttons from wxPropertyGridManager tool bar. @hideinitializer */ wxPG_EX_HIDE_PAGE_BUTTONS = 0x01000000, @@ -219,12 +219,12 @@ wxPG_EX_MULTIPLE_SELECTION = 0x02000000, */ wxPG_EX_ENABLE_TLP_TRACKING = 0x04000000, -/** Don't show divider above toolbar, on Windows. +/** Don't show divider above wxPropertyGridManager toolbar (wxMSW only). @hideinitializer */ wxPG_EX_NO_TOOLBAR_DIVIDER = 0x04000000, -/** Show a separator below the toolbar. +/** Show a separator below the wxPropertyGridManager toolbar. @hideinitializer */ wxPG_EX_TOOLBAR_SEPARATOR = 0x08000000, @@ -235,14 +235,23 @@ wxPG_EX_TOOLBAR_SEPARATOR = 0x08000000, */ wxPG_EX_ALWAYS_ALLOW_FOCUS = 0x00100000, +/** A mask which can be used to filter (out) all extra styles applicable to wxPropertyGrid. + @hideinitializer +*/ +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. + @hideinitializer +*/ +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. @hideinitializer */ -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 }; /** Combines various styles. diff --git a/src/propgrid/manager.cpp b/src/propgrid/manager.cpp index 6683ac502e..05872f8880 100644 --- a/src/propgrid/manager.cpp +++ b/src/propgrid/manager.cpp @@ -673,6 +673,9 @@ bool wxPropertyGridManager::SetFont( const wxFont& font ) // ----------------------------------------------------------------------- +// Which flags can affect the toolbar +#define wxPG_EX_WINDOW_TOOLBAR_STYLE_MASK (wxPG_EX_NO_FLAT_TOOLBAR|wxPG_EX_MODE_BUTTONS|wxPG_EX_NO_TOOLBAR_DIVIDER) + void wxPropertyGridManager::SetExtraStyle( long exStyle ) { // Pass only relevant flags to wxPropertyGrid. @@ -683,9 +686,14 @@ void wxPropertyGridManager::SetExtraStyle( long exStyle ) exStyle &= ~wxPG_EX_WINDOW_PG_STYLE_MASK; exStyle |= m_pPropGrid->GetExtraStyle() & wxPG_EX_WINDOW_PG_STYLE_MASK; +#if wxUSE_TOOLBAR + bool toolbarStyleChanged = + (GetExtraStyle() & wxPG_EX_WINDOW_TOOLBAR_STYLE_MASK) != (exStyle & wxPG_EX_WINDOW_TOOLBAR_STYLE_MASK); +#endif // wxUSE_TOOLBAR + wxWindow::SetExtraStyle( exStyle ); #if wxUSE_TOOLBAR - if ( (exStyle & (wxPG_EX_NO_FLAT_TOOLBAR|wxPG_EX_MODE_BUTTONS)) && m_pToolbar ) + if ( toolbarStyleChanged && m_pToolbar ) RecreateControls(); #endif } @@ -1479,13 +1487,12 @@ void wxPropertyGridManager::RecreateControls() { bool tbModified = false; + long toolBarFlags = HasExtraStyle(wxPG_EX_NO_FLAT_TOOLBAR) ? 0 : wxTB_FLAT; + if ( HasExtraStyle(wxPG_EX_NO_TOOLBAR_DIVIDER) ) + toolBarFlags |= wxTB_NODIVIDER; // Has toolbar. if ( !m_pToolbar ) { - long toolBarFlags = HasExtraStyle(wxPG_EX_NO_FLAT_TOOLBAR)? 0: wxTB_FLAT; - if ( HasExtraStyle(wxPG_EX_NO_TOOLBAR_DIVIDER) ) - toolBarFlags |= wxTB_NODIVIDER; - m_pToolbar = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, @@ -1514,6 +1521,11 @@ void wxPropertyGridManager::RecreateControls() m_categorizedModeToolId = -1; m_alphabeticModeToolId = -1; } + else + { + m_pToolbar->SetWindowStyle(toolBarFlags); + tbModified = true; + } if ( HasExtraStyle(wxPG_EX_MODE_BUTTONS) ) {