2 // Generated by gtkmmproc -- DO NOT MODIFY!
10 /* Copyright (C) 1998-2002 The gtkmm Development Team
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with this library; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 //#include <gtk/gtkmenu.h>
29 #include <gtkmm/menushell.h>
30 #include <gtkmm/menuitem.h>
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 typedef struct _GtkMenu GtkMenu;
34 typedef struct _GtkMenuClass GtkMenuClass;
35 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
39 { class Menu_Class; } // namespace Gtk
45 /** @defgroup Menus Menu classes
48 /** A drop-down menu consisting of Gtk::MenuItem objects which can be navigated and activated by the user to perform application functions.
49 * Menus are normally placed inside a Gtk::MenuBar or another MenuItem as a sub menu.
50 * A Menu can also be popped up, for instance as a right-click context menu, by calling the popup() method.
51 * See also Gtk::OptionMenu.
56 class Menu : public MenuShell
59 #ifndef DOXYGEN_SHOULD_SKIP_THIS
60 typedef Menu CppObjectType;
61 typedef Menu_Class CppClassType;
62 typedef GtkMenu BaseObjectType;
63 typedef GtkMenuClass BaseClassType;
64 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
68 #ifndef DOXYGEN_SHOULD_SKIP_THIS
71 friend class Menu_Class;
72 static CppClassType menu_class_;
76 Menu& operator=(const Menu&);
79 explicit Menu(const Glib::ConstructParams& construct_params);
80 explicit Menu(GtkMenu* 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 GtkMenu* gobj() { return reinterpret_cast<GtkMenu*>(gobject_); }
93 ///Provides access to the underlying C GtkObject.
94 const GtkMenu* gobj() const { return reinterpret_cast<GtkMenu*>(gobject_); }
98 //C++ methods used to invoke GTK+ virtual functions:
101 //GTK+ Virtual Functions (override these to change behaviour):
103 //Default Signal Handlers::
113 /* append, prepend, and insert are defined in MenuShell */
116 * void on_popup_menu_position(int& x, int& y, bool& push_in);
118 typedef sigc::slot<void, int&, int&, bool&> SlotPositionCalc;
120 void popup(MenuShell& parent_menu_shell, MenuItem& parent_menu_item, const SlotPositionCalc& slot, guint button, guint32 activate_time);
123 /** Displays a menu and makes it available for selection. Applications can use
124 * this function to display context-sensitive menus.
126 * The @a button parameter should be the mouse button pressed to initiate
127 * the menu popup. If the menu popup was initiated by something other than
128 * a mouse button press, such as a mouse button release or a keypress,
129 * @a button should be 0.
131 * The @a activate_time parameter should be the time stamp of the event that
132 * initiated the popup. If such an event is not available, use
133 * gtk_get_current_event_time() instead.
134 * @param func A position_calc_slot supplied function used to position the menu, or <tt>0</tt>.
135 * @param button The mouse button which was pressed to initiate the event.
136 * @param activate_time The time at which the activation event occurred.
138 void popup(const SlotPositionCalc& position_calc_slot, guint button, guint32 activate_time);
140 /** Displays a menu and makes it available for selection.
141 * Applications can use this function to display context-sensitive menus, at the current pointer position.
142 * @param button The button which was pressed to initiate the event.
143 * @param activate_time The time at which the activation event occurred.
145 void popup(guint button, guint32 activate_time);
154 MenuItem* get_active();
156 const MenuItem* get_active() const;
158 void set_active(guint index);
161 void set_accel_group(const Glib::RefPtr<AccelGroup>& accel_group);
162 void unset_accel_group();
164 Glib::RefPtr<AccelGroup> get_accel_group();
166 Glib::RefPtr<const AccelGroup> get_accel_group() const;
169 /** Sets an accelerator path for this menu from which accelerator paths
170 * for its immediate children, its menu items, can be constructed.
171 * The main purpose of this function is to spare the programmer the
172 * inconvenience of having to call Gtk::MenuItem::set_accel_path() on
173 * each menu item that should support runtime user changable accelerators.
174 * Instead, by just calling set_accel_path() on their parent,
175 * each menu item of this menu, that contains a label describing its purpose,
176 * automatically gets an accel path assigned. For example, a menu containing
177 * menu items "New" and "Exit", will, after
178 * <tt>gtk_menu_set_accel_path (menu, "<Gnumeric-Sheet>/File");</tt>
179 * has been called, assign its items the accel paths:
180 * <tt>"<Gnumeric-Sheet>/File/New"</tt> and <tt>"<Gnumeric-Sheet>/File/Exit"</tt>.
181 * Assigning accel paths to menu items then enables the user to change
182 * their accelerators at runtime. More details about accelerator paths
183 * and their default setups can be found at gtk_accel_map_add_entry().
184 * @param accel_path A valid accelerator path.
186 void set_accel_path(const Glib::ustring& accel_path);
191 Widget* get_attach_widget();
193 const Widget* get_attach_widget() const;
196 void set_tearoff_state(bool torn_off = true);
198 /** Returns whether the menu is torn off. See
199 * set_tearoff_state().
200 * @return <tt>true</tt> if the menu is currently torn off.
202 bool get_tearoff_state() const;
205 /** Sets the title string for the menu. The title is displayed when the menu
206 * is shown as a tearoff menu.
207 * @param title A string containing the title for the menu.
209 void set_title(const Glib::ustring& title);
212 /** Returns the title of the menu. See set_title().
213 * @return The title of the menu, or <tt>0</tt> if the menu has no
214 * title set on it. This string is owned by the widget and should
215 * not be modified or freed.
217 Glib::ustring get_title() const;
219 /** Sets the Gdk::Screen on which the menu will be displayed.
222 * @param screen A Gdk::Screen, or <tt>0</tt> if the screen should be
223 * determined by the widget the menu is attached to.
225 void set_screen(const Glib::RefPtr<Gdk::Screen>& screen);
228 /** Adds a new Gtk::MenuItem to a (table) menu. The number of 'cells' that
229 * an item will occupy is specified by @a left_attach , @a right_attach ,
230 * @a top_attach and @a bottom_attach . These each represent the leftmost,
231 * rightmost, uppermost and lower column and row numbers of the table.
232 * (Columns and rows are indexed from zero).
234 * Note that this function is not related to detach().
237 * @param child A Gtk::MenuItem.
238 * @param left_attach The column number to attach the left side of the item to.
239 * @param right_attach The column number to attach the right side of the item to.
240 * @param top_attach The row number to attach the top of the item to.
241 * @param bottom_attach The row number to attach the bottom of the item to.
243 void attach(Gtk::Widget& child, guint left_attach, guint right_attach, guint top_attach, guint bottom_attach);
246 /** Informs GTK+ on which monitor a menu should be popped up.
247 * See gdk_screen_get_monitor_geometry().
249 * This function should be called from a Gtk::MenuPositionFunc if the
250 * menu should not appear on the same monitor as the pointer. This
251 * information can't be reliably inferred from the coordinates returned
252 * by a Gtk::MenuPositionFunc, since, for very long menus, these coordinates
253 * may extend beyond the monitor boundaries or even the screen boundaries.
256 * @param monitor_num The number of the monitor on which the menu should
259 void set_monitor(int monitor_num);
261 void reorder_child(const MenuItem& child, int position);
264 /** A title that may be displayed by the window manager when this menu is torn-off.
266 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
267 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
268 * the value of the property changes.
270 Glib::PropertyProxy<Glib::ustring> property_tearoff_title() ;
272 /** A title that may be displayed by the window manager when this menu is torn-off.
274 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
275 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
276 * the value of the property changes.
278 Glib::PropertyProxy_ReadOnly<Glib::ustring> property_tearoff_title() const;
283 //We can not wrap this as a slot because there is no data parameter, and no destroy callback to destroy that data.
284 typedef void (*GtkMenuDetachFunc) (GtkWidget *attach_widget, GtkMenu *menu);
286 void attach_to_widget(Widget& widget, GtkMenuDetachFunc detacher);
296 /** @relates Gtk::Menu
297 * @param object The C instance
298 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
299 * @result A C++ instance that wraps this C instance.
301 Gtk::Menu* wrap(GtkMenu* object, bool take_copy = false);
303 #endif /* _GTKMM_MENU_H */