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

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.

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

or

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

METHODS

tabs

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

active_tab_index

$index = $ribbon->active_tab_index

Returns the index of the currently-active tab

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.

render

$ribbon->render( %args )

lines

$lines = $ribbon->lines

cols

$cols = $ribbon->cols

As per the Tickit::Widget methods.

on_key

$handled = $ribbon->on_key( $ev )

on_mouse

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

scroll_to_visible

$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>