Hi,
I need to create dynamically (at run-time with callbacks) widget groups,
but when adding buttons and sub-windows in the same group,
the buttons are shown ok, but the window not. What's wrong here..?
Below, Using the program example provided by greg, with an little variant,
to sample this question.
Any idea..?
Thank you.
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Button.H>
Fl_Window *window;
Fl_Group *flow_panel;
Fl_Button *button1;
Fl_Window *window1;
//------------------------------------------------------------------
//ADDING DYNAMIC WIDGETS to PARENT WIDGETS..!!
//------------------------------------------------------------------
void callback_add_widget(Fl_Widget *pWidget, void *)
{
flow_panel->add(button1);
flow_panel->add(window1);
window->add(flow_panel);
window->redraw();
}
//
// MAIN..
//
int main(int argc, char **argv)
{
// CREATE A PANEL (group)
flow_panel = new Fl_Group(2,2,300,300);
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
button1 = new Fl_Button(2,2,80,40,"Hello(group)");
// CREATE A SUBWINDOW
window1 = new Fl_Window(92,92,80,40,"Window(group)");
window1->color(fl_rgb_color(0,0,255));
window1->end();
// MAIN WINDOW
window = new Fl_Window(2,2,500,500);
window->color(fl_rgb_color(0,255,0));
Fl_Button *button2 = new Fl_Button(400,400,80,40,"add window(group)");
button2->callback(callback_add_widget,0);
window->end(); // end the window!
// NOW START PARENTING THE WIDGETS
/*--- code below, is passed to callback..
flow_panel->add(button1);
flow_panel->add(window1);
window->add(flow_panel);
---*/
window->show(); // do this last
return(Fl::run());
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk