2 Copyright (C) 2000-2007 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <gtkmm/main.h>
25 #include "pbd/stacktrace.h"
27 #include <gtkmm2ext/stateful_button.h>
31 using namespace Gtkmm2ext
;
34 StateButton::StateButton () : visual_state (0), _self_managed (false), _is_realized (false)
40 StateButton::set_visual_state (int n
)
43 /* not yet realized */
48 if (n
== visual_state
) {
52 string name
= get_widget_name ();
53 name
= name
.substr (0, name
.find_last_of ('-'));
67 set_widget_name (name
);
71 /* ----------------------------------------------------------------- */
74 StatefulToggleButton::on_realize ()
76 ToggleButton::on_realize ();
79 visual_state
++; // to force transition
80 set_visual_state (visual_state
- 1);
84 StatefulButton::on_realize ()
86 Button::on_realize ();
89 visual_state
++; // to force transition
90 set_visual_state (visual_state
- 1);
94 StatefulToggleButton::on_toggled ()
100 set_visual_state (0);
106 StatefulToggleButton::set_widget_name (const std::string
& name
)
109 Widget
* w
= get_child();
114 cerr
<< "Statefull TOggle button - no child\n";
115 PBD::stacktrace (cerr
, 20);
120 StatefulButton::set_widget_name (const std::string
& name
)
123 Widget
* w
= get_child();
128 cerr
<< "Stateful button - no child\n";
129 PBD::stacktrace (cerr
, 20);