wxToolBarToolBase::~wxToolBarToolBase()
{
delete m_dropdownMenu;
+ if ( IsControl() )
+ GetControl()->Destroy();
}
const wxString& longHelp,
wxObject *clientData)
{
- wxCHECK_MSG( pos <= GetToolsCount(), (wxToolBarToolBase *)NULL,
+ wxCHECK_MSG( pos <= GetToolsCount(), NULL,
_T("invalid position in wxToolBar::InsertTool()") );
wxToolBarToolBase *tool = CreateTool(id, label, bitmap, bmpDisabled, kind,
wxToolBarToolBase *
wxToolBarBase::InsertTool(size_t pos, wxToolBarToolBase *tool)
{
- wxCHECK_MSG( pos <= GetToolsCount(), (wxToolBarToolBase *)NULL,
+ wxCHECK_MSG( pos <= GetToolsCount(), NULL,
_T("invalid position in wxToolBar::InsertTool()") );
if ( !tool || !DoInsertTool(pos, tool) )
}
m_tools.Insert(pos, tool);
+ tool->Attach(this);
return tool;
}
wxControl *control,
const wxString& label)
{
- wxCHECK_MSG( control, (wxToolBarToolBase *)NULL,
+ wxCHECK_MSG( control, NULL,
_T("toolbar: can't insert NULL control") );
- wxCHECK_MSG( control->GetParent() == this, (wxToolBarToolBase *)NULL,
+ wxCHECK_MSG( control->GetParent() == this, NULL,
_T("control must have toolbar as parent") );
- wxCHECK_MSG( pos <= GetToolsCount(), (wxToolBarToolBase *)NULL,
+ wxCHECK_MSG( pos <= GetToolsCount(), NULL,
_T("invalid position in wxToolBar::InsertControl()") );
wxToolBarToolBase *tool = CreateTool(control, label);
wxToolBarToolBase *wxToolBarBase::InsertSeparator(size_t pos)
{
- wxCHECK_MSG( pos <= GetToolsCount(), (wxToolBarToolBase *)NULL,
+ wxCHECK_MSG( pos <= GetToolsCount(), NULL,
_T("invalid position in wxToolBar::InsertSeparator()") );
wxToolBarToolBase *tool = CreateTool(wxID_SEPARATOR,
wxEmptyString,
wxNullBitmap, wxNullBitmap,
- wxITEM_SEPARATOR, (wxObject *)NULL,
+ wxITEM_SEPARATOR, NULL,
wxEmptyString, wxEmptyString);
if ( !tool || !DoInsertTool(pos, tool) )
{
// 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;
}
wxToolBarToolBase *wxToolBarBase::FindById(int id) const
{
- wxToolBarToolBase *tool = (wxToolBarToolBase *)NULL;
+ wxToolBarToolBase *tool = NULL;
for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
node;
{
wxToolBarToolBase *tool = FindById(id);
- return tool ? tool->GetClientData() : (wxObject *)NULL;
+ return tool ? tool->GetClientData() : NULL;
}
void wxToolBarBase::SetToolClientData(int id, wxObject *clientData)
event.SetExtraLong((long)toggleDown);
// Send events to this toolbar instead (and thence up the window hierarchy)
- GetEventHandler()->ProcessEvent(event);
+ HandleWindowEvent(event);
return true;
}
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);