X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a9a0ceca5b549414a6119e98bc6d868c071a8b1b..916eabe60eee4adb05387bbf1eaf1915ae5eac18:/src/common/tbarbase.cpp?ds=sidebyside diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 071dac26d3..8d07da7930 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -62,6 +62,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxToolBarToolBase, wxObject) wxToolBarToolBase::~wxToolBarToolBase() { delete m_dropdownMenu; + if ( IsControl() ) + GetControl()->Destroy(); } @@ -125,6 +127,7 @@ void wxToolBarToolBase::SetDropdownMenu(wxMenu* menu) m_dropdownMenu = menu; } + // ---------------------------------------------------------------------------- // wxToolBarBase adding/deleting items // ---------------------------------------------------------------------------- @@ -207,6 +210,7 @@ wxToolBarBase::InsertTool(size_t pos, wxToolBarToolBase *tool) } m_tools.Insert(pos, tool); + tool->Attach(this); return tool; } @@ -313,17 +317,19 @@ wxToolBarToolBase *wxToolBarBase::RemoveTool(int id) { // don't give any error messages - sometimes we might call RemoveTool() // without knowing whether the tool is or not in the toolbar - return (wxToolBarToolBase *)NULL; + return NULL; } wxToolBarToolBase *tool = node->GetData(); + wxCHECK_MSG( tool, NULL, "NULL tool in the tools list?" ); + if ( !DoDeleteTool(pos, tool) ) - { - return (wxToolBarToolBase *)NULL; - } + return NULL; m_tools.Erase(node); + tool->Detach(); + return tool; } @@ -596,6 +602,12 @@ void wxToolBarBase::SetRows(int WXUNUSED(nRows)) // nothing } +bool wxToolBarBase::IsVertical() const +{ + return HasFlag(wxTB_LEFT | wxTB_RIGHT); +} + + // ---------------------------------------------------------------------------- // event processing // ---------------------------------------------------------------------------- @@ -685,7 +697,11 @@ void wxToolBarBase::UpdateWindowUI(long flags) node; node = node->GetNext() ) { - int id = node->GetData()->GetId(); + wxToolBarToolBase * const tool = node->GetData(); + if ( tool->IsSeparator() ) + continue; + + int id = tool->GetId(); wxUpdateUIEvent event(id); event.SetEventObject(this);