>> i mean for example imagine a grid of 'buttons'..
>
> I'd suggest using an Fl_Tile and procedurally adding
> the buttons to that with a for() loop.
Actually, the Fl_Tile isn't even necessary with the procedural
technique; you can just add the buttons directly to the window
(or an encompassing group), setting the positions based on the loop.
The below is a simple example that makes an A-Z dialog window
of buttons, where each button generates a callback that prints
the button's label.
You can resize the window, and all the buttons grow to follow
its size as you'd expect.
* * *
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
//
// Make a grid of buttons
//
static void Button_CB(Fl_Widget *w, void*) {
fprintf(stderr, "You hit '%s'\n", w->label());
}
int main(int argc, char **argv) {
char s[2];
int nboxes = 0;
Fl_Window *win = new Fl_Window(220,260, "test");
for ( int yy=10; yy<win->h()-40; yy += 40 ) {
for ( int xx=10; xx<win->w()-40; xx += 40 ) {
sprintf(s, "%c", 'A'+nboxes); ++nboxes; // label for each button
Fl_Button *but = new Fl_Button(xx,yy,40,40);
but->copy_label(s);
but->callback(Button_CB);
}
}
win->resizable(win);
win->end();
win->show(argc,argv);
return(Fl::run());
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk