Sanko Robinson > FLTK-0.532009 > FLTK::TabGroup



Annotate this POD


View/Report Bugs
Module Version: 0.532006   Source  


FLTK::TabGroup - For Making a 'Tabbed' Dialog Boxes

Description ^

This is the "file card tabs" interface to allow you to put lots and lots of buttons and switches in a panel. This first appeared in NeXTStep, but is best known from Windows control panesl. FLTK's version draws in a style more reminiscent of NeXT or PageMaker, and avoids the confusing multiple-lines of Windows by drawing overlapping tabs.

Each child widget is a card, and it's label() is printed on the card tab (including the label font and style). The color() of the child is used to color the tab as well.

The size of the tabs is controlled by the bounding box of the children (there should be some space between the children and the edge of this widget). If there is a larger gap on the bottom than the top, the tabs are placed "inverted" along the bottom.

Clicking the tab makes that child visible() and hides all the other children. If the widget with the focus does not consume them, the Ctrl+Tab and Ctrl+Shift+Tab keys will also switch tabs. The user can also navigate the focus to the tabs and change them with the arrow keys.

The callback() of the TabGroup widget is called when the user changes the visible tab, and SHOW and HIDE events are passed to the children.

Functions ^


$tabgroup->default_pager( $value );

Sets the default pager for future TabGroups. By design, the defualt pager is never undefined.

$tabgroup->default_pager( $value );

Sets the default pager from the built-in ones.

The current built-in pagers are...

Menu Displays two left and right buttons and provides 'prev page' and 'next page' functionality. This is the new default.

Pass 0 for this type.

Shrink Tabs outside the rectangle are shrunken to very small slice to fit. This is the original default.

Pass 1 for this type.


my $style = $tabgroup->default_style( );

The default style has a gray color( ) and the box( ) is set to THIN_UP_BOX. The box( ) is used to draw the edge around the cards, including the top edge, but the tab itself is designed only to match THIN_UP_BOX. You can also use FLAT_BOX and it will look correct if the tabs fill the entire width of a window or parent box.

$tabgroup->default_style( $style );

Set the style.


$tabgroup->draw_tab( $x1, $x2, $W, $H, $o, $sel );


$tabgroup->draw_tab_background( );


my $group = $tabgroup->new( $x, $y, $w, $h, $label, $begin );

Creates a new TabGroup widget using the given position, size, and label string. Use add(widget) to add each child. Each child is probably an FLTK::Group widget containing the actual widgets the user sees. The children should be sized to stay away from the top or bottom edge of the FLTK::Tabs, which is where the tabs are drawn.


$tabgroup->pager( $value );

Sets the pager to a TabGroup. By design, pager is never undefined.

my $pager = $tabgroup->pager( );


my $child = $tabgroup->selected_child( );

Returns $tabgroup-child($tabgroup->value())> or an undefined value if no children exist.

my $new = $tabgroup->selected_child( $newval );

Switches to this child widget, or to a child that contains( ) this widget. Returns true if this is a different selection than before. Does not do the callback( ). If the widget is null or not a descendent of this, the last child is selected.


$tabgroup->set_draw_outline( $draw_outline );


my $height = $tabgroup->tab_height( );

Returns the space needed for tabs. Negative values will place tabs on the bottom.


my $index = $tabgroup->tab_positions( );

Returns the index of the selected item, the left edges of each tab (plus a fake left edge for a tab past the right-hand one). These positions are actually of the left edge of the slope. They are either seperated by the correct distance or by $tabgroup-pager->slope( )> or by zero.

Return value is the index of the selected item.


my $val = $tabgroup->value( );

Returns the index of the first visible( ) child, which is normally the one the user selected.

This will automatically force a single child to be visible( ) if more than one is, or if none are. If more than one is visible all except the first is hidden. If none are, the last one is made visible. The resulting visible child's index is returned. This behavior allows new TabGroups to be created with all children visible, and allows children to be deleted, moved to other groups, and show( )/hide( ) called on them without the display ever looking wrong to the user.

If there are no children then -1 is returned.

$tabgroup->value( $newval );

Switch so index $newval is selected. If n is less than zero selects zero, if $newval is greater than the children, it selects the last one. Returns true if this is a different child than last time. Does not do the callback( ).


my $index = $tabgroup->which( $event_x, $event_y );

Returns the child index that would be selected by a click at the given mouse position. Returns -1 if the mouse position is not in a tab.

Author ^

Sanko Robinson <> -

License and Legal ^

Copyright (C) 2008-2010 by Sanko Robinson <>

This program is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0. See the LICENSE file included with this distribution or notes on the Artistic License 2.0 for clarification.

When separated from the distribution, all original POD documentation is covered by the Creative Commons Attribution-Share Alike 3.0 License. See the clarification of the CCA-SA3.0.

syntax highlighting: