Greg Ercolano wrote:
> Would it make sense to make a new method that does the following
> common coding pattern to find the inside area of a widget:
> 
>       int X = yourwidget->x() + Fl::box_dx(yourwidget->box());
>       int Y = yourwidget->y() + Fl::box_dy(yourwidget->box());
>       int W = yourwidget->w() - Fl::box_dw(yourwidget->box());
>       int H = yourwidget->h() - Fl::box_dh(yourwidget->box());

Yes, IMHO this would be useful.

> This seems to be a common coding pattern that could maybe be made
> into something much simpler, like:
> 
>     int X,Y,W,H;
>     Fl::inner_box(yourwidget,X,Y,W,H);
> 
> Maybe there is something like this, and I'm just not finding it..?

I'm not aware of such an existing method, but there is a similar
problem to find the widget's area inside the scrollbars, and
there are (estimated) at least two widgets with a bbox()
method. Note: these are two different things.

However, IMHO this should not be in the Fl class, but in
Fl_Widget.

My proposal for such an inner_box() method is:

virtual Fl_Widget::inner_box(int X, int Y, int W, int H);

It should be virtual, so that a widget with a custom draw
method can override the default method to provide its own
correct inner_box() values. The default implementation would
be as proposed above.

Maybe there could be an additional optional argument (flag)
to return the inside area of the scrollbars instead:

virtual Fl_Widget::inner_box(int X, int Y, int W, int H, int scroll=0);

Fl_Scroll would then implement this method to account for the
scrollbars, if scroll=1.

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

Reply via email to