On 12.12.2011 20:15, David FLEURY wrote:
> [...]
>
>>    // 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.
>
> It works fine.

But note that this is a bad hack. Relying on calling Fl::check() twice
can fail if there are timing problems, and it will probably do this in
a remote X11 situation. Please don't use it, it was only thought as a
test environment (to show what happened).

>> 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 ;-)
>
> Here what I have done using group for the same behavior.
> What afraid me, its in the case of more complex window,
> (I think of one of the Nedit window for exemple), the computation of the 
> button positioning can become quickly a nightmare.
> (at least Fl_Pack hide some with spacing parameters)

It's easy to do spacing with a minimal subroutine to save current
positions, add some pixels, or do anything you like. Don't write
coordinates literally - that *will* become a nightmare if you want
to add widgets later. Did you look at fluid for interactive layout?
Personally I don't use it, but lots of users do. It can use a grid
setup value (or similar, don't know) to aid you in positioning on
rows and columns, e.g. set it to 5, and fluid will only position
on every 5'th pixel (Menu: Layout/Grid and Size Settings (Ctrl+g)).

> Or may be, I have come the wrong way using Fl_Group.
>
> Fl_Double_Window *FirstTry(int WW, int HH) {
>      Fl_Double_Window* w = new Fl_Double_Window(WW, HH, "First Group Test");
>
>      const int border = 5;
>      Fl_Box* box = new Fl_Box(border,border,WW-2*border,HH-50-border, "A Tree 
> Widget" );
>      box->box(FL_DOWN_BOX);
>      box->color( fl_lighter( FL_GRAY ) );
>
>      Fl_Group* g = new Fl_Group(border,border + box->h() + 
> border,WW-2*border,30);
>      Fl_Button* b1 = new Fl_Button( border, border + box->h() + border, 100, 
> 30, "Go Up" );
>      Fl_Button* b2 = new Fl_Button( b1->x() + b1->w() + border, b1->y(),100, 
> 30, "Go Down" );
>      Fl_Box* b = new Fl_Box(b2->x() + b2->w(), b1->y(), 1, 30 );
>      b->hide();
>      g->resizable( b );
>      g->end();
>
>      w->resizable(box);
>      return w;
> }

Where's the problem? This looks perfectly well to me and works
for me (tested). See attached code. I did only add the headers
and the main function, and I changed *only* the initial window
size.

Albrecht

#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Box.H>

Fl_Double_Window *FirstTry(int WW, int HH) {
     Fl_Double_Window* w = new Fl_Double_Window(WW, HH, "First Group Test");

     const int border = 5;
     Fl_Box* box = new Fl_Box(border,border,WW-2*border,HH-50-border, "A 
Tree Widget" );
     box->box(FL_DOWN_BOX);
     box->color( fl_lighter( FL_GRAY ) );

     Fl_Group* g = new Fl_Group(border,border + box->h() + 
border,WW-2*border,30);
     Fl_Button* b1 = new Fl_Button( border, border + box->h() + border, 
100, 30, "Go Up" );
     Fl_Button* b2 = new Fl_Button( b1->x() + b1->w() + border, 
b1->y(),100, 30, "Go Down" );
     Fl_Box* b = new Fl_Box(b2->x() + b2->w(), b1->y(), 1, 30 );
     b->hide();
     g->resizable( b );
     g->end();

     w->resizable(box);
     return w;
}

int main( int argc, char** argv ) {
   Fl_Window* second = FirstTry( 350,500); // SecondTry( 350,50);
   if ( argc > 1 ) second->size(800,600);
   second->show();
   return Fl::run();
}

_______________________________________________
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to