Fl_Widget | +----Fl_Menu_----Fl_Menu_Item | +----Fl_Choice, Fl_Menu_Bar, Fl_Menu_Button
#include <FL/Fl_Menu_.H>
The class contains a pointer to an array of structures of type Fl_Menu_Item. These describe the contents of the menu. Usually the array is a large initialization constant, but there are methods to build it dynamically.
Currently there can be only one global() menu. Setting a new one
will replace the old one. There is no way to remove the global()
setting (including destroying the menu).
const char* Fl_Menu_::text() const
Returns the title of the last item chosen, or of item i.
const char* Fl_Menu_::text(int i) constint Fl_Menu_::size() const
This returns menu()->size(), which is how many entries are in
the array, not counting the NULL ending, but including all
submenus titles and the NULL's that end them. If the menu is
NULL this returns zero.
int Fl_Menu_::add(const char *,const char *,Fl_Callback *,void *v=0,int f=0)
The first form adds a new menu item, with a title string,
shortcut string, callback, argument to the callback,
and flags. If menu() was originally set with NULL
then space is allocated for the new item. If instead you gave it an
array then the array must have enough empty space for the new item.
The title string is copied, but the shortcut is not.
int Fl_Menu_::add(const char *)
The second form splits the string at any | characters and then does add(s,0,0,0,0) with each section. This is often useful if you are just using the value, and is compatable with some Forms programs.
Text is a string of the form "foo/bar/baz", this example will result in a submenu called "foo" and one in that called "bar" and and entry called "baz". The text is copied to new memory and can be freed. The other arguments are copied into the menu item unchanged.
If an item exists already with that name then it is replaced with this new one. Otherwise this new one is added to the end of the correct menu or submenu. The return value is the offset into the array that the new entry was placed at.
No bounds checking is done, the table must be big enough for all the entries you plan to add. Don't forget that there is a NULL terminator on the end, and the first time a item is added to a submenu three items are added (the title and the NULL terminator, as well as the actual menu item)
The return value is the index into the array that the entry was put.