Tree¶
Tree is derived from Control class.
[lide.widgets] ^1.1lide.widgets.controls.tree 1.0
A tree control presents information as a hierarchy, with items that may be expanded to show further items.
The general look of a control at runtime is demonstrated in the following picture:
Note
Items in a tree control are referenced by wxTreeItemId handles, which may be tested for validity by calling wxTreeItemId:IsOk().
Constructor¶
Control class has a single constructor:
Tree:new {
object Parent, string Name,
number PosX, number PosY,
}
Arguments¶
These arguments are received by class constructor.
| Argument | Description | |||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Name | The control name | |||||||||||||||||||||||||||||||||||||||||||||
| Parent | The control parent | |||||||||||||||||||||||||||||||||||||||||||||
| PosX | Position related to X | |||||||||||||||||||||||||||||||||||||||||||||
| PosY | Position related to Y | |||||||||||||||||||||||||||||||||||||||||||||
| Flags |
|
Events¶
The following events are emitted by this class:
| Event name | Description |
|---|---|
| Tree.onSelectCell | When the selected date was changed. |
Inherited Methods¶
These methods are inherited from its super classes:
| Class Method | Description |
|---|---|
| Object:getName | Returns control’s name. |
| Object:setName | Sets the control name. |
| Widget:getParent | Returns control’s parent. |
| Widget:setParent | Sets the control parent. |
| Widget:getPosX | Returns control’s position related to X. |
| Widget:setPosX | Sets the control position related to X. |
| Widget:getPosY | Returns control’s position related to Y. |
| Widget:setPosY | Sets the control position related to Y. |
| Widget:getEnabled | Returns true if is enabled. |
| Widget:setEnabled | Set control enabled or disabled. |
| Widget:getVisible | Returns the control visibility. |
| Widget:setVisible | Returns the control visibility. |
| Widget:getBind | Returns a reference to the C++ control. |
Class Methods¶
These methods are defined by this class.
Tree:addRoot¶
Adds the root node to the tree, returning the new item.
| nil | Tree:addRoot( string Text, string Image ) |
Tree:addItem¶
Appends an item to the end of the branch identified by parent, return a new item id.
| nil | Tree:addItem( string Text, number ItemID, object_ ParentItem, string Image, number selImage ) |
Tree:insertItem¶
Inserts an item after a given one (previous).
| nil | Tree:insertItem( string Text, number ItemID, string ParentItem, string PreviousItemID, string Image, string selImage ) |
Tree:startEditItemText¶
Starts editing the label of the given item.
This function generates a EVT_TREE_BEGIN_LABEL_EDIT event which can be vetoed so that no text control will appear for in-place editing.
If the user changed the label (i.e. s/he does not press ESC or leave the text control without changes, a EVT_TREE_END_LABEL_EDIT event will be sent which can be vetoed as well.
| nil | Tree:startEditItemText( number nItemID ) |
Tree:endEditItemText¶
Ends label editing.
Note:
This function is currently supported under Windows only.
| nil | Tree:editItemText( number nItemID, bool bDiscardChanges = false ) |
Tree:collapseAllChildren¶
Collapses this item and all of its children, recursively.
| nil | Tree:collapseAllChildren() |
Tree:collapseAndReset¶
Collapses the given item and removes all children.
| nil | Tree:collapseAndReset ( ItemID ) |
Tree:deleteChildren¶
Deletes all children of the given item (but not the item itself).
| string | Tree:deleteChildren ( number nItemID ) |
Tree:expandAllChildren¶
Expands the given item and all its children recursively.
| nil | Tree:expandAllChildren( number nItemID ) |
Tree:ensureVisible¶
Scrolls and/or expands items to ensure that the given item is visible.
| nil | Tree:ensureVisible ( nItemID ) |
Tree:getChildrenCount¶
Returns the number of items in the branch.
| number | Tree:getChildrenCount( number nItemID, bool bRecursively = true ) |
Tree:getSelection¶
Returns the selection, or an invalid item if there is no selection.
| number, string | Tree:getSelection( ) |
Tree:isExpanded¶
Returns true if the item is expanded (only makes sense if it has children).
| nil | Tree:isExpanded( number nItemID ) |
Tree:isVisible¶
Returns true if the item is visible on the screen.
| nil | Tree:isVisible( number nItemID ) |
Tree:itemHasChildren¶
Returns true if the item has children.
| nil | Tree:itemHasChildren( number nItem ) |
Tree:isEmpty¶
Returns true if the control is empty (i.e. has no items, even no root one).
| bool | Tree:isEmpty( ) |
Tree:selectItem¶
Selects the given item.
In multiple selection controls, can be also used to deselect a currently selected item if the value of select is false.
| nil | Tree:selectItem( nItemID, bool bSelect ) |
Tree:setItemBold¶
Makes item appear in bold font if bold parameter is true or resets it to the normal state.
| nil | Tree:setItemBold( number nItemID, bool bBold ) |
Tree:setItemDropHighlight¶
Gives the item the visual feedback for Drag’n’Drop actions, which is useful if something is dragged from the outside onto the tree control (as opposed to a DnD operation within the tree control, which already is implemented internally).
| nil | Tree:setItemDropHighlight( number nItemID, bool bHighlight ) |
Tree:sortChildren¶
Sorts the children of the given item using OnCompareItems().
You should override that method to change the sort order (the default is ascending case-sensitive alphabetical order).
| nil | Tree:sortChildren( number nItemID ) |
Tree:toggle¶
Toggles the given item between collapsed and expanded states.
| nil | Tree:toggle( number nItemID ) |
Tree:toggleItemSelection¶
Toggles the given item between selected and unselected states.
For multiselection controls only.
| nil | Tree:toggle( number nItemID ) |
Tree:unselect¶
Removes the selection from the currently selected item (if any).
| nil | Tree:unselect( ) |
Tree:unselectAll¶
This function either behaves the same as unselect() if the control doesn’t have TR_MULTIPLE style, or removes the selection from all items if it does have this style.
| nil | Tree:unselectAll( ) |