fltk::TabGroup Class Reference

Inherits fltk::Group.

List of all members.

Public Member Functions

void draw_tab (int x1, int x2, int W, int H, Widget *o, int sel=0)
void draw_tab_background ()
int handle (int)
TabGroupPagerpager () const
 returning the current pager_ responsible of this instance
void pager (TabGroupPager *value)
 setting the pager_ to a tabgroup, pager is _never_ null by design
bool selected_child (Widget *)
Widgetselected_child ()
void set_draw_outline (bool draw_outline)
int tab_height ()
int tab_positions (int *, int *)
 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 (int factory_pager_index)
 setting the default pager_ from the built-in ones
static void default_pager (TabGroupPager *v)
 setting the default pager_ for future tabgroups, a default pager is _never_ null by design

Static Public Attributes

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

tabs.gif

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.

References fltk::TabGroupPager::clone(), default_style, and fltk::Group::focus_index().


Member Function Documentation

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.

References fltk::Group::child(), fltk::Group::children(), fltk::Widget::hide(), fltk::Widget::show(), and fltk::Widget::visible().

Referenced by selected_child().

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

References fltk::Group::child(), fltk::Group::children(), and selected_child().

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.

References fltk::TabGroupPager::which().

Widget * TabGroup::selected_child (  ) 

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

References fltk::Group::child(), and value().

Referenced by value().

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.

References fltk::Group::child(), fltk::Group::children(), fltk::Widget::contains(), fltk::focus(), fltk::Widget::focused(), fltk::Widget::hide(), fltk::Widget::show(), fltk::Widget::take_focus(), and fltk::Widget::visible().

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

References fltk::TabGroupPager::clone(), and fltk::Widget::redraw().


Member Data Documentation

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.

Referenced by TabGroup().


Wed Jun 17 08:58:18 2009. FLTK ©2007 Bill Spitzak and others.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.