On 06.04.2013 07:55, Greg Ercolano wrote:
> Is there a method that returns the top-level "window manager window"
> for the current widget?
>
> window() is not it; this just returns the parent window
> which won't be the top-level window when there are
> windows within windows, eg:
>
> Fl_Window *top = new Fl_Window(..);
> top->begin();
> Fl_Window *sub = new Fl_Window(..);
> sub->begin();
> :
>
> It seems unlikely we don't have such a thing, but I think
> supporting nested windows is something recent, and I see
> places in our code that do inline loops instead of calling a method.
>
> If there isn't such a method, would like to suggest we add one,
> the code being something like:
>
> ---
> Fl_Window *Fl_Widget::toplevel_window() const {
> Fl_Window *top = window();
> while (top && top->window()) top = top->window();
> return top;
> }
> ---
>
> Comments?
ISTR that we discussed adding such a method a while ago, and that
it probably wasn't done for some reasons. However, thinking about
it, I don't know what this might have been. Too simple ? What, if
the top-level window still has a (non-window) parent widget? Does
it matter ? I don't know.
Anyway, since it's not much code, could we probably add it to the
header file as an inline method ? I think so. If there were a vote
request, my vote would be +1, unless there are reasons not to do
it that I don't know of (yet). Other opinions, votes?
BTW: toplevel_window() doesn't look bad, but what about top_window().
Less typing ;-)
Albrecht
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev