2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_MENUITEM_H
4 #define _GTKMM_MENUITEM_H
13 * Copyright (C) 1998-2002 The gtkmm Development Team
15 * This library is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Library General Public
17 * License as published by the Free Software Foundation; either
18 * version 2 of the License, or (at your option) any later version.
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Library General Public License for more details.
25 * You should have received a copy of the GNU Library General Public
26 * License along with this library; if not, write to the Free
27 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #include <gtkmm/item.h>
31 #include <gtkmm/accelkey.h>
32 #include <gtkmm/accellabel.h>
35 #ifndef DOXYGEN_SHOULD_SKIP_THIS
36 typedef struct _GtkMenuItem GtkMenuItem;
37 typedef struct _GtkMenuItemClass GtkMenuItemClass;
38 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
42 { class MenuItem_Class; } // namespace Gtk
47 namespace Menu_Helpers { class Element; }
49 /** Child item for menus.
50 * Handle highlighting, alignment, events and submenus.
51 * As it derives from Gtk::Bin it can hold any valid child widget, altough only a few are really useful.
56 class MenuItem : public Item
59 #ifndef DOXYGEN_SHOULD_SKIP_THIS
60 typedef MenuItem CppObjectType;
61 typedef MenuItem_Class CppClassType;
62 typedef GtkMenuItem BaseObjectType;
63 typedef GtkMenuItemClass BaseClassType;
64 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
68 #ifndef DOXYGEN_SHOULD_SKIP_THIS
71 friend class MenuItem_Class;
72 static CppClassType menuitem_class_;
75 MenuItem(const MenuItem&);
76 MenuItem& operator=(const MenuItem&);
79 explicit MenuItem(const Glib::ConstructParams& construct_params);
80 explicit MenuItem(GtkMenuItem* castitem);
82 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
85 #ifndef DOXYGEN_SHOULD_SKIP_THIS
86 static GType get_type() G_GNUC_CONST;
87 static GType get_base_type() G_GNUC_CONST;
90 ///Provides access to the underlying C GtkObject.
91 GtkMenuItem* gobj() { return reinterpret_cast<GtkMenuItem*>(gobject_); }
93 ///Provides access to the underlying C GtkObject.
94 const GtkMenuItem* gobj() const { return reinterpret_cast<GtkMenuItem*>(gobject_); }
98 //C++ methods used to invoke GTK+ virtual functions:
101 //GTK+ Virtual Functions (override these to change behaviour):
103 //Default Signal Handlers::
104 virtual void on_activate();
105 virtual void on_activate_item();
106 virtual void on_toggle_size_request(int* requisition);
107 virtual void on_toggle_size_allocate(int allocation);
114 /// Create an empty menu item
117 /// Create a menu item with widget
118 explicit MenuItem(Widget& widget);
120 /// Create a menu item with label
121 explicit MenuItem(const Glib::ustring& label, bool mnemonic = false);
124 void set_submenu(Menu& submenu);
126 /** Gets the submenu underneath this menu item, if any. See
128 * @return Submenu for this menu item, or <tt>0</tt> if none.
132 /** Gets the submenu underneath this menu item, if any. See
134 * @return Submenu for this menu item, or <tt>0</tt> if none.
136 const Menu* get_submenu() const;
137 bool has_submenu() const;
140 void remove_submenu();
148 void toggle_size_request(int& requisition);
150 void toggle_size_allocate(int allocation);
152 /** Sets whether the menu item appears justified at the right
153 * side of a menu bar. This was traditionally done for "Help" menu
154 * items, but is now considered a bad idea. (If the widget
155 * layout is reversed for a right-to-left language like Hebrew
156 * or Arabic, right-justified-menu-items appear at the left.)
157 * @param right_justified If <tt>true</tt> the menu item will appear at the
158 * far right if added to a menu bar.
160 void set_right_justified(bool right_justified = true);
162 /** Gets whether the menu item appears justified at the right
163 * side of the menu bar.
164 * @return <tt>true</tt> if the menu item will appear at the
165 * far right if added to a menu bar.
167 bool get_right_justified() const;
169 /** Set the accelerator path on @a menu_item , through which runtime changes of the
170 * menu item's accelerator caused by the user can be identified and saved to
171 * persistant storage (see gtk_accel_map_save() on this).
172 * To setup a default accelerator for this menu item, call
173 * gtk_accel_map_add_entry() with the same @a accel_path .
174 * See also gtk_accel_map_add_entry() on the specifics of accelerator paths,
175 * and set_accel_path() for a more convenient variant of this function.
177 * This function is basically a convenience wrapper that handles calling
178 * Gtk::Widget::set_accel_path() with the appropriate accelerator group for
181 * Note that you do need to set an accelerator on the parent menu with
182 * set_accel_group() for this to work.
183 * @param accel_path Accelerator path, corresponding to this menu item's
186 void set_accel_path(const Glib::ustring& accel_path);
187 void unset_accel_path();
190 Glib::SignalProxy0< void > signal_activate();
193 Glib::SignalProxy0< void > signal_activate_item();
196 Glib::SignalProxy1< void,int* > signal_toggle_size_request();
199 Glib::SignalProxy1< void,int > signal_toggle_size_allocate();
202 void accelerate(Window& window);
206 void add_accel_label(const Glib::ustring& label, bool mnemonic = true);
208 void set_accel_key(const AccelKey& accel_key);
212 friend class Menu_Helpers::Element;
214 //This data is set by MenuElem, and will be used in on_realize(), in the call to add_accelerator().
220 } /* namespace Gtk */
225 /** @relates Gtk::MenuItem
226 * @param object The C instance
227 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
228 * @result A C++ instance that wraps this C instance.
230 Gtk::MenuItem* wrap(GtkMenuItem* object, bool take_copy = false);
232 #endif /* _GTKMM_MENUITEM_H */