Paul Evans > Tickit-Widget-Tabbed > Tickit::Widget::Tabbed::Ribbon

Download:
Tickit-Widget-Tabbed-0.015.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.015   Source  

NAME ^

Tickit::Widget::Tabbed::Ribbon - base class for Tickit::Widget::Tabbed control ribbon

DESCRIPTION ^

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.

CUSTOM RIBBON CLASS ^

To perform create a custom ribbon class, create a subclass of Tickit::Widget::Tabbed::Ribbon with a constructor having the following behaviour:

 package Custom::Ribbon::Class;
 use base qw( Tickit::Widget::Tabbed::Ribbon );

 sub new_for_orientation
 {
         my $class = shift;
         my ( $orientation, %args ) = @_;

         ...

         return $self;
 }

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.

 package Custom::Ribbon::Class;
 use base qw( Tickit::Widget::Tabbed::Ribbon );

 package Custom::Ribbon::Class::horizontal;
 use base qw( Custom::Ribbon::Class );

 ...

 package Custom::Ribbon::Class::vertical;
 use base qw( 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.

 my $tabbed = Tickit::Widget::Tabbed->new(
         ribbon_class => "Ribbon::Class::Name"
 );

or

 use constant RIBBON_CLASS => "Ribbon::Class::Name";

METHODS ^

@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.

SUBCLASS METHODS ^

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.

AUTHOR ^

Paul Evans <leonerd@leonerd.org.uk>

syntax highlighting: