Add bbt_add that does not take Metric parameter.
[ardour.git] / libs / gtkmm2ext / stateful_button.cc
index 000b7b8ea1dba5618eb008b3445779dfac2225df..580e0deb1c6e080655eb8dcab8b12061e7ae3a8f 100644 (file)
@@ -1,3 +1,22 @@
+/*
+    Copyright (C) 2000-2007 Paul Davis 
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
 #include <string>
 #include <iostream>
 
@@ -10,24 +29,15 @@ using namespace Glib;
 using namespace Gtkmm2ext;
 using namespace std;
 
-StateButton::StateButton ()
+StateButton::StateButton () : visual_state (0), _self_managed (false), _is_realized (false)
 {
-       visual_state = 0;
-       have_saved_bg = false;
-}
-
-void
-StateButton::set_colors (const vector<Gdk::Color>& c)
-{
-       colors = c;
-       visual_state++; // to force transition
-       set_visual_state (visual_state - 1);
+  
 }
 
 void
 StateButton::set_visual_state (int n)
 {
-       if (!have_saved_bg) {
+       if (!_is_realized) {
                /* not yet realized */
                visual_state = n;
                return;
@@ -36,29 +46,23 @@ StateButton::set_visual_state (int n)
        if (n == visual_state) {
                return;
        }
-       
-       if (n == 0) {
-               
-               /* back to the default color */
-               
-               if (have_saved_bg) {
-                       bg_modify (STATE_NORMAL, saved_bg);
-                       bg_modify (STATE_ACTIVE, saved_bg);
-                       bg_modify (STATE_SELECTED, saved_bg);
-                       bg_modify (STATE_PRELIGHT, saved_bg);
-               }
-               
-               
-       } else {
-               
-               int index = (n-1) % colors.size ();
-               
-               bg_modify (STATE_NORMAL, colors[index]);
-               bg_modify (STATE_ACTIVE, colors[index]);
-               bg_modify (STATE_SELECTED, colors[index]);
-               bg_modify (STATE_PRELIGHT, colors[index]);
+
+       string name = get_widget_name ();
+       name = name.substr (0, name.find_last_of ('-'));
+
+       switch (n) {
+       case 0:
+               /* relax */
+               break;
+       case 1:
+               name += "-active";
+               break;
+       case 2:
+               name += "-alternate";
+               break;
        }
 
+       set_widget_name (name);
        visual_state = n;
 }
 
@@ -69,11 +73,7 @@ StatefulToggleButton::on_realize ()
 {
        ToggleButton::on_realize ();
 
-       if (!have_saved_bg) {
-               saved_bg = get_style()->get_bg (STATE_NORMAL);
-               have_saved_bg = true;
-       }
-
+       _is_realized = true;
        visual_state++; // to force transition
        set_visual_state (visual_state - 1);
 }
@@ -83,11 +83,7 @@ StatefulButton::on_realize ()
 {
        Button::on_realize ();
 
-       if (!have_saved_bg) {
-               saved_bg = get_style()->get_bg (STATE_NORMAL);
-               have_saved_bg = true;
-       }
-
+       _is_realized = true;
        visual_state++; // to force transition
        set_visual_state (visual_state - 1);
 }