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

@@ -1883,6 +1883,39 @@ void wxTreeCtrl::UnselectAll()
}
}
void wxTreeCtrl::DoSelectChildren(const wxTreeItemId& parent)
{
DoUnselectAll();
wxTreeItemIdValue cookie;
wxTreeItemId child = GetFirstChild(parent, cookie);
while ( child.IsOk() )
{
DoSelectItem(child, true);
child = GetNextChild(child, cookie);
}
}
void wxTreeCtrl::SelectChildren(const wxTreeItemId& parent)
{
wxCHECK_RET( HasFlag(wxTR_MULTIPLE),
"this only works with multiple selection controls" );
HTREEITEM htFocus = (HTREEITEM)TreeView_GetSelection(GetHwnd());
wxTreeEvent changingEvent(wxEVT_COMMAND_TREE_SEL_CHANGING, this);
changingEvent.m_itemOld = htFocus;
if ( IsTreeEventAllowed(changingEvent) )
{
DoSelectChildren(parent);
wxTreeEvent changedEvent(wxEVT_COMMAND_TREE_SEL_CHANGED, this);
changedEvent.m_itemOld = htFocus;
(void)HandleTreeEvent(changedEvent);
}
}
void wxTreeCtrl::DoSelectItem(const wxTreeItemId& item, bool select)
{
TempSetter set(m_changingSelection);