Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / gtkmm2 / gtk / src / toggleaction.hg
1 /* $Id: toggleaction.hg,v 1.5 2004/07/01 08:55:45 murrayc Exp $ */
2
3 /* Copyright (C) 2003 The gtkmm Development Team
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 #include <gtkmm/action.h>
21
22 _DEFS(gtkmm,gtk)
23 _PINCLUDE(gtkmm/private/action_p.h)
24
25
26 namespace Gtk
27 {
28
29 /** An action which can be toggled between two states.
30  *
31  * A Gtk::ToggleAction corresponds roughly to a Gtk::CheckMenuItem. 
32  * It has an "active" state specifying whether the action has been checked or not.
33  *
34  */
35 class ToggleAction : public Gtk::Action
36 {
37   _CLASS_GOBJECT(ToggleAction, GtkToggleAction, GTK_TOGGLE_ACTION, Gtk::Action, GtkAction)
38
39 protected:
40   _CTOR_DEFAULT
41    explicit ToggleAction(const Glib::ustring& name, const StockID& stock_id = StockID(), const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring(), bool is_active = false);
42
43 public:
44   //Note that gtk_toggle_action_new() does not allow name to be NULL, which suggests that we should not have a default constructor,
45   //but it's OK to set the name later:
46   _WRAP_CREATE()
47
48    static Glib::RefPtr<ToggleAction> create(const Glib::ustring& name, const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip =  Glib::ustring(), bool is_active = false);
49    static Glib::RefPtr<ToggleAction> create(const Glib::ustring& name, const Gtk::StockID& stock_id, const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring(), bool is_active = false);
50
51   _WRAP_METHOD(void toggled(), gtk_toggle_action_toggled)
52   _WRAP_METHOD(void set_active(bool is_active = true), gtk_toggle_action_set_active)
53   _WRAP_METHOD(bool get_active() const, gtk_toggle_action_get_active)
54   _WRAP_METHOD(void set_draw_as_radio(bool draw_as_radio = true), gtk_toggle_action_set_draw_as_radio)
55   _WRAP_METHOD(bool get_draw_as_radio() const, gtk_toggle_action_get_draw_as_radio)
56
57   _WRAP_SIGNAL(void toggled(), "toggled")
58
59   _WRAP_PROPERTY("draw_as_radio", bool)          
60 };
61
62 } // namespace Gtk
63