~inkscape.dev/inkscape-devlibs/devlibs-gtk3

« back to all changes in this revision

Viewing changes to include/gtkmm-2.4/gtkmm/menushell.h

  • Committer: JazzyNico
  • Date: 2013-01-21 10:11:05 UTC
  • Revision ID: nicoduf@yahoo.fr-20130121101105-i8d8slkq9ng4olx8
Adding gtk2 libraries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- c++ -*-
 
2
// Generated by gtkmmproc -- DO NOT MODIFY!
 
3
#ifndef _GTKMM_MENUSHELL_H
 
4
#define _GTKMM_MENUSHELL_H
 
5
 
 
6
 
 
7
#include <glibmm.h>
 
8
 
 
9
/* $Id: menushell.hg,v 1.9 2006/06/21 20:04:25 murrayc Exp $ */
 
10
 
 
11
/* Copyright (C) 1998-2002 The gtkmm Development Team
 
12
 *
 
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.
 
17
 *
 
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.
 
22
 *
 
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.
 
26
 */
 
27
 
 
28
#include <gdk/gdkkeysyms.h>
 
29
 
 
30
 
 
31
#include <gtkmm/container.h>
 
32
#include <gtkmm/menu_elems.h>
 
33
#include <glibmm/helperlist.h>
 
34
 
 
35
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
36
typedef struct _GtkMenuShell GtkMenuShell;
 
37
typedef struct _GtkMenuShellClass GtkMenuShellClass;
 
38
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
39
 
 
40
 
 
41
namespace Gtk
 
42
{ class MenuShell_Class; } // namespace Gtk
 
43
namespace Gtk
 
44
{
 
45
 
 
46
class Menu;
 
47
class MenuShell;
 
48
class Window;
 
49
 
 
50
namespace Menu_Helpers
 
51
{
 
52
 
 
53
/*********************************************************************
 
54
***** List properties
 
55
*********************************************************************/
 
56
 
 
57
 
 
58
class MenuList : public Glib::HelperList< MenuItem, const Element, Glib::List_Cpp_Iterator<GtkMenuItem,MenuItem> >
 
59
{
 
60
public:
 
61
  MenuList();
 
62
  explicit MenuList(GtkMenuShell* gparent);
 
63
  MenuList(const MenuList& src);
 
64
  virtual ~MenuList() {}
 
65
 
 
66
  MenuList& operator=(const MenuList& src);
 
67
 
 
68
  typedef Glib::HelperList< MenuItem, const Element,  Glib::List_Cpp_Iterator<GtkMenuItem,MenuItem> > type_base;
 
69
 
 
70
  GtkMenuShell* gparent();
 
71
  const GtkMenuShell* gparent() const;
 
72
 
 
73
  virtual GList*& glist() const;      // front of list
 
74
 
 
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
 
78
 
 
79
  /// This is order n. (use at own risk)
 
80
  reference operator[](size_type l) const;
 
81
 
 
82
public:
 
83
  iterator insert(iterator position, element_type& e); //custom-implemented.
 
84
 
 
85
  template <class InputIterator>
 
86
  inline void insert(iterator position, InputIterator first, InputIterator last)
 
87
  {
 
88
    for(;first != last; ++first)
 
89
      position = insert(position, *first);
 
90
  }
 
91
 
 
92
 inline void push_front(element_type& e)
 
93
    { insert(begin(), e); }
 
94
  inline void push_back(element_type& e)
 
95
    { insert(end(), e); }
 
96
 
 
97
 
 
98
  virtual void remove(Widget& widget); //custom
 
99
  };
 
100
 
 
101
 
 
102
} // namespace Menu_Helpers
 
103
 
 
104
 
 
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.
 
110
 * @ingroup Widgets
 
111
 * @ingroup Containers
 
112
 * @ingroup Menus
 
113
 */
 
114
 
 
115
class MenuShell : public Container
 
116
{
 
117
  public:
 
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 */
 
124
 
 
125
  virtual ~MenuShell();
 
126
 
 
127
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
128
 
 
129
private:
 
130
  friend class MenuShell_Class;
 
131
  static CppClassType menushell_class_;
 
132
 
 
133
  // noncopyable
 
134
  MenuShell(const MenuShell&);
 
135
  MenuShell& operator=(const MenuShell&);
 
136
 
 
137
protected:
 
138
  explicit MenuShell(const Glib::ConstructParams& construct_params);
 
139
  explicit MenuShell(GtkMenuShell* castitem);
 
140
 
 
141
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
142
 
 
143
public:
 
144
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
145
  static GType get_type()      G_GNUC_CONST;
 
146
 
 
147
 
 
148
  static GType get_base_type() G_GNUC_CONST;
 
149
#endif
 
150
 
 
151
  ///Provides access to the underlying C GtkObject.
 
152
  GtkMenuShell*       gobj()       { return reinterpret_cast<GtkMenuShell*>(gobject_); }
 
153
 
 
154
  ///Provides access to the underlying C GtkObject.
 
155
  const GtkMenuShell* gobj() const { return reinterpret_cast<GtkMenuShell*>(gobject_); }
 
156
 
 
157
 
 
158
public:
 
159
  //C++ methods used to invoke GTK+ virtual functions:
 
160
 
 
161
protected:
 
162
  //GTK+ Virtual Functions (override these to change behaviour):
 
163
 
 
164
  //Default Signal Handlers::
 
165
  virtual void on_deactivate();
 
166
  virtual void on_selection_done();
 
167
 
 
168
 
 
169
private:
 
170
 
 
171
 
 
172
public:
 
173
  
 
174
 
 
175
  typedef Menu_Helpers::MenuList MenuList;
 
176
  friend class Menu_Helpers::MenuList;
 
177
 
 
178
  
 
179
  void append(MenuItem& menu_item);
 
180
  
 
181
  void prepend(MenuItem& menu_item);
 
182
  
 
183
  void insert(MenuItem& menu_item, int position);
 
184
 
 
185
  
 
186
  void select_item(MenuItem& menu_item);
 
187
  
 
188
  void deselect();
 
189
 
 
190
  //TODO: Is force_deactivate = false a good default?
 
191
  
 
192
  void activate_item(MenuItem& menu_item, bool force_deactivate =  false);
 
193
  
 
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
 
196
   * item.
 
197
   * 
 
198
   * @newin{2,2}
 
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.
 
204
   */
 
205
  void select_first(bool search_sensitive =  true);
 
206
  
 
207
  void deactivate();
 
208
  
 
209
  /** Cancels the selection within the menu shell.  
 
210
   * 
 
211
   * @newin{2,4}
 
212
   */
 
213
  void cancel();
 
214
 
 
215
  
 
216
  /**
 
217
   * @par Prototype:
 
218
   * <tt>void on_my_%deactivate()</tt>
 
219
   */
 
220
 
 
221
  Glib::SignalProxy0< void > signal_deactivate();
 
222
 
 
223
  
 
224
  /**
 
225
   * @par Prototype:
 
226
   * <tt>void on_my_%selection_done()</tt>
 
227
   */
 
228
 
 
229
  Glib::SignalProxy0< void > signal_selection_done();
 
230
 
 
231
  
 
232
  /**
 
233
   * @par Prototype:
 
234
   * <tt>gboolean on_my_%move_selected(int distance)</tt>
 
235
   */
 
236
 
 
237
  Glib::SignalProxy1< gboolean,int > signal_move_selected();
 
238
 
 
239
 
 
240
  //Keybinding signals:
 
241
  
 
242
  
 
243
  MenuList& items();
 
244
  const MenuList& items() const;
 
245
 
 
246
  /**
 
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.
 
251
   *
 
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.
 
256
   *
 
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.
 
264
   *
 
265
   * @param window Window where the menu is shown. Inside this window
 
266
   *   the AccelGroup object is stored that will be used to initialize
 
267
   *   the accelerators.
 
268
   */
 
269
  void accelerate(Window& window);
 
270
 
 
271
  /**
 
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.
 
277
   *
 
278
   * @param parent Parent widget used as starting point for searching
 
279
   *   the toplevel window.
 
280
   */
 
281
  void accelerate(Widget& parent);
 
282
 
 
283
  
 
284
  /** Returns <tt>true</tt> if the menu shell will take the keyboard focus on popup.
 
285
   * 
 
286
   * @newin{2,8}
 
287
   * @return <tt>true</tt> if the menu shell will take the keyboard focus on popup.
 
288
   */
 
289
  bool get_take_focus() const;
 
290
  
 
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.
 
294
   * 
 
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
 
297
   * focus.
 
298
   * 
 
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.
 
304
   * 
 
305
   * Note that setting it to <tt>false</tt> has side-effects:
 
306
   * 
 
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.
 
310
   * 
 
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.
 
314
   * 
 
315
   * See also gdk_keyboard_grab()
 
316
   * 
 
317
   * @newin{2,8}
 
318
   * @param take_focus <tt>true</tt> if the menu shell should take the keyboard focus on popup.
 
319
   */
 
320
  void set_take_focus(bool take_focus =  true);
 
321
 
 
322
  #ifdef GLIBMM_PROPERTIES_ENABLED
 
323
/** A boolean that determines whether the menu grabs the keyboard focus.
 
324
   *
 
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.
 
328
   */
 
329
  Glib::PropertyProxy<bool> property_take_focus() ;
 
330
#endif //#GLIBMM_PROPERTIES_ENABLED
 
331
 
 
332
#ifdef GLIBMM_PROPERTIES_ENABLED
 
333
/** A boolean that determines whether the menu grabs the keyboard focus.
 
334
   *
 
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.
 
338
   */
 
339
  Glib::PropertyProxy_ReadOnly<bool> property_take_focus() const;
 
340
#endif //#GLIBMM_PROPERTIES_ENABLED
 
341
 
 
342
 
 
343
protected:
 
344
  MenuShell();
 
345
  
 
346
 
 
347
private:
 
348
 
 
349
 
 
350
  MenuList      items_proxy_;
 
351
  Gtk::Window*  accel_window_;
 
352
 
 
353
 
 
354
};
 
355
 
 
356
} // namespace Gtk
 
357
 
 
358
 
 
359
namespace Glib
 
360
{
 
361
  /** A Glib::wrap() method for this object.
 
362
   * 
 
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.
 
366
   *
 
367
   * @relates Gtk::MenuShell
 
368
   */
 
369
  Gtk::MenuShell* wrap(GtkMenuShell* object, bool take_copy = false);
 
370
} //namespace Glib
 
371
 
 
372
 
 
373
#endif /* _GTKMM_MENUSHELL_H */
 
374