fltk  1.3.5-source
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X.
  Fossies Dox: fltk-1.3.5-source.tar.bz2  ("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:

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 *constarray () 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 ()
- Public Member Functions inherited from Fl_Widget
virtual ~Fl_Widget ()
int is_label_copied () const
Fl_Groupparent () const
void parent (Fl_Group *p)
uchar type () const
void type (uchar t)
int x () const
int y () const
int w () const
int h () const
int damage_resize (int, int, int, int)
void position (int X, int Y)
void size (int W, int H)
Fl_Align align () const
void align (Fl_Align alignment)
Fl_Boxtype box () const
void box (Fl_Boxtype new_box)
Fl_Color color () const
void color (Fl_Color bg)
Fl_Color selection_color () const
void selection_color (Fl_Color a)
void color (Fl_Color bg, Fl_Color sel)
const char * label () const
void label (const char *text)
void copy_label (const char *new_label)
void label (Fl_Labeltype a, const char *b)
Fl_Labeltype labeltype () const
void labeltype (Fl_Labeltype a)
Fl_Color labelcolor () const
void labelcolor (Fl_Color c)
Fl_Font labelfont () const
void labelfont (Fl_Font f)
Fl_Fontsize labelsize () const
void labelsize (Fl_Fontsize pix)
Fl_Imageimage ()
const Fl_Imageimage () const
void image (Fl_Image *img)
void image (Fl_Image &img)
Fl_Imagedeimage ()
const Fl_Imagedeimage () const
void deimage (Fl_Image *img)
void deimage (Fl_Image &img)
const char * tooltip () const
void tooltip (const char *text)
void copy_tooltip (const char *text)
Fl_Callback_p callback () const
void callback (Fl_Callback *cb, void *p)
void callback (Fl_Callback *cb)
void callback (Fl_Callback0 *cb)
void callback (Fl_Callback1 *cb, long p=0)
void * user_data () const
void user_data (void *v)
long argument () const
void argument (long v)
Fl_When when () const
void when (uchar i)
unsigned int visible () const
int visible_r () const
virtual void show ()
virtual void hide ()
void set_visible ()
void clear_visible ()
unsigned int active () const
int active_r () const
void activate ()
void deactivate ()
unsigned int output () const
void set_output ()
void clear_output ()
unsigned int takesevents () const
unsigned int changed () const
void set_changed ()
void clear_changed ()
void clear_active ()
void set_active ()
int take_focus ()
void set_visible_focus ()
void clear_visible_focus ()
void visible_focus (int v)
unsigned int visible_focus ()
void do_callback ()
void do_callback (Fl_Widget *o, long arg)
void do_callback (Fl_Widget *o, void *arg=0)
int test_shortcut ()
void _set_fullscreen ()
void _clear_fullscreen ()
int contains (const Fl_Widget *w) const
int inside (const Fl_Widget *wgt) const
void redraw ()
void redraw_label ()
uchar damage () const
void clear_damage (uchar c=0)
void damage (uchar c)
void damage (uchar c, int x, int y, int w, int h)
void draw_label (int, int, int, int, Fl_Align) const
void measure_label (int &ww, int &hh) const
Fl_Windowwindow () const
Fl_Windowtop_window () const
Fl_Windowtop_window_offset (int &xoff, int &yoff) const
virtual Fl_Windowas_window ()
virtual class Fl_Gl_Windowas_gl_window ()
int use_accents_menu ()
Fl_Color color2 () const
void color2 (unsigned a)

Static Public Member Functions

static Fl_Groupcurrent ()
static void current (Fl_Group *g)
- Static Public Member Functions inherited from Fl_Widget
static void default_callback (Fl_Widget *cb, void *d)
static unsigned int label_shortcut (const char *t)
static int test_shortcut (const char *, const bool require_alt=false)

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 ()
- Protected Member Functions inherited from Fl_Widget
 Fl_Widget (int x, int y, int w, int h, const char *label=0L)
void x (int v)
void y (int v)
void w (int v)
void h (int v)
unsigned int flags () const
void set_flag (unsigned int c)
void clear_flag (unsigned int c)
void draw_box () const
void draw_box (Fl_Boxtype t, Fl_Color c) const
void draw_box (Fl_Boxtype t, int x, int y, int w, int h, Fl_Color c) const
void draw_backdrop () const
void draw_focus ()
void draw_focus (Fl_Boxtype t, int x, int y, int w, int h) const
void draw_label () const
void draw_label (int, int, int, int) const

Private Member Functions

int navigation (int)
 Fl_Group (const Fl_Group &)
Fl_Groupoperator= (const Fl_Group &)

Private Attributes

Fl_Widget ** array_
int children_
int * sizes_

Static Private Attributes

static Fl_Groupcurrent_

Additional Inherited Members

- Protected Types inherited from Fl_Widget
enum  {
  INACTIVE = 1<<0, INVISIBLE = 1<<1, OUTPUT = 1<<2, NOBORDER = 1<<3,
  MENU_WINDOW = 1<<12, TOOLTIP_WINDOW = 1<<13, MODAL = 1<<14, NO_OVERLAY = 1<<15,
  USERFLAG3 = 1<<29, USERFLAG2 = 1<<30, USERFLAG1 = 1<<31

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.

The tab and arrow keys are used to move the focus between widgets of this group, and to other groups. The only modifier grabbed is shift (for shift-tab), so that ctrl-tab, alt-up, and such are free for the app to use as shortcuts.

Definition at line 41 of file Fl_Group.H.

Constructor & Destructor Documentation

◆ Fl_Group() [1/2]

Fl_Group::Fl_Group ( const Fl_Group )

◆ Fl_Group() [2/2]

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 363 of file Fl_Group.cxx.

References Fl_Widget::align(), array_, begin(), children_, FL_ALIGN_TOP, resizable_, savedfocus_, and sizes_.

◆ ~Fl_Group()

Fl_Group::~Fl_Group ( )

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 448 of file Fl_Group.cxx.

References clear().

Member Function Documentation

◆ _ddfdesign_kludge()

Fl_Widget* & Fl_Group::_ddfdesign_kludge ( )

This is for forms compatibility only

Definition at line 191 of file Fl_Group.H.

◆ add() [1/2]

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.

Definition at line 491 of file Fl_Group.cxx.

References children_, and insert().

Referenced by Fl_File_Chooser::add_extra(), Fl_Scroll::clear(), Fl_Widget::Fl_Widget(), live_mode_cb(), Fl_Widget_Class_Type::make(), and makeform().

◆ add() [2/2]

void Fl_Group::add ( Fl_Widget o)

See void Fl_Group::add(Fl_Widget &w)

Definition at line 98 of file Fl_Group.H.

References add().

Referenced by add().

◆ add_resizable()

void Fl_Group::add_resizable ( Fl_Widget o)

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

Definition at line 156 of file Fl_Group.H.

◆ array()

◆ as_group()

virtual Fl_Group* Fl_Group::as_group ( )

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.


void my_callback (Fl_Widget *w, void *) {
Fl_Group *g = w->as_group();
if (g)
printf ("This group has %d children\n",g->children());
printf ("This widget is not a group!\n");
Return values
NULLif this widget is not derived from Fl_Group.
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 179 of file Fl_Group.H.

◆ begin()

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!

Definition at line 69 of file Fl_Group.cxx.

References current_.

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

◆ child()

Fl_Widget* Fl_Group::child ( int  n) const

◆ children()

◆ clear()

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.

Definition at line 383 of file Fl_Group.cxx.

References array(), child(), children_, Fl_Widget::contains(), init_sizes(), Fl::pushed(), remove(), resizable_, savedfocus_, and Fl_Widget::w().

Referenced by Fl_Scroll::clear(), Fl_Browser::~Fl_Browser(), Fl_Check_Browser::~Fl_Check_Browser(), and ~Fl_Group().

◆ clip_children() [1/2]

unsigned int Fl_Group::clip_children ( )

Returns the current clipping mode.

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

Definition at line 176 of file Fl_Group.H.

References Fl_Widget::flags().

Referenced by draw_children().

◆ clip_children() [2/2]

void Fl_Group::clip_children ( int  c)

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 168 of file Fl_Group.H.

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

◆ current() [1/2]

◆ current() [2/2]

void Fl_Group::current ( Fl_Group g)

Sets the current group.

See also

Definition at line 90 of file Fl_Group.cxx.

References current_.

◆ draw()

void Fl_Group::draw ( )

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_Table, Fl_Tree, Fl_Text_Display, Overlay_Window, Fl_Help_View, Fl_Tabs, Fl_Window, Fl_Scroll, menuwindow, menutitle, CodeViewer, Fl_TooltipBox, Fl_Pack, Fl_Glut_Window, Fl_Wizard, and ColorMenu.

Definition at line 738 of file Fl_Group.cxx.

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

Referenced by Fl_Table::draw().

◆ draw_child()

void Fl_Group::draw_child ( Fl_Widget widget) const

◆ draw_children()

void Fl_Group::draw_children ( )

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 715 of file Fl_Group.cxx.

References array(), Fl_Widget::box(), Fl::box_dh(), Fl::box_dw(), Fl::box_dx(), Fl::box_dy(), children_, 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 draw(), and Fl_Window::draw().

◆ draw_outside_label()

◆ end()

◆ find() [1/2]

int Fl_Group::find ( const Fl_Widget o) const

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

Definition at line 84 of file Fl_Group.H.

References find().

Referenced by find().

◆ find() [2/2]

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.

Definition at line 52 of file Fl_Group.cxx.

References array(), and children_.

Referenced by exit_cb(), insert(), relative(), and remove().

◆ focus()

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

Definition at line 188 of file Fl_Group.H.

References Fl_Widget::take_focus().

◆ forms_end()

void Fl_Group::forms_end ( )

◆ handle()

int Fl_Group::handle ( int  event)

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.

[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

Reimplemented from Fl_Widget.

Reimplemented in Overlay_Window, Fl_Help_View, Fl_Window, Widget_Browser, Fl_Tabs, Fl_Scroll, menuwindow, Fl_Glut_Window, ColorMenu, Fl_Spinner, Fl_Table_Row, Fl_Tile, CodeViewer, Fl_Tree, Fl_Table, Fl_Text_Display, Fl_TooltipBox, and Fl_Text_Editor.

Definition at line 147 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, Fl::focus(), Fl::focus_, Fl_Widget::handle(), navigation(), navkey(), Fl::pushed(), savedfocus_, send(), Fl_Widget::take_focus(), Fl_Widget::takesevents(), and Fl_Widget::visible().

Referenced by Fl_Tile::handle(), Fl_Text_Editor::handle(), Fl_Spinner::handle(), Fl_Scroll::handle(), Fl_Text_Display::handle(), Fl_Browser_::handle(), Fl_Tabs::handle(), Fl_Window::handle(), Fl_Help_View::handle(), Fl_Table::handle(), and Fl_Tree::handle().

◆ init_sizes()

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.

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

Definition at line 572 of file Fl_Group.cxx.

References sizes_.

Referenced by clear(), Fl_Help_View::draw(), insert(), Fl_File_Chooser::ok_label(), Fl_Table::recalc_dimensions(), remove(), Fl_Tree::resize(), and Fl_Table::table_resized().

◆ insert() [1/2]

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.

Definition at line 458 of file Fl_Group.cxx.

References array_, children_, find(), init_sizes(), malloc(), Fl_Widget::parent(), Fl_Widget::parent_, and remove().

Referenced by add().

◆ insert() [2/2]

void Fl_Group::insert ( Fl_Widget o,
Fl_Widget before 

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

Definition at line 104 of file Fl_Group.H.

References find(), and insert().

Referenced by insert().

◆ navigation()

int Fl_Group::navigation ( int  key)

◆ operator=()

Fl_Group& Fl_Group::operator= ( const Fl_Group )

◆ remove() [1/3]

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.

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.

Definition at line 537 of file Fl_Group.cxx.

References children_, find(), and remove().

◆ remove() [2/3]

void Fl_Group::remove ( Fl_Widget o)

Removes the widget o from the group.

See also
void remove(Fl_Widget&)

Definition at line 111 of file Fl_Group.H.

References remove().

Referenced by remove().

◆ remove() [3/3]

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.

FLTK 1.3.0

Definition at line 503 of file Fl_Group.cxx.

References array_, child(), children_, free(), init_sizes(), Fl_Widget::parent_, and savedfocus_.

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

◆ resizable() [1/3]

◆ resizable() [2/3]

◆ resizable() [3/3]

void Fl_Group::resizable ( Fl_Widget o)

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, 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 148 of file Fl_Group.H.

◆ resize()

◆ sizes()

int * Fl_Group::sizes ( )

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.

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
Should the internal representation of the sizes() array be documented?

Definition at line 590 of file Fl_Group.cxx.

References array(), children_, FL_WINDOW, Fl_Widget::h(), p, resizable(), sizes_, 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().

◆ update_child()

void Fl_Group::update_child ( Fl_Widget widget) const

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 754 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_Wizard::draw(), Fl_Pack::draw(), Fl_Scroll::draw(), Fl_Browser_::draw(), Fl_Tabs::draw(), Fl_Text_Display::draw(), and draw_children().

Member Data Documentation

◆ array_

Fl_Widget** Fl_Group::array_

Definition at line 43 of file Fl_Group.H.

Referenced by array(), Fl_Group(), insert(), navigation(), and remove().

◆ children_

int Fl_Group::children_

◆ current_

Fl_Group * Fl_Group::current_

Definition at line 50 of file Fl_Group.H.

Referenced by begin(), current(), and end().

◆ resizable_

Fl_Widget* Fl_Group::resizable_

Definition at line 45 of file Fl_Group.H.

Referenced by clear(), and Fl_Group().

◆ savedfocus_

Fl_Widget* Fl_Group::savedfocus_

Definition at line 44 of file Fl_Group.H.

Referenced by clear(), Fl_Group(), handle(), and remove().

◆ sizes_

int* Fl_Group::sizes_

Definition at line 47 of file Fl_Group.H.

Referenced by Fl_Group(), init_sizes(), and sizes().

The documentation for this class was generated from the following files:
int w() const
Definition: Fl_Widget.H:294
Definition: Fl_Widget.H:101
Definition: Fl_Group.H:41
int children() const
Definition: Fl_Group.H:75
virtual void draw()=0