Install ardour as a binary, a script and a set of shared
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / menuitem.h
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_MENUITEM_H
4 #define _GTKMM_MENUITEM_H
5
6 #include <glibmm.h>
7
8 /* $Id$ */
9
10
11 /* menuitem.h
12  * 
13  * Copyright (C) 1998-2002 The gtkmm Development Team
14  *
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.
19  *
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.
24  *
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.
28  */
29  
30 #include <gtkmm/item.h>
31 #include <gtkmm/accelkey.h>
32 #include <gtkmm/accellabel.h>
33
34
35 #ifndef DOXYGEN_SHOULD_SKIP_THIS
36 typedef struct _GtkMenuItem GtkMenuItem;
37 typedef struct _GtkMenuItemClass GtkMenuItemClass;
38 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
39
40
41 namespace Gtk
42 { class MenuItem_Class; } // namespace Gtk
43 namespace Gtk
44 {
45
46 class Menu;
47 namespace Menu_Helpers { class Element; }
48
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.
52  * @ingroup Widgets
53  * @ingroup Menus
54  */
55
56 class MenuItem : public Item
57 {
58   public:
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 */
65
66   virtual ~MenuItem();
67
68 #ifndef DOXYGEN_SHOULD_SKIP_THIS
69
70 private:
71   friend class MenuItem_Class;
72   static CppClassType menuitem_class_;
73
74   // noncopyable
75   MenuItem(const MenuItem&);
76   MenuItem& operator=(const MenuItem&);
77
78 protected:
79   explicit MenuItem(const Glib::ConstructParams& construct_params);
80   explicit MenuItem(GtkMenuItem* 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   GtkMenuItem*       gobj()       { return reinterpret_cast<GtkMenuItem*>(gobject_); }
92
93   ///Provides access to the underlying C GtkObject.
94   const GtkMenuItem* gobj() const { return reinterpret_cast<GtkMenuItem*>(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   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);
108
109
110 private:
111
112 public:
113
114   /// Create an empty menu item
115   MenuItem();
116
117   /// Create a menu item with widget
118   explicit MenuItem(Widget& widget);
119
120   /// Create a menu item with label
121   explicit MenuItem(const Glib::ustring& label, bool mnemonic = false);
122
123   
124   void set_submenu(Menu& submenu);
125   
126   /** Gets the submenu underneath this menu item, if any. See
127    * set_submenu().
128    * @return Submenu for this menu item, or <tt>0</tt> if none.
129    */
130   Menu* get_submenu();
131   
132   /** Gets the submenu underneath this menu item, if any. See
133    * set_submenu().
134    * @return Submenu for this menu item, or <tt>0</tt> if none.
135    */
136   const Menu* get_submenu() const;
137   bool has_submenu() const;
138
139   
140   void remove_submenu();
141   
142   void select();
143   
144   void deselect();
145   
146   void activate();
147   
148   void toggle_size_request(int& requisition);
149   
150   void toggle_size_allocate(int allocation);
151   
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.
159    */
160   void set_right_justified(bool right_justified = true);
161   
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.
166    */
167   bool get_right_justified() const;
168   
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.
176    * 
177    * This function is basically a convenience wrapper that handles calling
178    * Gtk::Widget::set_accel_path() with the appropriate accelerator group for
179    * the menu item.
180    * 
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
184    * functionality.
185    */
186   void set_accel_path(const Glib::ustring& accel_path);
187   void unset_accel_path();
188
189   
190   Glib::SignalProxy0< void > signal_activate();
191
192   
193   Glib::SignalProxy0< void > signal_activate_item();
194
195   
196   Glib::SignalProxy1< void,int* > signal_toggle_size_request();
197
198   
199   Glib::SignalProxy1< void,int > signal_toggle_size_allocate();
200
201
202   void accelerate(Window& window);
203
204 protected:
205
206   void add_accel_label(const Glib::ustring& label, bool mnemonic = true);
207
208   void set_accel_key(const AccelKey& accel_key);
209
210 private:
211
212   friend class Menu_Helpers::Element;
213
214   //This data is set by MenuElem, and will be used in on_realize(), in the call to add_accelerator().
215   AccelKey accel_key_;
216
217
218 };
219
220 } /* namespace Gtk */
221
222
223 namespace Glib
224 {
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.
229    */
230   Gtk::MenuItem* wrap(GtkMenuItem* object, bool take_copy = false);
231 }
232 #endif /* _GTKMM_MENUITEM_H */
233