Fl_Sys_Menu_Bar Class Reference

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>

Inheritance diagram for Fl_Sys_Menu_Bar:
Fl_Menu_Bar Fl_Menu_ Fl_Widget

List of all members.

Public Member Functions

int add (const char *str)
 Forms-compatible procedure to add items to the system menu bar.
int add (const char *label, const char *shortcut, Fl_Callback *cb, void *user_data=0, int flags=0)
 Adds a new menu item.
int add (const char *label, int shortcut, Fl_Callback *, void *user_data=0, int flags=0)
 Add a new menu item to the system menu bar.
void clear ()
 Set the Fl_Menu_Item 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.
void global ()
 Make the shortcuts for this menu work no matter what window has the focus when you type it.
int insert (int index, const char *label, const char *shortcut, Fl_Callback *cb, void *user_data=0, int flags=0)
 Insert a new menu item.
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
void menu (const Fl_Menu_Item *m)
 create a system menu bar using the given list of menu structs
const Fl_Menu_Itemmenu () const
 Return the system menu's array of Fl_Menu_Item's.
int mode (int i) const
 Gets the flags of item i.
void mode (int i, int fl)
 Sets the flags of item i.
void remove (int n)
 remove an item from the system menu bar
void replace (int index, const char *name)
 rename an item from the system menu bar
void setonly (Fl_Menu_Item *item)
 Turns the radio item "on" for the menu item and turns "off" adjacent radio items of the same group.
void shortcut (int i, int s)
 Changes the shortcut of item i to n.
 ~Fl_Sys_Menu_Bar ()
 The destructor.

Protected Member Functions

void draw ()
 Draws the widget.
void update ()
 Updates the system menu after any change to its items.

Detailed Description

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.
To use this class, just replace Fl_Menu_Bar by Fl_Sys_Menu_Bar, and, on the Mac platform, a system menu at the top of the screen will be available. This menu will match an array of Fl_Menu_Item's exactly as with standard FLTK menus.

Changes to the menu state are immediately visible in the menubar when they are made using member functions of the Fl_Sys_Menu_Bar class. Other changes (e.g., by a call to Fl_Menu_Item::set()) should be followed by a call to Fl_Sys_Menu_Bar::update() to be visible in the menubar across all platforms.

A few FLTK features are not supported by the Mac System menu:

You can configure a callback for the 'About' menu item to invoke your own code with fl_mac_set_about().


Constructor & Destructor Documentation

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().


Member Function Documentation

int Fl_Sys_Menu_Bar::add ( const char *  str  ) 

Forms-compatible procedure to add items to the system menu bar.

Returns:
the index into the menu() array, where the entry was added
See also:
Fl_Menu_::add(const char* str)

Reimplemented from Fl_Menu_.

int Fl_Sys_Menu_Bar::add ( const char *  label,
const char *  shortcut,
Fl_Callback cb,
void *  user_data = 0,
int  flags = 0 
) [inline]

Adds a new menu item.

See also:
Fl_Menu_::add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0)

Reimplemented from Fl_Menu_.

int Fl_Sys_Menu_Bar::add ( const char *  label,
int  shortcut,
Fl_Callback cb,
void *  user_data = 0,
int  flags = 0 
)

Add a new menu item to the system menu bar.

Parameters:
label - new menu item's label
shortcut - new menu item's integer shortcut (can be 0 for none, or e.g. FL_ALT+'x')
cb - callback to be invoked when item selected (can be 0 for none, in which case the menubar's callback() can be used instead)
user_data - argument to the callback
flags - item's flags, e.g. FL_MENU_TOGGLE, etc.
Returns:
the index into the menu() array, where the entry was added
See also:
Fl_Menu_::add(const char* label, int shortcut, Fl_Callback *cb, void *user_data, int flags)

Reimplemented from Fl_Menu_.

void Fl_Sys_Menu_Bar::clear (  ) 

Set the Fl_Menu_Item array pointer to null, indicating a zero-length menu.

See also:
Fl_Menu_::clear()

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.

See also:
Fl_Menu_::clear_submenu(int index)

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,
const char *  shortcut,
Fl_Callback cb,
void *  user_data = 0,
int  flags = 0 
) [inline]

Insert a new menu item.

See also:
Fl_Menu_::insert(int index, const char* label, const char* shortcut, Fl_Callback *cb, void *user_data=0, int flags=0)

Reimplemented from Fl_Menu_.

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.

Returns:
the index into the menu() array, where the entry was inserted
See also:
Fl_Menu_::insert(int index, const char* label, int shortcut, Fl_Callback *cb, void *user_data, int flags)

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

Author:
Matthias Melcher
Parameters:
m list of Fl_Menu_Item

Reimplemented from Fl_Menu_.

void Fl_Sys_Menu_Bar::mode ( int  i,
int  fl 
) [inline]

Sets the flags of item i.

See also:
Fl_Menu_::mode(int i, int fl)

Reimplemented from Fl_Menu_.

void Fl_Sys_Menu_Bar::remove ( int  index  ) 

remove an item from the system menu bar

Parameters:
index the index of the item to remove

Reimplemented from Fl_Menu_.

void Fl_Sys_Menu_Bar::replace ( int  index,
const char *  name 
)

rename an item from the system menu bar

Parameters:
index the index of the item to rename
name the new item name as a UTF8 string

Reimplemented from Fl_Menu_.

void Fl_Sys_Menu_Bar::setonly ( Fl_Menu_Item item  )  [inline]

Turns the radio item "on" for the menu item and turns "off" adjacent radio items of the same group.

Reimplemented from Fl_Menu_.


The documentation for this class was generated from the following files: