2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_MENUITEM_H
4 #define _GTKMM_MENUITEM_H
14 * Copyright (C) 1998-2002 The gtkmm Development Team
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Library General Public
18 * License as published by the Free Software Foundation; either
19 * version 2 of the License, or (at your option) any later version.
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Library General Public License for more details.
26 * You should have received a copy of the GNU Library General Public
27 * License along with this library; if not, write to the Free
28 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 #include <gtkmm/item.h>
32 #include <gtkmm/accelkey.h>
33 #include <gtkmm/accellabel.h>
36 #ifndef DOXYGEN_SHOULD_SKIP_THIS
37 typedef struct _GtkMenuItem GtkMenuItem;
38 typedef struct _GtkMenuItemClass GtkMenuItemClass;
39 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
43 { class MenuItem_Class; } // namespace Gtk
48 namespace Menu_Helpers { class Element; }
50 /** Child item for menus.
51 * Handle highlighting, alignment, events and submenus.
52 * As it derives from Gtk::Bin it can hold any valid child widget, altough only a few are really useful.
57 class MenuItem : public Item
60 #ifndef DOXYGEN_SHOULD_SKIP_THIS
61 typedef MenuItem CppObjectType;
62 typedef MenuItem_Class CppClassType;
63 typedef GtkMenuItem BaseObjectType;
64 typedef GtkMenuItemClass BaseClassType;
65 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
69 #ifndef DOXYGEN_SHOULD_SKIP_THIS
72 friend class MenuItem_Class;
73 static CppClassType menuitem_class_;
76 MenuItem(const MenuItem&);
77 MenuItem& operator=(const MenuItem&);
80 explicit MenuItem(const Glib::ConstructParams& construct_params);
81 explicit MenuItem(GtkMenuItem* castitem);
83 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
86 #ifndef DOXYGEN_SHOULD_SKIP_THIS
87 static GType get_type() G_GNUC_CONST;
88 static GType get_base_type() G_GNUC_CONST;
91 ///Provides access to the underlying C GtkObject.
92 GtkMenuItem* gobj() { return reinterpret_cast<GtkMenuItem*>(gobject_); }
94 ///Provides access to the underlying C GtkObject.
95 const GtkMenuItem* gobj() const { return reinterpret_cast<GtkMenuItem*>(gobject_); }
99 //C++ methods used to invoke GTK+ virtual functions:
100 #ifdef GLIBMM_VFUNCS_ENABLED
101 #endif //GLIBMM_VFUNCS_ENABLED
104 //GTK+ Virtual Functions (override these to change behaviour):
105 #ifdef GLIBMM_VFUNCS_ENABLED
106 #endif //GLIBMM_VFUNCS_ENABLED
108 //Default Signal Handlers::
109 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
110 virtual void on_activate();
111 virtual void on_activate_item();
112 virtual void on_toggle_size_request(int* requisition);
113 virtual void on_toggle_size_allocate(int allocation);
114 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
121 /// Create an empty menu item
124 /// Create a menu item with widget
125 explicit MenuItem(Widget& widget);
127 /// Create a menu item with label
128 explicit MenuItem(const Glib::ustring& label, bool mnemonic = false);
131 /** Sets or replaces the menu item's submenu, or removes it when a <tt>0</tt>
133 * @param submenu The submenu, or <tt>0</tt>.
135 void set_submenu(Menu& submenu);
137 /** Gets the submenu underneath this menu item, if any. See
139 * @return Submenu for this menu item, or <tt>0</tt> if none.
143 /** Gets the submenu underneath this menu item, if any. See
145 * @return Submenu for this menu item, or <tt>0</tt> if none.
147 const Menu* get_submenu() const;
148 bool has_submenu() const;
151 /** Removes the widget's submenu.
153 * Deprecated: 2.12: remove_submenu() is deprecated and
154 * should not be used in newly written code. Use
155 * set_submenu() instead.
157 void remove_submenu();
165 void toggle_size_request(int& requisition);
167 void toggle_size_allocate(int allocation);
169 /** Sets whether the menu item appears justified at the right
170 * side of a menu bar. This was traditionally done for "Help" menu
171 * items, but is now considered a bad idea. (If the widget
172 * layout is reversed for a right-to-left language like Hebrew
173 * or Arabic, right-justified-menu-items appear at the left.)
174 * @param right_justified If <tt>true</tt> the menu item will appear at the
175 * far right if added to a menu bar.
177 void set_right_justified(bool right_justified = true);
179 /** Gets whether the menu item appears justified at the right
180 * side of the menu bar.
181 * @return <tt>true</tt> if the menu item will appear at the
182 * far right if added to a menu bar.
184 bool get_right_justified() const;
186 /** Set the accelerator path on @a menu_item , through which runtime changes of the
187 * menu item's accelerator caused by the user can be identified and saved to
188 * persistant storage (see gtk_accel_map_save() on this).
189 * To setup a default accelerator for this menu item, call
190 * gtk_accel_map_add_entry() with the same @a accel_path .
191 * See also gtk_accel_map_add_entry() on the specifics of accelerator paths,
192 * and set_accel_path() for a more convenient variant of this function.
194 * This function is basically a convenience wrapper that handles calling
195 * Gtk::Widget::set_accel_path() with the appropriate accelerator group for
198 * Note that you do need to set an accelerator on the parent menu with
199 * set_accel_group() for this to work.
200 * @param accel_path Accelerator path, corresponding to this menu item's
203 void set_accel_path(const Glib::ustring& accel_path);
204 void unset_accel_path();
209 * <tt>void on_my_%activate()</tt>
212 Glib::SignalProxy0< void > signal_activate();
217 * <tt>void on_my_%activate_item()</tt>
220 Glib::SignalProxy0< void > signal_activate_item();
225 * <tt>void on_my_%toggle_size_request(int* requisition)</tt>
228 Glib::SignalProxy1< void,int* > signal_toggle_size_request();
233 * <tt>void on_my_%toggle_size_allocate(int allocation)</tt>
236 Glib::SignalProxy1< void,int > signal_toggle_size_allocate();
239 void accelerate(Window& window);
243 void add_accel_label(const Glib::ustring& label, bool mnemonic = true);
245 void set_accel_key(const AccelKey& accel_key);
249 friend class Menu_Helpers::Element;
251 //This data is set by MenuElem, and will be used in on_realize(), in the call to add_accelerator().
257 } /* namespace Gtk */
262 /** A Glib::wrap() method for this object.
264 * @param object The C instance.
265 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
266 * @result A C++ instance that wraps this C instance.
268 * @relates Gtk::MenuItem
270 Gtk::MenuItem* wrap(GtkMenuItem* object, bool take_copy = false);
274 #endif /* _GTKMM_MENUITEM_H */