Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::Gtk::MenuItem Class Reference

A GtkMenuItem C++ wrapper class. More...

`#include <inti/gtk/menuitem.h>`

Inheritance diagram for Inti::Gtk::MenuItem:

List of all members.

## Public Member Functions

Constructors

- MenuItem ()
    Construct a new MenuItem.
- MenuItem (const String &label, bool use_underline=false)
    Construct a new MenuItem whose child is a Label.
- MenuItem (const String &label, Menu &submenu, bool use_underline=false)
    Construct a new MenuItem that pops up a submenu.
- virtual ~MenuItem ()
    Destructor.

Accessors

- GtkMenuItem * gtk_menu_item () const
    Get a pointer to the GtkMenuItem structure.
- GtkMenuItemClass * gtk_menu_item_class () const
    Get a pointer to the GtkMenuItemClass structure.
- operator GtkMenuItem * () const
    Conversion operator; safely converts a MenuItem to a GtkMenuItem pointer.
- bool has_submenu () const
    Returns true if the menu item displays a submenu.
- bool get_right_justified () const
    Gets whether the menu item appears justified at the right side of the menu bar.
- Menu * get_submenu () const
    Gets the submenu underneath this menu item, if any (see set_submenu()).

Methods

- void set_label (const String &label, bool use_underline=false)
    Sets the label text to label.
- void set_submenu (Menu &submenu)
    Sets the widget submenu, or changes it.
- void remove_submenu ()
    Removes the widget's submenu.
- void activate ()
    Emits the "activate" signal on the given item.
- void toggle_size_request (int *requisition)
    Emits the "toggle_size_request" signal on the menu item.
- void toggle_size_allocate (int allocation)
    Emits the "toggle_size_allocate" signal on the menu item.
- void set_right_justified (bool right_justified)
    Sets whether the menu item appears justified at the right side of a menu bar.
- void set_accel_path (const char *accel_path)
    Set the accelerator path on the menu item, through which runtime changes of the menu item's accelerator caused by the user can be identified and saved to persistant storage (see Gtk::AccelMap::save() on this).

Signal Proxies

- const ActivateSignalProxy sig_activate ()
    Connect to the activate_signal; emitted when the menu item is activated.
- const ActivateItemSignalProxy sig_activate_item ()
    Connect to the activate_item_signal; emitted when the item is activated, but also if the menu item has a submenu.
- const ToggleSizeRequestSignalProxy sig_toggle_size_request ()
    Connect to the toggle_size_request_signal; emitted when MenuBar or Menu requests the size of the toggle.
- const ToggleSizeAllocateSignalProxy sig_toggle_size_allocate ()
    Connect to the toggle_size_allocate_signal; emitted when MenuBar or Menu allocates a size for the toggle.

## Protected Member Functions

Contructors

- MenuItem (GtkMenuItem *menu_item, bool reference=false)
    Construct a new MenuItem from an existing GtkMenuItem.

Methods

- void add_label (const String &label, bool use_underline)
    Adds a label widget to an empty menu item with the text label.

Signal Handlers

- virtual void on_activate ()
    Called when the menu item is activated.
- virtual void on_activate_item ()
    Called when the menu item is activated, but also if the menu item has a submenu.
- virtual void on_toggle_size_request (int *requisition)
    Called when MenuBar or Menu requests the size of the toggle.
- virtual void on_toggle_size_allocate (int allocate)
    Called when MenuBar or Menu allocates a size for the toggle.

## Detailed Description

A GtkMenuItem C++ wrapper class.

The MenuItem widget and its derived widgets are the only valid child widgets for menus. Their function is to correctly handle highlighting, alignment, events and submenus. As MenuItem derives from Bin it can hold any valid child widget, although only a few are really useful.

## Constructor & Destructor Documentation

Inti::Gtk::MenuItem::MenuItem | ( | GtkMenuItem * | menu_item,
|  | bool | reference = false
| ) | `[explicit, protected]`

  | Construct a new MenuItem from an existing GtkMenuItem. Parameters:
  menu_item | A pointer to a GtkMenuItem.
  reference | Set false if the initial reference count is floating, set true if it's not.
The menu_item can be a newly created GtkMenuItem or an existing GtkMenuItem (see G::Object::Object).

Inti::Gtk::MenuItem::MenuItem | ( | const String & | label,
|  | bool | use_underline = false
| ) | `[explicit]`

  | Construct a new MenuItem whose child is a Label. Parameters:
  label | The text for the label.
  use_underline | Set true if there is an underscore in front of the mnemonic character.

Inti::Gtk::MenuItem::MenuItem | ( | const String & | label,
|  | Menu & | submenu,
|  | bool | use_underline = false
| ) |

  | Construct a new MenuItem that pops up a submenu. Parameters:
  label | The text for the label.
  submenu | The submenu.
  use_underline | Set true if there is an underscore in front of the mnemonic character.

## Member Function Documentation

void Inti::Gtk::MenuItem::add_label | ( | const String & | label,
|  | bool | use_underline
| ) | `[protected]`

  | Adds a label widget to an empty menu item with the text label. Parameters:
  label | The text for the label.
  use_underline | Set true if there is an underscore in front of the mnemonic character.
This method is used by the derived menu item widgets such as CheckMenuItem and ImageMenuItem. You probably wont find much use for it.

bool Inti::Gtk::MenuItem::get_right_justified | ( |  | ) | const

| Gets whether the menu item appears justified at the right side of the menu bar. Returns: true if the menu item will appear at the far right if added to a menu bar.

Menu* Inti::Gtk::MenuItem::get_submenu | ( |  | ) | const

| Gets the submenu underneath this menu item, if any (see set_submenu()). Returns: The submenu for this menu item, or null if there is none.

virtual void Inti::Gtk::MenuItem::on_activate_item | ( |  | ) | `[protected, virtual]`

| Called when the menu item is activated, but also if the menu item has a submenu. For normal applications, the relevant signal is "activate".

virtual void Inti::Gtk::MenuItem::on_toggle_size_allocate | ( | int | allocate | ) | `[protected, virtual]`

  | Called when MenuBar or Menu allocates a size for the toggle. Parameters:
  allocate | The size allocated to the toggle.
For CheckMenuItem the toggle is a checkbox. For ImageMenuItem the Toggle is an image.

virtual void Inti::Gtk::MenuItem::on_toggle_size_request | ( | int * | requisition | ) | `[protected, virtual]`

  | Called when MenuBar or Menu requests the size of the toggle. Parameters:
  requisition | The return location for the size of the toggle.
For CheckMenuItem the toggle is a checkbox. For ImageMenuItem the Toggle is an image.

void Inti::Gtk::MenuItem::set_accel_path | ( | const char * | accel_path | ) |

  | Set the accelerator path on the menu item, through which runtime changes of the menu item's accelerator caused by the user can be identified and saved to persistant storage (see Gtk::AccelMap::save() on this). Parameters:
  accel_path | The accelerator path, corresponding to this menu item's functionality, or null to unset the current path.
To setup a default accelerator for this menu item, call Gtk::AccelMap::add_entry() with the same accel_path. See also Gtk::AccelMap::add_entry() on the specifics of accelerator paths, and Gtk::Menu::set_accel_path() for a more convenient variant of this function. This Method is basically a convenience wrapper that handles calling Gtk::Widget::set_accel_path() with the appropriate accelerator group for the menu item. Note that you do need to set an accelerator group on the parent menu at construction or later with Gtk::Menu::set_accel_group() for this to work.

void Inti::Gtk::MenuItem::set_label | ( | const String & | label,
|  | bool | use_underline = false
| ) |

  | Sets the label text to label. Parameters:
  label | The text for the label.
  use_underline | Set true if there is an underscore in front of the mnemonic character.
This method can be used to dynamically change the menu item text. If the menu item is empty, a label widget is added with the text label.

void Inti::Gtk::MenuItem::set_right_justified | ( | bool | right_justified | ) |

  | Sets whether the menu item appears justified at the right side of a menu bar. Parameters:
  right_justified | If true the menu item will appear at the far right if added to a menu bar. This was traditionally done for "Help" menu items, but is now considered a bad idea. If the widget layout is reversed for a right-to-left language like Hebrew or Arabic, right-justified-menu-items appear at the left.

void Inti::Gtk::MenuItem::set_submenu | ( | Menu & | submenu | ) |

  | Sets the widget submenu, or changes it. Parameters:
  submenu | The submenu.

const ActivateItemSignalProxy Inti::Gtk::MenuItem::sig_activate_item | ( |  | ) | `[inline]`

| Connect to the activate_item_signal; emitted when the item is activated, but also if the menu item has a submenu. For normal applications, the relevant signal is "activate".

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

- menuitem.h

Main Page - Footer