[...]

> It's easy to do spacing with a minimal subroutine to save current
> positions, add some pixels, or do anything you like.

Here my 10 minutes attemp before sleep...
You were right quite easy. I will try to make one that can be use nested.
Thanks.


#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>

struct HPacker {
    HPacker(int b, int X, int Y, int W, int H) : border(b), currentX(border) {
        g = new Fl_Group( border + X, border + Y, W - 2 * border, H );
    }
   void end() {
        Fl_Box* b = new Fl_Box(currentX, g->y(), 1, g->h() );
        b->hide();
        g->resizable( b );
        g->end();
    }
    Fl_Button* packButton( int W, int H, const char* label ) {
        Fl_Button* button = new Fl_Button( currentX, g->y(), W, H, label );
        currentX += border + W;
        return button;
    }
    Fl_Group* g;
    int border;
    int currentX;
};

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 ) );

     HPacker packer( border, 0, box->h() + border, w->w(), 30 );
     Fl_Button* b1 = packer.packButton( 100, 30, "Go Up" );
     Fl_Button* b2 = packer.packButton( 100, 30, "Go Down" );
     Fl_Button* b3 = packer.packButton( 100, 30, "Go Left" );
     Fl_Button* b4 = packer.packButton( 100, 30, "Go Right" );
     packer.end();

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

int main( int argc, char** argv ) {
  Fl_Window* first = FirstTry(800, 600);
  first->show();
  return Fl::run();
}

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

Reply via email to