TabGroup Class Reference

Inherits Group.

List of all members.

Public Member Functions

int handle (int)
 TabGroup (int, int, int, int, const char *=0, bool begin=false)
int value () const
bool value (int)
int which (int event_x, int event_y)
Widgetselected_child ()
bool selected_child (Widget *)
void set_draw_outline (bool draw_outline)
void pager (TabGroupPager *value)
TabGroupPagerpager () const
int tab_height ()
int tab_positions (int *, int *)
void draw_tab (int x1, int x2, int W, int H, Widget *o, int sel=0)
void draw_tab_background ()

Static Public Member Functions

void default_pager (TabGroupPager *v)
void default_pager (int factory_pager_index)

Static Public Attributes

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 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 Tabs, which is where the tabs are drawn.


Member Function Documentation

void TabGroup::default_pager int  factory_pager_index  )  [static]
 

setting the default pager_ from the built-in ones

void TabGroup::default_pager TabGroupPager v  )  [static]
 

setting the default pager_ for future tabgroups, a default pager is _never_ null by design

TabGroupPager* TabGroup::pager  )  const [inline]
 

returning the current pager_ responsible of this instance

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

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.

Widget * TabGroup::selected_child  ) 
 

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

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

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


The documentation for this class was generated from the following files:
Sun Jan 7 00:55:18 2007. FLTK ©2006 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.