BUTTON: Fix bug that set the color of the radio button
authorHyunJong Park <paulhj.park@samsung.com>
Wed, 22 Jun 2016 08:04:37 +0000 (17:04 +0900)
committerHyunJong Park <paulhj.park@samsung.com>
Wed, 22 Jun 2016 08:29:39 +0000 (17:29 +0900)
Show the background color when a user set background color.

Change-Id: Icf9f3b34cc8050b6c2ca088e77a412878178e0e4
Signed-off-by: HyunJong Park <paulhj.park@samsung.com>
bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TizenButtonAttribute.java
bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TizenRadioButtonRenderer.java

index 9bca859..70e50fa 100644 (file)
@@ -33,6 +33,9 @@ public class TizenButtonAttribute {
 
     private String text;
 
+    private Color backgroundColor = null;
+    private Color foregroundColor = null;
+
     private int align = SWT.CENTER;
     private Image iconImage = null;
 
@@ -153,4 +156,20 @@ public class TizenButtonAttribute {
         return this.outlineInColors.get(state);
     }
 
+    public Color getBackground() {
+        return backgroundColor;
+    }
+
+    public void setBackground(Color color) {
+        backgroundColor = color;
+    }
+
+    public Color getForeground() {
+        return foregroundColor;
+    }
+
+    public void setForeground(Color color) {
+        foregroundColor = color;
+    }
+
 }
index 84f01f3..fcd475e 100644 (file)
@@ -69,12 +69,12 @@ public class TizenRadioButtonRenderer extends TizenAbstractButtonRenderer {
 
     @Override
     protected void setBackground(Color color) {
-        parent.getAttribute().setBackGroundColor(ENABLE, color);
+        parent.getAttribute().setBackground(color);
     }
 
     @Override
     protected void setForeground(Color color) {
-        parent.getAttribute().setForeGroundColor(ENABLE, color);
+        parent.getAttribute().setForeground(color);
     }
 
     private void drawMouseHover() {
@@ -130,7 +130,7 @@ public class TizenRadioButtonRenderer extends TizenAbstractButtonRenderer {
 
     @Override
     protected boolean getSelection() {
-        return((state & SELECT) == SELECT);
+        return ((state & SELECT) == SELECT);
     }
 
     @Override
@@ -195,10 +195,34 @@ public class TizenRadioButtonRenderer extends TizenAbstractButtonRenderer {
         }
     }
 
+    private void drawBackground(Rectangle rect, GC gc) {
+        Color color = parent.getAttribute().getBackground();
+        if (null == color) {
+            return;
+        }
+        gc.setBackground(color);
+        gc.fillRectangle(rect);
+    }
+
+    private void drawForeground(GC gc) {
+        Color color = parent.getAttribute().getForeground();
+        if (null != color) {
+            gc.setForeground(color);
+            return;
+        }
+
+        if (isState(state, ENABLE)) {
+            gc.setForeground(TizenResourceManager.RADIO_BUTTON_NORMAL_FONT_COLOR);
+        } else {
+            gc.setForeground(TizenResourceManager.RADIO_BUTTON_DISABLE_FONT_COLOR);
+        }
+    }
+
     @Override
     protected void drawButton(final Event e) {
         TizenButton me = (TizenButton) e.widget;
         Rectangle rect = me.getClientArea();
+        drawBackground(rect, e.gc);
         int x = 0;
         int y = 0;
         Image img = getImage();
@@ -212,13 +236,7 @@ public class TizenRadioButtonRenderer extends TizenAbstractButtonRenderer {
             y = (rect.height - fontHeight) / 2;
         }
 
-        if (null != parent.getAttribute().getForeGroundcolor(ENABLE)) {
-            e.gc.setForeground(parent.getAttribute().getForeGroundcolor(ENABLE));
-        } else if (null != parent.getForeground()) {
-            e.gc.setForeground(parent.getForeground());
-        } else {
-            e.gc.setForeground(TizenResourceManager.BLACK_COLOR);
-        }
+        drawForeground(e.gc);
 
         if (null != parent.getAttribute().getFont()) {
             e.gc.setFont(parent.getAttribute().getFont());