wTreeCtrl

A tree control presents information as a hierarchy, with items that may be expanded to show further items. Items in a tree control are referenced by wTreeItem handles, which may be tested for validity by calling wTreeItem.isOk().

Appearance:
Superclass:wControl
Styles:
StylesDescription
wTrNoButtonsFor convenience to document that no buttons are to be drawn.
wTrHasButtonsUse this style to show + and - buttons to the left of parent items.
wTrHasLinesUse this style to show vertical level connectors.
wTrEditLabelsUse this style if you wish the user to be able to edit labels in the tree control.
wTrFullRowHighLightUse this style to have the background colour and the selection highlight extend over the entire horizontal row of the tree control window. Cannot use with wTrHasLines.
wTrLinesAtRootUse this style to show lines between root nodes.
wTrCheckBoxEnables check boxes for items.
wTrTwistButtonsSelects alternative style of +/- buttons and shows rotating ("twisting") arrows instead. Windows vista later.
wTrNoHScrollDisables horizontal scrolling.
wTrNoScrollDisables both horizontal and vertical scrolling.
wTrSingleExpandCauses the item being selected to expand and the item being unselected to collapse upon selection in the tree view.
Events:wTreeEvent

Types

wTreeCtrl_Compare = proc (data1: int; data2: int; data: int): int
Comparing callback function prototype used in sortChildren()
wTreeCtrl_ItemCompare = proc (item1: wTreeItem; item2: wTreeItem; data: int): int
Comparing callback function prototype used in sortChildren()

Consts

wTrNoButtons = 0
wTrHasButtons = 0x00000001
wTrHasLines = 0x00000002
wTrEditLabels = 0x00000008
wTrFullRowHighLight = 0x00001000
wTrLinesAtRoot = 0x00000004
wTrCheckBox = 0x00000100
wTrTwistButtons = 1152921504606846976
wTrNoHScroll = 0x00008000
wTrNoScroll = 0x00002000
wTrSingleExpand = 0x00000400
wTrShowSelectAlways = 0x00000020
wTreeItemStateBold = 0x00000010
wTreeItemStateCut = 0x00000004
wTreeItemStateDropHighlighted = 0x00000008
wTreeItemStateSelected = 0x00000002
wTreeImageCallback = -1
wTreeImageNone = -2
wTreeIgnore = -3
wTreeItemIconNormal = 0
wTreeItemIconSelected = 1
wTreeHittestAbove = 0x00000100
wTreeHittestBelow = 0x00000200
wTreeHittestNoWhere = 0x00000001
wTreeHittestOnItemButton = 0x00000010
wTreeHittestOnItemIcon = 0x00000002
wTreeHittestOnItemIndent = 0x00000008
wTreeHittestOnItemLabel = 0x00000004
wTreeHittestOnItemRight = 0x00000020
wTreeHittestOnItemStateIcon = 0x00000040
wTreeHittestOnItem = 70
wTreeHittestToLeft = 0x00000800
wTreeHittestToRight = 0x00000400

Procs

proc TreeItem(treeCtrl: wTreeCtrl; handle: HTREEITEM): wTreeItem {...}{.inline, raises: [],
    tags: [].}
Default constructor.
proc `==`(a, b: wTreeItem): bool {...}{.inline, raises: [], tags: [].}
Checks for equality between two wTreeItem.
proc isOk(self: wTreeItem): bool {...}{.inline, raises: [], tags: [].}
Returns true if this instance is referencing a valid tree item.
proc unset(self: var wTreeItem) {...}{.inline, raises: [], tags: [].}
Unset the tree item.
proc len(self: wTreeItem): int {...}{.raises: [NilAccessError], tags: [].}
Gets the number of children in this item.
proc set(self: wTreeItem; text = ""; image = wTreeIgnore; selImage = wTreeIgnore; state = 0;
        flag = true) {...}{.raises: [NilAccessError], tags: [].}
Sets the item attributes.
proc select(self: wTreeItem) {...}{.raises: [NilAccessError], tags: [].}
Select, focus, and ensure visible of the item, also unselect others.
proc scrollTo(self: wTreeItem) {...}{.raises: [NilAccessError], tags: [].}
Scrolls the specified item into view.
proc unselect(self: wTreeItem) {...}{.inline, raises: [NilAccessError], tags: [].}
Unselects this item. Notice: this will broken single selection states, don't use this if possible.
proc expand(self: wTreeItem) {...}{.raises: [NilAccessError], tags: [].}
Expands the item.
proc collapse(self: wTreeItem) {...}{.raises: [NilAccessError], tags: [].}
Collapses the item.
proc collapseAndReset(self: wTreeItem) {...}{.raises: [NilAccessError], tags: [].}
Collapses the given item and removes all children.
proc toggle(self: wTreeItem) {...}{.raises: [NilAccessError], tags: [].}
Toggles the item between collapsed and expanded states.
proc isBold(self: wTreeItem): bool {...}{.raises: [NilAccessError], tags: [].}
Returns true if the item is in bold state.
proc isCut(self: wTreeItem): bool {...}{.raises: [NilAccessError], tags: [].}
Returns true if the item is in cut-and-paste operation state.
proc isDropHighlight(self: wTreeItem): bool {...}{.raises: [NilAccessError], tags: [].}
Returns true if the item is in drop hightlight state.
proc isSelected(self: wTreeItem): bool {...}{.raises: [NilAccessError], tags: [].}
Returns true if the item is in selected state.
proc isExpanded(self: wTreeItem): bool {...}{.raises: [NilAccessError], tags: [].}
Returns true if the item is expanded.
proc isFocused(self: wTreeItem): bool {...}{.raises: [NilAccessError], tags: [].}
Returns true if the item is focused.
proc hasChildren(self: wTreeItem): bool {...}{.raises: [NilAccessError], tags: [].}
Returns true if the item is in having children state. Notice this only gets the state that can be set by setHasChildren().
proc expandAllChildren(self: wTreeItem) {...}{.raises: [NilAccessError], tags: [].}
Expands the item and all its children recursively.
proc collapseAllChildren(self: wTreeItem) {...}{.raises: [NilAccessError], tags: [].}
Collapses this item and all of its children, recursively.
proc isVisible(self: wTreeItem): bool {...}{.raises: [NilAccessError, Exception],
                                    tags: [RootEffect].}
Returns true if the item is visible on the screen.
proc ensureVisible(self: wTreeItem) {...}{.raises: [NilAccessError], tags: [].}
Scrolls and/or expands items to ensure that the item is visible.
proc delete(self: wTreeItem) {...}{.raises: [NilAccessError], tags: [].}
Deletes the specified item.
proc deleteChildren(self: wTreeItem) {...}{.raises: [NilAccessError], tags: [].}
Deletes all children of the given item (but not the item itself).
proc toggleSelection(self: wTreeItem) {...}{.raises: [NilAccessError], tags: [].}
Toggles the item between selected and unselected states.
proc selectChildren(self: wTreeItem) {...}{.raises: [NilAccessError], tags: [].}
Select all the immediate children of the given parent.
proc sortChildren(self: wTreeItem; recursively = false) {...}{.raises: [NilAccessError],
    tags: [].}
Sorts the children of the item by text (alphabetically).
proc sortChildren(self: wTreeItem; callback: wTreeCtrl_Compare; data: int = 0;
                 recursively = false) {...}{.raises: [NilAccessError], tags: [].}
Sorts the children of the item. The value passed into callback function is the data associated with the item
proc setFocused(self: wTreeItem) {...}{.raises: [NilAccessError], tags: [].}
Sets the currently focused item. Use select() instead of this if possible.

Iterators

iterator items(self: wTreeItem): wTreeItem {...}{.raises: [NilAccessError], tags: [].}
Iterate each child in this item.
iterator allItems(self: wTreeItem): wTreeItem {...}{.raises: [NilAccessError], tags: [].}
Iterate each child in this item, including all descendants.