2
// Generated by gtkmmproc -- DO NOT MODIFY!
3
#ifndef _GTKMM_MENUSHELL_H
4
#define _GTKMM_MENUSHELL_H
9
/* $Id: menushell.hg,v 1.9 2006/06/21 20:04:25 murrayc Exp $ */
11
/* Copyright (C) 1998-2002 The gtkmm Development Team
13
* This library is free software; you can redistribute it and/or
14
* modify it under the terms of the GNU Lesser General Public
15
* License as published by the Free Software Foundation; either
16
* version 2.1 of the License, or (at your option) any later version.
18
* This library is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
* Lesser General Public License for more details.
23
* You should have received a copy of the GNU Lesser General Public
24
* License along with this library; if not, write to the Free
25
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28
#include <gdk/gdkkeysyms.h>
31
#include <gtkmm/container.h>
32
#include <gtkmm/menu_elems.h>
33
#include <glibmm/helperlist.h>
35
#ifndef DOXYGEN_SHOULD_SKIP_THIS
36
typedef struct _GtkMenuShell GtkMenuShell;
37
typedef struct _GtkMenuShellClass GtkMenuShellClass;
38
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
42
{ class MenuShell_Class; } // namespace Gtk
50
namespace Menu_Helpers
53
/*********************************************************************
55
*********************************************************************/
58
class MenuList : public Glib::HelperList< MenuItem, const Element, Glib::List_Cpp_Iterator<GtkMenuItem,MenuItem> >
62
explicit MenuList(GtkMenuShell* gparent);
63
MenuList(const MenuList& src);
64
virtual ~MenuList() {}
66
MenuList& operator=(const MenuList& src);
68
typedef Glib::HelperList< MenuItem, const Element, Glib::List_Cpp_Iterator<GtkMenuItem,MenuItem> > type_base;
70
GtkMenuShell* gparent();
71
const GtkMenuShell* gparent() const;
73
virtual GList*& glist() const; // front of list
75
virtual void erase(iterator start, iterator stop);
76
virtual iterator erase(iterator); //Implented as custom or by LIST_CONTAINER_REMOVE
77
virtual void remove(const_reference); //Implented as custom or by LIST_CONTAINER_REMOVE
79
/// This is order n. (use at own risk)
80
reference operator[](size_type l) const;
83
iterator insert(iterator position, element_type& e); //custom-implemented.
85
template <class InputIterator>
86
inline void insert(iterator position, InputIterator first, InputIterator last)
88
for(;first != last; ++first)
89
position = insert(position, *first);
92
inline void push_front(element_type& e)
93
{ insert(begin(), e); }
94
inline void push_back(element_type& e)
98
virtual void remove(Widget& widget); //custom
102
} // namespace Menu_Helpers
105
/** The abstract base class for Gtk::Menu and Gtk::MenuBar.
106
* 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.
107
* It can have a submenu associated with it, allowing for nested hierarchical menus.
108
* You can use append(), prepend() and insert() to add Gtk::MenuItem widgets,
109
* but you will probably find it more convenient to use the STL-style items() interface with the Gtk::Menu_Helpers::MenuElem() class.
111
* @ingroup Containers
115
class MenuShell : public Container
118
#ifndef DOXYGEN_SHOULD_SKIP_THIS
119
typedef MenuShell CppObjectType;
120
typedef MenuShell_Class CppClassType;
121
typedef GtkMenuShell BaseObjectType;
122
typedef GtkMenuShellClass BaseClassType;
123
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
125
virtual ~MenuShell();
127
#ifndef DOXYGEN_SHOULD_SKIP_THIS
130
friend class MenuShell_Class;
131
static CppClassType menushell_class_;
134
MenuShell(const MenuShell&);
135
MenuShell& operator=(const MenuShell&);
138
explicit MenuShell(const Glib::ConstructParams& construct_params);
139
explicit MenuShell(GtkMenuShell* castitem);
141
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
144
#ifndef DOXYGEN_SHOULD_SKIP_THIS
145
static GType get_type() G_GNUC_CONST;
148
static GType get_base_type() G_GNUC_CONST;
151
///Provides access to the underlying C GtkObject.
152
GtkMenuShell* gobj() { return reinterpret_cast<GtkMenuShell*>(gobject_); }
154
///Provides access to the underlying C GtkObject.
155
const GtkMenuShell* gobj() const { return reinterpret_cast<GtkMenuShell*>(gobject_); }
159
//C++ methods used to invoke GTK+ virtual functions:
162
//GTK+ Virtual Functions (override these to change behaviour):
164
//Default Signal Handlers::
165
virtual void on_deactivate();
166
virtual void on_selection_done();
175
typedef Menu_Helpers::MenuList MenuList;
176
friend class Menu_Helpers::MenuList;
179
void append(MenuItem& menu_item);
181
void prepend(MenuItem& menu_item);
183
void insert(MenuItem& menu_item, int position);
186
void select_item(MenuItem& menu_item);
190
//TODO: Is force_deactivate = false a good default?
192
void activate_item(MenuItem& menu_item, bool force_deactivate = false);
194
/** Select the first visible or selectable child of the menu shell;
195
* don't select tearoff items unless the only item is a tearoff
199
* @param search_sensitive If <tt>true</tt>, search for the first selectable
200
* menu item, otherwise select nothing if
201
* the first item isn't sensitive. This
202
* should be <tt>false</tt> if the menu is being
203
* popped up initially.
205
void select_first(bool search_sensitive = true);
209
/** Cancels the selection within the menu shell.
218
* <tt>void on_my_%deactivate()</tt>
221
Glib::SignalProxy0< void > signal_deactivate();
226
* <tt>void on_my_%selection_done()</tt>
229
Glib::SignalProxy0< void > signal_selection_done();
234
* <tt>gboolean on_my_%move_selected(int distance)</tt>
237
Glib::SignalProxy1< gboolean,int > signal_move_selected();
240
//Keybinding signals:
244
const MenuList& items() const;
247
* Initializes menu accelerators.
248
* This method initializes the menu accelerators. Therefore an
249
* AccelGroup object is needed which is stored in each Window object
250
* in the Gtkmm library implementation.
252
* When using MenuBar and OptionMenu objects this method is called
253
* automatically when the menus are realized. Because most likely the
254
* MenuBar and OptionMenu is attached to a window at this time and
255
* the window object can be found automatically.
257
* Important note when using popup menus:
258
* If you are using accelerated menu entries inside a popup
259
* menu you have to call the accelerate() method manually. This is
260
* because the popup menu is not connected to any window and the
261
* accelerators should be initialized even before the popup menu is
262
* shown. The right place to call the accelerate() method is right
263
* after the popup menu has been build.
265
* @param window Window where the menu is shown. Inside this window
266
* the AccelGroup object is stored that will be used to initialize
269
void accelerate(Window& window);
272
* Initializes menu accelerators.
273
* Does the same as the accelerate(Window& window) method. But you can
274
* use any parent widget where the menu is used. This method then gets
275
* the toplevel window using Widget::get_toplevel() and uses this
276
* window for registering the menu accelerators.
278
* @param parent Parent widget used as starting point for searching
279
* the toplevel window.
281
void accelerate(Widget& parent);
284
/** Returns <tt>true</tt> if the menu shell will take the keyboard focus on popup.
287
* @return <tt>true</tt> if the menu shell will take the keyboard focus on popup.
289
bool get_take_focus() const;
291
/** If @a take_focus is <tt>true</tt> (the default) the menu shell will take the keyboard
292
* focus so that it will receive all keyboard events which is needed to enable
293
* keyboard navigation in menus.
295
* Setting @a take_focus to <tt>false</tt> is useful only for special applications
296
* like virtual keyboard implementations which should not take keyboard
299
* The @a take_focus state of a menu or menu bar is automatically propagated
300
* to submenus whenever a submenu is popped up, so you don't have to worry
301
* about recursively setting it for your entire menu hierarchy. Only when
302
* programmatically picking a submenu and popping it up manually, the
303
* @a take_focus property of the submenu needs to be set explicitely.
305
* Note that setting it to <tt>false</tt> has side-effects:
307
* If the focus is in some other app, it keeps the focus and keynav in
308
* the menu doesn't work. Consequently, keynav on the menu will only
309
* work if the focus is on some toplevel owned by the onscreen keyboard.
311
* To avoid confusing the user, menus with @a take_focus set to <tt>false</tt>
312
* should not display mnemonics or accelerators, since it cannot be
313
* guaranteed that they will work.
315
* See also gdk_keyboard_grab()
318
* @param take_focus <tt>true</tt> if the menu shell should take the keyboard focus on popup.
320
void set_take_focus(bool take_focus = true);
322
#ifdef GLIBMM_PROPERTIES_ENABLED
323
/** A boolean that determines whether the menu grabs the keyboard focus.
325
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
326
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
327
* the value of the property changes.
329
Glib::PropertyProxy<bool> property_take_focus() ;
330
#endif //#GLIBMM_PROPERTIES_ENABLED
332
#ifdef GLIBMM_PROPERTIES_ENABLED
333
/** A boolean that determines whether the menu grabs the keyboard focus.
335
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
336
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
337
* the value of the property changes.
339
Glib::PropertyProxy_ReadOnly<bool> property_take_focus() const;
340
#endif //#GLIBMM_PROPERTIES_ENABLED
350
MenuList items_proxy_;
351
Gtk::Window* accel_window_;
361
/** A Glib::wrap() method for this object.
363
* @param object The C instance.
364
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
365
* @result A C++ instance that wraps this C instance.
367
* @relates Gtk::MenuShell
369
Gtk::MenuShell* wrap(GtkMenuShell* object, bool take_copy = false);
373
#endif /* _GTKMM_MENUSHELL_H */