Tickit::Widget::Tabbed::Ribbon - base class for Tickit::Widget::Tabbed control ribbon
Tickit::Widget::Tabbed::Ribbon
Tickit::Widget::Tabbed
This class contains the default implementation for the control ribbon used by Tickit::Widget::Tabbed, and also acts as a base class to assist in the creation of a custom ribbon. Details of this class and its operation are useful to know when implenting a custom control ribbon.
It is not necessary to consider this class if simply using the Tickit::Widget::Tabbed with its default control ribbon.
To create a custom ribbon class, create a subclass of Tickit::Widget::Tabbed::Ribbon with a constructor having the following behaviour:
use Object::Pad; class Custom::Ribbon::Class :isa(Tickit::Widget::Tabbed::Ribbon); sub new_for_orientation # note: Not a method { my $class = shift; my ( $orientation, %args ) = @_; ... }
Alternatively if this is not done, then one of two subclasses will be used for the constructor, by appending ::horizontal or ::vertical to the class name. In this case, the custom class should provide these as well.
::horizontal
::vertical
use Object::Pad; class Custom::Ribbon::Class :isa(Tickit::Widget::Tabbed::Ribbon); class Custom::Ribbon::Class::horizontal :isa(Custom::Ribbon::Class); ... class Custom::Ribbon::Class::vertical :isa(Custom::Ribbon::Class); ...
Arrange for this class to be used by the tabbed widget either by passing its name as a constructor argument called ribbon_class, or by overriding a method called RIBBON_CLASS.
ribbon_class
RIBBON_CLASS
my $tabbed = Tickit::Widget::Tabbed->new( ribbon_class => "Ribbon::Class::Name" );
or
use constant RIBBON_CLASS => "Ribbon::Class::Name";
@tabs = $ribbon->tabs $count = $ribbon->tabs
Returns a list of the contained Tickit::Widget::Tabbed tab objects in list context, or the count of them in scalar context.
$index = $ribbon->active_tab_index
Returns the index of the currently-active tab
$tab = $ribbon->active_tab
Returns the currently-active tab as a Tickit::Widget::Tabbed tab object.
The subclass will need to provide implementations of the following methods.
$ribbon->render( %args )
$lines = $ribbon->lines
$cols = $ribbon->cols
As per the Tickit::Widget methods.
$handled = $ribbon->on_key( $ev )
$handled = $ribbon->on_mouse( $ev )
As per the Tickit::Widget methods. Optional. If not supplied then the ribbon will not respond to keyboard or mouse events.
$ribbon->scroll_to_visible( $index )
Requests that a scrollable control ribbon scrolls itself so that the given $index tab is visible.
$index
Paul Evans <leonerd@leonerd.org.uk>
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.