FLTK 1.3.0
|
A class to create, modify and delete menus that appear on Mac OS X in the menu bar at the top of the screen. More...
#include <Fl_Sys_Menu_Bar.H>
Public Member Functions | |
int | add (const char *label, int shortcut, Fl_Callback *, void *user_data=0, int flags=0) |
add to the system menu bar a new menu item | |
void | clear () |
Same as menu(NULL), set the array pointer to null, indicating a zero-length menu. | |
int | clear_submenu (int index) |
Clears the specified submenu pointed to by index of all menu items. | |
Fl_Sys_Menu_Bar (int x, int y, int w, int h, const char *l=0) | |
The constructor. | |
int | insert (int index, const char *label, int shortcut, Fl_Callback *cb, void *user_data=0, int flags=0) |
insert in the system menu bar a new menu item | |
const Fl_Menu_Item * | menu () const |
Returns a pointer to the array of Fl_Menu_Items. | |
void | menu (const Fl_Menu_Item *m) |
create a system menu bar using the given list of menu structs | |
void | remove (int n) |
remove an item from the system menu bar | |
void | replace (int rank, const char *name) |
rename an item from the system menu bar | |
Protected Member Functions | |
void | draw () |
Draws the widget. |
A class to create, modify and delete menus that appear on Mac OS X in the menu bar at the top of the screen.
On other than Mac OS X platforms, Fl_Sys_Menu_Bar is a synonym of class Fl_Menu_Bar.
You can configure a callback for the 'About' menu item to invoke your own code with fl_mac_set_about().
Fl_Sys_Menu_Bar::Fl_Sys_Menu_Bar | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
const char * | l = 0 |
||
) |
The constructor.
On Mac OS X, all arguments are unused. On other platforms they are used as by Fl_Menu_Bar::Fl_Menu_Bar().
int Fl_Sys_Menu_Bar::add | ( | const char * | label, |
int | shortcut, | ||
Fl_Callback * | cb, | ||
void * | user_data = 0 , |
||
int | flags = 0 |
||
) |
add to the system menu bar a new menu item
add to the system menu bar a new menu item, with a title string, shortcut int, callback, argument to the callback, and flags.
Reimplemented from Fl_Menu_.
void Fl_Sys_Menu_Bar::clear | ( | ) |
Same as menu(NULL), set the array pointer to null, indicating a zero-length menu.
Menus must not be cleared during a callback to the same menu.
Reimplemented from Fl_Menu_.
int Fl_Sys_Menu_Bar::clear_submenu | ( | int | index | ) |
Clears the specified submenu pointed to by index
of all menu items.
This method is useful for clearing a submenu so that it can be re-populated with new items. Example: a "File/Recent Files/..." submenu that shows the last few files that have been opened.
The specified index
must point to a submenu.
The submenu is cleared with remove(). If the menu array was directly set with menu(x), then copy() is done to make a private array.
Example:
int index = menubar->find_index("File/Recent"); // get index of "File/Recent" submenu if ( index != -1 ) menubar->clear_submenu(index); // clear the submenu menubar->add("File/Recent/Aaa"); menubar->add("File/Recent/Bbb"); [..]
index | The index of the submenu to be cleared |
Reimplemented from Fl_Menu_.
void Fl_Sys_Menu_Bar::draw | ( | ) | [protected, virtual] |
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget's draw method from within your own draw() method, e.g. for an embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl_Widget *s = &scroll; // scroll is an embedded Fl_Scrollbar s->draw(); // calls Fl_Scrollbar::draw()
Reimplemented from Fl_Menu_Bar.
int Fl_Sys_Menu_Bar::insert | ( | int | index, |
const char * | label, | ||
int | shortcut, | ||
Fl_Callback * | cb, | ||
void * | user_data = 0 , |
||
int | flags = 0 |
||
) |
insert in the system menu bar a new menu item
insert in the system menu bar a new menu item, with a title string, shortcut int, callback, argument to the callback, and flags.
Reimplemented from Fl_Menu_.
const Fl_Menu_Item* Fl_Sys_Menu_Bar::menu | ( | ) | const [inline] |
Returns a pointer to the array of Fl_Menu_Items.
This will either be the value passed to menu(value) or the private copy.
Example: How to walk the array:
for ( int t=0; t<menubar->size(); t++ ) { // walk array of items const Fl_Menu_Item &item = menubar->menu()[t]; // get each item fprintf(stderr, "item #%d -- label=%s, value=%s type=%s\n", t, item.label() ? item.label() : "(Null)", // menu terminators have NULL labels (item.flags & FL_MENU_VALUE) ? "set" : "clear", // value of toggle or radio items (item.flags & FL_SUBMENU) ? "Submenu" : "Item"); // see if item is a submenu or actual item }
Reimplemented from Fl_Menu_.
void Fl_Sys_Menu_Bar::menu | ( | const Fl_Menu_Item * | m | ) |
create a system menu bar using the given list of menu structs
m | list of Fl_Menu_Item |
Reimplemented from Fl_Menu_.
void Fl_Sys_Menu_Bar::remove | ( | int | rank | ) |
remove an item from the system menu bar
rank | the rank of the item to remove |
Reimplemented from Fl_Menu_.
void Fl_Sys_Menu_Bar::replace | ( | int | rank, |
const char * | name | ||
) |
rename an item from the system menu bar
rank | the rank of the item to rename |
name | the new item name as a UTF8 string |
Reimplemented from Fl_Menu_.