Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / action.h
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_ACTION_H
4 #define _GTKMM_ACTION_H
5
6
7 #include <glibmm.h>
8
9 /* $Id$ */
10
11 /* Copyright (C) 2003 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 Library General Public
15  * License as published by the Free Software Foundation; either
16  * version 2 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  * Library General Public License for more details.
22  *
23  * You should have received a copy of the GNU Library 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 <gtkmm/widget.h>
29 #include <gtkmm/accelgroup.h>
30 #include <gtkmm/stockid.h>
31
32
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
34 typedef struct _GtkAction GtkAction;
35 typedef struct _GtkActionClass GtkActionClass;
36 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
37
38
39 namespace Gtk
40 { class Action_Class; } // namespace Gtk
41 namespace Gtk
42 {
43
44 class Menu;
45 class MenuItem;
46 class ToolItem;
47 class Image;
48
49 /** An action which can be triggered by a menu or toolbar item.
50  *
51  * Actions represent operations that the user can perform, along with 
52  * some information about how it should be presented in the user interface. 
53  * Each action provides methods to create icons, menu items and toolbar 
54  * items representing itself.
55  *
56  * As well as the callback that is called when the action is activated, 
57  * the following is also associated with the action:
58  *
59  *  - a name (not translated, for path lookup)
60  *  - a label (translated, for display)
61  *  - an accelerator
62  *  - whether the label indicates a stock id
63  *  - a tooltip (optional, translated)
64  *  - a toolbar label (optional, shorter than label)
65  *
66  * The action will also have some state information:
67  *
68  *  - visible (shown/hidden)
69  *  - sensitive (enabled/disabled)
70  *
71  * Apart from regular actions, there are toggle actions, 
72  * which can be toggled between two states and radio actions, 
73  * of which only one in a group can be in the "active" state. 
74  * Other actions can be implemented as Gtk::Action subclasses.
75  * 
76  * Each action can have one or more proxy menu item, toolbar button or other proxy widgets. 
77  * Proxies mirror the state of the action (text label, tooltip, icon, visible, sensitive, etc), and should change when the action's state changes. When the proxy is activated, it should activate its action.
78  */
79
80 class Action : public Glib::Object
81 {
82   
83 #ifndef DOXYGEN_SHOULD_SKIP_THIS
84
85 public:
86   typedef Action CppObjectType;
87   typedef Action_Class CppClassType;
88   typedef GtkAction BaseObjectType;
89   typedef GtkActionClass BaseClassType;
90
91 private:  friend class Action_Class;
92   static CppClassType action_class_;
93
94 private:
95   // noncopyable
96   Action(const Action&);
97   Action& operator=(const Action&);
98
99 protected:
100   explicit Action(const Glib::ConstructParams& construct_params);
101   explicit Action(GtkAction* castitem);
102
103 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
104
105 public:
106   virtual ~Action();
107
108 #ifndef DOXYGEN_SHOULD_SKIP_THIS
109   static GType get_type()      G_GNUC_CONST;
110   static GType get_base_type() G_GNUC_CONST;
111 #endif
112
113   ///Provides access to the underlying C GObject.
114   GtkAction*       gobj()       { return reinterpret_cast<GtkAction*>(gobject_); }
115
116   ///Provides access to the underlying C GObject.
117   const GtkAction* gobj() const { return reinterpret_cast<GtkAction*>(gobject_); }
118
119   ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
120   GtkAction* gobj_copy();
121
122 private:
123
124  
125 protected:
126  Action();
127   explicit Action(const Glib::ustring& name, const StockID& stock_id = StockID(), const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring());
128
129 public:
130   //Note that gtk_action_new() does not allow name to be NULL, which suggests that we should not have a default constructor,
131   //but it's OK to set the name later:
132   
133   static Glib::RefPtr<Action> create();
134
135
136   static Glib::RefPtr<Action> create(const Glib::ustring& name, const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring());
137   static Glib::RefPtr<Action> create(const Glib::ustring& name, const Gtk::StockID& stock_id, const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring());
138
139   
140   /** Return value: the name of the action. The string belongs to GTK+ and should not
141    * @return The name of the action. The string belongs to GTK+ and should not
142    * be freed.
143    * 
144    * @newin2p4.
145    */
146   Glib::ustring get_name() const;
147
148   
149   /** Return value: <tt>true</tt> if the action and its associated action group
150    * @return <tt>true</tt> if the action and its associated action group 
151    * are both sensitive.
152    * 
153    * @newin2p4.
154    */
155   bool is_sensitive() const;
156   
157   /** Return value: <tt>true</tt> if the action itself is sensitive.
158    * @return <tt>true</tt> if the action itself is sensitive.
159    * 
160    * @newin2p4.
161    */
162   bool get_sensitive() const;
163
164    void set_tooltip(const Glib::ustring& tooltip);
165
166   
167   /** Sets the ::sensitive property of the action to @a sensitive . Note that 
168    * this doesn't necessarily mean effective sensitivity. See 
169    * is_sensitive() 
170    * for that.
171    * 
172    * @newin2p6
173    * @param sensitive <tt>true</tt> to make the action sensitive.
174    */
175   void set_sensitive(bool sensitive = true);
176
177   
178   /** Return value: <tt>true</tt> if the action and its associated action group
179    * @return <tt>true</tt> if the action and its associated action group 
180    * are both visible.
181    * 
182    * @newin2p4.
183    */
184   bool is_visible() const;
185   
186   /** Return value: <tt>true</tt> if the action itself is visible.
187    * @return <tt>true</tt> if the action itself is visible.
188    * 
189    * @newin2p4.
190    */
191   bool get_visible() const;
192   
193   /** Sets the ::visible property of the action to @a visible . Note that 
194    * this doesn't necessarily mean effective visibility. See 
195    * is_visible() 
196    * for that.
197    * 
198    * @newin2p6
199    * @param visible <tt>true</tt> to make the action visible.
200    */
201   void set_visible(bool visible = true);
202
203   
204   /** Emits the "activate" signal on the specified action, if it isn't 
205    * insensitive. This gets called by the proxy widgets when they get 
206    * activated.
207    * 
208    * It can also be used to manually activate an action.
209    * 
210    * @newin2p4
211    */
212   void activate();
213   
214   /** This function is intended for use by action implementations to
215    * create icons displayed in the proxy widgets.
216    * @param icon_size The size of the icon that should be created.
217    * @return A widget that displays the icon for this action.
218    * 
219    * @newin2p4.
220    */
221   Image* create_icon(IconSize icon_size);
222   
223   /** Creates a menu item widget that proxies for the given action.
224    * @return A menu item connected to the action.
225    * 
226    * @newin2p4.
227    */
228   MenuItem* create_menu_item();
229   
230   /** Creates a toolbar item widget that proxies for the given action.
231    * @return A toolbar item connected to the action.
232    * 
233    * @newin2p4.
234    */
235   ToolItem* create_tool_item();
236   
237   /** If @a action  provides a Gtk::Menu widget as a submenu for the menu
238    * item or the toolbar item it creates, this function returns an
239    * instance of that menu.
240    * @return The menu item provided by the action, or <tt>0</tt>.
241    * 
242    * @newin2p12.
243    */
244   Menu* create_menu();
245   
246   /** Connects a widget to an action object as a proxy.  Synchronises 
247    * various properties of the action with the widget (such as label 
248    * text, icon, tooltip, etc), and attaches a callback so that the 
249    * action gets activated when the proxy widget does.
250    * 
251    * If the widget is already connected to an action, it is disconnected
252    * first.
253    * 
254    * @newin2p4
255    * @param proxy The proxy widget.
256    */
257   void connect_proxy(Widget& proxy);
258   
259   /** Disconnects a proxy widget from an action.  
260    * Does <em>not</em> destroy the widget, however.
261    * 
262    * @newin2p4
263    * @param proxy The proxy widget.
264    */
265   void disconnect_proxy(Widget& proxy);
266
267   
268   /** Return value: a G::SList of proxy widgets. The list is owned by GTK+
269    * @return A G::SList of proxy widgets. The list is owned by GTK+
270    * and must not be modified.
271    * 
272    * @newin2p4.
273    */
274   Glib::SListHandle<Widget*> get_proxies();
275   
276   /** Return value: a G::SList of proxy widgets. The list is owned by GTK+
277    * @return A G::SList of proxy widgets. The list is owned by GTK+
278    * and must not be modified.
279    * 
280    * @newin2p4.
281    */
282   Glib::SListHandle<const Widget*> get_proxies() const;
283
284   
285   /** Installs the accelerator for @a action  if @a action  has an
286    * accel path and group. See set_accel_path() and 
287    * set_accel_group()
288    * 
289    * Since multiple proxies may independently trigger the installation
290    * of the accelerator, the @a action  counts the number of times this
291    * function has been called and doesn't remove the accelerator until
292    * disconnect_accelerator() has been called as many times.
293    * 
294    * @newin2p4
295    */
296   void connect_accelerator();
297   
298   /** Undoes the effect of one call to connect_accelerator().
299    * 
300    * @newin2p4
301    */
302   void disconnect_accelerator();
303   
304   
305   /** Returns: the accel path for this action, or <tt>0</tt>
306    * @return The accel path for this action, or <tt>0</tt>
307    * if none is set. The returned string is owned by GTK+ 
308    * and must not be freed or modified.
309    */
310   Glib::ustring get_accel_path() const;
311
312   /// For instance, void on_activate();
313   typedef sigc::slot<void> SlotActivate;
314   
315   /** The "activate" signal is emitted when the action is activated.
316    *
317    * @par Prototype:
318    * <tt>void on_my_%activate()</tt>
319    */
320
321   Glib::SignalProxy0< void > signal_activate();
322
323
324   //Used by AccelGroup:
325   
326   /** Sets the accel path for this action.  All proxy widgets associated
327    * with the action will have this accel path, so that their
328    * accelerators are consistent.
329    * 
330    * @newin2p4
331    * @param accel_path The accelerator path.
332    */
333   void set_accel_path(const Glib::ustring& accel_path);
334   
335   /** Sets the Gtk::AccelGroup in which the accelerator for this action
336    * will be installed.
337    * 
338    * @newin2p4
339    * @param accel_group A Gtk::AccelGroup or <tt>0</tt>.
340    */
341   void set_accel_group(const Glib::RefPtr<AccelGroup>& accel_group);
342
343   #ifdef GLIBMM_PROPERTIES_ENABLED
344 /** A unique name for the action.
345    *
346    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
347    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
348    * the value of the property changes.
349    */
350   Glib::PropertyProxy_ReadOnly<Glib::ustring> property_name() const;
351 #endif //#GLIBMM_PROPERTIES_ENABLED
352
353
354   #ifdef GLIBMM_PROPERTIES_ENABLED
355 /** The label used for menu items and buttons that activate this action.
356    *
357    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
358    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
359    * the value of the property changes.
360    */
361   Glib::PropertyProxy<Glib::ustring> property_label() ;
362 #endif //#GLIBMM_PROPERTIES_ENABLED
363
364 #ifdef GLIBMM_PROPERTIES_ENABLED
365 /** The label used for menu items and buttons that activate this action.
366    *
367    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
368    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
369    * the value of the property changes.
370    */
371   Glib::PropertyProxy_ReadOnly<Glib::ustring> property_label() const;
372 #endif //#GLIBMM_PROPERTIES_ENABLED
373
374   #ifdef GLIBMM_PROPERTIES_ENABLED
375 /** A shorter label that may be used on toolbar buttons.
376    *
377    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
378    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
379    * the value of the property changes.
380    */
381   Glib::PropertyProxy<Glib::ustring> property_short_label() ;
382 #endif //#GLIBMM_PROPERTIES_ENABLED
383
384 #ifdef GLIBMM_PROPERTIES_ENABLED
385 /** A shorter label that may be used on toolbar buttons.
386    *
387    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
388    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
389    * the value of the property changes.
390    */
391   Glib::PropertyProxy_ReadOnly<Glib::ustring> property_short_label() const;
392 #endif //#GLIBMM_PROPERTIES_ENABLED
393
394   #ifdef GLIBMM_PROPERTIES_ENABLED
395 /** A tooltip for this action.
396    *
397    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
398    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
399    * the value of the property changes.
400    */
401   Glib::PropertyProxy<Glib::ustring> property_tooltip() ;
402 #endif //#GLIBMM_PROPERTIES_ENABLED
403
404 #ifdef GLIBMM_PROPERTIES_ENABLED
405 /** A tooltip for this action.
406    *
407    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
408    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
409    * the value of the property changes.
410    */
411   Glib::PropertyProxy_ReadOnly<Glib::ustring> property_tooltip() const;
412 #endif //#GLIBMM_PROPERTIES_ENABLED
413
414   #ifdef GLIBMM_PROPERTIES_ENABLED
415 /** The stock icon displayed in widgets representing this action.
416    *
417    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
418    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
419    * the value of the property changes.
420    */
421   Glib::PropertyProxy<StockID> property_stock_id() ;
422 #endif //#GLIBMM_PROPERTIES_ENABLED
423
424 #ifdef GLIBMM_PROPERTIES_ENABLED
425 /** The stock icon displayed in widgets representing this action.
426    *
427    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
428    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
429    * the value of the property changes.
430    */
431   Glib::PropertyProxy_ReadOnly<StockID> property_stock_id() const;
432 #endif //#GLIBMM_PROPERTIES_ENABLED
433
434   #ifdef GLIBMM_PROPERTIES_ENABLED
435 /** Whether the toolbar item is visible when the toolbar is in a horizontal orientation.
436    *
437    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
438    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
439    * the value of the property changes.
440    */
441   Glib::PropertyProxy<bool> property_visible_horizontal() ;
442 #endif //#GLIBMM_PROPERTIES_ENABLED
443
444 #ifdef GLIBMM_PROPERTIES_ENABLED
445 /** Whether the toolbar item is visible when the toolbar is in a horizontal orientation.
446    *
447    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
448    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
449    * the value of the property changes.
450    */
451   Glib::PropertyProxy_ReadOnly<bool> property_visible_horizontal() const;
452 #endif //#GLIBMM_PROPERTIES_ENABLED
453
454   #ifdef GLIBMM_PROPERTIES_ENABLED
455 /** Whether the toolbar item is visible when the toolbar is in a vertical orientation.
456    *
457    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
458    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
459    * the value of the property changes.
460    */
461   Glib::PropertyProxy<bool> property_visible_vertical() ;
462 #endif //#GLIBMM_PROPERTIES_ENABLED
463
464 #ifdef GLIBMM_PROPERTIES_ENABLED
465 /** Whether the toolbar item is visible when the toolbar is in a vertical orientation.
466    *
467    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
468    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
469    * the value of the property changes.
470    */
471   Glib::PropertyProxy_ReadOnly<bool> property_visible_vertical() const;
472 #endif //#GLIBMM_PROPERTIES_ENABLED
473
474   #ifdef GLIBMM_PROPERTIES_ENABLED
475 /** Whether the action is considered important. When TRUE
476    *
477    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
478    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
479    * the value of the property changes.
480    */
481   Glib::PropertyProxy<bool> property_is_important() ;
482 #endif //#GLIBMM_PROPERTIES_ENABLED
483
484 #ifdef GLIBMM_PROPERTIES_ENABLED
485 /** Whether the action is considered important. When TRUE
486    *
487    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
488    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
489    * the value of the property changes.
490    */
491   Glib::PropertyProxy_ReadOnly<bool> property_is_important() const;
492 #endif //#GLIBMM_PROPERTIES_ENABLED
493
494   #ifdef GLIBMM_PROPERTIES_ENABLED
495 /** When TRUE
496    *
497    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
498    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
499    * the value of the property changes.
500    */
501   Glib::PropertyProxy<bool> property_hide_if_empty() ;
502 #endif //#GLIBMM_PROPERTIES_ENABLED
503
504 #ifdef GLIBMM_PROPERTIES_ENABLED
505 /** When TRUE
506    *
507    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
508    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
509    * the value of the property changes.
510    */
511   Glib::PropertyProxy_ReadOnly<bool> property_hide_if_empty() const;
512 #endif //#GLIBMM_PROPERTIES_ENABLED
513
514   #ifdef GLIBMM_PROPERTIES_ENABLED
515 /** Whether the action is enabled.
516    *
517    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
518    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
519    * the value of the property changes.
520    */
521   Glib::PropertyProxy<bool> property_sensitive() ;
522 #endif //#GLIBMM_PROPERTIES_ENABLED
523
524 #ifdef GLIBMM_PROPERTIES_ENABLED
525 /** Whether the action is enabled.
526    *
527    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
528    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
529    * the value of the property changes.
530    */
531   Glib::PropertyProxy_ReadOnly<bool> property_sensitive() const;
532 #endif //#GLIBMM_PROPERTIES_ENABLED
533
534   #ifdef GLIBMM_PROPERTIES_ENABLED
535 /** Whether the action is visible.
536    *
537    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
538    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
539    * the value of the property changes.
540    */
541   Glib::PropertyProxy<bool> property_visible() ;
542 #endif //#GLIBMM_PROPERTIES_ENABLED
543
544 #ifdef GLIBMM_PROPERTIES_ENABLED
545 /** Whether the action is visible.
546    *
547    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
548    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
549    * the value of the property changes.
550    */
551   Glib::PropertyProxy_ReadOnly<bool> property_visible() const;
552 #endif //#GLIBMM_PROPERTIES_ENABLED
553
554
555 protected:
556   //For use by child actions:  
557   
558   /** Disables calls to the activate()
559    * function by signals on the given proxy widget.  This is used to
560    * break notification loops for things like check or radio actions.
561    * 
562    * This function is intended for use by action implementations.
563    * 
564    * @newin2p4
565    * @param proxy A proxy widget.
566    */
567   void block_activate_from(Widget& proxy);
568   
569   /** Re-enables calls to the activate()
570    * function by signals on the given proxy widget.  This undoes the
571    * blocking done by block_activate_from().
572    * 
573    * This function is intended for use by action implementations.
574    * 
575    * @newin2p4
576    * @param proxy A proxy widget.
577    */
578   void unblock_activate_from(Widget& proxy);
579
580
581 protected: 
582   //Widget-creation routines:
583   #ifdef GLIBMM_VFUNCS_ENABLED
584   virtual Widget* create_menu_item_vfunc();
585 #endif //GLIBMM_VFUNCS_ENABLED
586
587   #ifdef GLIBMM_VFUNCS_ENABLED
588   virtual Widget* create_tool_item_vfunc();
589 #endif //GLIBMM_VFUNCS_ENABLED
590
591   #ifdef GLIBMM_VFUNCS_ENABLED
592   virtual void connect_proxy_vfunc(Widget* proxy);
593 #endif //GLIBMM_VFUNCS_ENABLED
594
595   #ifdef GLIBMM_VFUNCS_ENABLED
596   virtual void disconnect_proxy_vfunc(Widget* proxy);
597 #endif //GLIBMM_VFUNCS_ENABLED
598
599
600 public:
601
602 public:
603   //C++ methods used to invoke GTK+ virtual functions:
604 #ifdef GLIBMM_VFUNCS_ENABLED
605 #endif //GLIBMM_VFUNCS_ENABLED
606
607 protected:
608   //GTK+ Virtual Functions (override these to change behaviour):
609 #ifdef GLIBMM_VFUNCS_ENABLED
610 #endif //GLIBMM_VFUNCS_ENABLED
611
612   //Default Signal Handlers::
613 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
614   virtual void on_activate();
615 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
616
617
618 };
619
620 } // namespace Gtk
621
622
623 namespace Glib
624 {
625   /** A Glib::wrap() method for this object.
626    * 
627    * @param object The C instance.
628    * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
629    * @result A C++ instance that wraps this C instance.
630    *
631    * @relates Gtk::Action
632    */
633   Glib::RefPtr<Gtk::Action> wrap(GtkAction* object, bool take_copy = false);
634 }
635
636
637 #endif /* _GTKMM_ACTION_H */
638