Install ardour as a binary, a script and a set of shared
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / menu.h
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_MENU_H
4 #define _GTKMM_MENU_H
5
6 #include <glibmm.h>
7
8 /* $Id$ */
9
10 /* Copyright (C) 1998-2002 The gtkmm Development Team
11  *
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.
16  *
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.
21  *
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.
25  */
26
27
28 //#include <gtk/gtkmenu.h>
29 #include <gtkmm/menushell.h>
30 #include <gtkmm/menuitem.h>
31
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 typedef struct _GtkMenu GtkMenu;
34 typedef struct _GtkMenuClass GtkMenuClass;
35 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
36
37
38 namespace Gtk
39 { class Menu_Class; } // namespace Gtk
40 namespace Gtk
41 {
42
43 class AccelGroup;
44
45 /** @defgroup Menus Menu classes
46  */
47
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.
52  * @ingroup Widgets
53  * @ingroup Menus
54  */
55
56 class Menu : public MenuShell
57 {
58   public:
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 */
65
66   virtual ~Menu();
67
68 #ifndef DOXYGEN_SHOULD_SKIP_THIS
69
70 private:
71   friend class Menu_Class;
72   static CppClassType menu_class_;
73
74   // noncopyable
75   Menu(const Menu&);
76   Menu& operator=(const Menu&);
77
78 protected:
79   explicit Menu(const Glib::ConstructParams& construct_params);
80   explicit Menu(GtkMenu* castitem);
81
82 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
83
84 public:
85 #ifndef DOXYGEN_SHOULD_SKIP_THIS
86   static GType get_type()      G_GNUC_CONST;
87   static GType get_base_type() G_GNUC_CONST;
88 #endif
89
90   ///Provides access to the underlying C GtkObject.
91   GtkMenu*       gobj()       { return reinterpret_cast<GtkMenu*>(gobject_); }
92
93   ///Provides access to the underlying C GtkObject.
94   const GtkMenu* gobj() const { return reinterpret_cast<GtkMenu*>(gobject_); }
95
96
97 public:
98   //C++ methods used to invoke GTK+ virtual functions:
99
100 protected:
101   //GTK+ Virtual Functions (override these to change behaviour):
102
103   //Default Signal Handlers::
104
105
106 private:
107
108   
109    //deprecated.
110 public:
111   Menu();
112
113 /* append, prepend, and insert are defined in MenuShell */
114
115   /** For instance,
116    * void on_popup_menu_position(int& x, int& y, bool& push_in);
117    */
118   typedef sigc::slot<void, int&, int&, bool&> SlotPositionCalc;
119              
120   void popup(MenuShell& parent_menu_shell, MenuItem& parent_menu_item, const SlotPositionCalc& slot, guint button, guint32 activate_time);
121   
122
123   /** Displays a menu and makes it available for selection.  Applications can use
124    * this function to display context-sensitive menus.
125    *
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.
130    *
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.
137    */
138   void popup(const SlotPositionCalc& position_calc_slot, guint button, guint32 activate_time);
139
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.
144    */
145   void popup(guint button, guint32 activate_time);
146
147   
148   void reposition();
149
150   
151   void popdown();
152
153   
154   MenuItem* get_active();
155   
156   const MenuItem* get_active() const;
157   
158   void set_active(guint index);
159
160   
161   void set_accel_group(const Glib::RefPtr<AccelGroup>& accel_group);
162   void unset_accel_group();
163   
164   Glib::RefPtr<AccelGroup> get_accel_group();
165   
166   Glib::RefPtr<const AccelGroup> get_accel_group() const;
167   
168   
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, "&lt;Gnumeric-Sheet&gt;/File");</tt>
179    * has been called, assign its items the accel paths:
180    * <tt>"&lt;Gnumeric-Sheet&gt;/File/New"</tt> and <tt>"&lt;Gnumeric-Sheet&gt;/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.
185    */
186   void set_accel_path(const Glib::ustring& accel_path);
187
188   
189   void detach();
190   
191   Widget* get_attach_widget();
192   
193   const Widget* get_attach_widget() const;
194
195   
196   void set_tearoff_state(bool torn_off = true);
197   
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.
201    */
202   bool get_tearoff_state() const;
203
204   
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.
208    */
209   void set_title(const Glib::ustring& title);
210   void unset_title();
211   
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.
216    */
217   Glib::ustring get_title() const;
218   
219   /** Sets the Gdk::Screen on which the menu will be displayed.
220    * 
221    * Since: 2.2
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.
224    */
225   void set_screen(const Glib::RefPtr<Gdk::Screen>& screen);
226
227   
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).
233    * 
234    * Note that this function is not related to detach().
235    * 
236    * Since: 2.4
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.
242    */
243   void attach(Gtk::Widget& child, guint left_attach, guint right_attach, guint top_attach, guint bottom_attach);
244
245   
246   /** Informs GTK+ on which monitor a menu should be popped up. 
247    * See gdk_screen_get_monitor_geometry().
248    * 
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. 
254    * 
255    * Since: 2.4
256    * @param monitor_num The number of the monitor on which the menu should
257    * be popped up.
258    */
259   void set_monitor(int monitor_num);
260   
261   void reorder_child(const MenuItem& child, int position);
262   
263
264   /** A title that may be displayed by the window manager when this menu is torn-off.
265    *
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.
269    */
270   Glib::PropertyProxy<Glib::ustring> property_tearoff_title() ;
271
272 /** A title that may be displayed by the window manager when this menu is torn-off.
273    *
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.
277    */
278   Glib::PropertyProxy_ReadOnly<Glib::ustring> property_tearoff_title() const;
279
280
281 protected:
282
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);
285   
286   void attach_to_widget(Widget& widget, GtkMenuDetachFunc detacher);
287
288
289 };
290
291 } // namespace Gtk
292
293
294 namespace Glib
295 {
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.
300    */
301   Gtk::Menu* wrap(GtkMenu* object, bool take_copy = false);
302 }
303 #endif /* _GTKMM_MENU_H */
304