2
// Generated by gtkmmproc -- DO NOT MODIFY!
3
#ifndef _GTKMM_MENUSHELL_H
4
#define _GTKMM_MENUSHELL_H
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.
27
#include <gdk/gdkkeysyms.h>
30
#include <gtkmm/container.h>
31
#include <gtkmm/menu_elems.h>
32
#include <glibmm/helperlist.h>
34
#ifndef DOXYGEN_SHOULD_SKIP_THIS
35
typedef struct _GtkMenuShell GtkMenuShell;
36
typedef struct _GtkMenuShellClass GtkMenuShellClass;
37
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
41
{ class MenuShell_Class; } // namespace Gtk
49
namespace Menu_Helpers
52
/*********************************************************************
54
*********************************************************************/
57
class MenuList : public Glib::HelperList< MenuItem, const Element, Glib::List_Cpp_Iterator<GtkMenuItem,MenuItem> >
61
explicit MenuList(GtkMenuShell* gparent);
62
MenuList(const MenuList& src);
63
virtual ~MenuList() {}
65
MenuList& operator=(const MenuList& src);
67
typedef Glib::HelperList< MenuItem, const Element, Glib::List_Cpp_Iterator<GtkMenuItem,MenuItem> > type_base;
69
GtkMenuShell* gparent();
70
const GtkMenuShell* gparent() const;
72
virtual GList*& glist() const; // front of list
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
78
/// This is order n. (use at own risk)
79
reference operator[](size_type l) const;
82
iterator insert(iterator position, element_type& e); //custom-implemented.
84
template <class InputIterator>
85
inline void insert(iterator position, InputIterator first, InputIterator last)
87
for(;first != last; ++first)
88
position = insert(position, *first);
91
inline void push_front(element_type& e)
92
{ insert(begin(), e); }
93
inline void push_back(element_type& e)
97
virtual void remove(Widget& widget); //custom
101
} // namespace Menu_Helpers
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.
110
* @ingroup Containers
114
class MenuShell : public Container
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 */
124
virtual ~MenuShell();
126
#ifndef DOXYGEN_SHOULD_SKIP_THIS
129
friend class MenuShell_Class;
130
static CppClassType menushell_class_;
133
MenuShell(const MenuShell&);
134
MenuShell& operator=(const MenuShell&);
137
explicit MenuShell(const Glib::ConstructParams& construct_params);
138
explicit MenuShell(GtkMenuShell* castitem);
140
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
143
#ifndef DOXYGEN_SHOULD_SKIP_THIS
144
static GType get_type() G_GNUC_CONST;
145
static GType get_base_type() G_GNUC_CONST;
148
///Provides access to the underlying C GtkObject.
149
GtkMenuShell* gobj() { return reinterpret_cast<GtkMenuShell*>(gobject_); }
151
///Provides access to the underlying C GtkObject.
152
const GtkMenuShell* gobj() const { return reinterpret_cast<GtkMenuShell*>(gobject_); }
156
//C++ methods used to invoke GTK+ virtual functions:
159
//GTK+ Virtual Functions (override these to change behaviour):
161
//Default Signal Handlers::
162
virtual void on_deactivate();
163
virtual void on_selection_done();
172
typedef Menu_Helpers::MenuList MenuList;
173
friend class Menu_Helpers::MenuList;
176
void append(MenuItem& menu_item);
178
void prepend(MenuItem& menu_item);
180
void insert(MenuItem& menu_item, int position);
183
void select_item(MenuItem& menu_item);
187
//TODO: Is force_deactivate = false a good default?
189
void activate_item(MenuItem& menu_item, bool force_deactivate = false);
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
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.
202
void select_first(bool search_sensitive = true);
206
/** Cancels the selection within the menu shell.
213
Glib::SignalProxy0< void > signal_deactivate();
216
Glib::SignalProxy0< void > signal_selection_done();
219
//Keybinding signals:
223
const MenuList& items() const;
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.
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.
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.
244
* @param window Window where the menu is shown. Inside this window
245
* the AccelGroup object is stored that will be used to initialize
248
void accelerate(Window& window);
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.
257
* @param parent Parent widget used as starting point for searching
258
* the toplevel window.
260
void accelerate(Widget& parent);
269
MenuList items_proxy_;
270
Gtk::Window* accel_window_;
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.
285
Gtk::MenuShell* wrap(GtkMenuShell* object, bool take_copy = false);
287
#endif /* _GTKMM_MENUSHELL_H */