fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
  SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation)  

Fl_Group Class Reference

#include <Fl_Group.H>

Inheritance diagram for Fl_Group:
Collaboration diagram for Fl_Group:

List of all members.

Public Member Functions

int handle (int)
void begin ()
void end ()
int children () const
Fl_Widgetchild (int n) const
int find (const Fl_Widget *) const
int find (const Fl_Widget &o) const
Fl_Widget *const array () const
void resize (int, int, int, int)
 Fl_Group (int, int, int, int, const char *=0)
virtual ~Fl_Group ()
void add (Fl_Widget &)
void add (Fl_Widget *o)
void insert (Fl_Widget &, int i)
void insert (Fl_Widget &o, Fl_Widget *before)
void remove (int index)
void remove (Fl_Widget &)
void remove (Fl_Widget *o)
void clear ()
void resizable (Fl_Widget &o)
void resizable (Fl_Widget *o)
Fl_Widgetresizable () const
void add_resizable (Fl_Widget &o)
void init_sizes ()
void clip_children (int c)
unsigned int clip_children ()
virtual Fl_Groupas_group ()
void focus (Fl_Widget *W)
Fl_Widget *& _ddfdesign_kludge ()
void forms_end ()

Static Public Member Functions

static Fl_Groupcurrent ()
static void current (Fl_Group *g)

Protected Member Functions

void draw ()
void draw_child (Fl_Widget &widget) const
void draw_children ()
void draw_outside_label (const Fl_Widget &widget) const
void update_child (Fl_Widget &widget) const
int * sizes ()

Detailed Description

The Fl_Group class is the FLTK container widget. It maintains an array of child widgets. These children can themselves be any widget including Fl_Group. The most important subclass of Fl_Group is Fl_Window, however groups can also be used to control radio buttons or to enforce resize behavior.

Definition at line 45 of file Fl_Group.H.


Constructor & Destructor Documentation

Fl_Group::Fl_Group ( int  X,
int  Y,
int  W,
int  H,
const char *  l = 0 
)

Creates a new Fl_Group widget using the given position, size, and label string. The default boxtype is FL_NO_BOX.

Definition at line 366 of file Fl_Group.cxx.

References Fl_Widget::align(), begin(), and FL_ALIGN_TOP.

Fl_Group::~Fl_Group ( ) [virtual]

The destructor also deletes all the children. This allows a whole tree to be deleted at once, without having to keep a pointer to all the children in the user code.

It is allowed that the Fl_Group and all of its children are automatic (local) variables, but you must declare the Fl_Group first, so that it is destroyed last.

If you add static or automatic (local) variables to an Fl_Group, then it is your responsibility to remove (or delete) all such static or automatic child widgets before destroying the group - otherwise the child widgets' destructors would be called twice!

Definition at line 451 of file Fl_Group.cxx.

References clear().


Member Function Documentation

Fl_Widget* & Fl_Group::_ddfdesign_kludge ( ) [inline]

This is for forms compatibility only

Definition at line 193 of file Fl_Group.H.

void Fl_Group::add ( Fl_Widget o)

The widget is removed from its current group (if any) and then added to the end of this group.

Reimplemented in Fl_Table.

Definition at line 494 of file Fl_Group.cxx.

References insert().

Referenced by Fl_File_Chooser::add_extra(), Fl_Scroll::clear(), fl_add_object(), Fl_Widget::Fl_Widget(), and live_mode_cb().

void Fl_Group::add ( Fl_Widget o) [inline]

See void Fl_Group::add(Fl_Widget &w)

Reimplemented in Fl_Table.

Definition at line 102 of file Fl_Group.H.

References add().

Referenced by add().

void Fl_Group::add_resizable ( Fl_Widget o) [inline]

Adds a widget to the group and makes it the resizable widget.

Definition at line 158 of file Fl_Group.H.

Fl_Widget *const Fl_Group::array ( ) const
virtual Fl_Group* Fl_Group::as_group ( ) [inline, virtual]

Returns an Fl_Group pointer if this widget is an Fl_Group.

Use this method if you have a widget (pointer) and need to know whether this widget is derived from Fl_Group. If it returns non-NULL, then the widget in question is derived from Fl_Group, and you can use the returned pointer to access its children or other Fl_Group-specific methods.

Example:

      void my_callback (Fl_Widget *w, void *) {
        Fl_Group *g = w->as_group();
        if (g)
          printf ("This group has %d children\n",g->children());
        else
          printf ("This widget is not a group!\n");
      }
Return values:
NULLif this widget is not derived from Fl_Group.
Note:
This method is provided to avoid dynamic_cast.
See also:
Fl_Widget::as_window(), Fl_Widget::as_gl_window()

Reimplemented from Fl_Widget.

Definition at line 181 of file Fl_Group.H.

void Fl_Group::begin ( )

Sets the current group so you can build the widget tree by just constructing the widgets.

begin() is automatically called by the constructor for Fl_Group (and thus for Fl_Window as well). begin() is exactly the same as current(this). Don't forget to end() the group or window!

Reimplemented in Fl_Table.

Definition at line 74 of file Fl_Group.cxx.

Referenced by fl_addto_form(), Fl_Group(), Fl_Table::Fl_Table(), and read_fdesign().

Fl_Widget* Fl_Group::child ( int  n) const [inline]

Returns array()[n]. No range checking is done!

Reimplemented in Fl_Table.

Definition at line 83 of file Fl_Group.H.

Referenced by clear(), Fl_Tabs::client_area(), Fl_Pack::draw(), Fl_Tabs::handle(), remove(), toggle_sourceview_cb(), and Fl_Tabs::which().

void Fl_Group::clear ( )

Deletes all child widgets from memory recursively.

This method differs from the remove() method in that it affects all child widgets and deletes them from memory.

Reimplemented in Fl_Browser, Fl_Check_Browser, Fl_Input_Choice, Fl_Scroll, Fl_Table, Fl_Table_Row, and Fl_Tree.

Definition at line 386 of file Fl_Group.cxx.

References array(), child(), Fl_Widget::contains(), i, init_sizes(), Fl_Widget::parent(), Fl::pushed(), and Fl_Widget::w().

Referenced by Fl_Tree::remove(), Fl_Browser::~Fl_Browser(), and ~Fl_Group().

unsigned int Fl_Group::clip_children ( ) [inline]

Returns the current clipping mode.

Returns:
true, if clipping is enabled, false otherwise.
See also:
void Fl_Group::clip_children(int c)

Definition at line 178 of file Fl_Group.H.

References Fl_Widget::flags().

Referenced by draw_children().

void Fl_Group::clip_children ( int  c) [inline]

Controls whether the group widget clips the drawing of child widgets to its bounding box.

Set c to 1 if you want to clip the child widgets to the bounding box.

The default is to not clip (0) the drawing of child widgets.

Definition at line 170 of file Fl_Group.H.

References Fl_Widget::clear_flag(), and Fl_Widget::set_flag().

void Fl_Group::current ( Fl_Group g) [static]

Sets the current group.

See also:
Fl_Group::current()

Definition at line 95 of file Fl_Group.cxx.

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

Draws the widget. Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must be redrawn as soon as possible, call redraw() instead.

Override this function to draw your own widgets.

If you ever need to call another widget's draw method from within your own draw() method, e.g. for an embedded scrollbar, you can do it (because draw() is virtual) like this:

        Fl_Widget *s = &scroll;         // scroll is an embedded Fl_Scrollbar
        s->draw();                      // calls Fl_Scrollbar::draw()

Implements Fl_Widget.

Reimplemented in Fl_Browser_, Fl_Gl_Window, Fl_Pack, Fl_Scroll, Fl_Table, Fl_Tabs, Fl_Text_Display, Fl_Tree, Fl_Window, Fl_Glut_Window, and Fl_TooltipBox.

Definition at line 741 of file Fl_Group.cxx.

References Fl_Widget::damage(), Fl_Widget::draw_box(), draw_children(), Fl_Widget::draw_label(), and FL_DAMAGE_CHILD.

void Fl_Group::draw_child ( Fl_Widget widget) const [protected]

Forces a child to redraw.

This draws a child widget, if it is not clipped. The damage bits are cleared after drawing.

Definition at line 771 of file Fl_Group.cxx.

References Fl_Widget::clear_damage(), Fl_Widget::draw(), FL_DAMAGE_ALL, fl_not_clipped(), FL_WINDOW, Fl_Widget::h(), Fl_Widget::type(), Fl_Widget::visible(), Fl_Widget::w(), Fl_Widget::x(), and Fl_Widget::y().

Referenced by Fl_Tabs::draw(), Fl_Scroll::draw(), Fl_Pack::draw(), Fl_Browser_::draw(), and draw_children().

void Fl_Group::draw_children ( ) [protected]

Draws all children of the group.

This is useful, if you derived a widget from Fl_Group and want to draw a special border or background. You can call draw_children() from the derived draw() method after drawing the box, border, or background.

Definition at line 718 of file Fl_Group.cxx.

References array(), Fl_Widget::box(), Fl::box_dh(), Fl::box_dw(), Fl::box_dx(), Fl::box_dy(), clip_children(), Fl_Widget::damage(), draw_child(), draw_outside_label(), FL_DAMAGE_CHILD, fl_pop_clip(), fl_push_clip(), Fl_Widget::h(), update_child(), Fl_Widget::w(), Fl_Widget::x(), and Fl_Widget::y().

Referenced by Fl_Window::draw(), Fl_Tree::draw(), and draw().

int Fl_Group::find ( const Fl_Widget o) const

Searches the child array for the widget and returns the index. Returns children() if the widget is NULL or not found.

Reimplemented in Fl_Table.

Definition at line 57 of file Fl_Group.cxx.

References array(), and i.

Referenced by exit_cb(), insert(), Fl_File_Browser::load(), and remove().

int Fl_Group::find ( const Fl_Widget o) const [inline]

See int Fl_Group::find(const Fl_Widget *w) const

Reimplemented in Fl_Table.

Definition at line 88 of file Fl_Group.H.

References find().

Referenced by find().

void Fl_Group::focus ( Fl_Widget W) [inline]
Deprecated:
This is for backwards compatibility only. You should use W->take_focus() instead.
See also:
Fl_Widget::take_focus();

Definition at line 190 of file Fl_Group.H.

References Fl_Widget::take_focus().

Referenced by Fl_Tree::handle(), Fl_Text_Editor::handle(), Fl_Text_Display::handle(), Fl_Tabs::handle(), Fl_Table::handle(), handle(), and Fl_Browser_::handle().

void Fl_Group::forms_end ( )
int Fl_Group::handle ( int  event) [virtual]

Handles the specified event. You normally don't call this method directly, but instead let FLTK do it when the user interacts with the widget.

When implemented in a widget, this function must return 0 if the widget does not use the event or 1 otherwise.

Most of the time, you want to call the inherited handle() method in your overridden method so that you don't short-circuit events that you don't handle. In this last case you should return the callee retval.

Parameters:
[in]eventthe kind of event received
Return values:
0if the event was not used or understood
1if the event was used and can be deleted
See also:
Fl_Event

Reimplemented from Fl_Widget.

Reimplemented in Fl_Browser_, Fl_Check_Browser, Fl_Gl_Window, Fl_Scroll, Fl_Spinner, Fl_Table, Fl_Table_Row, Fl_Tabs, Fl_Text_Display, Fl_Text_Editor, Fl_Tile, Fl_Tree, Fl_Window, Fl_Glut_Window, CodeViewer, Widget_Browser, Overlay_Window, and menuwindow.

Definition at line 150 of file Fl_Group.cxx.

References Fl_Widget::active(), array(), Fl::belowmouse(), children(), Fl_Widget::contains(), Fl::e_number, Fl::event_inside(), Fl::event_key(), Fl_Widget_Tracker::exists(), FL_ACTIVATE, FL_DEACTIVATE, FL_DND_DRAG, FL_DND_ENTER, FL_Down, FL_DRAG, FL_ENTER, FL_Enter, FL_FOCUS, FL_HIDE, FL_KEYBOARD, FL_KP_Enter, FL_Left, FL_MOUSEWHEEL, FL_MOVE, fl_oldfocus, FL_PUSH, FL_RELEASE, FL_Right, FL_SHORTCUT, FL_SHOW, FL_UNFOCUS, FL_Up, focus(), Fl::focus(), Fl::focus_, Fl_Widget::handle(), i, Fl::pushed(), Fl_Widget::take_focus(), Fl_Widget::takesevents(), and Fl_Widget::visible().

Referenced by Fl_Tree::handle(), Fl_Text_Editor::handle(), Fl_Text_Display::handle(), Fl_Browser_::handle(), and Fl_Spinner::handle().

void Fl_Group::init_sizes ( )

Resets the internal array of widget sizes and positions.

The Fl_Group widget keeps track of the original widget sizes and positions when resizing occurs so that if you resize a window back to its original size the widgets will be in the correct places. If you rearrange the widgets in your group, call this method to register the new arrangement with the Fl_Group that contains them.

If you add or remove widgets, this will be done automatically.

Note:
The internal array of widget sizes and positions will be allocated and filled when the next resize() occurs.
See also:
sizes()

Reimplemented in Fl_Table.

Definition at line 575 of file Fl_Group.cxx.

Referenced by clear(), insert(), Fl_File_Chooser::ok_label(), Fl_File_Chooser::preview(), Fl_Table::recalc_dimensions(), and remove().

void Fl_Group::insert ( Fl_Widget o,
int  index 
)

The widget is removed from its current group (if any) and then inserted into this group. It is put at index n - or at the end, if n >= children(). This can also be used to rearrange the widgets inside a group.

Reimplemented in Fl_Table.

Definition at line 461 of file Fl_Group.cxx.

References find(), init_sizes(), Fl_Widget::parent(), and remove().

Referenced by add(), and fl_insert_object().

void Fl_Group::insert ( Fl_Widget o,
Fl_Widget before 
) [inline]

This does insert(w, find(before)). This will append the widget if before is not in the group.

Reimplemented in Fl_Table.

Definition at line 108 of file Fl_Group.H.

References insert().

Referenced by insert().

void Fl_Group::remove ( Fl_Widget o)

Removes a widget from the group but does not delete it.

This method does nothing if the widget is not a child of the group.

This method differs from the clear() method in that it only affects a single widget and does not delete it from memory.

Note:
If you have the child's index anyway, use remove(int index) instead, because this doesn't need a child lookup in the group's table of children. This can be much faster, if there are lots of children.

Reimplemented in Fl_Table.

Definition at line 540 of file Fl_Group.cxx.

References find(), and i.

void Fl_Group::remove ( int  index)

Removes the widget at index from the group but does not delete it.

This method does nothing if index is out of bounds.

This method differs from the clear() method in that it only affects a single widget and does not delete it from memory.

Since:
FLTK 1.3.0

Reimplemented in Fl_Browser, and Fl_Check_Browser.

Definition at line 506 of file Fl_Group.cxx.

References child(), and init_sizes().

Referenced by Fl_File_Chooser::add_extra(), fl_delete_object(), Fl_Value_Input::Fl_Value_Input(), insert(), Fl_File_Chooser::~Fl_File_Chooser(), and Fl_Widget::~Fl_Widget().

void Fl_Group::remove ( Fl_Widget o) [inline]

Removes the widget o from the group.

See also:
void remove(Fl_Widget&)

Definition at line 115 of file Fl_Group.H.

void Fl_Group::resizable ( Fl_Widget o) [inline]

The resizable widget defines the resizing box for the group. When the group is resized it calculates a new size and position for all of its children. Widgets that are horizontally or vertically inside the dimensions of the box are scaled to the new size. Widgets outside the box are moved.

In these examples the gray area is the resizable:

resizebox1.png
resizebox2.png

The resizable may be set to the group itself, in which case all the contents are resized. This is the default value for Fl_Group, although NULL is the default for Fl_Window and Fl_Pack.

If the resizable is NULL then all widgets remain a fixed size and distance from the top-left corner.

It is possible to achieve any type of resize behavior by using an invisible Fl_Box as the resizable and/or by using a hierarchy of child Fl_Group's.

Definition at line 150 of file Fl_Group.H.

void Fl_Group::resize ( int  X,
int  Y,
int  W,
int  H 
) [virtual]
int * Fl_Group::sizes ( ) [protected]

Returns the internal array of widget sizes and positions.

If the sizes() array does not exist, it will be allocated and filled with the current widget sizes and positions.

Note:
You should never need to use this method directly, unless you have special needs to rearrange the children of a Fl_Group. Fl_Tile uses this to rearrange its widget positions.
See also:
init_sizes()
Todo:
Should the internal representation of the sizes() array be documented?

Definition at line 593 of file Fl_Group.cxx.

References array(), FL_WINDOW, Fl_Widget::h(), resizable(), Fl_Widget::type(), Fl_Widget::w(), Fl_Widget::x(), and Fl_Widget::y().

Referenced by Fl_Tile::handle(), Fl_Tile::position(), Fl_Tile::resize(), and resize().

void Fl_Group::update_child ( Fl_Widget widget) const [protected]

Draws a child only if it needs it.

This draws a child widget, if it is not clipped and if any damage() bits are set. The damage bits are cleared after drawing.

See also:
Fl_Group::draw_child(Fl_Widget& widget) const

Definition at line 757 of file Fl_Group.cxx.

References Fl_Widget::clear_damage(), Fl_Widget::damage(), Fl_Widget::draw(), fl_not_clipped(), FL_WINDOW, Fl_Widget::h(), Fl_Widget::type(), Fl_Widget::visible(), Fl_Widget::w(), Fl_Widget::x(), and Fl_Widget::y().

Referenced by Fl_Text_Display::draw(), Fl_Tabs::draw(), Fl_Scroll::draw(), Fl_Pack::draw(), Fl_Browser_::draw(), and draw_children().


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