Inherited by fltk::AlignGroup, fltk::BarGroup, fltk::ColorChooser, fltk::HelpView, fltk::Menu, fltk::PackedGroup, fltk::ScrollGroup, fltk::StatusBarGroup, fltk::TabGroup, fltk::TextDisplay, fltk::TiledGroup, fltk::Window, and fltk::WizardGroup.
Public Member Functions | |
void | add (Widget *o) |
void | add (Widget &) |
void | add_resizable (Widget &o) |
void | begin () |
Widget * | child (int n) const |
int | children () const |
void | clear () |
void | draw () |
void | end () |
int | find (const Widget &o) const |
int | find (const Widget *) const |
void | fix_old_positions () |
int | focus_index () const |
void | focus_index (int v) |
Group (int, int, int, int, const char *=0, bool begin=false) | |
int | handle (int) |
void | init_sizes () |
void | insert (Widget &o, Widget *before) |
void | insert (Widget &, int index) |
void | layout () |
void | remove (Widget *o) |
void | remove (Widget &o) |
void | remove (int index) |
void | remove_all () |
void | replace (Widget &old, Widget &o) |
void | replace (int index, Widget &) |
Widget * | resizable () const |
void | resizable (Widget *o) |
void | resizable (Widget &o) |
void | resize_align (Flags f) |
Flags | resize_align () const |
void | set_focus (Widget *w) |
void | swap (int indexA, int indexB) |
virtual | ~Group () |
Static Public Member Functions | |
static void | current (Group *g) |
static Group * | current () |
static int | navigation_key () |
Protected Member Functions | |
void | draw_child (Widget &) const |
void | draw_outside_label (Widget &) const |
void | layout (const Rectangle &, int layout_damage) |
int * | sizes () |
void | update_child (Widget &) const |
Protected Attributes | |
int | initial_h |
int | initial_w |
Friends | |
void | end_group () |
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.
Setting resizable() will change the layout behavior so that it responds to resizing by moving or resizing the children to fit. See below for details.
You may want to use an fltk::Pack or a fltk::Scroll to get other common layout behavior that can respond to changes in the sizes of child widgets.
The most-used subclass of fltk::Group is fltk::Window, all the rules about resizing apply to windows. Setting 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.
Group::Group | ( | int | X, | |
int | Y, | |||
int | W, | |||
int | H, | |||
const char * | l = 0 , |
|||
bool | begin = false | |||
) |
Creates a new fltk::Group widget using the given position, size, and label string. The default boxtype is fltk::NO_BOX.
References fltk::ALIGN_BOTTOMRIGHT, fltk::ALIGN_TOP, fltk::ALIGN_TOPLEFT, begin(), fltk::Rectangle::h(), fltk::Widget::type(), and fltk::Rectangle::w().
int Group::children | ( | ) | const [inline] |
Returns how many child widgets the group has.
Reimplemented in fltk::Menu.
Referenced by fltk::Window::borders(), fltk::List::child(), fltk::List::children(), fltk::WizardGroup::draw(), fix_old_positions(), fltk::Menu::get_item(), fltk::Item::handle(), handle(), fltk::WizardGroup::next(), fltk::WizardGroup::prev(), remove_all(), fltk::TabGroup::selected_child(), fltk::Menu::set_item(), fltk::Widget::setonly(), fltk::Menu::try_popup(), fltk::WizardGroup::value(), and fltk::TabGroup::value().
Widget * Group::child | ( | int | n | ) | const [inline] |
Returns a child, n >= 0 && n < children(). No range checking is done!
Reimplemented in fltk::Menu.
Referenced by fltk::List::child(), fltk::List::children(), fltk::WizardGroup::draw(), fix_old_positions(), fltk::Menu::get_item(), fltk::Item::handle(), handle(), fltk::WizardGroup::next(), fltk::WizardGroup::prev(), fltk::TabGroup::selected_child(), fltk::Menu::set_item(), fltk::Widget::setonly(), fltk::WizardGroup::value(), and fltk::TabGroup::value().
int Group::handle | ( | int | event | ) | [virtual] |
Calls send() on some or all of the children widgets.
Reimplemented from fltk::Widget.
Reimplemented in fltk::ItemGroup.
References child(), children(), fltk::DND_DRAG, fltk::DND_ENTER, fltk::DND_LEAVE, fltk::DND_RELEASE, fltk::DownKey, fltk::DRAG, fltk::ENTER, fltk::event_x(), fltk::event_y(), find(), fltk::FOCUS, fltk::focus(), fltk::FOCUS_CHANGE, fltk::Rectangle::h(), fltk::Widget::handle(), fltk::key(), fltk::KEY, fltk::LEAVE, fltk::LeftKey, fltk::MOUSEWHEEL, fltk::MOVE, navigation_key(), fltk::Widget::parent(), fltk::PUSH, fltk::RELEASE, fltk::RightKey, fltk::Widget::send(), fltk::Widget::tab_to_focus(), fltk::Widget::take_focus(), fltk::Widget::takesevents(), fltk::UpKey, fltk::Rectangle::w(), fltk::Rectangle::x(), and fltk::Rectangle::y().
Referenced by fltk::Window::show().
void Group::begin | ( | ) | [inline] |
void Group::end | ( | ) | [inline] |
Group * Group::current | ( | ) | [inline, static] |
Returns the group being currently built. The fltk::Widget constructor automatically does current()->add(widget) if this is not null. To prevent new widgets from being added to a group, call Group::current(0).
Referenced by fltk::Browser::Browser(), fltk::Browser::column_labels(), fltk::handle(), fltk::modal(), fltk::StatusBarGroup::set(), fltk::Window::show(), fltk::Widget::throw_focus(), fltk::Menu::try_popup(), and fltk::Widget::Widget().
int Group::find | ( | const Widget * | widget | ) | const |
Searches the children for widget, returns the index of widget or of a parent of widget that is a child() of this. Returns children() if the widget is NULL or not found.
References fltk::Widget::parent().
Referenced by fltk::GlWindow::can_do(), fltk::Window::first(), handle(), fltk::Window::hotspot(), insert(), fltk::Tooltip::layout(), fltk::GlWindow::make_current(), and fltk::Widget::setonly().
void Group::add | ( | Widget & | o | ) |
The widget is removed from it's current group (if any) and then added to the end of this group.
References insert().
Referenced by fltk::Widget::Widget().
void Group::insert | ( | Widget & | o, | |
int | index | |||
) |
This does insert(w, find(beforethis)). This will append the widget if beforethis is not in the group.
References fltk::ACTIVATE, fltk::Widget::active(), fltk::Widget::active_r(), fltk::Widget::clear_flag(), fltk::DEACTIVATE, find(), fltk::Widget::flag(), fltk::Widget::handle(), fltk::INACTIVE_R, init_sizes(), fltk::Widget::parent(), remove(), fltk::Widget::set_flag(), fltk::SHOW, and fltk::Widget::visible_r().
Referenced by add().
void Group::remove | ( | int | index | ) |
Remove the indexed widget from the group.
References init_sizes(), fltk::NO_BOX, fltk::Widget::parent(), fltk::Widget::redraw(), and fltk::Widget::visible_r().
Referenced by insert(), and fltk::Widget::~Widget().
void Group::remove | ( | Widget & | widget | ) | [inline] |
Removes a widget from the group. This does nothing if the widget is not currently a child of this group.
void Group::remove_all | ( | ) |
Removes all widgets from the group. This does not call the destructor on the child widget (see clear()).
References children().
void Group::replace | ( | int | index, | |
Widget & | o | |||
) |
Remove the indexed widget and insert the passed widget in it's place.
References init_sizes(), and fltk::Widget::parent().
void Group::clear | ( | ) |
Deletes all children from the group and makes it empty. This calls the destructor on all the children!!!
Reimplemented from fltk::Widget.
References init_sizes(), and fltk::Widget::parent().
Referenced by ~Group().
Widget * Group::resizable | ( | ) | const [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.
Orignal size, the gray area is the resizable():
And here is the same Group resized larger:
The resizable may be set to the group itself, in which case all the contents are resized. If the resizable is NULL (the default) 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 InvisibleBox as the resizable and/or by using a hierarchy of child fltk::Group's.
Referenced by fltk::Window::borders(), fltk::Window::show(), and sizes().
void Group::init_sizes | ( | ) |
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 layout().
This is automatically done when any child is added or removed.
References fltk::Rectangle::h(), fltk::Widget::relayout(), and fltk::Rectangle::w().
int Group::focus_index | ( | ) | const [inline] |
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, use widget->take_focus() instead.
For some subclasses such as fltk::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.
This is also used by fltk::Menu to locate the item selected by the user. See fltk::Menu::get_item().
Reimplemented in fltk::Browser.
Referenced by fltk::Menu::get_item(), fltk::Menu::set_item(), fltk::TabGroup::TabGroup(), and fltk::Menu::value().
int Group::navigation_key | ( | ) | [static] |
Turn Tab into Right or Left for keyboard navigation
References fltk::CTRL, fltk::DownKey, fltk::event_key(), fltk::event_state(), fltk::LeftKey, fltk::RightKey, fltk::SHIFT, fltk::TabKey, and fltk::UpKey.
Referenced by handle().
void Group::fix_old_positions | ( | ) |
If this is a Group and not a Window, subtract x() and y() from the position of all children. This will fix the positions of widgets created for fltk1.1 that are inside a group.
References child(), children(), fltk::Widget::is_window(), fltk::Rectangle::x(), and fltk::Rectangle::y().
void Group::draw_child | ( | Widget & | w | ) | const [protected] |
Force a child to draw, by turning on DAMAGE_ALL and DAMAGE_EXPOSE, and calling it's draw() after temporarily translating so 0,0 in drawing coordinates is the upper-left corner. It's damage is then set to 0.
References fltk::DAMAGE_ALL, fltk::DAMAGE_EXPOSE, fltk::Widget::draw(), fltk::Widget::is_window(), fltk::not_clipped(), fltk::pop_matrix(), fltk::push_matrix(), fltk::Widget::set_damage(), fltk::translate(), fltk::Widget::visible(), fltk::Rectangle::x(), and fltk::Rectangle::y().
void Group::update_child | ( | Widget & | w | ) | const [protected] |
If the child's damage() is not zero, force it to update calling it's draw() after temporarily translating so 0,0 in drawing coordinates is the upper-left corner. It's damage is then set to 0.
References fltk::Widget::damage(), fltk::Widget::draw(), fltk::Widget::is_window(), fltk::not_clipped(), fltk::pop_matrix(), fltk::push_matrix(), fltk::Widget::set_damage(), fltk::translate(), fltk::Widget::visible(), fltk::Rectangle::x(), and fltk::Rectangle::y().
void Group::draw_outside_label | ( | Widget & | w | ) | const [protected] |
Groups normally call this to draw the label() outside a widget. This uses the flags() to determine where to put the label. If the ALIGN flags are all zero, or if ALIGN_INSIDE is turned on, then nothing is done. Otherwise the align is used to select a rectangle outside the widget and the widget's label() is formatted into that area.
The font is set to labelfont()/labelsize(), and labelcolor() is used to color the text. The flags are passed to the draw() function, but with the alignment changed to put the text against the widget, and INACTIVE is added if active_r() is false.
The image() of the widget is not drawn by this. It is always drawn inside the widget.
References fltk::ALIGN_BOTTOM, fltk::ALIGN_INSIDE, fltk::ALIGN_LEFT, fltk::ALIGN_RIGHT, fltk::ALIGN_TOP, fltk::Rectangle::b(), fltk::drawstyle(), fltk::Widget::flags(), fltk::Rectangle::h(), fltk::HIGHLIGHT, fltk::INVISIBLE, fltk::Widget::label(), fltk::Widget::labeltype(), fltk::OUTPUT, fltk::PUSHED, fltk::Rectangle::r(), fltk::Rectangle::set_b(), fltk::Rectangle::set_r(), fltk::Widget::style(), fltk::Rectangle::w(), fltk::Rectangle::x(), and fltk::Rectangle::y().
int * Group::sizes | ( | ) | [protected] |
Returns array of initial sizes of the widget and it's children.
The sizes() array stores the initial positions of widgets as left,right,top,bottom quads. The first quad is the group, the second is the resizable (clipped to the group), and the rest are the children. This is a convienent order for the algorithim.
This array is not calculated until the first time sizes() is called. It then returns the same array from then on. Calling init_sizes() deletes the array so the next call of this creates a new one.
References fltk::Rectangle::h(), fltk::Rectangle::r(), resizable(), fltk::Rectangle::w(), fltk::Rectangle::x(), and fltk::Rectangle::y().
Referenced by layout(), and fltk::Window::show().
void Group::layout | ( | const Rectangle & | r, | |
int | layout_damage | |||
) | [protected] |
Inner implementation of layout(). The child widgets are resized and positioned so that the area that was initially surrounded by this widget now fits inside the rectangle.
r is a rectangle, in the coordinate system of this Group (ie 0,0 is the top-left corner of the Group).
layout_damage controls what is done. If LAYOUT_W or LAYOUT_H are off then no resizing or moving of widgets in that direction is done.
This is used by ScrollGroup to resize the widgets to fit inside the scrollbars.
References fltk::ALIGN_BOTTOM, fltk::ALIGN_LEFT, fltk::ALIGN_RIGHT, fltk::ALIGN_TOP, fltk::Widget::flags(), fltk::Rectangle::h(), fltk::Widget::is_window(), fltk::Widget::layout(), fltk::LAYOUT_DAMAGE, fltk::Widget::layout_damage(), fltk::LAYOUT_H, fltk::LAYOUT_WH, fltk::LAYOUT_X, fltk::LAYOUT_XY, fltk::LAYOUT_Y, sizes(), fltk::Rectangle::w(), fltk::Rectangle::x(), and fltk::Rectangle::y().