Main Page Widgets Namespaces Book

# Gtk::Menu Class Reference
[Widgets, Menu classes]

A drop-down menu consisting of Gtk::MenuItem objects which can be navigated and activated by the user to perform application functions. More...

Inheritance diagram for Gtk::Menu:

[legend]
List of all members.

## Public Types

typedef SigC::Slot3< void, int&, int&, bool& > | SlotPositionCalc
| void on_menu_position(int&, int&, bool& push_in);

## Public Methods

virtual | ~Menu ()
GtkMenu* | gobj ()
const GtkMenu* | gobj () const
| Menu ()
void | popup (MenuShell& parent_menu_shell, MenuItem& parent_menu_item, GtkMenuPositionFunc func, gpointer data, guint button, guint32 activate_time)
void | popup (const SlotPositionCalc& position_calc_slot, guint button, guint32 activate_time)
| Displays a menu and makes it available for selection.
void | popup (guint button, guint32 activate_time)
| Displays a menu and makes it available for selection.
void | reposition ()
void | popdown ()
MenuItem* | get_active ()
const MenuItem* | get_active () const
void | set_active (guint index)
void | set_accel_group (const Glib::RefPtr<AccelGroup>& accel_group)
void | unset_accel_group ()
Glib::RefPtr<AccelGroup> | get_accel_group ()
void | set_accel_path (const Glib::ustring& accel_path)
| Sets an accelerator path for this menu from which accelerator paths for its immediate children, its menu items, can be constructed.
void | detach ()
Widget* | get_attach_widget ()
const Widget* | get_attach_widget () const
void | set_tearoff_state (bool torn_off=true)
bool | get_tearoff_state () const
| Returns whether the menu is torn off.
void | set_title (const Glib::ustring& title)
| Sets the title string for the menu.
void | unset_title ()
Glib::ustring | get_title () const
| Returns the title of the menu.
void | reorder_child (const MenuItem& child, int position)
Glib::PropertyProxy<Glib::ustring> | property_tearoff_title ()

## Protected Methods

void | attach_to_widget (Widget& widget, GtkMenuDetachFunc detacher)

## Related Functions

(Note that these are not member functions.)
Gtk::Menu* | wrap (GtkMenu* object, bool take_copy=false)

## Detailed Description

A drop-down menu consisting of Gtk::MenuItem objects which can be navigated and activated by the user to perform application functions.

Menus are normally placed inside a Gtk::MenuBar or another MenuItem as a sub menu. A Menu can also be popped up, for instance as a right-click context menu, by calling the popup() method. See also Gtk::OptionMenu.

## Member Typedef Documentation

typedef SigC::Slot3<void, int&, int&, bool&> Gtk::Menu::SlotPositionCalc

| void on_menu_position(int&, int&, bool& push_in);

## Constructor & Destructor Documentation

virtual Gtk::Menu::~Menu | ( |  | ) | `[virtual]`

Gtk::Menu::Menu | ( |  | ) |

## Member Function Documentation

void Gtk::Menu::attach_to_widget | ( | Widget& | widget,
|  | GtkMenuDetachFunc | detacher
| ) | `[protected]`

void Gtk::Menu::detach | ( |  | ) |

Glib::RefPtr<AccelGroup> Gtk::Menu::get_accel_group | ( |  | ) |

const MenuItem* Gtk::Menu::get_active | ( |  | ) |

MenuItem* Gtk::Menu::get_active | ( |  | ) |

const Widget* Gtk::Menu::get_attach_widget | ( |  | ) |

Widget* Gtk::Menu::get_attach_widget | ( |  | ) |

bool Gtk::Menu::get_tearoff_state | ( |  | ) |

Returns whether the menu is torn off.

See set_tearoff_state().

Returns:
  `true` if the menu is currently torn off.

Glib::ustring Gtk::Menu::get_title | ( |  | ) |

Returns the title of the menu.

See set_title().

Returns:
  The title of the menu, or `0` if the menu has no title set on it.

const GtkMenu* Gtk::Menu::gobj | ( |  | ) | const`[inline]`

| Reimplemented from Gtk::MenuShell.

GtkMenu* Gtk::Menu::gobj | ( |  | ) | `[inline]`

| Reimplemented from Gtk::MenuShell.

void Gtk::Menu::popdown | ( |  | ) |

void Gtk::Menu::popup | ( | guint | button,
|  | guint32 | activate_time
| ) |

Displays a menu and makes it available for selection.

Applications can use this function to display context-sensitive menus. The default menu positioning function will position the menu at the current pointer position.

Parameters:

  button | The button which was pressed to initiate the event.
  activate_time | The time at which the activation event occurred.

void Gtk::Menu::popup | ( | const SlotPositionCalc& | position_calc_slot,
|  | guint | button,
|  | guint32 | activate_time
| ) |

| Displays a menu and makes it available for selection.

void Gtk::Menu::popup | ( | MenuShell& | parent_menu_shell,
|  | MenuItem& | parent_menu_item,
|  | GtkMenuPositionFunc | func,
|  | gpointer | data,
|  | guint | button,
|  | guint32 | activate_time
| ) |

Glib::PropertyProxy<Glib::ustring> Gtk::Menu::property_tearoff_title | ( |  | ) |

void Gtk::Menu::reorder_child | ( | const MenuItem& | child,
|  | int | position
| ) |

void Gtk::Menu::reposition | ( |  | ) |

void Gtk::Menu::set_accel_group | ( | const Glib::RefPtr<AccelGroup>& | accel_group | ) |

void Gtk::Menu::set_accel_path | ( | const Glib::ustring& | accel_path | ) |

Sets an accelerator path for this menu from which accelerator paths for its immediate children, its menu items, can be constructed.

The main purpose of this function is to spare the programmer the inconvenience of having to call Gtk::MenuItem::set_accel_path() on each menu item that should support runtime user changable accelerators. Instead, by just calling set_accel_path() on their parent, each menu item of this menu, that contains a label describing its purpose, automatically gets an accel path assigned. For example, a menu containing menu items "New" and "Exit", will, after `gtk_menu_set_accel_path (menu, "<Gnumeric-Sheet>/File");` has been called, assign its items the accel paths: `"<Gnumeric-Sheet>/File/New"` and `"<Gnumeric-Sheet>/File/Exit"`. Assigning accel paths to menu items then enables the user to change their accelerators at runtime. More details about accelerator paths and their default setups can be found at gtk_accel_map_add_entry().

Parameters:

  accel_path | A valid accelerator path.

void Gtk::Menu::set_active | ( | guint | index | ) |

void Gtk::Menu::set_tearoff_state | ( | bool | torn_off = true | ) |

void Gtk::Menu::set_title | ( | const Glib::ustring& | title | ) |

Sets the title string for the menu.

The title is displayed when the menu is shown as a tearoff menu.

Parameters:

  title | A string containing the title for the menu.

void Gtk::Menu::unset_accel_group | ( |  | ) |

void Gtk::Menu::unset_title | ( |  | ) |

## Friends And Related Function Documentation

Gtk::Menu* wrap | ( | GtkMenu* | object,
|  | bool | take_copy = false
| ) | `[related]`

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

- menu.h