On 06/14/11 08:16, asif saeed wrote:
> int main(int argc, char **argv)
> [..]
The important thing is to end() the group widgets
(window and group) before creating the other widgets,
otherwise those groups will absorb the widgets that follow.
Also, I don't *think* it's necessary to call begin()/end()
around each add(). The begin() and end() stuff is to control
the 'automated' inclusion of widgets, which is relevant when
you create widgets.
Note that when you do:
Fl_Window *win = new ..; // implies begin()
Fl_Button *but = new ..; // becomes parented to window
win->end(); // ends the window
..the begin() is implied for the win, so if you don't want
but to become parented to it, you have to end() the win first.
Ditto for groups, and all widgets that derive from groups.
Here's how I would do it. Note the added end()'s to prevent
the implied auto-parenting. Also, I show() the window last.
You don't need to call show() for everything, just the window.
---
#include <FL/Fl_Window.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Button.H>
#include <FL/Fl.H>
int main(int argc, char **argv)
{
// CREATE A PANEL
Fl_Group *flow_panel = new Fl_Group(2,2,100,100);
flow_panel->color(FL_RED); // for debugging
flow_panel->box(FL_FLAT_BOX); // for debugging
flow_panel->end(); // end the group! (so it doesnt absorb
widgets that follow
// CREATE A BUTTON
Fl_Button *button1 = new Fl_Button(2,2,80,40,"Hello");
// CREATE A WINDOW
Fl_Window *window = new Fl_Window(2,2,300,300);
window->end(); // end the window!
// NOW START PARENTING THE WIDGETS
flow_panel->add(button1);
window->add(flow_panel);
window->show(); // do this last
return(Fl::run());
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk