X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f19259fce02ed19263b3bad7269c11546ce95e07..e6b3b53c2c20fe75dc410a22a99b88a63653aef5:/src/msw/treectrl.cpp diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 7baecbd622..9464bec90b 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -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);