FLTK - Simple Dropdown menu in C++
FLTK is free lightweight gui toolkit for generating windowed guis. It is designed to be cross-platform compatible (you can compile it in win32,linux,mac etc). It is a nice alternative to MFC or other proprietary gui builders.
Here is a simple File/Edit drop down menu chunk of source code.
#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Menu_Bar.H>
void quit_cb(Fl_Widget*, void*) { /*exit(0); */}
Fl_Menu_Item menutable[] = {
{"&File",0,0,0,FL_SUBMENU},
{"&Open", FL_ALT+'o', 0, 0, FL_MENU_INACTIVE},
{"&Close", 0, 0},
{"&Quit", FL_ALT+'q', quit_cb, 0, FL_MENU_DIVIDER},
{0},
{"&Edit",FL_F+2,0,0,FL_SUBMENU},
{"Undo", FL_ALT+'z', 0},
{"Redo", FL_ALT+'r', 0, 0, FL_MENU_DIVIDER},
{"Cut", FL_ALT+'x', 0},
{"Copy", FL_ALT+'c', 0},
{"Paste", FL_ALT+'v', 0},
{"Inactive",FL_ALT+'d', 0, 0, FL_MENU_INACTIVE},
{"Clear", 0, 0, 0, FL_MENU_DIVIDER},
{"Invisible",FL_ALT+'e', 0, 0, FL_MENU_INVISIBLE},
{"Preferences",0, 0},
{"Size", 0, 0},
{0},
{0}
};
int main(int argc, char **argv) {
Fl_Window window(600,400);
Fl_Menu_Bar menubar(0,0,600,30);
menubar.menu(menutable);
window.size_range(300,400,0,400);
window.end();
window.show(argc, argv);
return Fl::run();
}code snippets are licensed under Creative Commons CC-By-SA 3.0 (unless otherwise specified)
|