On 28.04.2011 11:00, Paul R wrote:

> ... One of the
> problems i am facing is finding out the status of a large number of
> checkboxes.
>
> Say i needed to step through each of the children of my Fl_Group
> how can i go about that, I am experimenting with some of the member
> functions shown in the docs but without getting anything going so far.

Iterating all children of an Fl_Group is easy. You can use children()
to get the no. of children and use child(i) to get each child.

> I need to look at each Fl_Check_Button in the group and ask something
> like " if(chkBtn->value()) "

Given the above, you will have to cast the widget pointer to a valid
Fl_Check_Button* pointer, and that is the trickier part if you don't
know which of the children are check buttons and which might be other
widget types. FLTK doesn't use dynamic_cast, but if you can use it in
your application (i.e. if you have the proper runtime support in your
compiler/build environment), then you can use it, maybe like this:

   for (int i=0; i < group->children(); i++) {
     Fl_Widget *w = group->child(i);
     Fl_Check_Button* b = dynamic_cast<Fl_Check_Button*>(w);
     if (b) {
       int v = b->value();
       // use value ...
     }
   }

Although you can also use type(), I don't recommend using it, because
this wouldn't be unique among different classes of widgets (e.g.
FL_TOGGLE_BUTTON == 1, but some other type value can be 1 as well).

OTOH, if you need the check buttons for specific tasks, then you will
probably have appropriately named variables (pointers to Fl_Check_Buttons)
anyway, and then you can use these directly.

Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to