Install ardour as a binary, a script and a set of shared
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / menushell.h
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_MENUSHELL_H
4 #define _GTKMM_MENUSHELL_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 #include <gdk/gdkkeysyms.h>
28
29
30 #include <gtkmm/container.h>
31 #include <gtkmm/menu_elems.h>
32 #include <glibmm/helperlist.h>
33
34 #ifndef DOXYGEN_SHOULD_SKIP_THIS
35 typedef struct _GtkMenuShell GtkMenuShell;
36 typedef struct _GtkMenuShellClass GtkMenuShellClass;
37 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
38
39
40 namespace Gtk
41 { class MenuShell_Class; } // namespace Gtk
42 namespace Gtk
43 {
44
45 class Menu;
46 class MenuShell;
47 class Window;
48
49 namespace Menu_Helpers
50 {
51
52 /*********************************************************************
53 ***** List properties
54 *********************************************************************/
55
56  
57 class MenuList : public Glib::HelperList< MenuItem, const Element, Glib::List_Cpp_Iterator<GtkMenuItem,MenuItem> >
58 {
59 public:
60   MenuList();
61   explicit MenuList(GtkMenuShell* gparent);
62   MenuList(const MenuList& src);
63   virtual ~MenuList() {}
64
65   MenuList& operator=(const MenuList& src);
66
67   typedef Glib::HelperList< MenuItem, const Element,  Glib::List_Cpp_Iterator<GtkMenuItem,MenuItem> > type_base;
68
69   GtkMenuShell* gparent();
70   const GtkMenuShell* gparent() const;
71
72   virtual GList*& glist() const;      // front of list
73
74   virtual void erase(iterator start, iterator stop);
75   virtual iterator erase(iterator);  //Implented as custom or by LIST_CONTAINER_REMOVE
76   virtual void remove(const_reference); //Implented as custom or by LIST_CONTAINER_REMOVE
77
78   /// This is order n. (use at own risk)
79   reference operator[](size_type l) const;
80
81 public:
82   iterator insert(iterator position, element_type& e); //custom-implemented.
83
84   template <class InputIterator>
85   inline void insert(iterator position, InputIterator first, InputIterator last)
86   {
87     for(;first != last; ++first)
88       position = insert(position, *first);
89   }
90
91  inline void push_front(element_type& e)
92     { insert(begin(), e); }
93   inline void push_back(element_type& e)
94     { insert(end(), e); }
95
96
97   virtual void remove(Widget& widget); //custom
98   };
99
100
101 } // namespace Menu_Helpers
102
103
104 /** The abstract base class for Gtk::Menu and Gtk::MenuBar.
105  * It is a container of Gtk::MenuItem objects arranged in a list which can be navigated, selected, and activated by the user to perform application functions.
106  * It can have a submenu associated with it, allowing for nested hierarchical menus.
107  * You can use append(), prepend() and insert() to add Gtk::MenuItem widgets,
108  * but you will probably find it more convenient to use the STL-style items() interface with the Gtk::Menu_Helpers::MenuElem() class.
109  * @ingroup Widgets
110  * @ingroup Containers
111  * @ingroup Menus
112  */
113
114 class MenuShell : public Container 
115 {
116   public:
117 #ifndef DOXYGEN_SHOULD_SKIP_THIS
118   typedef MenuShell CppObjectType;
119   typedef MenuShell_Class CppClassType;
120   typedef GtkMenuShell BaseObjectType;
121   typedef GtkMenuShellClass BaseClassType;
122 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
123
124   virtual ~MenuShell();
125
126 #ifndef DOXYGEN_SHOULD_SKIP_THIS
127
128 private:
129   friend class MenuShell_Class;
130   static CppClassType menushell_class_;
131
132   // noncopyable
133   MenuShell(const MenuShell&);
134   MenuShell& operator=(const MenuShell&);
135
136 protected:
137   explicit MenuShell(const Glib::ConstructParams& construct_params);
138   explicit MenuShell(GtkMenuShell* castitem);
139
140 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
141
142 public:
143 #ifndef DOXYGEN_SHOULD_SKIP_THIS
144   static GType get_type()      G_GNUC_CONST;
145   static GType get_base_type() G_GNUC_CONST;
146 #endif
147
148   ///Provides access to the underlying C GtkObject.
149   GtkMenuShell*       gobj()       { return reinterpret_cast<GtkMenuShell*>(gobject_); }
150
151   ///Provides access to the underlying C GtkObject.
152   const GtkMenuShell* gobj() const { return reinterpret_cast<GtkMenuShell*>(gobject_); }
153
154
155 public:
156   //C++ methods used to invoke GTK+ virtual functions:
157
158 protected:
159   //GTK+ Virtual Functions (override these to change behaviour):
160
161   //Default Signal Handlers::
162   virtual void on_deactivate();
163   virtual void on_selection_done();
164
165
166 private:
167
168
169 public:
170   
171
172   typedef Menu_Helpers::MenuList MenuList;
173   friend class Menu_Helpers::MenuList;
174
175   
176   void append(MenuItem& menu_item);
177   
178   void prepend(MenuItem& menu_item);
179   
180   void insert(MenuItem& menu_item, int position);
181
182   
183   void select_item(MenuItem& menu_item);
184   
185   void deselect();
186
187   //TODO: Is force_deactivate = false a good default?
188   
189   void activate_item(MenuItem& menu_item, bool force_deactivate = false);
190   
191   /** Select the first visible or selectable child of the menu shell;
192    * don't select tearoff items unless the only item is a tearoff
193    * item.
194    * 
195    * Since: 2.2
196    * @param search_sensitive If <tt>true</tt>, search for the first selectable
197    * menu item, otherwise select nothing if
198    * the first item isn't sensitive. This
199    * should be <tt>false</tt> if the menu is being
200    * popped up initially.
201    */
202   void select_first(bool search_sensitive = true);
203   
204   void deactivate();
205   
206   /** Cancels the selection within the menu shell.  
207    * 
208    * Since: 2.4
209    */
210   void cancel();
211
212   
213   Glib::SignalProxy0< void > signal_deactivate();
214
215   
216   Glib::SignalProxy0< void > signal_selection_done();
217
218
219   //Keybinding signals:
220   
221   
222   MenuList& items();
223   const MenuList& items() const;
224
225   /**
226    * Initializes menu accelerators.
227    * This method initializes the menu accelerators. Therefore an
228    * AccelGroup object is needed which is stored in each Window object
229    * in the Gtkmm library implementation.
230    *
231    * When using MenuBar and OptionMenu objects this method is called
232    * automatically when the menus are realized. Because most likely the
233    * MenuBar and OptionMenu is attached to a window at this time and
234    * the window object can be found automatically.
235    *
236    * Important note when using popup menus: 
237    * If you are using accelerated menu entries inside a popup
238    * menu you have to call the accelerate() method manually. This is
239    * because the popup menu is not connected to any window and the
240    * accelerators should be initialized even before the popup menu is
241    * shown. The right place to call the accelerate() method is right
242    * after the popup menu has been build.
243    *
244    * @param window Window where the menu is shown. Inside this window
245    *   the AccelGroup object is stored that will be used to initialize
246    *   the accelerators.
247    */
248   void accelerate(Window& window);
249
250   /**
251    * Initializes menu accelerators.
252    * Does the same as the accelerate(Window& window) method. But you can
253    * use any parent widget where the menu is used. This method then gets
254    * the toplevel window using Widget::get_toplevel() and uses this
255    * window for registering the menu accelerators.
256    *
257    * @param parent Parent widget used as starting point for searching
258    *   the toplevel window.
259    */
260   void accelerate(Widget& parent);
261
262 protected:
263   MenuShell();
264   
265
266 private:
267
268
269   MenuList      items_proxy_;
270   Gtk::Window*  accel_window_;
271
272
273 };
274
275 } // namespace Gtk
276
277
278 namespace Glib
279 {
280   /** @relates Gtk::MenuShell
281    * @param object The C instance
282    * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
283    * @result A C++ instance that wraps this C instance.
284    */
285   Gtk::MenuShell* wrap(GtkMenuShell* object, bool take_copy = false);
286 }
287 #endif /* _GTKMM_MENUSHELL_H */
288