Tickit::Widget::Tree - support for an expandable tree widget
version 0.003
my $tree = Tickit::Widget::Tree->new( is_open => 1, label => 'Root', line_style => 'single', ); $tree->add(Tickit::Widget::Tree->new( is_open => 1, label => 'First', ));
Simple tree widget. See examples in main source for more info.
Instantiate new tree.
Takes the following named parameters:
root - the root widget for this tree (optional)
parent - the parent widget (optional)
line_style - type of line used, see "LINE STYLES" (optional, defaults to single)
label - the text label to use for this tree entry
Set or retrieve the label for this widget.
By default all nodes use a Tickit::Widget::Static widget as a label, see the "label_widget" method for more control over this.
Set or retrieve the label widget for this node. Typically a Tickit::Widget::Static, this must accept a pen which will be used for displaying the currently-highlighted node.
The 'previous element' is determined as follows:
If we have a previous sibling:
If the previous sibling is open and has children, returns the last of those
If the previous sibling is closed or empty, returns it (the previous sibling)
If we have a parent and no previous sibling(s):
Return the parent
Return ourselves
Returns the previous sibling for this node. RO accessor.
Returns the next sibling for this node. RO accessor.
The 'next element' is determined as follows:
If we're open and have children, next is the first child element.
If we're closed or empty, next is the next sibling at our current level.
If there's no next sibling, call the parent's "next" method.
If there's no parent, return $self.
Returns the next node, ignoring any children in the current node for the purposes of the search.
Returns the number of lines used by this node. Will be the label height unless the widget is open.
Number of cols for autocalculation. We're flexible, so we just use the default 1.
Returns true if this node is open, false if not.
If open state is undefined, then we inherit from the parent if we have one, or return 0 as a fallback.
Returns true if we're closed, false if not.
Callback to clear children and label when we lose our window.
Callback to adjust our widgets when we get a window.
Callback to adjust the label window when our window is resized.
Adjust our label window to fit the current window.
Calculate windows for all widgets.
insert_after
Adds $v after $self.
Takes over $self->next, including backlink from $self->next->prev.
Adds a child node after all other children.
Returns a list of all children.
Returns true if this node is highlighted.
Note that the highlighted widget itself is tracked through the root node, see "highlighted" for more information.
Returns the appropriate line prefix text for the current style.
Returns hashref which maps a component to the character string used to represent it.
Tickit::Window
Open this node. Triggers a redraw.
Close this node. Triggers a redraw.
Make sure everything has a consistent view of root and parent nodes when adding a widget to a parent.
Returns current line style. Inherits from parent, root or defaults to 'single'.
Tom Molesworth <cpan@entitymodel.com>
Copyright Tom Molesworth 2011. Licensed under the same terms as Perl itself.
To install Tickit::Widget::Tree, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tickit::Widget::Tree
CPAN shell
perl -MCPAN -e shell install Tickit::Widget::Tree
For more information on module installation, please visit the detailed CPAN module installation guide.