Add wxTreeCtrl::SelectChildren() method.

Add MSW and generic implementation, documentation and change to the sample
showing it.

Closes #11620.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63277 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-01-26 12:43:39 +00:00
parent 6b2f55531a
commit 5cb3a695e0
9 changed files with 100 additions and 1 deletions

View File

@@ -1983,6 +1983,42 @@ void wxGenericTreeCtrl::UnselectAll()
}
}
void wxGenericTreeCtrl::SelectChildren(const wxTreeItemId& parent)
{
wxCHECK_RET( HasFlag(wxTR_MULTIPLE),
"this only works with multiple selection controls" );
UnselectAll();
if ( !HasChildren(parent) )
return;
wxArrayGenericTreeItems&
children = ((wxGenericTreeItem*) parent.m_pItem)->GetChildren();
size_t count = children.GetCount();
wxGenericTreeItem *
item = (wxGenericTreeItem*) ((wxTreeItemId)children[0]).m_pItem;
wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, this, item);
event.m_itemOld = m_current;
if ( GetEventHandler()->ProcessEvent( event ) && !event.IsAllowed() )
return;
for ( size_t n = 0; n < count; ++n )
{
m_current = m_key_current = children[n];
m_current->SetHilight(true);
RefreshSelected();
}
event.SetEventType(wxEVT_COMMAND_TREE_SEL_CHANGED);
GetEventHandler()->ProcessEvent( event );
}
// Recursive function !
// To stop we must have crt_item<last_item
// Algorithm :