Several fixes for removing/readding controls to the toolbar:

1. Don't destroy the control in wxToolBar::RemoveTool() as this prevents
   it from being added back with is the purpose of using RemoveTool() rather
   than DeleteTool().

2. Call wxToolBarTool::Attach/Detach() from the base code, not just from wxMSW
   and wxMac (wasn't called by wxGTK at all).

3. Allow adding back the removed control tool in wxGTK.

4. Add test for removing/adding back a control tool to the sample.



git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52840 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-03-27 00:10:19 +00:00
parent aba6d9ffc6
commit 1be45608e7
6 changed files with 144 additions and 92 deletions

View File

@@ -477,8 +477,6 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool)
{
// nothing special to do here - we really create the toolbar buttons in
// Realize() later
tool->Attach(this);
InvalidateBestSize();
return true;
}
@@ -524,7 +522,6 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
{
nButtonsToDelete = ((wxToolBarTool *)tool)->GetSeparatorsCount();
width *= nButtonsToDelete;
tool->GetControl()->Destroy();
}
// do delete all buttons
@@ -539,8 +536,6 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
}
}
tool->Detach();
// and finally reposition all the controls after this button (the toolbar
// takes care of all normal items)
for ( /* node -> first after deleted */ ; node; node = node->GetNext() )