FLTK::Group - Base class for all container widgets
The FLTK::Group class is the FLTK container widget. It maintains an array of child widgets. These children can themselves be any widget including FLTK::Group, nesting groups allows much more control over layout and resize behavior. Nested groups are also necessary to group radio buttons together.
By default FLTK::Group preserves the positions and sizes of all it's children, they do not move no matter what sizes or other children are added or removed.
resizable() will change the layout behavior so that it responds to resizing by moving or resizing the children to fit.
See below for details.
The most-used subclass of FLTK::Group is FLTK::Window,
all the rules about resizing apply to windows.
resizable() on a window will allow the user to resize it.
If you want different behavior (such as from FLTK::Pack) for your window you should make the window have that as a single resizable child that fills it.
FLTK::Menu is a subclass and thus all menus and browsers are groups and the items in them are widgets.
my $widget = $group->add( $widget );
The widget is removed from its current group (if any) and then added to the end of this group.
Don't forget to
end() the group or window!
my $kid = $group->child( $index );
Returns a child,
index >= 0 && index < children().
Range checking is done internally!
my $kids = $group->children( );
Returns how many child widgets the group has.
Deletes all children from the group and makes it empty. This calls the destructor on all the children.
my $group = $group->current( );
Returns the group being currently built.
The Widget constructor automatically does
current()->add($widget) if this is not undef.
To prevent new widgets from being added to a group,
$group->current( $group );
Sets the group being currently built.
Exactly the same as
Any new widgets added to the widget tree will be added to the parent of the group.
my $index = $group->find( $widget );
$group->focus_index( $index );
The index of the widget that contains the focus.
You can initialize this before the group is displayed.
Changing it while it is displayed does not work,
For some subclasses such as TabGroup, a negative number indicates that the group itself has the focus. In most cases any illegal value means it will search for any widget that accepts focus.
my $index = $group->focus_index( );
Returns the index of the widget currently having focus.
Indicate that all the remembered child sizes should be reinitialized.
The group remembers the initial size of itself and all it's children, so that the layout can be restored even if the group is resized so that some children go to zero or negative sizes.
This can produce unwanted behavior if you try to rearrange the child widgets yourself,
as the next resize will put them right back where they were initially.
Call this to make it forget all the saved sizes and reinitialize them during the next
This is automatically done when any child is added or removed.
my $widget = $group->insert( $widget, $index );
widget in the <index>th position of this group's stack.
my $widget = $group->insert( $widget, $before );
This will append the widget if
$beforethis is not in the group.
my $key = $group->navigation_key( );
Turn Tab into Right or Left for keyboard navigation.
my $grp = $group->new( $x, $y, $w, $h, $label, $begin );
Creates a new
FLTK::Group widget using the given position,
and label string.
The default boxtype is
$group->remove( $index );
indexth widget from the group.
$group->remove( $widget );
widget from the group.
This does nothing if the widget is not currently a child of this group.
Removes all widgets from the group. This does not call the destructor on the child widget.
my $widget_b = $group->replace( $index, $widget_b );
indexth widget and inserts
widget_b in its place.
my $widget_b = $group->replace( $widget, $widget_b );
widget and inserts
widget_b in its place.
$group->resizable( $widget );
Sets the resizing widget.
my $elastic = $group->resizable( );
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.
The resizable may be set to the group itself, in which case all the contents are resized. If the resizable is undef (the default) then all widgets remain a fixed size and distance from the top-left corner.
$group->swap( $indexA, $indexB );
indexAth widget with the
Sanko Robinson <firstname.lastname@example.org> - http://sankorobinson.com/
Copyright (C) 2008-2010 by Sanko Robinson <email@example.com>
This program is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0. See the LICENSE file included with this distribution or notes on the Artistic License 2.0 for clarification.
When separated from the distribution, all original POD documentation is covered by the Creative Commons Attribution-Share Alike 3.0 License. See the clarification of the CCA-SA3.0.