Hi all,
I have been trying to create an application (in fltk2.0). The
application has a single window which should contain different frames at
different times; much like JPanel's in java, or gtk_frames in gtk.
I tried to use fltk::Group class; but I am not able to find a way to replace
frames at runtime..like there is a mainWindow which contains a frame1 (instance
of fltk::Group class). frame1 has a button which on being clicked should remove
frame1 from mainWindow and attach frame2 to the mainWindow.
Here is the code:
#include <stdio.h>
#include <stdlib.h>
#include <fltk/run.h>
#include <fltk/Window.h>
#include <fltk/Button.h>
#include <fltk/TiledImage.h>
#include <fltk/SharedImage.h>
#include <fltk/InvisibleBox.h>
using namespace fltk;
class MainWindow : public Group {
Button button1;
Button button2;
Button button3;
static void btn_callback(Widget*, void* v) {
printf("hello world\n");
}
public:
MainWindow(const char* label=0) :
Group(0,0,240,270),
button1(110,10,100,20,"button1"),
button2(110,50,100,20,"button2"),
button3(110,100,100,20,"button3")
{
this->clear_visible();
this->hide();
button1.callback(btn_callback,this);
button2.callback(btn_callback,this);
button3.callback(btn_callback,this);
}
~MainWindow() {}
};
class samplewindow : public Window {
MainWindow main1;
// static void btn_callback(Widget*, void* v) {
// printf("hello world\n");
public:
samplewindow(const char* label=0) :
Window(0,0,240,270,label,true)
{
//clear_visible();
//hide();
}
~samplewindow() {}
};
int main(int argc, char ** argv) {
samplewindow window1("Window 1");
window1.show(argc,argv);
return run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk