1 /* $Id: menu.hg,v 1.11 2006/04/12 11:11:25 murrayc Exp $ */
3 /* Copyright (C) 1998-2002 The gtkmm Development Team
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 _PINCLUDE(gtkmm/private/menushell_p.h)
23 //#include <gtk/gtkmenu.h>
24 #include <gtkmm/menushell.h>
25 #include <gtkmm/menuitem.h>
32 /** @defgroup Menus Menu classes
35 /** A drop-down menu consisting of Gtk::MenuItem objects which can be navigated and activated by the user to perform application functions.
36 * Menus are normally placed inside a Gtk::MenuBar or another MenuItem as a sub menu.
37 * A Menu can also be popped up, for instance as a right-click context menu, by calling the popup() method.
38 * See also Gtk::OptionMenu.
42 class Menu : public MenuShell
44 _CLASS_GTKOBJECT(Menu,GtkMenu,GTK_MENU,Gtk::MenuShell,GtkMenuShell)
46 _IGNORE(gtk_menu_append, gtk_menu_prepend, gtk_menu_insert) //deprecated.
50 /* append, prepend, and insert are defined in MenuShell */
53 * void on_popup_menu_position(int& x, int& y, bool& push_in);
55 typedef sigc::slot<void, int&, int&, bool&> SlotPositionCalc;
57 void popup(MenuShell& parent_menu_shell, MenuItem& parent_menu_item, const SlotPositionCalc& slot, guint button, guint32 activate_time);
58 _IGNORE(gtk_menu_popup)
60 /** Displays a menu and makes it available for selection. Applications can use
61 * this function to display context-sensitive menus.
63 * The @a button parameter should be the mouse button pressed to initiate
64 * the menu popup. If the menu popup was initiated by something other than
65 * a mouse button press, such as a mouse button release or a keypress,
66 * @a button should be 0.
68 * The @a activate_time parameter should be the time stamp of the event that
69 * initiated the popup. If such an event is not available, use
70 * gtk_get_current_event_time() instead.
71 * @param func A position_calc_slot supplied function used to position the menu, or <tt>0</tt>.
72 * @param button The mouse button which was pressed to initiate the event.
73 * @param activate_time The time at which the activation event occurred.
75 void popup(const SlotPositionCalc& position_calc_slot, guint button, guint32 activate_time);
77 /** Displays a menu and makes it available for selection.
78 * Applications can use this function to display context-sensitive menus, at the current pointer position.
79 * @param button The button which was pressed to initiate the event.
80 * @param activate_time The time at which the activation event occurred.
82 void popup(guint button, guint32 activate_time);
84 _WRAP_METHOD(void reposition(), gtk_menu_reposition)
86 _WRAP_METHOD(void popdown(), gtk_menu_popdown)
88 _WRAP_METHOD(MenuItem* get_active(),gtk_menu_get_active)
89 _WRAP_METHOD(const MenuItem* get_active() const, gtk_menu_get_active, constversion)
90 _WRAP_METHOD(void set_active(guint index),gtk_menu_set_active)
92 _WRAP_METHOD(void set_accel_group(const Glib::RefPtr<AccelGroup>& accel_group), gtk_menu_set_accel_group)
93 void unset_accel_group();
94 _WRAP_METHOD(Glib::RefPtr<AccelGroup> get_accel_group(), gtk_menu_get_accel_group, refreturn)
95 _WRAP_METHOD(Glib::RefPtr<const AccelGroup> get_accel_group() const, gtk_menu_get_accel_group, refreturn, constversion)
97 _WRAP_METHOD(void set_accel_path(const Glib::ustring& accel_path), gtk_menu_set_accel_path)
99 _WRAP_METHOD(void detach(),gtk_menu_detach)
100 _WRAP_METHOD(Widget* get_attach_widget(), gtk_menu_get_attach_widget)
101 _WRAP_METHOD(const Widget* get_attach_widget() const, gtk_menu_get_attach_widget, constversion)
103 _WRAP_METHOD(void set_tearoff_state(bool torn_off = true), gtk_menu_set_tearoff_state)
104 _WRAP_METHOD(bool get_tearoff_state() const, gtk_menu_get_tearoff_state)
106 _WRAP_METHOD(void set_title(const Glib::ustring& title), gtk_menu_set_title)
108 _WRAP_METHOD(Glib::ustring get_title() const, gtk_menu_get_title)
109 _WRAP_METHOD(void set_screen(const Glib::RefPtr<Gdk::Screen>& screen), gtk_menu_set_screen)
111 _WRAP_METHOD(void attach(Gtk::Widget& child, guint left_attach, guint right_attach, guint top_attach, guint bottom_attach), gtk_menu_attach)
113 _WRAP_METHOD(void set_monitor(int monitor_num), gtk_menu_set_monitor)
115 void reorder_child(const MenuItem& child, int position);
116 _IGNORE(gtk_menu_reorder_child)
118 _IGNORE_SIGNAL("move_scroll")
119 _WRAP_PROPERTY("tearoff-title", Glib::ustring)
123 //We can not wrap this as a slot because there is no data parameter, and no destroy callback to destroy that data.
124 typedef void (*GtkMenuDetachFunc) (GtkWidget *attach_widget, GtkMenu *menu);
125 _WRAP_METHOD(void attach_to_widget(Widget& attach_widget, GtkMenuDetachFunc detacher), gtk_menu_attach_to_widget)
127 //TODO: What does "attach" actually mean here? murrayc
128 /** Attaches the menu to the widget.
130 * param @attach_widget: the Widget that the menu will be attached to.
134 void attach_to_widget(Widget& attach_widget);