class Fl_Menu_ : public Fl_Widget
This is the base class for all widgets that contain a menu, including
Fl_Menu_Button, Fl_Choice, and Fl_Menu_Bar. This base class provides the
methods for setting or modifying the menu.
The menu is an array of Fl_Menu objects. You may either declare the
array yourself, or call methods on this object to construct it's own array.
Fl_Menu_::~Fl_Menu_();
The destructor deletes its own storage if it has allocated a menu.
const Fl_Menu* Fl_Menu_::menu() const ;
void Fl_Menu_::menu(const Fl_Menu*);
Get or set the menu array directly. Setting it to null indicates that
you want the widget to allocate its own array.
int Fl_Menu_::value() const ;
const Fl_Menu* Fl_Menu_::mvalue() const;
int Fl_Menu_::value(int);
int Fl_Menu_::value(const Fl_Menu*);
The value is the index into the Fl_Menu array of the last item chosen
by the user. It is zero initially. You can set it as an integer, or
set it with a pointer to a menu item. The set routines return
non-zero if the new value is different than the old one.
int Fl_Widget::changed() const;
void Fl_Widget::set_changed();
void Fl_Widget::clear_changed();
This value is true if the user picks a different value. It is
turned off by value(x) and just before doing a callback (the callback
can turn it back on if desired).
uchar Fl_Widget::when() const;
void Fl_Widget::when(uchar);
It is probably useless to set this to any value other than the default
FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED
. See Fl_Choice for a subclass that uses this.
const Fl_Menu* Fl_Menu_::popup(int X, int Y, int W = 0,
int H = 0);
Pop up the menu, wait for the user to pick an item, and if they pick
one set value(), do the callback or set changed() as described above.
The menu item is returned or NULL is returned if the user dismisses
the menu.
X, Y, W, H describe a rectangle that the currently selected menu
item will cover (use a W and H of zero to make the current item be
centered at X,Y). X and Y are relative to whatever window the last
event was directed to, so using Fl::event_x() and Fl::event_y() will
work to make a popup at the mouse cursor.
See also Fl_Menu_Button::popup(void).
const char* Fl_Menu_::text() const ;
const char* Fl_Menu_::text(int i) const ;
Returns the title of the last item chosen, or of item i.
int 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 nulls 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);
Add 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.
See the Fl_Menu documentation for information on what a slash in
the item title does.
The return value is the index into the array that the entry was put.
int Fl_Menu_::add(const char *);
void Fl_Menu_::clear();
Delete all the menu items. This deletes the copied strings if you
originally set Fl_Menu_::menu() to null.
void Fl_Menu_::replace(int,const char *);
Change the text of item n. The passed string is copied.
void Fl_Menu_::remove(int);
Delete item n from the menu.
void Fl_Menu_::shortcut(int i,const char *str);
Change the shortcut of item n. The passed string is not
copied.
void Fl_Menu_::mode(int i,int x);
Change the flags of item n. This can be used to enable and disable
items and to create and set check boxes.
FL_PUP_GRAY = 1,
FL_PUP_BOX = 2,
FL_PUP_CHECK = 4,
FL_PUP_INVISIBLE = 8,
uchar Fl_Menu_::textfont() const;
void Fl_Menu_::textfont(uchar);
uchar Fl_Menu_::textsize() const;
void Fl_Menu_::textsize(uchar);
uchar Fl_Menu_::textcolor() const;
void Fl_Menu_::textcolor(uchar);
Get or set the font, font size, or color of the text displayed in the
menu (the current implementation ignores the color, although the
Fl_Choice subclass will use it for it's own display). The default is
normal-sized Bold Italic Helvetica and black.