retrofit from gjexer
[fanfix.git] / src / jexer / TButton.java
index 29f37432826cf7fbc3556df35462117cc557ced8..83ff2d241f0c1c31dc27b45c65285c346f87b417 100644 (file)
@@ -68,6 +68,11 @@ public class TButton extends TWidget {
      */
     private TAction action;
 
+    /**
+     * The background color used for the button "shadow".
+     */
+    private CellAttributes shadowColor;
+
     // ------------------------------------------------------------------------
     // Constructors -----------------------------------------------------------
     // ------------------------------------------------------------------------
@@ -92,6 +97,11 @@ public class TButton extends TWidget {
         setY(y);
         setHeight(2);
         setWidth(mnemonic.getRawLabel().length() + 3);
+
+        shadowColor = new CellAttributes();
+        shadowColor.setTo(getWindow().getBackground());
+        shadowColor.setForeColor(Color.BLACK);
+        shadowColor.setBold(false);
     }
 
     /**
@@ -209,10 +219,6 @@ public class TButton extends TWidget {
     public void draw() {
         CellAttributes buttonColor;
         CellAttributes menuMnemonicColor;
-        CellAttributes shadowColor = new CellAttributes();
-        shadowColor.setTo(getWindow().getBackground());
-        shadowColor.setForeColor(Color.BLACK);
-        shadowColor.setBold(false);
 
         if (!isEnabled()) {
             buttonColor = getTheme().getColor("tbutton.disabled");
@@ -247,7 +253,6 @@ public class TButton extends TWidget {
                 putCharXY(1 + mnemonic.getShortcutIdx(), 0,
                     mnemonic.getShortcut(), menuMnemonicColor);
             }
-
         }
     }
 
@@ -275,4 +280,16 @@ public class TButton extends TWidget {
         }
     }
 
+    /**
+     * Set the background color used for the button "shadow".
+     *
+     * @param color the new background color
+     */
+    public void setShadowColor(final CellAttributes color) {
+        shadowColor = new CellAttributes();
+        shadowColor.setTo(color);
+        shadowColor.setForeColor(Color.BLACK);
+        shadowColor.setBold(false);
+    }
+
 }