3 #include "gtkmm2ext/stateful_button.h"
7 using namespace Gtkmm2ext;
10 StatefulButton::StatefulButton ()
13 have_saved_bg = false;
16 StatefulButton::StatefulButton (const string& label)
20 have_saved_bg = false;
24 StatefulButton::set_colors (const vector<Gdk::Color>& c)
27 current_state++; // to force transition
28 set_state (current_state - 1);
32 StatefulButton::on_realize ()
34 Button::on_realize ();
37 saved_bg = get_style()->get_bg (STATE_NORMAL);
41 current_state++; // to force transition
42 set_state (current_state - 1);
46 StatefulButton::set_state (int n)
50 if (n == current_state) {
56 /* back to the default color */
59 modify_bg (STATE_NORMAL, saved_bg);
60 modify_bg (STATE_ACTIVE, saved_bg);
61 modify_bg (STATE_SELECTED, saved_bg);
62 modify_bg (STATE_PRELIGHT, saved_bg);
68 int index = (n-1) % colors.size ();
70 modify_bg (STATE_NORMAL, colors[index]);
71 modify_bg (STATE_ACTIVE, colors[index]);
72 modify_bg (STATE_SELECTED, colors[index]);
73 modify_bg (STATE_PRELIGHT, colors[index]);
76 /* leave insensitive alone */