goeb wrote:
> I am wondering if there is a way to known what size takes a group of
> widgets. In other words: the smallest rectangle which contains them all,
> including their labels.

        Yes, see below.

> If this is not possible for a group of widgets, is it possible for a single
> widget: get the rectangular size of the widget and its label ?

        The widget's own x()/y()/w()/h() should give you that.

        And with those values, you should be able to calculate a frame
        around many widgets just by looping through them, and getting the
        min/max of the x/y corners, eg:


int x1=0, x2=0, y1=0, y2 = 0;
for ( int t=0; t<grp->children(); t++ ) {
    Fl_Widget *ww = grp->child(t);
    if ( t == 0 ) {
        x1 = ww->x();
        y1 = ww->y();
        x2 = ww->x() + ww->w();
        y2 = ww->y() + ww->h();
    } else {
        x1 = min(x1, ww->x());
        y1 = min(y1, ww->y());
        x2 = max(x2, ww->x() + ww->w());
        y2 = max(y2, ww->y() + ww->h());
    }
}

        ..where min() and max() are integer versions of fmin/fmax.
        The resulting x1/x2/y1/y2 values should be a frame that
        defines a border around all the widgets.

        Above code is not tested.

        There might even be a built in fltk function that does this,
        but I don't know it offhand.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to