fltk  1.3.5-source
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X.
  Fossies Dox: fltk-1.3.5-source.tar.bz2  ("inofficial" and yet experimental doxygen-generated source code documentation)  

Fl_Menu_Item Struct Reference

#include <Fl_Menu_Item.H>

Public Member Functions

const Fl_Menu_Itemnext (int=1) const
 
Fl_Menu_Itemnext (int i=1)
 
const Fl_Menu_Itemfirst () const
 
Fl_Menu_Itemfirst ()
 
const char * label () const
 
void label (const char *a)
 
void label (Fl_Labeltype a, const char *b)
 
Fl_Labeltype labeltype () const
 
void labeltype (Fl_Labeltype a)
 
Fl_Color labelcolor () const
 
void labelcolor (Fl_Color a)
 
Fl_Font labelfont () const
 
void labelfont (Fl_Font a)
 
Fl_Fontsize labelsize () const
 
void labelsize (Fl_Fontsize a)
 
Fl_Callback_p callback () const
 
void callback (Fl_Callback *c, void *p)
 
void callback (Fl_Callback *c)
 
void callback (Fl_Callback0 *c)
 
void callback (Fl_Callback1 *c, long p=0)
 
void * user_data () const
 
void user_data (void *v)
 
long argument () const
 
void argument (long v)
 
int shortcut () const
 
void shortcut (int s)
 
int submenu () const
 
int checkbox () const
 
int radio () const
 
int value () const
 
void set ()
 
void clear ()
 
void setonly ()
 
int visible () const
 
void show ()
 
void hide ()
 
int active () const
 
void activate ()
 
void deactivate ()
 
int activevisible () const
 
void image (Fl_Image *a)
 
void image (Fl_Image &a)
 
int measure (int *h, const Fl_Menu_ *) const
 
void draw (int x, int y, int w, int h, const Fl_Menu_ *, int t=0) const
 
const Fl_Menu_Itempopup (int X, int Y, const char *title=0, const Fl_Menu_Item *picked=0, const Fl_Menu_ *=0) const
 
const Fl_Menu_Itempulldown (int X, int Y, int W, int H, const Fl_Menu_Item *picked=0, const Fl_Menu_ *=0, const Fl_Menu_Item *title=0, int menubar=0) const
 
const Fl_Menu_Itemtest_shortcut () const
 
const Fl_Menu_Itemfind_shortcut (int *ip=0, const bool require_alt=false) const
 
void do_callback (Fl_Widget *o) const
 
void do_callback (Fl_Widget *o, void *arg) const
 
void do_callback (Fl_Widget *o, long arg) const
 
int checked () const
 
void check ()
 
void uncheck ()
 
int insert (int, const char *, int, Fl_Callback *, void *=0, int=0)
 
int add (const char *, int shortcut, Fl_Callback *, void *=0, int=0)
 
int add (const char *a, const char *b, Fl_Callback *c, void *d=0, int e=0)
 
int size () const
 

Public Attributes

const char * text
 menu item text, returned by label() More...
 
int shortcut_
 menu item shortcut More...
 
Fl_Callbackcallback_
 menu item callback More...
 
void * user_data_
 menu item user_data for the menu's callback More...
 
int flags
 menu item flags like FL_MENU_TOGGLE, FL_MENU_RADIO More...
 
uchar labeltype_
 how the menu item text looks like More...
 
Fl_Font labelfont_
 which font for this menu item text More...
 
Fl_Fontsize labelsize_
 size of menu item text More...
 
Fl_Color labelcolor_
 menu item text color More...
 

Detailed Description

The Fl_Menu_Item structure defines a single menu item that is used by the Fl_Menu_ class.

struct Fl_Menu_Item {
const char* text; // label()
void* user_data_;
int flags;
};
enum { // values for flags:
FL_MENU_INACTIVE = 1, // Deactivate menu item (gray out)
FL_MENU_TOGGLE = 2, // Item is a checkbox toggle (shows checkbox for on/off state)
FL_MENU_VALUE = 4, // The on/off state for checkbox/radio buttons (if set, state is 'on')
FL_MENU_RADIO = 8, // Item is a radio button (one checkbox of many can be on)
FL_MENU_INVISIBLE = 0x10, // Item will not show up (shortcut will work)
FL_SUBMENU_POINTER = 0x20, // Indicates user_data() is a pointer to another menu array
FL_SUBMENU = 0x40, // This item is a submenu to other items
FL_MENU_DIVIDER = 0x80, // Creates divider line below this item. Also ends a group of radio buttons.
FL_MENU_HORIZONTAL = 0x100 // ??? -- reserved
};

Typically menu items are statically defined; for example:

{"&alpha", FL_ALT+'a', the_cb, (void*)1},
{"&beta", FL_ALT+'b', the_cb, (void*)2},
{"gamma", FL_ALT+'c', the_cb, (void*)3, FL_MENU_DIVIDER},
{"&strange", 0, strange_cb},
{"&charm", 0, charm_cb},
{"&truth", 0, truth_cb},
{"b&eauty", 0, beauty_cb},
{"sub&menu", 0, 0, 0, FL_SUBMENU},
{"one"},
{"two"},
{"three"},
{0},
{"inactive", FL_ALT+'i', 0, 0, FL_MENU_INACTIVE|FL_MENU_DIVIDER},
{"invisible",FL_ALT+'i', 0, 0, FL_MENU_INVISIBLE},
{"check", FL_ALT+'i', 0, 0, FL_MENU_TOGGLE|FL_MENU_VALUE},
{"box", FL_ALT+'i', 0, 0, FL_MENU_TOGGLE},
{0}};

produces:

A submenu title is identified by the bit FL_SUBMENU in the flags field, and ends with a label() that is NULL. You can nest menus to any depth. A pointer to the first item in the submenu can be treated as an Fl_Menu array itself. It is also possible to make separate submenu arrays with FL_SUBMENU_POINTER flags.

You should use the method functions to access structure members and not access them directly to avoid compatibility problems with future releases of FLTK.

Definition at line 112 of file Fl_Menu_Item.H.

Member Function Documentation

◆ activate()

void Fl_Menu_Item::activate ( )
inline

Allows a menu item to be picked.

Definition at line 343 of file Fl_Menu_Item.H.

References FL_MENU_INACTIVE.

Referenced by Fl_Choice::draw(), redo_cb(), set_modflag(), undo_cb(), and undo_checkpoint().

◆ active()

int Fl_Menu_Item::active ( ) const
inline

Gets whether or not the item can be picked.

Definition at line 340 of file Fl_Menu_Item.H.

References FL_MENU_INACTIVE.

Referenced by Fl_Choice::draw(), draw(), find_shortcut(), and test_shortcut().

◆ activevisible()

int Fl_Menu_Item::activevisible ( ) const
inline

Returns non 0 if FL_INACTIVE and FL_INVISIBLE are cleared, 0 otherwise.

Definition at line 350 of file Fl_Menu_Item.H.

References FL_MENU_INACTIVE, and FL_MENU_INVISIBLE.

Referenced by backward(), forward(), and pulldown().

◆ add() [1/2]

int Fl_Menu_Item::add ( const char *  mytext,
int  sc,
Fl_Callback cb,
void *  data = 0,
int  myflags = 0 
)

Adds a menu item.

The text is split at '/' characters to automatically produce submenus (actually a totally unnecessary feature as you can now add submenu titles directly by setting FL_SUBMENU in the flags).

Returns
the index into the menu() array, where the entry was added
See also
Fl_Menu_Item::insert(int, const char*, int, Fl_Callback*, void*, int)

Definition at line 106 of file Fl_Menu_add.cxx.

References cb(), and insert().

Referenced by Fl_Input_Choice::add().

◆ add() [2/2]

int Fl_Menu_Item::add ( const char *  a,
const char *  b,
Fl_Callback c,
void *  d = 0,
int  e = 0 
)
inline

◆ argument() [1/2]

long Fl_Menu_Item::argument ( ) const
inline

Gets the user_data() argument that is sent to the callback function. For convenience you can also define the callback as taking a long argument. This method casts the stored userdata() argument to long and returns it as a long value.

Definition at line 262 of file Fl_Menu_Item.H.

Referenced by align_position_cb(), align_text_image_cb(), item_name(), item_number(), and subtype_cb().

◆ argument() [2/2]

void Fl_Menu_Item::argument ( long  v)
inline

Sets the user_data() argument that is sent to the callback function. For convenience you can also define the callback as taking a long argument. This method casts the given argument v to void* and stores it in the menu item's userdata() member. This may not be portable to some machines.

Definition at line 270 of file Fl_Menu_Item.H.

◆ callback() [1/5]

Fl_Callback_p Fl_Menu_Item::callback ( ) const
inline

Returns the callback function that is set for the menu item. Each item has space for a callback function and an argument for that function. Due to back compatibility, the Fl_Menu_Item itself is not passed to the callback, instead you have to get it by calling ((Fl_Menu_*)w)->mvalue() where w is the widget argument.

Definition at line 217 of file Fl_Menu_Item.H.

Referenced by Fl_Menu_Type::build_menu(), Fl_Input_Choice_Type::build_menu(), and Fl_Window_Type::handle().

◆ callback() [2/5]

void Fl_Menu_Item::callback ( Fl_Callback c)
inline

Sets the menu item's callback function. This method does not set the userdata() argument.

See also
Fl_Callback_p Fl_MenuItem::callback() const

Definition at line 230 of file Fl_Menu_Item.H.

◆ callback() [3/5]

void Fl_Menu_Item::callback ( Fl_Callback c,
void *  p 
)
inline

Sets the menu item's callback function and userdata() argument.

See also
Fl_Callback_p Fl_MenuItem::callback() const

Definition at line 223 of file Fl_Menu_Item.H.

References p.

◆ callback() [4/5]

void Fl_Menu_Item::callback ( Fl_Callback0 c)
inline

Sets the menu item's callback function. This method does not set the userdata() argument.

See also
Fl_Callback_p Fl_MenuItem::callback() const

Definition at line 237 of file Fl_Menu_Item.H.

◆ callback() [5/5]

void Fl_Menu_Item::callback ( Fl_Callback1 c,
long  p = 0 
)
inline

Sets the menu item's callback function and userdata() argument. This method does not set the userdata() argument. The argument is cast to void* and stored as the userdata() for the menu item's callback function.

See also
Fl_Callback_p Fl_MenuItem::callback() const

Definition at line 246 of file Fl_Menu_Item.H.

References p.

◆ check()

void Fl_Menu_Item::check ( )
inline

back compatibility only

Deprecated:

Definition at line 408 of file Fl_Menu_Item.H.

References FL_MENU_VALUE.

◆ checkbox()

int Fl_Menu_Item::checkbox ( ) const
inline

Returns true if a checkbox will be drawn next to this item. This is true if FL_MENU_TOGGLE or FL_MENU_RADIO is set in the flags.

Definition at line 303 of file Fl_Menu_Item.H.

References FL_MENU_TOGGLE.

◆ checked()

int Fl_Menu_Item::checked ( ) const
inline

back compatibility only

Deprecated:

Definition at line 405 of file Fl_Menu_Item.H.

References FL_MENU_VALUE.

◆ clear()

void Fl_Menu_Item::clear ( )
inline

Turns the check or radio item "off" for the menu item.

Definition at line 326 of file Fl_Menu_Item.H.

References FL_MENU_VALUE.

Referenced by Fl_Input_Choice::clear(), Fl_Menu_::setonly(), and setonly().

◆ deactivate()

void Fl_Menu_Item::deactivate ( )
inline

Prevents a menu item from being picked. Note that this will also cause the menu item to appear grayed-out.

Definition at line 348 of file Fl_Menu_Item.H.

References FL_MENU_INACTIVE.

Referenced by Fl_Choice::draw(), redo_cb(), set_modflag(), undo_cb(), and undo_checkpoint().

◆ do_callback() [1/3]

void Fl_Menu_Item::do_callback ( Fl_Widget o) const
inline

Calls the Fl_Menu_Item item's callback, and provides the Fl_Widget argument. The callback is called with the stored user_data() as its second argument. You must first check that callback() is non-zero before calling this.

Definition at line 384 of file Fl_Menu_Item.H.

Referenced by Fl_Window_Type::handle(), and Fl_Menu_::picked().

◆ do_callback() [2/3]

void Fl_Menu_Item::do_callback ( Fl_Widget o,
long  arg 
) const
inline

Calls the Fl_Menu_Item item's callback, and provides the Fl_Widget argument. This call overrides the callback's second argument with the given value arg. long arg is cast to void* when calling the callback. You must first check that callback() is non-zero before calling this.

Definition at line 400 of file Fl_Menu_Item.H.

References arg().

◆ do_callback() [3/3]

void Fl_Menu_Item::do_callback ( Fl_Widget o,
void *  arg 
) const
inline

Calls the Fl_Menu_Item item's callback, and provides the Fl_Widget argument. This call overrides the callback's second argument with the given value arg. You must first check that callback() is non-zero before calling this.

Definition at line 391 of file Fl_Menu_Item.H.

References arg().

◆ draw()

◆ find_shortcut()

const Fl_Menu_Item * Fl_Menu_Item::find_shortcut ( int *  ip = 0,
const bool  require_alt = false 
) const

Search only the top level menu for a shortcut.
Either &x in the label or the shortcut fields are used.

This tests the current event, which must be an FL_KEYBOARD or FL_SHORTCUT, against a shortcut value.

Parameters
ipreturns the index of the item, if ip is not NULL.
require_altif true: match only if Alt key is pressed.
Returns
found Fl_Menu_Item or NULL

Definition at line 1043 of file Fl_Menu.cxx.

References active(), next_visible_or_not(), shortcut_, Fl::test_shortcut(), Fl_Widget::test_shortcut(), and text.

Referenced by Fl_Menu_Bar::handle().

◆ first() [1/2]

Fl_Menu_Item* Fl_Menu_Item::first ( )
inline

Returns the first menu item, same as next(0).

Definition at line 138 of file Fl_Menu_Item.H.

◆ first() [2/2]

const Fl_Menu_Item* Fl_Menu_Item::first ( ) const
inline

Returns the first menu item, same as next(0).

Definition at line 135 of file Fl_Menu_Item.H.

Referenced by menuwindow::draw(), menuwindow::find_selected(), menuwindow::menuwindow(), and menuwindow::titlex().

◆ hide()

void Fl_Menu_Item::hide ( )
inline

Hides an item in the menu.

Definition at line 337 of file Fl_Menu_Item.H.

References FL_MENU_INVISIBLE.

Referenced by load_history(), and update_history().

◆ image() [1/2]

void Fl_Menu_Item::image ( Fl_Image a)
inline

compatibility api for FLUID, same as a.label(this)

Definition at line 358 of file Fl_Menu_Item.H.

References Fl_Image::label().

◆ image() [2/2]

void Fl_Menu_Item::image ( Fl_Image a)
inline

compatibility api for FLUID, same as a->label(this)

Definition at line 355 of file Fl_Menu_Item.H.

References Fl_Image::label().

Referenced by make_iconlabel().

◆ insert()

int Fl_Menu_Item::insert ( int  index,
const char *  mytext,
int  sc,
Fl_Callback cb,
void *  data = 0,
int  myflags = 0 
)

Inserts an item at position index.

If index is -1, the item is added the same way as Fl_Menu_Item::add().

If 'mytext' contains any un-escaped front slashes (/), it's assumed a menu pathname is being specified, and the value of index will be ignored.

In all other aspects, the behavior of insert() is the same as add().

Parameters
[in]indexinsert new items here
[in]mytextnew label string, details see above
[in]sckeyboard shortcut for new item
[in]cbcallback function for new item
[in]datauser data for new item
[in]myflagsmenu flags as described in FL_Menu_Item
Returns
the index into the menu() array, where the entry was added

Definition at line 137 of file Fl_Menu_add.cxx.

References array, array_insert(), buf, callback_, cb(), compare(), FL_MENU_DIVIDER, FL_SUBMENU, flags, local_array, local_array_size, next(), p, shortcut_, text, and user_data_.

Referenced by add(), and Fl_Menu_::insert().

◆ label() [1/3]

const char* Fl_Menu_Item::label ( ) const
inline

Returns the title of the item. A NULL here indicates the end of the menu (or of a submenu). A '&' in the item will print an underscore under the next letter, and if the menu is popped up that letter will be a "shortcut" to pick that item. To get a real '&' put two in a row.

Definition at line 148 of file Fl_Menu_Item.H.

Referenced by Fl_Menu_Type::build_menu(), Fl_Input_Choice_Type::build_menu(), fill_in_New_Menu(), Fl_Menu_::find_index(), Fl_Window_Type::fix_overlay(), item_name(), item_number(), Fl_Menu_::item_pathname_(), Fl_Bitmap::label(), Fl_Multi_Label::label(), Fl_Pixmap::label(), Fl_Image::label(), Fl_RGB_Image::label(), make_iconlabel(), toggle_overlays(), toggle_sourceview_cb(), and toggle_widgetbin_cb().

◆ label() [2/3]

void Fl_Menu_Item::label ( const char *  a)
inline

See const char* Fl_Menu_Item::label() const

Definition at line 151 of file Fl_Menu_Item.H.

◆ label() [3/3]

void Fl_Menu_Item::label ( Fl_Labeltype  a,
const char *  b 
)
inline

See const char* Fl_Menu_Item::label() const

Definition at line 154 of file Fl_Menu_Item.H.

References b.

◆ labelcolor() [1/2]

Fl_Color Fl_Menu_Item::labelcolor ( ) const
inline

Gets the menu item's label color. This color is passed to the labeltype routine, and is typically the color of the label text. This defaults to FL_BLACK. If this color is not black fltk will not use overlay bitplanes to draw the menu - this is so that images put in the menu draw correctly.

Definition at line 181 of file Fl_Menu_Item.H.

Referenced by Fl_Menu_Type::build_menu(), and Fl_Input_Choice_Type::build_menu().

◆ labelcolor() [2/2]

void Fl_Menu_Item::labelcolor ( Fl_Color  a)
inline

Sets the menu item's label color.

See also
Fl_Color Fl_Menu_Item::labelcolor() const

Definition at line 187 of file Fl_Menu_Item.H.

◆ labelfont() [1/2]

Fl_Font Fl_Menu_Item::labelfont ( ) const
inline

Gets the menu item's label font. Fonts are identified by small 8-bit indexes into a table. See the enumeration list for predefined fonts. The default value is a Helvetica font. The function Fl::set_font() can define new fonts.

Definition at line 194 of file Fl_Menu_Item.H.

Referenced by Fl_Menu_Type::build_menu(), and Fl_Input_Choice_Type::build_menu().

◆ labelfont() [2/2]

void Fl_Menu_Item::labelfont ( Fl_Font  a)
inline

Sets the menu item's label font. Fonts are identified by small 8-bit indexes into a table. See the enumeration list for predefined fonts. The default value is a Helvetica font. The function Fl::set_font() can define new fonts.

Definition at line 202 of file Fl_Menu_Item.H.

◆ labelsize() [1/2]

Fl_Fontsize Fl_Menu_Item::labelsize ( ) const
inline

Gets the label font pixel size/height.

Definition at line 205 of file Fl_Menu_Item.H.

Referenced by Fl_Menu_Type::build_menu(), and Fl_Input_Choice_Type::build_menu().

◆ labelsize() [2/2]

void Fl_Menu_Item::labelsize ( Fl_Fontsize  a)
inline

Sets the label font pixel size/height.

Definition at line 208 of file Fl_Menu_Item.H.

◆ labeltype() [1/2]

Fl_Labeltype Fl_Menu_Item::labeltype ( ) const
inline

Returns the menu item's labeltype. A labeltype identifies a routine that draws the label of the widget. This can be used for special effects such as emboss, or to use the label() pointer as another form of data such as a bitmap. The value FL_NORMAL_LABEL prints the label as text.

Definition at line 163 of file Fl_Menu_Item.H.

Referenced by Fl_Menu_Type::build_menu(), and Fl_Input_Choice_Type::build_menu().

◆ labeltype() [2/2]

void Fl_Menu_Item::labeltype ( Fl_Labeltype  a)
inline

Sets the menu item's labeltype. A labeltype identifies a routine that draws the label of the widget. This can be used for special effects such as emboss, or to use the label() pointer as another form of data such as a bitmap. The value FL_NORMAL_LABEL prints the label as text.

Definition at line 172 of file Fl_Menu_Item.H.

◆ measure()

int Fl_Menu_Item::measure ( int *  hp,
const Fl_Menu_ m 
) const

◆ next() [1/2]

Fl_Menu_Item* Fl_Menu_Item::next ( int  i = 1)
inline

Advances a pointer by n items through a menu array, skipping the contents of submenus and invisible items. There are two calls so that you can advance through const and non-const data.

Definition at line 131 of file Fl_Menu_Item.H.

◆ next() [2/2]

const Fl_Menu_Item * Fl_Menu_Item::next ( int  n = 1) const

Advance a pointer by n items through a menu array, skipping the contents of submenus and invisible items. There are two calls so that you can advance through const and non-const data.

Definition at line 94 of file Fl_Menu.cxx.

References next_visible_or_not(), text, and visible().

Referenced by backward(), Fl_Menu_Bar::draw(), menuwindow::draw(), menuwindow::find_selected(), forward(), insert(), menuwindow::menuwindow(), Fl_Menu_::remove(), setitem(), and menuwindow::titlex().

◆ popup()

const Fl_Menu_Item * Fl_Menu_Item::popup ( int  X,
int  Y,
const char *  title = 0,
const Fl_Menu_Item picked = 0,
const Fl_Menu_ button = 0 
) const

This method is called by widgets that want to display menus.

The menu stays up until the user picks an item or dismisses it. The selected item (or NULL if none) is returned. This does not do the callbacks or change the state of check or radio items.

X,Y is the position of the mouse cursor, relative to the window that got the most recent event (usually you can pass Fl::event_x() and Fl::event_y() unchanged here).

title is a character string title for the menu. If non-zero a small box appears above the menu with the title in it.

The menu is positioned so the cursor is centered over the item picked. This will work even if picked is in a submenu. If picked is zero or not in the menu item table the menu is positioned with the cursor in the top-left corner.

button is a pointer to an Fl_Menu_ from which the color and boxtypes for the menu are pulled. If NULL then defaults are used.

Definition at line 1020 of file Fl_Menu.cxx.

References button, pulldown(), title, and Y.

Referenced by Fl_Window_Type::handle(), and Fl_Menu_Button::popup().

◆ pulldown()

const Fl_Menu_Item * Fl_Menu_Item::pulldown ( int  X,
int  Y,
int  W,
int  H,
const Fl_Menu_Item initial_item = 0,
const Fl_Menu_ pbutton = 0,
const Fl_Menu_Item t = 0,
int  menubar = 0 
) const

◆ radio()

int Fl_Menu_Item::radio ( ) const
inline

Returns true if this item is a radio item. When a radio button is selected all "adjacent" radio buttons are turned off. A set of radio items is delimited by an item that has radio() false, or by an item with FL_MENU_DIVIDER turned on.

Definition at line 310 of file Fl_Menu_Item.H.

References FL_MENU_RADIO.

Referenced by Fl_Menu_::picked(), Fl_Menu_::setonly(), and setonly().

◆ set()

void Fl_Menu_Item::set ( )
inline

Turns the check or radio item "on" for the menu item. Note that this does not turn off any adjacent radio items like set_only() does.

Definition at line 323 of file Fl_Menu_Item.H.

References FL_MENU_VALUE.

◆ setonly()

void Fl_Menu_Item::setonly ( )

Turns the radio item "on" for the menu item and turns "off" adjacent radio items set.

Deprecated:
This method is dangerous if radio items are first in the menu. Use Fl_Menu_::setonly(Fl_Menu_Item*) instead.

Definition at line 367 of file Fl_Menu_.cxx.

References clear(), FL_MENU_DIVIDER, FL_MENU_RADIO, FL_MENU_VALUE, flags, radio(), and text.

◆ shortcut() [1/2]

int Fl_Menu_Item::shortcut ( ) const
inline

Gets what key combination shortcut will trigger the menu item.

Definition at line 273 of file Fl_Menu_Item.H.

Referenced by Fl_Menu_Type::build_menu(), Fl_Input_Choice_Type::build_menu(), and Fl_Menu_::shortcut().

◆ shortcut() [2/2]

void Fl_Menu_Item::shortcut ( int  s)
inline

Sets exactly what key combination will trigger the menu item. The value is a logical 'or' of a key and a set of shift flags, for instance FL_ALT+'a' or FL_ALT+FL_F+10 or just 'a'. A value of zero disables the shortcut.

The key can be any value returned by Fl::event_key(), but will usually be an ASCII letter. Use a lower-case letter unless you require the shift key to be held down.

The shift flags can be any set of values accepted by Fl::event_state(). If the bit is on that shift key must be pushed. Meta, Alt, Ctrl, and Shift must be off if they are not in the shift flags (zero for the other bits indicates a "don't care" setting).

Definition at line 290 of file Fl_Menu_Item.H.

◆ show()

void Fl_Menu_Item::show ( )
inline

Makes an item visible in the menu.

Definition at line 334 of file Fl_Menu_Item.H.

References FL_MENU_INVISIBLE.

◆ size()

int Fl_Menu_Item::size ( ) const

Size of the menu starting from this menu item.

This method counts all menu items starting with this menu item, including all menu items in the same (sub)menu level, all nested submenus, and the terminating empty (0) menu item.

It does not count menu items referred to by FL_SUBMENU_POINTER menu items (except the single menu item with FL_SUBMENU_POINTER).

All menu items counted are consecutive in memory (one array).

Example:

schemechoice = new Fl_Choice(X+125,Y,140,25,"FLTK Scheme");
schemechoice->add("none");
schemechoice->add("plastic");
schemechoice->add("gtk+");
schemechoice->add("gleam");
printf("schemechoice->menu()->size() = %d\n", schemechoice->menu()->size());

Output:

schemechoice->menu()->size() = 5

Definition at line 58 of file Fl_Menu.cxx.

References FL_SUBMENU, flags, and text.

Referenced by Fl_Menu_::copy(), and Fl_Menu_::size().

◆ submenu()

int Fl_Menu_Item::submenu ( ) const
inline

Returns true if either FL_SUBMENU or FL_SUBMENU_POINTER is on in the flags. FL_SUBMENU indicates an embedded submenu that goes from the next item through the next one with a NULL label(). FL_SUBMENU_POINTER indicates that user_data() is a pointer to another menu array.

Definition at line 298 of file Fl_Menu_Item.H.

References FL_SUBMENU, and FL_SUBMENU_POINTER.

Referenced by menuwindow::drawentry(), Fl_Menu_Bar::handle(), Fl_Choice::handle(), Fl_Menu_::item_pathname_(), pulldown(), and test_shortcut().

◆ test_shortcut()

const Fl_Menu_Item * Fl_Menu_Item::test_shortcut ( ) const

This is designed to be called by a widgets handle() method in response to a FL_SHORTCUT event. If the current event matches one of the items shortcut, that item is returned. If the keystroke does not match any shortcuts then NULL is returned. This only matches the shortcut() fields, not the letters in the title preceeded by '

Definition at line 1067 of file Fl_Menu.cxx.

References active(), FL_SUBMENU, flags, next_visible_or_not(), shortcut_, submenu(), test_shortcut(), Fl::test_shortcut(), text, and user_data_.

Referenced by Fl_Choice::handle(), Fl_Window_Type::handle(), and test_shortcut().

◆ uncheck()

void Fl_Menu_Item::uncheck ( )
inline

back compatibility only

Deprecated:

Definition at line 411 of file Fl_Menu_Item.H.

References FL_MENU_VALUE.

◆ user_data() [1/2]

◆ user_data() [2/2]

void Fl_Menu_Item::user_data ( void *  v)
inline

Sets the user_data() argument that is sent to the callback function.

Definition at line 255 of file Fl_Menu_Item.H.

◆ value()

int Fl_Menu_Item::value ( ) const
inline

Returns the current value of the check or radio item. This is zero (0) if the menu item is not checked and non-zero otherwise. You should not rely on a particular value, only zero or non-zero.

Note
The returned value for a checked menu item as of FLTK 1.3.2 is FL_MENU_VALUE (4), but may be 1 in a future version.

Definition at line 318 of file Fl_Menu_Item.H.

References FL_MENU_VALUE.

Referenced by draw(), Fl_Menu_::picked(), and Fl_Input_Choice::value().

◆ visible()

int Fl_Menu_Item::visible ( ) const
inline

Gets the visibility of an item.

Definition at line 331 of file Fl_Menu_Item.H.

References FL_MENU_INVISIBLE.

Referenced by next().

Member Data Documentation

◆ callback_

Fl_Callback* Fl_Menu_Item::callback_

menu item callback

Definition at line 115 of file Fl_Menu_Item.H.

Referenced by array_insert(), Fl_Menu_::copy(), Fl_Menu_::find_item(), insert(), and Fl_Menu_::picked().

◆ flags

◆ labelcolor_

Fl_Color Fl_Menu_Item::labelcolor_

menu item text color

Definition at line 121 of file Fl_Menu_Item.H.

Referenced by array_insert(), Fl_Choice::draw(), draw(), menutitle::menutitle(), and menuwindow::menuwindow().

◆ labelfont_

Fl_Font Fl_Menu_Item::labelfont_

which font for this menu item text

Definition at line 119 of file Fl_Menu_Item.H.

Referenced by array_insert(), Fl_Choice::draw(), draw(), menuwindow::drawentry(), and measure().

◆ labelsize_

Fl_Fontsize Fl_Menu_Item::labelsize_

size of menu item text

Definition at line 120 of file Fl_Menu_Item.H.

Referenced by array_insert(), Fl_Choice::draw(), draw(), menuwindow::drawentry(), and measure().

◆ labeltype_

uchar Fl_Menu_Item::labeltype_

how the menu item text looks like

Definition at line 118 of file Fl_Menu_Item.H.

Referenced by array_insert(), Fl_Choice::draw(), draw(), measure(), menutitle::menutitle(), and menuwindow::menuwindow().

◆ shortcut_

int Fl_Menu_Item::shortcut_

menu item shortcut

Definition at line 114 of file Fl_Menu_Item.H.

Referenced by array_insert(), menuwindow::drawentry(), find_shortcut(), insert(), menuwindow::menuwindow(), and test_shortcut().

◆ text

◆ user_data_

void* Fl_Menu_Item::user_data_

menu item user_data for the menu's callback

Definition at line 116 of file Fl_Menu_Item.H.

Referenced by array_insert(), Fl_Menu_::copy(), insert(), pulldown(), and test_shortcut().


The documentation for this struct was generated from the following files:
FL_MENU_RADIO
Item is a radio button (one checkbox of many can be on)
Definition: Fl_Menu_Item.H:36
Fl_Choice
A button that is used to pop up a menu.
Definition: Fl_Choice.H:83
Fl_Menu_Item::flags
int flags
menu item flags like FL_MENU_TOGGLE, FL_MENU_RADIO
Definition: Fl_Menu_Item.H:117
FL_SUBMENU_POINTER
Indicates user_data() is a pointer to another menu array.
Definition: Fl_Menu_Item.H:38
FL_MENU_INACTIVE
Deactivate menu item (gray out)
Definition: Fl_Menu_Item.H:33
FL_SUBMENU
This item is a submenu to other items.
Definition: Fl_Menu_Item.H:39
Fl_Menu_Item::labelfont_
Fl_Font labelfont_
which font for this menu item text
Definition: Fl_Menu_Item.H:119
Fl_Menu_Item::labeltype_
uchar labeltype_
how the menu item text looks like
Definition: Fl_Menu_Item.H:118
Fl_Callback
void() Fl_Callback(Fl_Widget *, void *)
Definition: Fl_Widget.H:49
FL_MENU_TOGGLE
Item is a checkbox toggle (shows checkbox for on/off state)
Definition: Fl_Menu_Item.H:34
FL_MENU_HORIZONTAL
??? – reserved
Definition: Fl_Menu_Item.H:41
FL_ALT
#define FL_ALT
One of the alt keys is down.
Definition: Enumerations.H:560
FL_MENU_VALUE
The on/off state for checkbox/radio buttons (if set, state is 'on')
Definition: Fl_Menu_Item.H:35
Fl_Menu_Item::user_data_
void * user_data_
menu item user_data for the menu's callback
Definition: Fl_Menu_Item.H:116
ulong
unsigned long ulong
Definition: fl_types.h:32
FL_MENU_INVISIBLE
Item will not show up (shortcut will work)
Definition: Fl_Menu_Item.H:37
Fl_Menu_Item::callback_
Fl_Callback * callback_
menu item callback
Definition: Fl_Menu_Item.H:115
FL_MENU_DIVIDER
Creates divider line below this item. Also ends a group of radio buttons.
Definition: Fl_Menu_Item.H:40
Fl_Menu_Item::shortcut_
int shortcut_
menu item shortcut
Definition: Fl_Menu_Item.H:114
Fl_Menu_Item::popup
const Fl_Menu_Item * popup(int X, int Y, const char *title=0, const Fl_Menu_Item *picked=0, const Fl_Menu_ *=0) const
Definition: Fl_Menu.cxx:1020
Fl_Menu_Item
Definition: Fl_Menu_Item.H:112
Fl_Menu_Item::labelcolor_
Fl_Color labelcolor_
menu item text color
Definition: Fl_Menu_Item.H:121
Y
static int Y
Definition: Fl_Tooltip.cxx:76
Fl_Menu_Item::text
const char * text
menu item text, returned by label()
Definition: Fl_Menu_Item.H:113
Fl_Menu_Item::labelsize_
Fl_Fontsize labelsize_
size of menu item text
Definition: Fl_Menu_Item.H:120
uchar
unsigned char uchar
Definition: fl_types.h:30