From 41e94974a0830eb3574a955a19e2cd4c796cf5b6 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 6 Jan 2016 23:06:40 +0100 Subject: [PATCH] Fixed positioning controls on the toolbar after removing a tool. When a tool is removed from the toolbar then all tools with controls on the right hand side have to be repositioned (shifted left) manually. --- src/msw/toolbar.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 7cdbd98573..33b75621c4 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -627,7 +627,23 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) static_cast(tool)->ToBeDeleted(); - // and finally rearrange the tools + // and finally rearrange the tools: + + // by shifting left all controls on the right hand side + wxToolBarToolsList::compatibility_iterator node; + for ( node = m_tools.Find(tool); node; node = node->GetNext() ) + { + wxToolBarTool * const tool = static_cast(node->GetData()); + + if ( tool->IsToBeDeleted() ) + continue; + + if ( tool->IsControl() ) + { + tool->MoveBy(-delta); + } + } + // by recalculating stretchable spacers, if there are any UpdateStretchableSpacersSize();