fltk::StatusBarGroup Class Reference

Inherits fltk::Group.

List of all members.

Public Types

enum  Position { SBAR_LEFT = 0, SBAR_CENTER, SBAR_RIGHT }

Public Member Functions

void child_box (Box *b)
 set a default box to all texts inside the status bar
void child_box (Box *b, Position i)
 set a default box to text at particular position inside the status bar
void hide ()
void layout ()
void set (Position pos, const char *format,...)
 sets the label at a particular pos, automatically handles alloc + drawing, variable parmeter format
void set (const char *t, Position pos=SBAR_RIGHT)
 sets the label at a particular pos, automatically handles alloc + drawing
void show ()
 StatusBarGroup (int H=24)
 statusbar default constructor

Protected Member Functions

void draw_label (Position pos, const char *label)
 draw a label on a particular (left,middle, right) Position
void update_box (InvisibleBox *b, Position pos)
 adapt box position and size according to Position pos and statusbar dimensions

Private Member Functions

void init ()
void resize_from_parent ()

Detailed Description

This class permits to create and handle a statusbar with minimum efforts.
It features automatic positionning and resizing adapting to parent Group/Window.
Only height matters when constructing a StatusBarGroup.
You can use the set() API's to easily print formatted text at one of the three standard position : left, center right.
You can also setup an optional custom box to the incorporated texts with child_box(), by default FLAT_BOX is used.
The StatusBarGroup widget can also be visually created in Fluid2.

Here's some typical code you can use to create a status bar:
Sample implementation:

  my_status_bar = new StatusBarGroup(24);
  my_status_bar->child_box(StatusBarGroup::SBAR_RIGHT, THIN_DOWN_BOX);
  //... more code ...
  // sets a right-aligned formatted text :
  my_status_bar->set(StatusBarGroup::SBAR_RIGHT, "%d items", count); 
  // sets a centered text :
  my_status_bar->set("Hi", StatusBarGroup::SBAR_CENTER); 
  //... more code ...
  // using a null or 0-len text removes the text box :
  my_status_bar->set(0, StatusBarGroup::SBAR_CENTER); 

Member Enumeration Documentation

Enumerator:
SBAR_LEFT 

statusbar text left-aligned

SBAR_CENTER 

statusbar text centered

SBAR_RIGHT 

statusbar text right-aligned (default)


Member Function Documentation

void StatusBarGroup::hide ( )

If visible() is true, turn it off. If visible_r() was true then send() a fltk::HIDE event, and redraw() the parent if necessary.

Reimplemented from fltk::Widget.

void StatusBarGroup::init ( ) [private]

widget initialisation

void StatusBarGroup::layout ( ) [virtual]

Virtual function to respond to layout_damage(), it should calculate the correct size of this widget and all it's children. This function is called by fltk or by the layout() method in other widgets. User programs should not call it.

A widget is allowed to alter it's own size in a layout() method, to indicate a size that the data will fit in. A parent widget is then expected to rearrange itself to accomodate the new size. This may mean it will move the widget and thus layout() will be called again.

You can look at layout_damage() to find out why this is being called.

The base class redraws the widget.

Reimplemented from fltk::Group.

void StatusBarGroup::resize_from_parent ( ) [private]

make sure that width will match optimally parent's width and that it will fit in the bottom also make sure that any child in the same group does not override the status bar and resize if necessary

void StatusBarGroup::set ( StatusBarGroup::Position  pos,
const char *  format,
  ... 
)

sets the label at a particular pos, automatically handles alloc + drawing, variable parmeter format

set a formatable (printf-like) text in the status bar at a given Position 'pos' alignment spec.

void StatusBarGroup::set ( const char *  t,
StatusBarGroup::Position  pos = SBAR_RIGHT 
)

sets the label at a particular pos, automatically handles alloc + drawing

set a simple string in the status bar at a given Position 'pos' alignment spec.

void StatusBarGroup::show ( )

If visible() is false, turn it on. If visible_r() is then true, send() a fltk::SHOW event.

Reimplemented from fltk::Widget.


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