Module CorsixTH.CorsixTH.Lua.dialogs.tree_ctrl
Interface for items within a UI tree control
Functions
| DummyRootNode:DummyRootNode (roots) | A tree node which can be used as a root node. |
| FileTreeNode:FileTreeNode (path) | A tree node representing a file (or directory) in the physical file-system. |
| FileTreeNode:getMostRecentlyModifiedChildFile (file_name_filter) | |
| FileTreeNode:isValidFile (name) | Returns whether the given file name is valid in this tree. |
| FileTreeNode:reSortChildren (sort_by, order) | Sorts the node and its children either by date or by name. |
| FileTreeNode:select () | Selects an item. |
| TreeControl:TreeControl (root, x, y, width, height, col_bg, col_fg, y_offset, has_font) | A control (to be placed on a window). |
| TreeControl:drawExtraOnRow (canvas, node, x, y) | Override this function if a certain row should have certain text or additional flavour to it. |
| TreeControl:setSelectCallback (callback) | Function to handle (final) selection by user that needs to feed back data to another dialog. |
| TreeControl:setValueChangeCallback (callback) | Function for where an action in the file tree needs to feed back data to another dialog. |
| TreeNode:contract () | Make the children of the item invisible |
| TreeNode:expand () | Make the children of the item visible |
| TreeNode:getChildByIndex (idx) | Get a child of the item. |
| TreeNode:getChildCount () | Get the number of childrem which the item has |
| TreeNode:getControl () | Get the tree control within which the item is displayed |
| TreeNode:getHighlightColour (canvas) | Get the background colour for when the item is highlighted |
| TreeNode:getIndexOfChild (child) | Given a child of the item, determine which index it is |
| TreeNode:getLabel () | Get the text to be displayed for the item |
| TreeNode:getLevel () | Get the depth from the root item to this item. |
| TreeNode:getNextVisible () | Get the next item in the on-screen display order |
| TreeNode:getParent () | Get the item's parent, if it has one |
| TreeNode:getPrevVisible () | Get the previous item in the on-screen display order |
| TreeNode:getSelectColour (canvas) | Get the background colour for when the item is selected |
| TreeNode:hasChildren () | Query if the item has any children at all. |
| TreeNode:isExpanded () | Query whether the item's children are visible |
| TreeNode:numVisibleDescendants () | The number of visible items in the set of this item and all its descendants |
Functions
- DummyRootNode:DummyRootNode (roots)
-
A tree node which can be used as a root node.
To give the effect of having multiple root nodes.
Parameters:
- roots (array) An array of `TreeNode`s which should be displayed as root nodes.
- FileTreeNode:FileTreeNode (path)
-
A tree node representing a file (or directory) in the physical file-system.
Parameters:
- path
- FileTreeNode:getMostRecentlyModifiedChildFile (file_name_filter)
-
Parameters:
- file_name_filter > (optional) return the most recently modified child file which has this string in its name.
Returns:
-
nil if no child file is found otherwise return the FileTreedNode for mostly recently modified child file.
- FileTreeNode:isValidFile (name)
-
Returns whether the given file name is valid
in this tree. Override for desired behaviour.
Parameters:
- name
- FileTreeNode:reSortChildren (sort_by, order)
-
Sorts the node and its children either by date or by name.
Parameters:
- sort_by What to sort by. Either "name" or "date".
- order If the ordering should be "ascending" or "descending".
- FileTreeNode:select ()
- Selects an item. By default everything selected is valid. Can be overridden by inheriting classes.
- TreeControl:TreeControl (root, x, y, width, height, col_bg, col_fg, y_offset, has_font)
-
A control (to be placed on a window).
Which allows the user to navigate a tree of items and select one item from it.
Parameters:
- root (TreeNode) The single root node of the tree (use a `DummyRootNode` here if multiple root nodes are desired).
- x (integer) The X-position, in pixels, where the control should start within its parent.
- y (integer) The Y-position, in pixels, where the control should start within its parent.
- width (integer) The width, in pixels, of the control.
- height (integer) The height, in pixels, of the control.
- col_bg (table) The background colour of the control - this should be a table with `red`, `green`, and `blue` fields, each an integer between 0 and 255.
- col_fg (table) The colour used for the scrollbar and highlighted items.
- y_offset (integer)
- has_font (boolean)
- TreeControl:drawExtraOnRow (canvas, node, x, y)
-
Override this function if a certain row should have certain text
or additional flavour to it.
Parameters:
- canvas luacheck
- node
- x
- y ignore 212 keep args for child class
- TreeControl:setSelectCallback (callback)
-
Function to handle (final) selection by user that needs to feed back data to
another dialog.
Parameters:
- callback (function) Code to execute on trigger
Returns:
-
self
- TreeControl:setValueChangeCallback (callback)
-
Function for where an action in the file tree needs to feed back data to another
dialog. Its specific usage should be noted in the parent element
Parameters:
- callback (function) Code to execute on trigger
Returns:
-
self
- TreeNode:contract ()
- Make the children of the item invisible
- TreeNode:expand ()
- Make the children of the item visible
- TreeNode:getChildByIndex (idx)
-
Get a child of the item.
Parameters:
- idx (integer) An integer between 1 and getChildCount() (inclusive).
- TreeNode:getChildCount ()
- Get the number of childrem which the item has
- TreeNode:getControl ()
- Get the tree control within which the item is displayed
- TreeNode:getHighlightColour (canvas)
-
Get the background colour for when the item is highlighted
Parameters:
- canvas luacheck ignore 212 keep args for child class
- TreeNode:getIndexOfChild (child)
-
Given a child of the item, determine which index it is
Parameters:
- child (TreeNode) A value returned from getChildByIndex()
- TreeNode:getLabel ()
- Get the text to be displayed for the item
- TreeNode:getLevel ()
- Get the depth from the root item to this item. The root item has level 0, its direct children have level 1, etc.
- TreeNode:getNextVisible ()
- Get the next item in the on-screen display order
- TreeNode:getParent ()
- Get the item's parent, if it has one
- TreeNode:getPrevVisible ()
- Get the previous item in the on-screen display order
- TreeNode:getSelectColour (canvas)
-
Get the background colour for when the item is selected
Parameters:
- canvas
- TreeNode:hasChildren ()
- Query if the item has any children at all. The simple way of doing this is checking if getChildCount() is non-zero, but often this can be implemented in a more efficient manner.
- TreeNode:isExpanded ()
- Query whether the item's children are visible
- TreeNode:numVisibleDescendants ()
- The number of visible items in the set of this item and all its descendants