Class Group

(back to index)

The base widget container

Inherits from Widget

Subclasses: Pack  Scroll  Tabs  Tile  Window  

Property index

Fl_Group.currentchildrenresizable

Function index

addchildfind
begin_layoutend_layoutremove

Key properties

typenamesummary
Widget resizableWidget controlling resize behavior

Key functions

typenamesummary
void begin_layout()Place new widgets in this Group
void end_layout()Stop placing new widgets in this Group
void add(Widget o)Add widget to group

Description

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

When you create any Group, it becomes the default container for new widgets, until you call group:end_layout(). As a convenience, End{} is a shortcut for this.

When you call delete() on any Group, all of its children are also deleted. This is convenient for deleting an entire Window at a time, but you should be careful not to reference subwidgets after their parent has been deleted.

Detailed reference

begin_layout(): void

begin_layout() sets this Group as the container that new widgets will be created in. begin_layout() is automatically called when you create any Group (including Windows). begin_layout() is exactly the same as Fl_Group.current = this.

Don't forget to call end_layout() on the group or window when you're done adding widgets!

end_layout(): void

end_layout() completes adding widgets to this Group, and returns to adding widgets to the Group's parent. Call this after you're finished building this group's contents. end_layout() is exactly the same as Fl_Group.current = self.parent. Any new widgets added to the widget tree will be added to the parent of the group.

Fl_Group.current: Group

Fl_Group.current is the current active Group. New widgets you create are implicitly added to this group.

To prevent new widgets from being added to this group, set Fl_Group.current = nil.

children: readonly integer

children is the number of child widgets currently contained in this Group.

child(integer n): Widget

Returns the nth child widget contained in this Group, counting from 0. Currently, no range checking is performed, so make sure that 0 <= n < self.children.

find(Widget w): integer

Searches the child array for the widget and returns the index. Returns self.children if the widget is nil or not found.

add(Widget o): void

The widget is added to this group; if the widget is in another Group, it is removed first.

Normally, you won't use this much; begin_layout() and end_layout() are a simpler way of controlling where widgets end up.

remove(Widget o): void

Removes a widget from the group. This does nothing if the widget is not currently a child of this group.

resizable: Widget

Simple version: set group.resizable to the widget you want to get bigger or smaller when the user resizes the group.

If you have a Button b inside a Group g inside a Window w, set g.resizable = b; w.resizable = g.

Detailed version: 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:

  

The resizable may be set to the group itself (this is the default value for an Group, although nil is the default for an Window), in which case all the contents are resized. If the resizable is nil 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 Box as the resizable and/or by using a hierarchy of child Group's.


doctool generated at Sun Aug 12 22:23:17 2001