default foreground color is [-1 -1 -1] in model, use this value to reset default... 65/13965/4
Antoine ELIAS [Mon, 10 Mar 2014 17:27:59 +0000 (18:27 +0100)]
Change-Id: Ibeceba36996315b45b890d563374c5b23d977a93

39 files changed:
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/uicontrol/Uicontrol.java
scilab/modules/gui/src/java/org/scilab/modules/gui/SwingViewWidget.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/checkbox/SwingScilabCheckBox.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/checkboxmenuitem/SwingScilabCheckBoxMenuItem.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/contextmenu/SwingScilabContextMenu.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/editbox/SwingScilabEditBox.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/editbox/SwingScilabSpinner.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/frame/SwingScilabFrame.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/frame/SwingScilabScrollableFrame.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/label/SwingScilabLabel.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/listbox/SwingScilabListBox.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/menu/SwingScilabMenu.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/menuitem/SwingScilabMenuItem.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/popupmenu/SwingScilabPopupMenu.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/pushbutton/SwingScilabPushButton.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/radiobutton/SwingScilabRadioButton.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/slider/SwingScilabScroll.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/slider/SwingScilabSlider.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabTabGroup.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/textbox/SwingScilabTextBox.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tree/SwingScilabTree.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/uidisplaytree/SwingScilabUiDisplayTree.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/uiimage/SwingScilabUiImage.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/uitable/SwingScilabUiTable.java
scilab/modules/gui/src/java/org/scilab/modules/gui/checkbox/ScilabCheckBox.java
scilab/modules/gui/src/java/org/scilab/modules/gui/contextmenu/ScilabContextMenu.java
scilab/modules/gui/src/java/org/scilab/modules/gui/editbox/ScilabEditBox.java
scilab/modules/gui/src/java/org/scilab/modules/gui/label/ScilabLabel.java
scilab/modules/gui/src/java/org/scilab/modules/gui/listbox/ScilabListBox.java
scilab/modules/gui/src/java/org/scilab/modules/gui/menu/ScilabMenu.java
scilab/modules/gui/src/java/org/scilab/modules/gui/popupmenu/ScilabPopupMenu.java
scilab/modules/gui/src/java/org/scilab/modules/gui/pushbutton/ScilabPushButton.java
scilab/modules/gui/src/java/org/scilab/modules/gui/radiobutton/ScilabRadioButton.java
scilab/modules/gui/src/java/org/scilab/modules/gui/slider/ScilabSlider.java
scilab/modules/gui/src/java/org/scilab/modules/gui/textbox/ScilabTextBox.java
scilab/modules/gui/src/java/org/scilab/modules/gui/tree/ScilabTree.java
scilab/modules/gui/src/java/org/scilab/modules/gui/uidisplaytree/ScilabUiDisplayTree.java
scilab/modules/gui/src/java/org/scilab/modules/gui/uitable/ScilabUiTable.java
scilab/modules/gui/src/java/org/scilab/modules/gui/widget/Widget.java

index 193d1fc..627e2bb 100644 (file)
@@ -296,7 +296,7 @@ public class Uicontrol extends GraphicObject {
     private double fontSize = 0;
     private String fontUnits = "points";
     private String fontWeight = "";
-    private Double[] foregroundColor = {0.0, 0.0, 0.0};
+    private Double[] foregroundColor = { -1.0, -1.0, -1.0};
     private String horizontalAlignment = "";
     private String verticalAlignment = "";
     private Integer[] listboxTop;
index d580aad..4644ddf 100644 (file)
@@ -195,10 +195,16 @@ public final class SwingViewWidget {
             }
             case __GO_UI_FOREGROUNDCOLOR__ : {
                 Double[] allColors = ((Double[]) value);
-                uiControl.setForeground(new Color(
-                                            (int) (allColors[0] * COLORS_COEFF),
-                                            (int) (allColors[1] * COLORS_COEFF),
-                                            (int) (allColors[2] * COLORS_COEFF)));
+                if (allColors[0] != -1) {
+                    uiControl.setForeground(new Color(
+                                                (int) (allColors[0] * COLORS_COEFF),
+                                                (int) (allColors[1] * COLORS_COEFF),
+                                                (int) (allColors[2] * COLORS_COEFF)));
+                } else {
+                    // Do not set ForegroundColor for widgets
+                    // rely on Look and Feel
+                    uiControl.resetForeground();
+                }
                 break;
             }
             case __GO_UI_HORIZONTALALIGNMENT__ : {
index 7486cbb..d597e03 100644 (file)
@@ -394,4 +394,11 @@ public class SwingScilabCheckBox extends JCheckBox implements SwingViewObject, S
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("CheckBox.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index 53df433..c7989b6 100644 (file)
@@ -435,4 +435,11 @@ public class SwingScilabCheckBoxMenuItem extends JCheckBoxMenuItem implements Sw
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("CheckBoxMenuItem.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index 05decf6..dd747db 100644 (file)
@@ -383,4 +383,11 @@ public class SwingScilabContextMenu extends JPopupMenu implements SwingViewObjec
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("PopupMenu.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index efaa88f..607bb46 100644 (file)
@@ -560,4 +560,11 @@ public class SwingScilabEditBox extends JScrollPane implements SwingViewObject,
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("TextField.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index 0880b70..b3d2d67 100644 (file)
@@ -194,4 +194,11 @@ public class SwingScilabSpinner extends JSpinner implements SwingViewObject, Sim
         }
     }
 
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("Spinner.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index 6a57da9..52f4ddb 100644 (file)
@@ -957,10 +957,22 @@ public class SwingScilabFrame extends JPanel implements SwingViewObject, SimpleF
         }
     }
 
+    //    public void setForeground(Color color) {
+    //        System.out.println((Color)UIManager.getLookAndFeelDefaults().get("Panel.foreground"));
+    //        super.setForeground((Color)UIManager.getLookAndFeelDefaults().get("Panel.foreground"));
+    //    }
+
     public void resetBackground() {
         Color color = (Color)UIManager.getLookAndFeelDefaults().get("Panel.background");
         if (color != null) {
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("Panel.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index 800afe1..ba35640 100644 (file)
@@ -602,4 +602,10 @@ public class SwingScilabScrollableFrame extends JScrollPane implements SwingView
         }
     }
 
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("ScrollPane.foreground");
+        if (color != null) {
+            super.setForeground(color);
+        }
+    }
 }
index 5ba052b..01433aa 100644 (file)
@@ -202,7 +202,6 @@ public class SwingScilabLabel extends JScrollPane implements SwingViewObject, Si
         setMinimumSize(new Dimension(
                            Math.max((int)label.getMinimumSize().getWidth(), newSize.getWidth()),
                            (int)label.getMinimumSize().getHeight()));
-        validate();
     }
 
     /**
@@ -364,13 +363,14 @@ public class SwingScilabLabel extends JScrollPane implements SwingViewObject, Si
             if (!ScilabSpecialTextUtilities.setText(label, newText)) {
                 // Normal Text
                 ((JLabel) label).setText(newText);
-                ((JLabel) label).invalidate();
-                invalidate();
-
             } else {
                 // Latex or MathML : Rendering will be done using Icon
                 ((JLabel) label).setText(null);
             }
+
+            ((JLabel) label).invalidate();
+            ((JLabel) label).validate();
+            ((JLabel) label).repaint();
         }
 
     }
@@ -409,7 +409,6 @@ public class SwingScilabLabel extends JScrollPane implements SwingViewObject, Si
 
             label = newLabel;
             alignmentPanel.add(label);
-            alignmentPanel.revalidate();
             setViewportView(alignmentPanel);
         } else {
             alignmentPanel.remove(label);
@@ -490,7 +489,6 @@ public class SwingScilabLabel extends JScrollPane implements SwingViewObject, Si
         }
 
         alignmentLayout.setConstraints(label, gbc);
-        alignmentPanel.revalidate();
     }
 
     /**
@@ -549,4 +547,11 @@ public class SwingScilabLabel extends JScrollPane implements SwingViewObject, Si
             label.setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("Label.foreground");
+        if (color != null) {
+            label.setForeground(color);
+        }
+    }
 }
index 6cca520..c51ae1b 100644 (file)
@@ -726,4 +726,11 @@ public class SwingScilabListBox extends JScrollPane implements SwingViewObject,
             getList().setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("List.foreground");
+        if (color != null) {
+            getList().setForeground(color);
+        }
+    }
 }
index 2871bb0..05292b0 100644 (file)
@@ -478,4 +478,11 @@ public class SwingScilabMenu extends JMenu implements SwingViewObject, SimpleMen
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("Menu.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index f49a609..12776ba 100644 (file)
@@ -482,4 +482,11 @@ public class SwingScilabMenuItem extends JMenuItem implements SwingViewObject, S
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("MenuItem.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index e8550c5..ca020e3 100644 (file)
@@ -524,4 +524,11 @@ public class SwingScilabPopupMenu extends JComboBox implements SwingViewObject,
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("ComboBox.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index 635fc66..2706505 100644 (file)
@@ -15,6 +15,7 @@
 package org.scilab.modules.gui.bridge.pushbutton;
 
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_ICON__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FOREGROUNDCOLOR__;
 
 import java.awt.Color;
 import java.awt.Font;
@@ -34,6 +35,7 @@ import javax.swing.border.Border;
 import org.scilab.modules.commons.gui.FindIconHelper;
 import org.scilab.modules.console.utils.ScilabSpecialTextUtilities;
 import org.scilab.modules.graphic_objects.console.Console;
+import org.scilab.modules.graphic_objects.graphicController.GraphicController;
 import org.scilab.modules.gui.SwingViewObject;
 import org.scilab.modules.gui.SwingViewWidget;
 import org.scilab.modules.gui.events.callback.CommonCallBack;
@@ -77,17 +79,16 @@ public class SwingScilabPushButton extends JButton implements SwingViewObject, S
             /* Avoid the L&F to erase user background settings */
             setContentAreaFilled(false);
             setOpaque(true);
-        }
-
-        addPropertyChangeListener(ICON_CHANGED_PROPERTY, new PropertyChangeListener() {
-            public void propertyChange(PropertyChangeEvent evt) {
-                final Icon newIcon = (Icon) evt.getNewValue();
-                final boolean iconEnable = newIcon != null;
 
-                setContentAreaFilled(iconEnable);
-                setOpaque(!iconEnable);
-            }
-        });
+            addPropertyChangeListener(ICON_CHANGED_PROPERTY, new PropertyChangeListener() {
+                public void propertyChange(PropertyChangeEvent evt) {
+                    final Icon newIcon = (Icon) evt.getNewValue();
+                    final boolean iconEnable = newIcon != null;
+                    setContentAreaFilled(iconEnable);
+                    setOpaque(!iconEnable);
+                }
+            });
+        }
     }
 
     /**
@@ -95,7 +96,7 @@ public class SwingScilabPushButton extends JButton implements SwingViewObject, S
      * @return the text
      */
     public String getBaseText() {
-        return this.text;
+        return text;
     }
 
     /**
@@ -195,15 +196,6 @@ public class SwingScilabPushButton extends JButton implements SwingViewObject, S
      */
     public void setEnabled(boolean status) {
         super.setEnabled(status);
-        /* (Des)Activate the callback */
-        if (callback != null) {
-            if (status) {
-                removeActionListener(callback); /* To be sure the callback is not added two times */
-                addActionListener(callback);
-            } else {
-                removeActionListener(callback);
-            }
-        }
     }
 
     /**
@@ -318,16 +310,21 @@ public class SwingScilabPushButton extends JButton implements SwingViewObject, S
     public void update(int property, Object value) {
         switch (property) {
             case __GO_UI_ICON__ : {
-                File file = new File((String)value);
-                if (file.exists() == false) {
-                    String filename = FindIconHelper.findImage((String)value);
-                    file = new File(filename);
-                }
-
-                try {
-                    BufferedImage icon = ImageIO.read(file);
-                    setIcon(new ImageIcon(icon));
-                } catch (IOException e) {
+                String iconName = (String)value;
+                if (iconName == null || iconName.equals("")) {
+                    super.setIcon(null);
+                } else {
+                    File file = new File((String)value);
+                    if (file.exists() == false) {
+                        String filename = FindIconHelper.findImage((String)value);
+                        file = new File(filename);
+                    }
+
+                    try {
+                        BufferedImage icon = ImageIO.read(file);
+                        setIcon(new ImageIcon(icon));
+                    } catch (IOException e) {
+                    }
                 }
                 break;
             }
@@ -351,4 +348,11 @@ public class SwingScilabPushButton extends JButton implements SwingViewObject, S
             super.setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("Button.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index 244e706..cc2cd40 100644 (file)
@@ -392,4 +392,11 @@ public class SwingScilabRadioButton extends JRadioButton implements SwingViewObj
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("RadioButton.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index 53f0646..b90d6eb 100644 (file)
@@ -429,4 +429,11 @@ public class SwingScilabScroll extends JScrollBar implements SwingViewObject, Si
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("ScrollBar.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index 6f0fc85..97ec66a 100644 (file)
@@ -493,4 +493,11 @@ public class SwingScilabSlider extends JSlider implements SwingViewObject, Simpl
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("Slider.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index c4237be..444384e 100644 (file)
@@ -422,4 +422,11 @@ public class SwingScilabTabGroup extends JTabbedPane implements SwingViewObject,
             super.setIconAt(index, null);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("TabbedPane.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index f111953..8c44a2d 100644 (file)
@@ -219,4 +219,11 @@ public class SwingScilabTextBox extends JTextArea implements SimpleTextBox {
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("TextArea.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index 393132b..a0c81f1 100644 (file)
@@ -363,4 +363,11 @@ public class SwingScilabTree extends DefaultMutableTreeNode implements SimpleTre
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("Tree.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index 370829c..ebd7d7f 100644 (file)
@@ -295,4 +295,11 @@ public class SwingScilabUiDisplayTree extends JScrollPane implements SimpleUiDis
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("ScrollPane.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index 7382c30..94cf338 100644 (file)
@@ -381,4 +381,11 @@ public class SwingScilabUiImage extends JLabel implements SwingViewObject, Simpl
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("Label.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index 4f26075..a5df05b 100644 (file)
@@ -478,4 +478,11 @@ public class SwingScilabUiTable extends JScrollPane implements SwingViewObject,
             setBackground(color);
         }
     }
+
+    public void resetForeground() {
+        Color color = (Color)UIManager.getLookAndFeelDefaults().get("ScrollPane.foreground");
+        if (color != null) {
+            setForeground(color);
+        }
+    }
 }
index 905f4c8..46bc762 100644 (file)
@@ -265,4 +265,9 @@ public class ScilabCheckBox extends ScilabWidget implements CheckBox {
 
     }
 
+    @Override
+    public void resetForeground() {
+        // TODO Auto-generated method stub
+
+    }
 }
index da10cb3..bc8fa79 100644 (file)
@@ -264,4 +264,9 @@ public class ScilabContextMenu extends ScilabWidget implements ContextMenu {
 
     }
 
+    @Override
+    public void resetForeground() {
+        // TODO Auto-generated method stub
+
+    }
 }
index b5f454c..b97a3bf 100644 (file)
@@ -251,4 +251,9 @@ public class ScilabEditBox extends ScilabWidget implements EditBox {
 
     }
 
+    @Override
+    public void resetForeground() {
+        // TODO Auto-generated method stub
+
+    }
 }
index ced2374..2d617eb 100644 (file)
@@ -249,4 +249,9 @@ public class ScilabLabel extends ScilabWidget implements Label {
 
     }
 
+    @Override
+    public void resetForeground() {
+        // TODO Auto-generated method stub
+
+    }
 }
index 5a30846..c28f8ec 100644 (file)
@@ -324,4 +324,10 @@ public class ScilabListBox extends ScilabWidget implements ListBox {
         // TODO Auto-generated method stub
 
     }
+
+    @Override
+    public void resetForeground() {
+        // TODO Auto-generated method stub
+
+    }
 }
index a79a249..616eddd 100644 (file)
@@ -317,4 +317,9 @@ public class ScilabMenu extends ScilabWidget implements Menu {
 
     }
 
+    @Override
+    public void resetForeground() {
+        // TODO Auto-generated method stub
+
+    }
 }
index 120f390..95d6fb9 100644 (file)
@@ -289,4 +289,9 @@ public class ScilabPopupMenu extends ScilabWidget implements PopupMenu {
 
     }
 
+    @Override
+    public void resetForeground() {
+        // TODO Auto-generated method stub
+
+    }
 }
index 2631b71..27bb7ac 100644 (file)
@@ -262,4 +262,9 @@ public class ScilabPushButton extends ScilabWidget implements PushButton {
 
     }
 
+    @Override
+    public void resetForeground() {
+        // TODO Auto-generated method stub
+
+    }
 }
index 6cbb11a..05ef3b6 100644 (file)
@@ -265,4 +265,9 @@ public class ScilabRadioButton extends ScilabWidget implements RadioButton {
 
     }
 
+    @Override
+    public void resetForeground() {
+        // TODO Auto-generated method stub
+
+    }
 }
index e146175..4a6aef1 100644 (file)
@@ -311,4 +311,9 @@ public class ScilabSlider extends ScilabWidget implements Slider {
 
     }
 
+    @Override
+    public void resetForeground() {
+        // TODO Auto-generated method stub
+
+    }
 }
index 817f204..9a8ccad 100644 (file)
@@ -252,4 +252,9 @@ public class ScilabTextBox extends ScilabText implements TextBox {
 
     }
 
+    @Override
+    public void resetForeground() {
+        // TODO Auto-generated method stub
+
+    }
 }
index 5316a65..e9e145c 100644 (file)
@@ -302,4 +302,9 @@ public class ScilabTree implements Tree {
 
     }
 
+    @Override
+    public void resetForeground() {
+        // TODO Auto-generated method stub
+
+    }
 }
index 9761bf4..b664242 100644 (file)
@@ -256,4 +256,10 @@ public class ScilabUiDisplayTree extends ScilabWidget implements UiDisplayTree {
         // TODO Auto-generated method stub
 
     }
+
+    @Override
+    public void resetForeground() {
+        // TODO Auto-generated method stub
+
+    }
 }
index b4cd9dd..61b3113 100644 (file)
@@ -289,4 +289,10 @@ public class ScilabUiTable extends ScilabWidget implements UiTable {
         // TODO Auto-generated method stub
 
     }
+
+    @Override
+    public void resetForeground() {
+        // TODO Auto-generated method stub
+
+    }
 }
index e2e8867..3a78cd1 100644 (file)
@@ -43,6 +43,7 @@ public interface Widget extends Dockable {
      * @param color the Color
      */
     void setForeground(Color color);
+    void resetForeground();
 
     /**
      * Get the Foreground color of the widget.