- wxGraphicsContext is now enabled by default if supported by the platform.
- Fix building with using system libpng 1.4 (Volker Grabsch).
- Add wxComboBox::Popup() and Dismiss() methods (Igor Korot).
+- Added wxTreeCtrl::SelectChildren() (Nikolay Tjushkov).
GTK:
virtual void Unselect();
virtual void UnselectAll();
virtual void SelectItem(const wxTreeItemId& item, bool select = true);
+ virtual void SelectChildren(const wxTreeItemId& parent);
virtual void EnsureVisible(const wxTreeItemId& item);
virtual void ScrollTo(const wxTreeItemId& item);
virtual void Unselect();
virtual void UnselectAll();
virtual void SelectItem(const wxTreeItemId& item, bool select = true);
+ virtual void SelectChildren(const wxTreeItemId& parent);
virtual void EnsureVisible(const wxTreeItemId& item);
virtual void ScrollTo(const wxTreeItemId& item);
void DoToggleItemSelection(const wxTreeItemId& item);
void DoUnselectAll();
+ void DoSelectChildren(const wxTreeItemId& parent);
void DeleteTextCtrl();
virtual void UnselectAll() = 0;
// select this item
virtual void SelectItem(const wxTreeItemId& item, bool select = true) = 0;
+ // selects all (direct) children for given parent (only for
+ // multiselection controls)
+ virtual void SelectChildren(const wxTreeItemId& parent) = 0;
// unselect this item
void UnselectItem(const wxTreeItemId& item) { SelectItem(item, false); }
// toggle item selection
protected:
virtual wxSize DoGetBestSize() const;
- // comon part of Get/SetItemState()
+ // common part of Get/SetItemState()
virtual int DoGetItemState(const wxTreeItemId& item) const = 0;
virtual void DoSetItemState(const wxTreeItemId& item, int state) = 0;
Unselects the given item. This works in multiselection controls only.
*/
void UnselectItem(const wxTreeItemId& item);
+
+ /**
+ Select all the immediate children of the given parent.
+
+ This function can be used with multiselection controls only.
+
+ @since 2.9.1
+ */
+ virtual void SelectChildren(const wxTreeItemId& parent);
};
MENU_LINK(Select)
MENU_LINK(Unselect)
MENU_LINK(ToggleSel)
+ MENU_LINK(SelectChildren)
#endif // NO_MULTIPLE_SELECTION
MENU_LINK(Rename)
MENU_LINK(Count)
tree_menu->Append(TreeTest_DeleteChildren, wxT("Delete &children"));
tree_menu->Append(TreeTest_DeleteAll, wxT("Delete &all items"));
tree_menu->Append(TreeTest_SelectRoot, wxT("Select root item"));
+
tree_menu->AppendSeparator();
tree_menu->Append(TreeTest_Count, wxT("Count children of current item"));
tree_menu->Append(TreeTest_CountRec, wxT("Recursively count children of current item"));
item_menu->Append(TreeTest_DumpSelected, wxT("Dump selected items\tAlt-D"));
item_menu->Append(TreeTest_Select, wxT("Select current item\tAlt-S"));
item_menu->Append(TreeTest_Unselect, wxT("Unselect everything\tAlt-U"));
+ item_menu->Append(TreeTest_SelectChildren, wxT("Select all children\tCtrl-A"));
#endif // NO_MULTIPLE_SELECTION
wxMenuBar *menu_bar = new wxMenuBar;
m_treeCtrl->UnselectAll();
}
+void MyFrame::OnSelectChildren(wxCommandEvent& WXUNUSED(event))
+{
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
+ if ( !item.IsOk() )
+ item = m_treeCtrl->GetRootItem();
+
+ m_treeCtrl->SelectChildren(item);
+}
+
#endif // NO_MULTIPLE_SELECTION
void MyFrame::DoSetBold(bool bold)
void OnSelect(wxCommandEvent& event);
void OnUnselect(wxCommandEvent& event);
void OnToggleSel(wxCommandEvent& event);
+ void OnSelectChildren(wxCommandEvent& event);
#endif // NO_MULTIPLE_SELECTION
void OnSelectRoot(wxCommandEvent& event);
void OnDelete(wxCommandEvent& event);
TreeTest_Select,
TreeTest_Unselect,
TreeTest_SelectRoot,
+ TreeTest_SelectChildren,
TreeTest_ShowFirstVisible,
TreeTest_ShowLastVisible,
TreeTest_ShowNextVisible,
}
}
+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 :
}
}
+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);