git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1225
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
void SortChildren(const wxTreeItemId& item,
wxTreeItemCmpFunc *cmpFunction = NULL);
void SortChildren(const wxTreeItemId& item,
wxTreeItemCmpFunc *cmpFunction = NULL);
void OnPaint( wxPaintEvent &event );
void OnSetFocus( wxFocusEvent &event );
void OnKillFocus( wxFocusEvent &event );
void OnPaint( wxPaintEvent &event );
void OnSetFocus( wxFocusEvent &event );
void OnKillFocus( wxFocusEvent &event );
void OnMouse( wxMouseEvent &event );
void OnIdle( wxIdleEvent &event );
void OnMouse( wxMouseEvent &event );
void OnIdle( wxIdleEvent &event );
+ // implementation
+ void SendDeleteEvent(wxGenericTreeItem *itemBeingDeleted);
+
protected:
wxGenericTreeItem *m_anchor;
wxGenericTreeItem *m_current;
protected:
wxGenericTreeItem *m_anchor;
wxGenericTreeItem *m_current;
wxGenericTreeItem *GetParent() const { return m_parent; }
// operations
wxGenericTreeItem *GetParent() const { return m_parent; }
// operations
+ // deletes all children notifying the treectrl about it if !NULL pointer
+ // given
+ void DeleteChildren(wxTreeCtrl *tree = NULL);
+ // FIXME don't know what is it for
void Reset();
// get count of all children (and grand children if 'recursively')
void Reset();
// get count of all children (and grand children if 'recursively')
+ wxASSERT_MSG( m_children.IsEmpty(),
+ "please call DeleteChildren() before deleting the item" );
-void wxGenericTreeItem::DeleteChildren()
+void wxGenericTreeItem::DeleteChildren(wxTreeCtrl *tree)
{
size_t count = m_children.Count();
for ( size_t n = 0; n < count; n++ )
{
size_t count = m_children.Count();
for ( size_t n = 0; n < count; n++ )
+ {
+ wxGenericTreeItem *child = m_children[n];
+ if ( tree )
+ {
+ tree->SendDeleteEvent(child);
+ }
+
+ child->DeleteChildren(tree);
+ delete child;
+ }
wxTreeCtrl::~wxTreeCtrl()
{
wxDELETE( m_hilightBrush );
wxTreeCtrl::~wxTreeCtrl()
{
wxDELETE( m_hilightBrush );
}
// -----------------------------------------------------------------------------
}
// -----------------------------------------------------------------------------
image, selImage, data);
}
image, selImage, data);
}
+void wxTreeCtrl::SendDeleteEvent(wxGenericTreeItem *item)
+{
+ wxTreeEvent event( wxEVT_COMMAND_TREE_DELETE_ITEM, GetId() );
+ event.m_item = item;
+ event.SetEventObject( this );
+ ProcessEvent( event );
+}
+
void wxTreeCtrl::DeleteChildren(const wxTreeItemId& itemId)
{
wxGenericTreeItem *item = itemId.m_pItem;
void wxTreeCtrl::DeleteChildren(const wxTreeItemId& itemId)
{
wxGenericTreeItem *item = itemId.m_pItem;
- item->DeleteChildren();
+ item->DeleteChildren(this);
wxGenericTreeItem *item = itemId.m_pItem;
wxGenericTreeItem *parent = item->GetParent();
wxGenericTreeItem *item = itemId.m_pItem;
wxGenericTreeItem *parent = item->GetParent();
- // notify the parent...
- wxTreeEvent event( wxEVT_COMMAND_TREE_DELETE_ITEM, GetId() );
- event.m_item = item;
- event.SetEventObject( this );
- ProcessEvent( event );
-
if ( parent )
{
parent->GetChildren().Remove(item);
}
if ( parent )
{
parent->GetChildren().Remove(item);
}
+ item->DeleteChildren(this);
+ SendDeleteEvent(item);
delete item;
m_dirty = TRUE;
delete item;
m_dirty = TRUE;
+ m_anchor->DeleteChildren(this);
m_anchor = NULL;
m_dirty = TRUE;
m_anchor = NULL;
m_dirty = TRUE;