> > I suspect (i.e. I haven't looked all that closely) that the 
> problem is
> > the order of events...
> >
> > > int main( int argc, char** argv ) {
> > >   Fl_Window* second =3D SecondTry( 350,50);
> > >   if ( argc > 1 ) second->size(800,600);
> > >   second->show();
> >
> > If argc is > 1 then size() is called before the second window
> > is shown.
> > The widget dimensions in the Fl_Packs are (I think) not really
> > set until the window is mapped, so if you change size() before the
> > window is fully shown, unexpected behaviours result... Maybe.
> 
> May be not. I have try. It changes nothing.

Huh?
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...

Hmm, OK, I'll post my test code below for comparisons...

> > Anyway, is this code just to illustrate your point?
> 
> Not exactly, I Try to make windows that looks like that and 
> fing a pretty straight forward to do it with fltk.
> It's a kind of proof of concept of the "usability" of the fltk layout.
> 
> > If not, if this is really what you need to do, then I wonder if
> > you need the Fl_Packs at all.
> > The default fltk resizing behaviour might get you what you want more
> > readily just with simple Fl_Groups...
> 
> It's quite annoying using Fl_Group with my fltk knowledge, too much
> border spacing computing and absolute positionning. 
> Logically, Fl_Pack should do the job for me without too much cost.

Well, I don't know, I find Fl_Pack to be more trouble than just setting
up the groups, but that may just be me...

Anyway, I think you can get the desired behaviour from your example -
see attached.

This has 3 states:

1) With no parameter, window is sized programmatically after being
mapped (by a crude brute force approach!)

2) With 1 parameter, the size() method is called before the window is
mapped.

3) With 2 parameters, the window is simply created the "right size".

Both (1) and (3) work, but (2) does not, so it is the mapping of the
window that is key here, it seems.

So if you can size the window before you create it, or after it is
mapped, I think all will be well.
If you try and size it before it is mapped, bad things can happen (but
then, if it is not yet mapped, you could presumably have created it the
"right" size in the first place?)



// Fleury Fl_Pack test //

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

Fl_Double_Window *SecondTry(int x, int y, int WW, int HH) {
    Fl_Double_Window* w = new Fl_Double_Window(WW, HH, "Pack Test");

    Fl_Pack* main = new Fl_Pack( 5, 5, WW-10, HH-10 );
    main->type(Fl_Pack::VERTICAL);
    main->spacing(10);

        Fl_Box* box = new Fl_Box(0,0,0,HH-50, "A Tree Widget" );
        box->box(FL_DOWN_BOX);
        box->color( fl_lighter( FL_GRAY ) );

        Fl_Pack* p = new Fl_Pack(0,0,0,30);
        p->type(Fl_Pack::HORIZONTAL);
        p->spacing(10);
            new Fl_Button(0,0,100, 1, "Go Up" );
            new Fl_Button(0,0,100, 1, "Go Down" );
        p->end();

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

Fl_Double_Window *second = NULL;

static void update(void *)
{
    if(second) {
        second->size(900,700);
    }
}

int main( int argc, char** argv ) {

    if(argc > 2) {
      second = SecondTry(350, 50, 800, 600);
    }
    else {
      second = SecondTry(350, 50, 300, 400);
    }

    second->show();

  // resize the window programaticaly, before it is mapped
  if ( argc == 2 )
  {
      second->size(800,600);
  }
    // resize the window programaticaly, after it is mapped
  else if (argc == 1)
  {
      Fl::add_timeout(1.0, update);
  }

  return Fl::run();
}

// end of file //


SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

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

Reply via email to