On 12.12.2011 17:36, MacArthur, Ian (SELEX GALILEO, UK) wrote: > OK, I just tested, and it does work - but they window has to be mapped > first, so simply calling show() on it is not enough, the window actually > has to have been drawn...
Yep, that's one of the problems with Fl_Pack I discussed with Bill in a recent thread, maybe in fltk.development. Fl_Pack resizes its children (i.e. does its job to *pack* them as requested) in its draw() method. Before you draw() it, you can (re-)arrange the children as you like, but then their positions and sizes get changed within the group. Whenever you call resize() on this group after this, the relative sizes and positions get saved within the Fl_Group's own sizes() array, and thereafter resizing works as expected (with normal groups at least, but obviously also with Fl_Pack). In the non-working case, the buttons and other contents of the Fl_Pack group get their initial positions saved internally *before* they are drawn, i.e. before Fl_Pack had a chance to calculate the proper positions and sizes. At least that's what I understand from reading the code. Calling init_sizes() at a certain point in that process might help, but I tried and didn't succeed - gave up. Back to Ian's solution: calling Fl::check() once (Windows) or twice (X11) instead of adding the timeout and waiting seems to do the job as well, something like this: ... // resize the window programaticaly, after it is mapped else if (argc == 1) { Fl::check(); Fl::check(); second->size(900,700); } I believe that I tested it, but I deleted it before finishing this posting. Anyway, I agree with Ian that using Fl_Groups and their built-in resizing behavior is often easier than trying to use (maybe nested) Fl_Pack's. Only the *initial* sizes and positions of widgets inside the groups are more difficult [1] to calculate, but resizing it then done automatically. Albrecht [1] actually it's not difficult, just a little work to be done ;-) _______________________________________________ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk