Manoj wrote:
> Suppose first i create a new window. Suppose window contains some menu. If i
> click on any menu item then i new dialog dhould be display. I want to add
> some controls(like any button, group) to this dialog.
> how to do that?
You should hang out on fltk.general to ask these questions.
fltk.developer is for people managing FLTK, or modifying it.
fltk.general is for general questions about fltk.
There's many example FLTK programs in the fltk/test directory,
and here: http://seriss.com/people/erco/fltk/
Here's an example of what you describing:
#include <stdio.h>
#include <stdlib.h>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Menu_Bar.H>
// A 'customizable dialog window' with buttons
class SomeDialog : public Fl_Window {
Fl_Button *but1; // two buttons in this dialog
Fl_Button *but2;
public:
// CTOR
SomeDialog(int W=400, int H=200, const char *L="Some Dialog") :
Fl_Window(W,H,L) {
// Create the buttons, end the window
but1 = new Fl_Button(10,10,100,25,"Button 1");
but2 = new Fl_Button(10,40,100,25,"Button 2");
end();
}
};
// A customizable 'application window'
// Not all that different from SomeDialog.. both are derived from Fl_Window.
//
class YourApp : public Fl_Window {
Fl_Menu_Bar *menubar; // your app's menubar
SomeDialog *dialog; // your app's dialog window
// Callback to show the dialog
static void ShowDialog_CB(Fl_Widget*,void*userdata) {
YourApp *app = (YourApp*)userdata;
app->dialog->show();
}
// Callback to exit the program
static void Quit_CB(Fl_Widget*,void*userdata) {
exit(0);
}
public:
// CTOR
YourApp(int W, int H, const char *L) : Fl_Window(W,H,L) {
// Create a menu bar and a couple of items, assign callbacks, end the
window
menubar = new Fl_Menu_Bar(0,0,W,25);
menubar->add("File/Show Dialog", FL_COMMAND+'p', ShowDialog_CB,
(void*)this);
menubar->add("File/Quit", FL_COMMAND+'q', Quit_CB,
(void*)this);
end();
// Create an instance of the dialog, but do not show it
dialog = new SomeDialog();
}
};
int main() {
// CREATE AN INSTANCE OF YOUR APP WINDOW
YourApp *appwin = new YourApp(400, 400, "Window With Menu");
appwin->resizable(appwin);
appwin->show();
return(Fl::run());
}
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev