fltk::TabGroup Class Reference

Inherits fltk::Group.

List of all members.

Public Member Functions

int handle (int)
void pager (TabGroupPager *value)
 setting the pager_ to a tabgroup, pager is _never_ null by design
TabGroupPagerpager () const
 returning the current pager_ responsible of this instance
bool selected_child (Widget *)
Widgetselected_child ()
 TabGroup (int, int, int, int, const char *=0, bool begin=false)
bool value (int)
int value () const
int which (int event_x, int event_y)

Static Public Member Functions

static void default_pager (TabGroupPager *v)
 setting the default pager_ for future tabgroups, a default pager is _never_ null by design
static void default_pager (int factory_pager_index)
 setting the default pager_ from the built-in ones

Static Public Attributes

static NamedStyledefault_style = &::style

Protected Member Functions

void draw ()

Detailed 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. It is easiest to lay this out in fluid, using the fluid browser to select each child group and resize them until the tabs look the way you want them to.

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.

Constructor & Destructor Documentation

TabGroup::TabGroup ( int  X,
int  Y,
int  W,
int  H,
const char *  l = 0,
bool  begin = false 

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.

Member Function Documentation

void TabGroup::draw ( void  ) [protected, virtual]

Fltk calls this virtual function to draw the widget, after setting up the graphics (current window, xy translation, etc) so that any drawing functions will go into this widget.

User code should not call this! You probably want to call redraw().

The default version calls draw_box() and draw_label(), thus drawing the box() to fill the widget and putting the label() and image() inside it to fill it, unless the align() flags are set to put it outside.

Information on how to write your own version is here.

Reimplemented from fltk::Group.

int TabGroup::handle ( int  event) [virtual]

Calls send() on some or all of the children widgets.

Reimplemented from fltk::Group.

void TabGroup::pager ( TabGroupPager value)

setting the pager_ to a tabgroup, pager is _never_ null by design

assign dynamically a new pager with a preconfigured prototype

Widget * TabGroup::selected_child ( )

Return child(value()), or return null if no children.

bool TabGroup::selected_child ( Widget newvalue)

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

int TabGroup::value ( ) const

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

bool TabGroup::value ( int  n)

Switch so index n is selected. If n is less than zero selects zero, if n 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().

int TabGroup::which ( int  event_x,
int  event_y 

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

Member Data Documentation

NamedStyle * TabGroup::default_style = &::style [static]

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.

Reimplemented from fltk::Widget.

The documentation for this class was generated from the following files: