FLTK 1.3.11
Toggle main menu visibility
Loading...
Searching...
No Matches
Fl_Menu_Item.H
Go to the documentation of this file.
1
//
2
// "$Id$"
3
//
4
// Menu item header file for the Fast Light Tool Kit (FLTK).
5
//
6
// Copyright 1998-2010 by Bill Spitzak and others.
7
//
8
// This library is free software. Distribution and use rights are outlined in
9
// the file "COPYING" which should have been included with this file. If this
10
// file is missing or damaged, see the license at:
11
//
12
// http://www.fltk.org/COPYING.php
13
//
14
// Please report all bugs and problems on the following page:
15
//
16
// http://www.fltk.org/str.php
17
//
18
19
#ifndef Fl_Menu_Item_H
20
#define Fl_Menu_Item_H
21
22
# include "
Fl_Widget.H
"
23
# include "
Fl_Image.H
"
24
25
# if defined(__APPLE__) && defined(check)
26
# undef check
27
# endif
28
29
// doxygen needs the following line to enable e.g. ::FL_MENU_TOGGLE to link to the enums
31
32
enum
{
// values for flags:
33
FL_MENU_INACTIVE
= 1,
34
FL_MENU_TOGGLE
= 2,
35
FL_MENU_VALUE
= 4,
36
FL_MENU_RADIO
= 8,
37
FL_MENU_INVISIBLE
= 0x10,
38
FL_SUBMENU_POINTER
= 0x20,
39
FL_SUBMENU
= 0x40,
40
FL_MENU_DIVIDER
= 0x80,
41
FL_MENU_HORIZONTAL
= 0x100
42
};
43
44
extern
FL_EXPORT
Fl_Shortcut
fl_old_shortcut
(
const
char
*);
45
46
class
Fl_Menu_
;
47
112
struct
FL_EXPORT
Fl_Menu_Item
{
113
const
char
*
text
;
114
int
shortcut_
;
115
Fl_Callback
*
callback_
;
116
void
*
user_data_
;
117
int
flags
;
118
uchar
labeltype_
;
119
Fl_Font
labelfont_
;
120
Fl_Fontsize
labelsize_
;
121
Fl_Color
labelcolor_
;
122
123
// advance N items, skipping submenus:
124
const
Fl_Menu_Item
*
next
(
int
=1)
const
;
125
131
Fl_Menu_Item
*
next
(
int
i=1) {
132
return
(
Fl_Menu_Item
*)(((
const
Fl_Menu_Item
*)
this
)->
next
(i));}
133
135
const
Fl_Menu_Item
*
first
()
const
{
return
next
(0); }
136
138
Fl_Menu_Item
*
first
() {
return
next
(0); }
139
140
// methods on menu items:
148
const
char
*
label
()
const
{
return
text
;}
149
151
void
label
(
const
char
* a) {
text
=a;}
152
154
void
label
(
Fl_Labeltype
a,
const
char
* b) {
labeltype_
= a;
text
= b;}
155
163
Fl_Labeltype
labeltype
()
const
{
return
(
Fl_Labeltype
)
labeltype_
;}
164
172
void
labeltype
(
Fl_Labeltype
a) {
labeltype_
= a;}
173
181
Fl_Color
labelcolor
()
const
{
return
labelcolor_
;}
182
187
void
labelcolor
(
Fl_Color
a) {
labelcolor_
= a;}
194
Fl_Font
labelfont
()
const
{
return
labelfont_
;}
195
202
void
labelfont
(
Fl_Font
a) {
labelfont_
= a;}
203
205
Fl_Fontsize
labelsize
()
const
{
return
labelsize_
;}
206
208
void
labelsize
(
Fl_Fontsize
a) {
labelsize_
= a;}
209
217
Fl_Callback_p
callback
()
const
{
return
callback_
;}
218
223
void
callback
(
Fl_Callback
* c,
void
* p) {
callback_
=c;
user_data_
=p;}
224
230
void
callback
(
Fl_Callback
* c) {
callback_
=c;}
231
237
void
callback
(
Fl_Callback0
*c) {
callback_
=(
Fl_Callback
*)c;}
238
246
void
callback
(
Fl_Callback1
*c,
long
p=0) {
callback_
=(
Fl_Callback
*)c;
user_data_
=(
void
*)(
fl_intptr_t
)p;}
247
251
void
*
user_data
()
const
{
return
user_data_
;}
255
void
user_data
(
void
* v) {
user_data_
= v;}
262
long
argument
()
const
{
return
(
long
)(
fl_intptr_t
)
user_data_
;}
270
void
argument
(
long
v) {
user_data_
= (
void
*)(
fl_intptr_t
)v;}
271
273
int
shortcut
()
const
{
return
shortcut_
;}
274
290
void
shortcut
(
int
s) {
shortcut_
= s;}
298
int
submenu
()
const
{
return
flags
&(
FL_SUBMENU
|
FL_SUBMENU_POINTER
);}
303
int
checkbox
()
const
{
return
flags
&
FL_MENU_TOGGLE
;}
310
int
radio
()
const
{
return
flags
&
FL_MENU_RADIO
;}
318
int
value
()
const
{
return
flags
&
FL_MENU_VALUE
;}
323
void
set
() {
flags
|=
FL_MENU_VALUE
;}
324
326
void
clear
() {
flags
&=
~FL_MENU_VALUE
;}
327
328
void
setonly();
329
331
int
visible
()
const
{
return
!(
flags
&
FL_MENU_INVISIBLE
);}
332
334
void
show
() {
flags
&=
~FL_MENU_INVISIBLE
;}
335
337
void
hide
() {
flags
|=
FL_MENU_INVISIBLE
;}
338
340
int
active
()
const
{
return
!(
flags
&
FL_MENU_INACTIVE
);}
341
343
void
activate
() {
flags
&=
~FL_MENU_INACTIVE
;}
348
void
deactivate
() {
flags
|=
FL_MENU_INACTIVE
;}
350
int
activevisible
()
const
{
return
!(
flags
& (
FL_MENU_INACTIVE
|
FL_MENU_INVISIBLE
));}
351
352
// compatibility for FLUID so it can set the image of a menu item...
353
355
void
image
(
Fl_Image
* a) {a->
label
(
this
);}
356
358
void
image
(
Fl_Image
& a) {a.
label
(
this
);}
359
360
// used by menubar:
361
int
measure(
int
* h,
const
Fl_Menu_
*)
const
;
362
void
draw(
int
x,
int
y,
int
w,
int
h,
const
Fl_Menu_
*,
int
t=0)
const
;
363
364
// popup menus without using an Fl_Menu_ widget:
365
const
Fl_Menu_Item
* popup(
366
int
X,
int
Y,
367
const
char
*title = 0,
368
const
Fl_Menu_Item
* picked=0,
369
const
Fl_Menu_
* = 0)
const
;
370
const
Fl_Menu_Item
* pulldown(
371
int
X,
int
Y,
int
W,
int
H,
372
const
Fl_Menu_Item
* picked = 0,
373
const
Fl_Menu_
* = 0,
374
const
Fl_Menu_Item
* title = 0,
375
int
menubar=0)
const
;
376
const
Fl_Menu_Item
* test_shortcut()
const
;
377
const
Fl_Menu_Item
* find_shortcut(
int
*ip=0,
const
bool
require_alt =
false
)
const
;
378
384
void
do_callback
(
Fl_Widget
* o)
const
{
callback_
(o,
user_data_
);}
385
391
void
do_callback
(
Fl_Widget
* o,
void
* arg)
const
{
callback_
(o, arg);}
392
400
void
do_callback
(
Fl_Widget
* o,
long
arg)
const
{
callback_
(o, (
void
*)(
fl_intptr_t
)arg);}
401
402
// back-compatibility, do not use:
403
405
int
checked
()
const
{
return
flags
&
FL_MENU_VALUE
;}
406
408
void
check
() {
flags
|=
FL_MENU_VALUE
;}
409
411
void
uncheck
() {
flags
&=
~FL_MENU_VALUE
;}
412
413
int
insert(
int
,
const
char
*,
int
,
Fl_Callback
*,
void
* =0,
int
=0);
414
int
add(
const
char
*,
int
shortcut,
Fl_Callback
*,
void
* =0,
int
= 0);
415
417
int
add
(
const
char
*a,
const
char
* b,
Fl_Callback
* c,
418
void
* d = 0,
int
e = 0) {
419
return
add
(a,
fl_old_shortcut
(b),c,d,e);}
420
421
int
size()
const
;
422
};
423
424
typedef
Fl_Menu_Item
Fl_Menu;
// back compatibility
425
426
enum
{
// back-compatibility enum:
427
FL_PUP_NONE = 0,
428
FL_PUP_GREY =
FL_MENU_INACTIVE
,
429
FL_PUP_GRAY =
FL_MENU_INACTIVE
,
430
FL_MENU_BOX =
FL_MENU_TOGGLE
,
431
FL_PUP_BOX =
FL_MENU_TOGGLE
,
432
FL_MENU_CHECK =
FL_MENU_VALUE
,
433
FL_PUP_CHECK =
FL_MENU_VALUE
,
434
FL_PUP_RADIO =
FL_MENU_RADIO
,
435
FL_PUP_INVISIBLE =
FL_MENU_INVISIBLE
,
436
FL_PUP_SUBMENU =
FL_SUBMENU_POINTER
437
};
438
439
#endif
440
441
//
442
// End of "$Id$".
443
//
Fl_Font
int Fl_Font
A font number is an index into the internal font table.
Definition
Enumerations.H:884
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition
Enumerations.H:941
Fl_Labeltype
Fl_Labeltype
The labeltype() method sets the type of the label.
Definition
Enumerations.H:770
Fl_Fontsize
int Fl_Fontsize
Size of a font in pixels.
Definition
Enumerations.H:913
Fl_Image.H
Fl_Image, Fl_RGB_Image classes.
FL_MENU_RADIO
@ FL_MENU_RADIO
Item is a radio button (one checkbox of many can be on).
Definition
Fl_Menu_Item.H:36
FL_SUBMENU
@ FL_SUBMENU
This item is a submenu to other items.
Definition
Fl_Menu_Item.H:39
FL_MENU_DIVIDER
@ FL_MENU_DIVIDER
Creates divider line below this item. Also ends a group of radio buttons.
Definition
Fl_Menu_Item.H:40
FL_MENU_TOGGLE
@ FL_MENU_TOGGLE
Item is a checkbox toggle (shows checkbox for on/off state).
Definition
Fl_Menu_Item.H:34
FL_SUBMENU_POINTER
@ FL_SUBMENU_POINTER
Indicates user_data() is a pointer to another menu array.
Definition
Fl_Menu_Item.H:38
FL_MENU_VALUE
@ FL_MENU_VALUE
The on/off state for checkbox/radio buttons (if set, state is 'on').
Definition
Fl_Menu_Item.H:35
FL_MENU_INVISIBLE
@ FL_MENU_INVISIBLE
Item will not show up (shortcut will work).
Definition
Fl_Menu_Item.H:37
FL_MENU_INACTIVE
@ FL_MENU_INACTIVE
Deactivate menu item (gray out).
Definition
Fl_Menu_Item.H:33
FL_MENU_HORIZONTAL
@ FL_MENU_HORIZONTAL
??? – reserved
Definition
Fl_Menu_Item.H:41
Fl_Widget.H
Fl_Widget, Fl_Label classes .
Fl_Callback
void Fl_Callback(Fl_Widget *, void *)
Default callback type definition for all fltk widgets (by far the most used).
Definition
Fl_Widget.H:49
Fl_Callback0
void Fl_Callback0(Fl_Widget *)
One parameter callback type definition passing only the widget.
Definition
Fl_Widget.H:53
Fl_Callback1
void Fl_Callback1(Fl_Widget *, long)
Callback type definition passing the widget and a long data value.
Definition
Fl_Widget.H:55
fl_intptr_t
long fl_intptr_t
Definition
Fl_Widget.H:39
Fl_Callback_p
Fl_Callback * Fl_Callback_p
Default callback type pointer definition for all fltk widgets.
Definition
Fl_Widget.H:51
Fl_Image
Base class for image caching and drawing.
Definition
Fl_Image.H:55
Fl_Image::label
virtual void label(Fl_Widget *w)
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
Definition
Fl_Image.cxx:127
Fl_Menu_
Base class of all widgets that have a menu in FLTK.
Definition
Fl_Menu_.H:51
Fl_Widget
Fl_Widget is the base class for all widgets in FLTK.
Definition
Fl_Widget.H:101
Fl_Shortcut
unsigned int Fl_Shortcut
24-bit Unicode character + 8-bit indicator for keyboard flags
Definition
fl_types.h:46
uchar
unsigned char uchar
unsigned char
Definition
fl_types.h:30
fl_old_shortcut
FL_EXPORT Fl_Shortcut fl_old_shortcut(const char *)
Emulation of XForms named shortcuts.
Definition
fl_shortcut.cxx:395
Fl_Menu_Item
The Fl_Menu_Item structure defines a single menu item that is used by the Fl_Menu_ class.
Definition
Fl_Menu_Item.H:112
Fl_Menu_Item::shortcut
int shortcut() const
Gets what key combination shortcut will trigger the menu item.
Definition
Fl_Menu_Item.H:273
Fl_Menu_Item::callback_
Fl_Callback * callback_
menu item callback
Definition
Fl_Menu_Item.H:115
Fl_Menu_Item::argument
long argument() const
Gets the user_data() argument that is sent to the callback function.
Definition
Fl_Menu_Item.H:262
Fl_Menu_Item::text
const char * text
menu item text, returned by label()
Definition
Fl_Menu_Item.H:113
Fl_Menu_Item::clear
void clear()
Turns the check or radio item "off" for the menu item.
Definition
Fl_Menu_Item.H:326
Fl_Menu_Item::argument
void argument(long v)
Sets the user_data() argument that is sent to the callback function.
Definition
Fl_Menu_Item.H:270
Fl_Menu_Item::labelsize_
Fl_Fontsize labelsize_
size of menu item text
Definition
Fl_Menu_Item.H:120
Fl_Menu_Item::user_data
void * user_data() const
Gets the user_data() argument that is sent to the callback function.
Definition
Fl_Menu_Item.H:251
Fl_Menu_Item::callback
void callback(Fl_Callback *c, void *p)
Sets the menu item's callback function and userdata() argument.
Definition
Fl_Menu_Item.H:223
Fl_Menu_Item::image
void image(Fl_Image &a)
compatibility api for FLUID, same as a.label(this)
Definition
Fl_Menu_Item.H:358
Fl_Menu_Item::labelcolor
void labelcolor(Fl_Color a)
Sets the menu item's label color.
Definition
Fl_Menu_Item.H:187
Fl_Menu_Item::checked
int checked() const
back compatibility only.
Definition
Fl_Menu_Item.H:405
Fl_Menu_Item::deactivate
void deactivate()
Prevents a menu item from being picked.
Definition
Fl_Menu_Item.H:348
Fl_Menu_Item::set
void set()
Turns the check or radio item "on" for the menu item.
Definition
Fl_Menu_Item.H:323
Fl_Menu_Item::labelsize
void labelsize(Fl_Fontsize a)
Sets the label font pixel size/height.
Definition
Fl_Menu_Item.H:208
Fl_Menu_Item::first
const Fl_Menu_Item * first() const
Returns the first menu item, same as next(0).
Definition
Fl_Menu_Item.H:135
Fl_Menu_Item::image
void image(Fl_Image *a)
compatibility api for FLUID, same as a->label(this)
Definition
Fl_Menu_Item.H:355
Fl_Menu_Item::callback
void callback(Fl_Callback1 *c, long p=0)
Sets the menu item's callback function and userdata() argument.
Definition
Fl_Menu_Item.H:246
Fl_Menu_Item::user_data
void user_data(void *v)
Sets the user_data() argument that is sent to the callback function.
Definition
Fl_Menu_Item.H:255
Fl_Menu_Item::active
int active() const
Gets whether or not the item can be picked.
Definition
Fl_Menu_Item.H:340
Fl_Menu_Item::do_callback
void do_callback(Fl_Widget *o, long arg) const
Calls the Fl_Menu_Item item's callback, and provides the Fl_Widget argument.
Definition
Fl_Menu_Item.H:400
Fl_Menu_Item::value
int value() const
Returns the current value of the check or radio item.
Definition
Fl_Menu_Item.H:318
Fl_Menu_Item::shortcut
void shortcut(int s)
Sets exactly what key combination will trigger the menu item.
Definition
Fl_Menu_Item.H:290
Fl_Menu_Item::label
const char * label() const
Returns the title of the item.
Definition
Fl_Menu_Item.H:148
Fl_Menu_Item::callback
Fl_Callback_p callback() const
Returns the callback function that is set for the menu item.
Definition
Fl_Menu_Item.H:217
Fl_Menu_Item::callback
void callback(Fl_Callback *c)
Sets the menu item's callback function.
Definition
Fl_Menu_Item.H:230
Fl_Menu_Item::check
void check()
back compatibility only.
Definition
Fl_Menu_Item.H:408
Fl_Menu_Item::next
const Fl_Menu_Item * next(int=1) const
Advance a pointer by n items through a menu array, skipping the contents of submenus and invisible it...
Definition
Fl_Menu.cxx:94
Fl_Menu_Item::first
Fl_Menu_Item * first()
Returns the first menu item, same as next(0).
Definition
Fl_Menu_Item.H:138
Fl_Menu_Item::labeltype
void labeltype(Fl_Labeltype a)
Sets the menu item's labeltype.
Definition
Fl_Menu_Item.H:172
Fl_Menu_Item::labelcolor_
Fl_Color labelcolor_
menu item text color
Definition
Fl_Menu_Item.H:121
Fl_Menu_Item::hide
void hide()
Hides an item in the menu.
Definition
Fl_Menu_Item.H:337
Fl_Menu_Item::labelfont
void labelfont(Fl_Font a)
Sets the menu item's label font.
Definition
Fl_Menu_Item.H:202
Fl_Menu_Item::shortcut_
int shortcut_
menu item shortcut
Definition
Fl_Menu_Item.H:114
Fl_Menu_Item::labelsize
Fl_Fontsize labelsize() const
Gets the label font pixel size/height.
Definition
Fl_Menu_Item.H:205
Fl_Menu_Item::callback
void callback(Fl_Callback0 *c)
Sets the menu item's callback function.
Definition
Fl_Menu_Item.H:237
Fl_Menu_Item::labelfont
Fl_Font labelfont() const
Gets the menu item's label font.
Definition
Fl_Menu_Item.H:194
Fl_Menu_Item::do_callback
void do_callback(Fl_Widget *o, void *arg) const
Calls the Fl_Menu_Item item's callback, and provides the Fl_Widget argument.
Definition
Fl_Menu_Item.H:391
Fl_Menu_Item::user_data_
void * user_data_
menu item user_data for the menu's callback
Definition
Fl_Menu_Item.H:116
Fl_Menu_Item::labelcolor
Fl_Color labelcolor() const
Gets the menu item's label color.
Definition
Fl_Menu_Item.H:181
Fl_Menu_Item::do_callback
void do_callback(Fl_Widget *o) const
Calls the Fl_Menu_Item item's callback, and provides the Fl_Widget argument.
Definition
Fl_Menu_Item.H:384
Fl_Menu_Item::flags
int flags
menu item flags like FL_MENU_TOGGLE, FL_MENU_RADIO
Definition
Fl_Menu_Item.H:117
Fl_Menu_Item::show
void show()
Makes an item visible in the menu.
Definition
Fl_Menu_Item.H:334
Fl_Menu_Item::labeltype_
uchar labeltype_
how the menu item text looks like
Definition
Fl_Menu_Item.H:118
Fl_Menu_Item::label
void label(Fl_Labeltype a, const char *b)
See const char* Fl_Menu_Item::label() const.
Definition
Fl_Menu_Item.H:154
Fl_Menu_Item::add
int add(const char *a, const char *b, Fl_Callback *c, void *d=0, int e=0)
See int add(const char*, int shortcut, Fl_Callback*, void*, int).
Definition
Fl_Menu_Item.H:417
Fl_Menu_Item::radio
int radio() const
Returns true if this item is a radio item.
Definition
Fl_Menu_Item.H:310
Fl_Menu_Item::labeltype
Fl_Labeltype labeltype() const
Returns the menu item's labeltype.
Definition
Fl_Menu_Item.H:163
Fl_Menu_Item::labelfont_
Fl_Font labelfont_
which font for this menu item text
Definition
Fl_Menu_Item.H:119
Fl_Menu_Item::submenu
int submenu() const
Returns true if either FL_SUBMENU or FL_SUBMENU_POINTER is on in the flags.
Definition
Fl_Menu_Item.H:298
Fl_Menu_Item::visible
int visible() const
Gets the visibility of an item.
Definition
Fl_Menu_Item.H:331
Fl_Menu_Item::activate
void activate()
Allows a menu item to be picked.
Definition
Fl_Menu_Item.H:343
Fl_Menu_Item::checkbox
int checkbox() const
Returns true if a checkbox will be drawn next to this item.
Definition
Fl_Menu_Item.H:303
Fl_Menu_Item::label
void label(const char *a)
See const char* Fl_Menu_Item::label() const.
Definition
Fl_Menu_Item.H:151
Fl_Menu_Item::uncheck
void uncheck()
back compatibility only.
Definition
Fl_Menu_Item.H:411
Fl_Menu_Item::activevisible
int activevisible() const
Returns non 0 if FL_INACTIVE and FL_INVISIBLE are cleared, 0 otherwise.
Definition
Fl_Menu_Item.H:350
Fl_Menu_Item::next
Fl_Menu_Item * next(int i=1)
Advances a pointer by n items through a menu array, skipping the contents of submenus and invisible i...
Definition
Fl_Menu_Item.H:131
Fl_Menu_Item::add
int add(const char *, int shortcut, Fl_Callback *, void *=0, int=0)
Adds a menu item.
Definition
Fl_Menu_add.cxx:106
FL
Fl_Menu_Item.H
Generated by
1.17.0