gtkmm 3.1.16
Public Member Functions | Protected Member Functions | Related Functions

Gtk::MenuItem Class Reference

Child item for menus. More...

Inheritance diagram for Gtk::MenuItem:
Inheritance graph
[legend]
Collaboration diagram for Gtk::MenuItem:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~MenuItem ()
GtkMenuItem* gobj ()
 Provides access to the underlying C GtkObject.
const GtkMenuItem* gobj () const
 Provides access to the underlying C GtkObject.
 MenuItem ()
 Create an empty menu item.
 MenuItem (Widget& widget)
 Create a menu item with widget.
 MenuItem (const Glib::ustring& label, bool mnemonic=false)
 Create a menu item with label.
void set_submenu (Menu& submenu)
 Sets or replaces the menu item's submenu, or removes it when a 0 submenu is passed.
void unset_submenu ()
 Remove the menu item's sub-menu.
Menuget_submenu ()
 Gets the submenu underneath this menu item, if any.
const Menuget_submenu () const
 Gets the submenu underneath this menu item, if any.
bool has_submenu () const
void select ()
 Emits the Gtk::MenuItem::select signal on the given item.
void deselect ()
 Emits the Gtk::MenuItem::deselect signal on the given item.
void activate ()
 Emits the Gtk::MenuItem::activate signal on the given item.
void toggle_size_request (int& requisition)
 Emits the Gtk::MenuItem::toggle-size-request signal on the given item.
void toggle_size_allocate (int allocation)
 Emits the Gtk::MenuItem::toggle-size-allocate signal on the given item.
void set_right_justified (bool right_justified=true)
 Sets whether the menu item appears justified at the right side of a menu bar.
bool get_right_justified () const
 Gets whether the menu item appears justified at the right side of the menu bar.
void set_accel_path (const Glib::ustring& accel_path)
 Set the accelerator path on 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).
void unset_accel_path ()
Glib::ustring get_accel_path () const
 Retrieve the accelerator path that was previously set on menu_item.
void set_label (const Glib::ustring& label)
 Sets text on the menu_item label.
Glib::ustring get_label () const
 Sets text on the menu_item label.
void set_use_underline (bool setting=true)
 If true, an underline in the text indicates the next character should be used for the mnemonic accelerator key.
bool get_use_underline () const
 Checks if an underline in the text indicates the next character should be used for the mnemonic accelerator key.
void set_reserve_indicator (bool reserve=true)
 Sets whether the menu_item should reserve space for the submenu indicator, regardless if it actually has a submenu or not.
bool get_reserve_indicator () const
 Returns whether the menu_item reserves space for the submenu indicator, regardless if it has a submenu or not.
Glib::SignalProxy0< void > signal_activate ()
Glib::SignalProxy0< void > signal_activate_item ()
Glib::SignalProxy1< void, int* > signal_toggle_size_request ()
Glib::SignalProxy1< void, int > signal_toggle_size_allocate ()
void accelerate (Window& window)
Glib::PropertyProxy< bool > property_right_justified ()
 Sets whether the menu item appears justified at the right side of a menu bar.
Glib::PropertyProxy_ReadOnly
< bool > 
property_right_justified () const
 Sets whether the menu item appears justified at the right side of a menu bar.
Glib::PropertyProxy< Gtk::Menu* > property_submenu ()
 The submenu attached to the menu item, or NULL if it has none.
Glib::PropertyProxy_ReadOnly
< Gtk::Menu* > 
property_submenu () const
 The submenu attached to the menu item, or NULL if it has none.
Glib::PropertyProxy
< Glib::ustring
property_accel_path ()
 Sets the accelerator path of the menu item.
Glib::PropertyProxy_ReadOnly
< Glib::ustring
property_accel_path () const
 Sets the accelerator path of the menu item.
Glib::PropertyProxy
< Glib::ustring
property_label ()
 The text for the child label.
Glib::PropertyProxy_ReadOnly
< Glib::ustring
property_label () const
 The text for the child label.
Glib::PropertyProxy< bool > property_use_underline ()
 If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key.
Glib::PropertyProxy_ReadOnly
< bool > 
property_use_underline () const
 If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key.

Protected Member Functions

virtual void on_activate ()
virtual void on_activate_item ()
virtual void on_toggle_size_request (int* requisition)
virtual void on_toggle_size_allocate (int allocation)
void add_accel_label (const Glib::ustring& label, bool mnemonic=true)
void set_accel_key (const AccelKey& accel_key)

Related Functions

(Note that these are not member functions.)
Gtk::MenuItemwrap (GtkMenuItem* object, bool take_copy=false)
 A Glib::wrap() method for this object.

Detailed Description

Child item for menus.

Handle highlighting, alignment, events and submenus. As it derives from Gtk::Bin it can hold any valid child widget, altough only a few are really useful.


Constructor & Destructor Documentation

virtual Gtk::MenuItem::~MenuItem ( ) [virtual]
Gtk::MenuItem::MenuItem ( )

Create an empty menu item.

Gtk::MenuItem::MenuItem ( Widget widget) [explicit]

Create a menu item with widget.

Gtk::MenuItem::MenuItem ( const Glib::ustring label,
bool  mnemonic = false 
) [explicit]

Create a menu item with label.


Member Function Documentation

void Gtk::MenuItem::accelerate ( Window window)
void Gtk::MenuItem::activate ( )

Emits the Gtk::MenuItem::activate signal on the given item.

Reimplemented from Gtk::Widget.

void Gtk::MenuItem::add_accel_label ( const Glib::ustring label,
bool  mnemonic = true 
) [protected]
void Gtk::MenuItem::deselect ( )

Emits the Gtk::MenuItem::deselect signal on the given item.

Behaves exactly like #gtk_item_deselect.

Glib::ustring Gtk::MenuItem::get_accel_path ( ) const

Retrieve the accelerator path that was previously set on menu_item.

See set_accel_path() for details.

Since gtkmm 2.14:
Returns:
The accelerator path corresponding to this menu item's functionality, or 0 if not set.
Glib::ustring Gtk::MenuItem::get_label ( ) const

Sets text on the menu_item label.

Since gtkmm 2.16:
Returns:
The text in the menu_item label. This is the internal string used by the label, and must not be modified.
bool Gtk::MenuItem::get_reserve_indicator ( ) const

Returns whether the menu_item reserves space for the submenu indicator, regardless if it has a submenu or not.

Since gtkmm 3.0:
Returns:
true if menu_item always reserves space for the submenu indicator.
bool Gtk::MenuItem::get_right_justified ( ) const

Gets whether the menu item appears justified at the right side of the menu bar.

Deprecated: 3.2: See set_right_justified()

Returns:
true if the menu item will appear at the far right if added to a menu bar.
const Menu* Gtk::MenuItem::get_submenu ( ) const

Gets the submenu underneath this menu item, if any.

See set_submenu().

Returns:
Submenu for this menu item, or 0 if none.
Menu* Gtk::MenuItem::get_submenu ( )

Gets the submenu underneath this menu item, if any.

See set_submenu().

Returns:
Submenu for this menu item, or 0 if none.
bool Gtk::MenuItem::get_use_underline ( ) const

Checks if an underline in the text indicates the next character should be used for the mnemonic accelerator key.

Since gtkmm 2.16:
Returns:
true if an embedded underline in the label indicates the mnemonic accelerator key.
const GtkMenuItem* Gtk::MenuItem::gobj ( ) const [inline]

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Activatable.

Reimplemented in Gtk::CheckMenuItem, Gtk::ImageMenuItem, Gtk::RadioMenuItem, Gtk::SeparatorMenuItem, and Gtk::TearoffMenuItem.

GtkMenuItem* Gtk::MenuItem::gobj ( ) [inline]

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Activatable.

Reimplemented in Gtk::CheckMenuItem, Gtk::ImageMenuItem, Gtk::RadioMenuItem, Gtk::SeparatorMenuItem, and Gtk::TearoffMenuItem.

bool Gtk::MenuItem::has_submenu ( ) const
virtual void Gtk::MenuItem::on_activate ( ) [protected, virtual]
virtual void Gtk::MenuItem::on_activate_item ( ) [protected, virtual]
virtual void Gtk::MenuItem::on_toggle_size_allocate ( int  allocation) [protected, virtual]
virtual void Gtk::MenuItem::on_toggle_size_request ( int *  requisition) [protected, virtual]
Glib::PropertyProxy<Glib::ustring> Gtk::MenuItem::property_accel_path ( )

Sets the accelerator path of the menu item.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<Glib::ustring> Gtk::MenuItem::property_accel_path ( ) const

Sets the accelerator path of the menu item.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<Glib::ustring> Gtk::MenuItem::property_label ( ) const

The text for the child label.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<Glib::ustring> Gtk::MenuItem::property_label ( )

The text for the child label.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<bool> Gtk::MenuItem::property_right_justified ( )

Sets whether the menu item appears justified at the right side of a menu bar.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<bool> Gtk::MenuItem::property_right_justified ( ) const

Sets whether the menu item appears justified at the right side of a menu bar.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<Gtk::Menu*> Gtk::MenuItem::property_submenu ( ) const

The submenu attached to the menu item, or NULL if it has none.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<Gtk::Menu*> Gtk::MenuItem::property_submenu ( )

The submenu attached to the menu item, or NULL if it has none.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<bool> Gtk::MenuItem::property_use_underline ( )

If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<bool> Gtk::MenuItem::property_use_underline ( ) const

If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
void Gtk::MenuItem::select ( )

Emits the Gtk::MenuItem::select signal on the given item.

Behaves exactly like #gtk_item_select.

void Gtk::MenuItem::set_accel_key ( const AccelKey accel_key) [protected]
void Gtk::MenuItem::set_accel_path ( const Glib::ustring accel_path)

Set the accelerator path on 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).

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 set_accel_path() for a more convenient variant of this function.

This function 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 on the parent menu with set_accel_group() for this to work.

Parameters:
accel_pathAccelerator path, corresponding to this menu item's functionality.
void Gtk::MenuItem::set_label ( const Glib::ustring label)

Sets text on the menu_item label.

Since gtkmm 2.16:
Parameters:
labelThe text you want to set.
void Gtk::MenuItem::set_reserve_indicator ( bool  reserve = true)

Sets whether the menu_item should reserve space for the submenu indicator, regardless if it actually has a submenu or not.

There should be little need for applications to call this functions.

Since gtkmm 3.0:
Parameters:
reserveThe new value.
void Gtk::MenuItem::set_right_justified ( bool  right_justified = true)

Sets whether the menu item appears justified at the right side of 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.)

Deprecated: 3.2: If you insist on using it, use Gtk::Widget::set_hexpand() and Gtk::Widget::set_halign().

Parameters:
right_justifiedIf true the menu item will appear at the far right if added to a menu bar.
void Gtk::MenuItem::set_submenu ( Menu submenu)

Sets or replaces the menu item's submenu, or removes it when a 0 submenu is passed.

Parameters:
submenuThe submenu, or 0.
void Gtk::MenuItem::set_use_underline ( bool  setting = true)

If true, an underline in the text indicates the next character should be used for the mnemonic accelerator key.

Since gtkmm 2.16:
Parameters:
settingtrue if underlines in the text indicate mnemonics.
Glib::SignalProxy0< void > Gtk::MenuItem::signal_activate ( )
Prototype:
void on_my_activate()
Glib::SignalProxy0< void > Gtk::MenuItem::signal_activate_item ( )
Prototype:
void on_my_activate_item()
Glib::SignalProxy1< void,int > Gtk::MenuItem::signal_toggle_size_allocate ( )
Prototype:
void on_my_toggle_size_allocate(int allocation)
Glib::SignalProxy1< void,int* > Gtk::MenuItem::signal_toggle_size_request ( )
Prototype:
void on_my_toggle_size_request(int* requisition)
void Gtk::MenuItem::toggle_size_allocate ( int  allocation)

Emits the Gtk::MenuItem::toggle-size-allocate signal on the given item.

Parameters:
allocationThe allocation to use as signal data.
void Gtk::MenuItem::toggle_size_request ( int &  requisition)

Emits the Gtk::MenuItem::toggle-size-request signal on the given item.

Parameters:
requisitionThe requisition to use as signal data.
void Gtk::MenuItem::unset_accel_path ( )
void Gtk::MenuItem::unset_submenu ( )

Remove the menu item's sub-menu.

Since gtkmm 2.22:

Friends And Related Function Documentation

Gtk::MenuItem* wrap ( GtkMenuItem *  object,
bool  take_copy = false 
) [related]

A Glib::wrap() method for this object.

Parameters:
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns:
A C++ instance that wraps this C instance.

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