Tickit::Widget::Tabbed - provide tabbed window support
version 0.002
use Tickit::Widget::Tabbed; my $tabbed = Tickit::Widget::Tabbed->new; $tabbed->add_tab(Tickit::Widget::Static->new(text => 'some text'), label => 'First tab'); $tabbed->add_tab(Tickit::Widget::Static->new(text => 'some text'), label => 'Second tab');
Provides a container that operates as a tabbed window.
Subclass of Tickit::ContainerWidget.
Instantiate a new tabbed window.
Takes the following named parameters:
tab_position - (optional) location of the tabs, should be one of left, top, right, bottom.
pen_tabs - (optional) Tickit::Pen to use to render the tabs
Tickit::Pen
pen_active - (optional) Tickit::Pen of additional attributes to use to render the active tab
Accessor for the tab position (top, left, right, bottom).
Accessors for the rendering pens.
Returns the 0-based index of the currently-active tab.
Returns the currently-active tab as a tab object. See below.
Add a new tab to this tabbed widget. Returns an object representing the tab; see "METHODS ON TAB OBJECTS" below.
First parameter is the widget to use.
Remaining form a hash:
Remove tab given by 0-based index or tab object.
Move tab given by 0-based index or tab object forward the given number of positions.
Returns the widget in the currently active tab.
Switch to the given tab; by 0-based index, or object.
Switch to the next tab.
Switch to the previous tab.
The following methods may be called on the objects returned by add_tab or active_tab.
add_tab
active_tab
Returns the 0-based index of this tab
Returns the Tickit::Widget contained by this tab
Tickit::Widget
Returns the current label text
Set new label text for the tab
Returns true if this tab is the currently active one
Set a callback to invoke when the tab is activated
Set a callback to invoke when the tab is deactivated
Returns the Tickit::Pen used to draw the label
Rather than use the default built-in object class for tab objects, a Tickit::Widget::Tabbed or subclass thereof can return objects in another class instead. This is most useful for subclasses of the tabbed widget itself.
Tickit::Widget::Tabbed
To perform this, create a subclass of Tickit::Widget::Tabbed::Tab with a constructor having the following behaviour:
Tickit::Widget::Tabbed::Tab
sub new { my $class = shift; my ( $tabbed, %args ) = @_; ... my $self = $class->SUPER::new( $tabbed, %args ); ... return $self; }
Arrange for this class to be used by the tabbed widget either by passing its name as a constructor argument called tab_class, or by overriding a method called TAB_CLASS.
tab_class
TAB_CLASS
my $tabbed = Tickit::Widget::Tabbed->new( tab_class => "Tab::Class::Name" );
or
use constant TAB_CLASS => "Tab::Class::Name";
Tickit::Widget::Table
Tickit::Widget::HBox
Tickit::Widget::VBox
Tickit::Widget::Tree
Tickit::Window
Tom Molesworth <cpan@entitymodel.com>
Copyright Tom Molesworth 2011. Licensed under the same terms as Perl itself.
To install Tickit::Widget::Tabbed, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tickit::Widget::Tabbed
CPAN shell
perl -MCPAN -e shell install Tickit::Widget::Tabbed
For more information on module installation, please visit the detailed CPAN module installation guide.