Merge branch 'treectrl-delete-events'
See https://github.com/wxWidgets/wxWidgets/pull/881
This commit is contained in:
@@ -310,15 +310,19 @@ public:
|
||||
virtual void Delete(const wxTreeItemId& item);
|
||||
|
||||
/**
|
||||
Deletes all items in the control. Note that this may not generate
|
||||
@c EVT_TREE_DELETE_ITEM events under some Windows versions although
|
||||
normally such event is generated for each removed item.
|
||||
Deletes all items in the control.
|
||||
|
||||
This function generates @c wxEVT_TREE_DELETE_ITEM events for each item
|
||||
being deleted, including the root one if it is shown, i.e. unless
|
||||
wxTR_HIDE_ROOT style is used.
|
||||
*/
|
||||
virtual void DeleteAllItems();
|
||||
|
||||
/**
|
||||
Deletes all children of the given item (but not the item itself). Note
|
||||
that this will @b not generate any events unlike Delete() method.
|
||||
Deletes all children of the given item (but not the item itself).
|
||||
|
||||
A @c wxEVT_TREE_DELETE_ITEM event will be generated for every item
|
||||
being deleted.
|
||||
|
||||
If you have called SetItemHasChildren(), you may need to call it again
|
||||
since DeleteChildren() does not automatically clear the setting.
|
||||
|
@@ -45,6 +45,8 @@ private:
|
||||
CPPUNIT_TEST_SUITE( TreeCtrlTestCase );
|
||||
WXUISIM_TEST( ItemClick );
|
||||
CPPUNIT_TEST( DeleteItem );
|
||||
CPPUNIT_TEST( DeleteChildren );
|
||||
CPPUNIT_TEST( DeleteAllItems );
|
||||
WXUISIM_TEST( LabelEdit );
|
||||
WXUISIM_TEST( KeyDown );
|
||||
#ifndef __WXGTK__
|
||||
@@ -72,6 +74,8 @@ private:
|
||||
|
||||
void ItemClick();
|
||||
void DeleteItem();
|
||||
void DeleteChildren();
|
||||
void DeleteAllItems();
|
||||
void LabelEdit();
|
||||
void KeyDown();
|
||||
#ifndef __WXGTK__
|
||||
@@ -269,12 +273,29 @@ void TreeCtrlTestCase::DeleteItem()
|
||||
|
||||
wxTreeItemId todelete = m_tree->AppendItem(m_root, "deleteme");
|
||||
m_tree->Delete(todelete);
|
||||
// We do not test DeleteAllItems() as under some versions of Windows events
|
||||
// are not generated.
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, deleteitem.GetCount());
|
||||
}
|
||||
|
||||
void TreeCtrlTestCase::DeleteChildren()
|
||||
{
|
||||
EventCounter deletechildren(m_tree, wxEVT_TREE_DELETE_ITEM);
|
||||
|
||||
m_tree->AppendItem(m_child1, "another grandchild");
|
||||
m_tree->DeleteChildren(m_child1);
|
||||
|
||||
CHECK( deletechildren.GetCount() == 2 );
|
||||
}
|
||||
|
||||
void TreeCtrlTestCase::DeleteAllItems()
|
||||
{
|
||||
EventCounter deleteall(m_tree, wxEVT_TREE_DELETE_ITEM);
|
||||
|
||||
m_tree->DeleteAllItems();
|
||||
|
||||
CHECK( deleteall.GetCount() == 4 );
|
||||
}
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
void TreeCtrlTestCase::LabelEdit()
|
||||
|
Reference in New Issue
Block a user