- Apply new icon images and color.
- Rename the state of each button.
- Change the data structure for the resource of the state of each button.
- Declared as an abstract class.
Change-Id: I0e46e6809a8a77978db9ccfcec4cd126873668df
Signed-off-by: HyunJong Park <paulhj.park@samsung.com>
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
-public class TizenAbstractButtonRenderer {
+public abstract class TizenAbstractButtonRenderer {
- protected int buttonState = TizenCheckBoxButtonRenderer.UNSELECTED;
+ protected int buttonState = TizenCheckBoxButtonRenderer.NORMAL;
protected Composite parentComposite = null;
protected TizenButton parent;
protected boolean isFocus = false;
protected static final int MARGIN = 5;
- protected boolean isWidgetEnable = true;
+ protected boolean isEnable = true;
protected boolean isMouseOverButton = false;
protected boolean isDefaultButton = false;
+ protected boolean isGrayed = false;
TizenAbstractButtonRenderer(final TizenButton parent, Composite parentComposite) {
this.parent = parent;
return isFocus;
}
- protected void drawButton(Event e) {
- }
-
- protected Listener getMouseListener() {
- return null;
- }
-
protected void setEnabled(boolean enabled) {
- isWidgetEnable = enabled;
+ isEnable = enabled;
}
protected void setButtonState(int buttonState) {
return this.buttonState;
}
- protected void setBackground(Color color) {
+ protected void setDefaultButtonListener(boolean enable) {
}
- protected void setForeground(Color color) {
- }
+ abstract protected void drawButton(Event e);
- protected void setSelection(boolean selected) {
- }
+ abstract protected Listener getMouseListener();
- protected void setDefaultButtonListener(boolean enable) {
- }
+ abstract protected void setBackground(Color color);
- protected boolean getSelection() {
- return false;
- }
+ abstract protected void setForeground(Color color);
- protected boolean setFocus() {
- return false;
- }
+ abstract protected void setSelection(boolean selected);
- protected boolean removeFocus() {
- return false;
- }
+ abstract protected boolean getSelection();
+
+ abstract protected boolean setFocus();
+
+ abstract protected boolean removeFocus();
}
case SWT.PUSH:
buttonRenderer = new TizenPushButtonRenderer(this, parent);
break;
+ case SWT.TOGGLE:
+ case SWT.FLAT:
default:
buttonRenderer = new TizenPushButtonRenderer(this, parent);
}
case '\n': // $NON-NLS-1$
redraw();
fireSelectionEvent();
+ updateCheckButtonStateWhenPressedSpaceKey();
break;
}
}
});
}
+ private void updateCheckButtonStateWhenPressedSpaceKey() {
+ if (this.isDisposed() || (!isEqualsType(getStyle(), SWT.CHECK) && !isFocus())) {
+ return;
+ }
+ buttonRenderer.setSelection(buttonRenderer.getSelection() == false);
+ }
+
protected void fireSelectionEvent() {
Event e = new Event();
e.item = this;
public void click() {
}
- /*
- * TODO: Re-implemented after the disign request is required.
- * @author paulhj.park@samsung.com
- * @since 2016-02-15
- */
public void setGrayed(boolean grayed) {
- if ((!isEqualsType(getStyle(), SWT.CHECK))) {
+ if (!isEqualsType(getStyle(), SWT.CHECK)) {
return;
}
+ buttonRenderer.isGrayed = grayed;
+ redraw();
}
- /*
- * TODO: Re-implemented after the disign request is required.
- * @author paulhj.park@samsung.com
- * @since 2016-02-15
- */
public boolean getGrayed() {
return false;
}
import org.eclipse.swt.graphics.*;
public class TizenButtonAttribute {
- final int MAX_SIZE = 6;
-
private Font font = null;
private String text;
+
private int align = SWT.CENTER;
private Image iconImage = null;
private Point fontPoint = null;
private Point buttonImagePoint;
- private List<Image> images = new ArrayList<Image>();
- private List<Color> backGroundcolors = new ArrayList<Color>();
- private List<Color> foreGroundcolors = new ArrayList<Color>();
- private List<Color> outlineColors = new ArrayList<Color>();
- private List<Color> outlineInColors = new ArrayList<Color>();
-
- public TizenButtonAttribute() {
- for (int i = 0; i < MAX_SIZE; i++) {
- images.add(null);
- backGroundcolors.add(null);
- foreGroundcolors.add(null);
- outlineColors.add(null);
- outlineInColors.add(null);
- }
- }
+ private HashMap<Integer, Image> images = new HashMap<Integer, Image>();
+ private HashMap<Integer, Color> backGroundcolors = new HashMap<Integer, Color>();
+ private HashMap<Integer, Color> foreGroundcolors = new HashMap<Integer, Color>();
+ private HashMap<Integer, Color> outlineColors = new HashMap<Integer, Color>();
+ private HashMap<Integer, Color> outlineInColors = new HashMap<Integer, Color>();
public String getText() {
return this.text;
}
public void setImage(int state, Image img) {
- images.set(state, img);
+ images.put(state, img);
}
public void setImage(Image img) {
- this.images.set(TizenRadioButtonRenderer.SELECTED, img);
- this.images.set(TizenRadioButtonRenderer.SELECTED_HOVER, img);
- this.images.set(TizenRadioButtonRenderer.SELECTED_DISABLE, img);
- this.images.set(TizenRadioButtonRenderer.UNSELECTED, img);
- this.images.set(TizenRadioButtonRenderer.UNSELECTED_HOVER, img);
- this.images.set(TizenRadioButtonRenderer.UNSELECTED_DISABLE, img);
+ this.images.put(TizenRadioButtonRenderer.SELECTED, img);
+ this.images.put(TizenRadioButtonRenderer.SELECTED_HOVER, img);
+ this.images.put(TizenRadioButtonRenderer.SELECTED_DISABLE, img);
+ this.images.put(TizenRadioButtonRenderer.NORMAL, img);
+ this.images.put(TizenRadioButtonRenderer.NORML_HOVER, img);
+ this.images.put(TizenRadioButtonRenderer.NORMAL_DISABLE, img);
}
public Color getBackGroundcolor(int state) {
}
public void setBackGroundColor(int state, Color color) {
- this.backGroundcolors.set(state, color);
+ this.backGroundcolors.put(state, color);
}
public Color getForeGroundcolor(int state) {
}
public void setForeGroundColor(int state, Color color) {
- this.foreGroundcolors.set(state, color);
+ this.foreGroundcolors.put(state, color);
}
public void setOutlineColor(int state, Color color) {
- this.outlineColors.set(state, color);
+ this.outlineColors.put(state, color);
}
public Color getOutlineColor(int state) {
}
public void setOutlineInColor(int state, Color color) {
- this.outlineInColors.set(state, color);
+ this.outlineInColors.put(state, color);
}
public Color getOutlineInColor(int state) {
@Override
protected Image getImage(int state) {
+ /*
+ * FIXME: To simplify the branch statement.
+ * @author: paulhj.park@samsung.com
+ * @since: 2016-05-24
+ */
switch (getButtonState()) {
case SELECTED:
- return TizenResourceManager.getInstance().checkBoxSelected;
+ if (isGrayed) {
+ return TizenResourceManager.getInstance().checkBoxGrayed;
+ } else {
+ return TizenResourceManager.getInstance().checkBoxSelected;
+ }
case SELECTED_HOVER:
- return TizenResourceManager.getInstance().checkBoxSelectedHover;
+ if (isGrayed) {
+ return TizenResourceManager.getInstance().checkBoxGrayedHover;
+ } else {
+ return TizenResourceManager.getInstance().checkBoxSelectedHover;
+ }
case SELECTED_DISABLE:
- return TizenResourceManager.getInstance().checkBoxSelectedDisable;
- case UNSELECTED:
- return TizenResourceManager.getInstance().checkBoxUnselected;
- case UNSELECTED_HOVER:
- return TizenResourceManager.getInstance().checkBoxUnelectedHover;
- case UNSELECTED_DISABLE:
- return TizenResourceManager.getInstance().checkBoxUnselectedDisable;
+ if (isGrayed) {
+ return TizenResourceManager.getInstance().checkBoxGrayedDisable;
+ } else {
+ return TizenResourceManager.getInstance().checkBoxSelectedDisable;
+ }
+ case SELECTED_FOCUSED:
+ if (isGrayed) {
+ return TizenResourceManager.getInstance().checkBoxGrayedFocused;
+ } else {
+ return TizenResourceManager.getInstance().checkBoxSelectedFocused;
+ }
+ case NORMAL:
+ return TizenResourceManager.getInstance().checkBoxNormal;
+ case NORML_HOVER:
+ return TizenResourceManager.getInstance().checkBoxNormalHover;
+ case NORMAL_DISABLE:
+ return TizenResourceManager.getInstance().checkBoxNormalDisable;
+ case NORMAL_FOCUSED:
+ return TizenResourceManager.getInstance().checkBoxNormalFocused;
default:
- return TizenResourceManager.getInstance().checkBoxUnselected;
+ return TizenResourceManager.getInstance().checkBoxNormal;
}
}
}
public class TizenPushButtonRenderer extends TizenAbstractButtonRenderer {
private final int STATE_NORMAL = 0;
- private final int STATE_PUSH = 1;
+ private final int STATE_FOCUSED = 1;
private final int STATE_HOVER = 2;
- private final int STATE_DISABLE = 3;
- private final int STATE_FOCUS = 4;
+ private final int STATE_PRESSED = 3;
+ private final int STATE_DIMMED = 4;
private static int eventEnterKeyTime = 0;
}
private void setPushButtonDefaultColors() {
+
setBackGroundColors(TizenResourceManager.PUSH_BUTTON_NORMAL_BG_COLOR,
- TizenResourceManager.PUSH_BUTTON_SELECT_BG_COLOR, TizenResourceManager.PUSH_BUTTON_HOVER_BG_COLOR,
- TizenResourceManager.PUSH_BUTTON_DISABLE_BG_COLOR, TizenResourceManager.PUSH_BUTTON_FOCUS_BG_COLOR);
+ TizenResourceManager.PUSH_BUTTON_PRESSED_BG_COLOR, TizenResourceManager.PUSH_BUTTON_HOVER_BG_COLOR,
+ TizenResourceManager.PUSH_BUTTON_DIMMED_BG_COLOR, TizenResourceManager.PUSH_BUTTON_FOCUSED_BG_COLOR);
+
setforeGroundColors(TizenResourceManager.PUSH_BUTTON_NORMAL_FONT_COLOR,
- TizenResourceManager.PUSH_BUTTON_PUSH_COLOR, TizenResourceManager.PUSH_BUTTON_HOVER_COLOR,
- TizenResourceManager.PUSH_BUTTON_DISABLE_FONT_COLOR, TizenResourceManager.PUSH_BUTTON_FOCUS_FONT_COLOR);
+ TizenResourceManager.PUSH_BUTTON_PRESSED_FONT_COLOR, TizenResourceManager.PUSH_BUTTON_HOVER_FONT_COLOR,
+ TizenResourceManager.PUSH_BUTTON_DIMMED_FONT_COLOR, TizenResourceManager.PUSH_BUTTON_FOCUSED_FONT_COLOR);
+
setlineColors(TizenResourceManager.PUSH_BUTTON_OUTLINE_NORMAL_COLOR,
- TizenResourceManager.PUSH_BUTTON_OUTLINE_PUSH_COLOR,
+ TizenResourceManager.PUSH_BUTTON_OUTLINE_PRESSED_COLOR,
TizenResourceManager.PUSH_BUTTON_OUTLINE_HOVER_COLOR,
- TizenResourceManager.PUSH_BUTTON_OUTLINE_DISABLE_COLOR, TizenResourceManager.PUSH_BUTTON_OUTLINE_FOCUS_COLOR);
+ TizenResourceManager.PUSH_BUTTON_OUTLINE_DIMMED_COLOR, TizenResourceManager.PUSH_BUTTON_OUTLINE_FOCUSED_COLOR);
}
- /**
- * Sets the color of button
- * @param normal The color of normal state
- * @param push The color of push state
- * @param hove The color of hover state
- * @param disabl The color of disable state
- */
private void setBackGroundColors(Color normal, Color push, Color hover, Color disable, Color focus) {
- parent.attr.setBackGroundColor(STATE_NORMAL, normal);
- parent.attr.setBackGroundColor(STATE_PUSH, push);
- parent.attr.setBackGroundColor(STATE_HOVER, hover);
- parent.attr.setBackGroundColor(STATE_DISABLE, disable);
- parent.attr.setBackGroundColor(STATE_FOCUS, focus);
+ parent.getAttribute().setBackGroundColor(STATE_NORMAL, normal);
+ parent.getAttribute().setBackGroundColor(STATE_PRESSED, push);
+ parent.getAttribute().setBackGroundColor(STATE_HOVER, hover);
+ parent.getAttribute().setBackGroundColor(STATE_DIMMED, disable);
+ parent.getAttribute().setBackGroundColor(STATE_FOCUSED, focus);
}
- /**
- * Sets the font color of button.
- * @param normal The color of normal state
- * @param push The color of push state
- * @param hover The color of hover state
- * @param disable The color of disable state
- */
private void setforeGroundColors(Color normal, Color push, Color hover, Color disable, Color focus) {
- parent.attr.setForeGroundColor(STATE_NORMAL, normal);
- parent.attr.setForeGroundColor(STATE_PUSH, push);
- parent.attr.setForeGroundColor(STATE_HOVER, hover);
- parent.attr.setForeGroundColor(STATE_DISABLE, disable);
- parent.attr.setForeGroundColor(STATE_FOCUS, focus);
+ parent.getAttribute().setForeGroundColor(STATE_NORMAL, normal);
+ parent.getAttribute().setForeGroundColor(STATE_PRESSED, push);
+ parent.getAttribute().setForeGroundColor(STATE_HOVER, hover);
+ parent.getAttribute().setForeGroundColor(STATE_DIMMED, disable);
+ parent.getAttribute().setForeGroundColor(STATE_FOCUSED, focus);
}
- /**
- * Sets the outside line color of button.
- * @param normal The line color of normal state.
- * @param push The line color of push state.
- * @param hover The line color of hover state.
- * @param disable The line color of disable state.
- */
private void setlineColors(Color normal, Color push, Color hover, Color disable, Color focus) {
- parent.attr.setOutlineColor(STATE_NORMAL, normal);
- parent.attr.setOutlineColor(STATE_PUSH, push);
- parent.attr.setOutlineColor(STATE_HOVER, hover);
- parent.attr.setOutlineColor(STATE_DISABLE, disable);
- parent.attr.setOutlineColor(STATE_FOCUS, focus);
+ parent.getAttribute().setOutlineColor(STATE_NORMAL, normal);
+ parent.getAttribute().setOutlineColor(STATE_PRESSED, push);
+ parent.getAttribute().setOutlineColor(STATE_HOVER, hover);
+ parent.getAttribute().setOutlineColor(STATE_DIMMED, disable);
+ parent.getAttribute().setOutlineColor(STATE_FOCUSED, focus);
}
@Override
@Override
protected void setEnabled(boolean enabled) {
super.setEnabled(enabled);
- int preState = getButtonState();
- if (enabled && preState != STATE_FOCUS) {
- setButtonState(STATE_NORMAL);
+ if (enabled) {
+ if (isFocus) {
+ setButtonState(STATE_FOCUSED);
+ } else {
+ setButtonState(STATE_NORMAL);
+ }
} else {
- setButtonState(STATE_DISABLE);
+ setButtonState(STATE_DIMMED);
}
parent.redraw();
}
@Override
protected boolean setFocus() {
isFocus = true;
- if (getButtonState() != STATE_DISABLE) {
- setButtonState(STATE_FOCUS);
+ if (getButtonState() != STATE_DIMMED) {
+ setButtonState(STATE_FOCUSED);
setLastFocusOnly();
parent.redraw();
}
-
return true;
}
@Override
protected boolean removeFocus() {
isFocus = false;
- if (getButtonState() != STATE_DISABLE) {
+ if (getButtonState() != STATE_DIMMED) {
setButtonState(STATE_NORMAL);
parent.redraw();
}
-
return false;
}
private boolean enableDefaultButton() {
- if (isDefaultButton && getButtonState() != STATE_DISABLE && getButtonState() != STATE_PUSH) {
+ if (isDefaultButton && getButtonState() != STATE_DIMMED && getButtonState() != STATE_PRESSED) {
return true;
} else {
return false;
if (!button.isEqualsType(child.getStyle(), SWT.PUSH)) {
continue;
}
- if (parent != child && button.isFocus()) {
- button.removeFocus();
- }
+ button.removeFocus();
button.redraw();
}
}
switch (event.type) {
case SWT.MouseHover:
case SWT.MouseEnter:
- if (!isWidgetEnable) {
+ if (!isEnable) {
break;
}
setButtonState(STATE_HOVER);
parent.redraw();
break;
case SWT.MouseExit:
- if (!isWidgetEnable) {
+ if (!isEnable) {
break;
}
setButtonState(STATE_NORMAL);
parent.redraw();
break;
case SWT.MouseDown:
- if (!isWidgetEnable) {
+ if (!isEnable) {
break;
}
- setButtonState(STATE_PUSH);
+ setButtonState(STATE_PRESSED);
parent.redraw();
break;
case SWT.MouseUp:
Rectangle rect = me.getClientArea();
drawBackground(e.gc, rect, getButtonState(), parent.getAttribute());
drawButtonImage(e.gc, rect, parent.getAttribute(), getButtonState());
- drawBorder(e.gc, rect, getButtonState(), parent.getAttribute());
drawIcon(e.gc, rect, parent.getAttribute());
- if (enableDefaultButton()) {
- drawDefaultButtonHighlight(e.gc, rect, getButtonState(), parent.getAttribute());
+ drawBorder(e.gc, rect, getButtonState(), parent.getAttribute());
+ drawButtonText(e.gc, rect, getButtonState(), parent.getAttribute());
+ if ((enableDefaultButton() || isFocus) && parent.isEnabled()) {
+ drawHighlightBorder(e.gc, rect, getButtonState(), parent.getAttribute());
+ } else {
+ drawBorder(e.gc, rect, getButtonState(), parent.getAttribute());
}
}
return;
}
Rectangle r = new Rectangle(0, 0, rect.width - 1, rect.height - 1);
- drawButtonText(gc, r, attr, state);
if (null != attr.getOutlineColor(state)) {
gc.setForeground(attr.getOutlineColor(state));
} else if (null != parent.getForeground()) {
gc.drawRectangle(r);
}
- private void drawDefaultButtonHighlight(GC gc, Rectangle rect, int state, TizenButtonAttribute attr) {
+ private void drawHighlightBorder(GC gc, Rectangle rect, int state, TizenButtonAttribute attr) {
if (null == attr) {
return;
}
Rectangle r = new Rectangle(0, 0, rect.width - 1, rect.height - 1);
- gc.setForeground(TizenResourceManager.PUSH_BUTTON_DEFAULT_BUTTON_FOCUS_COLOR);
+ gc.setForeground(TizenResourceManager.PUSH_BUTTON_OUTLINE_FOCUSED_COLOR);
gc.drawRectangle(r);
+
+ Rectangle ir = new Rectangle(r.x + 1, r.y + 1, r.width - 2,
+ r.height - 2);
+ gc.setForeground(TizenResourceManager.PUSH_BUTTON_OUTLINE_FOCUSED_COLOR);
+ gc.drawRectangle(ir);
}
private void drawButtonImage(GC gc, Rectangle rect, TizenButtonAttribute attr, int state) {
}
if (height > 0) {
y = height / 2;
+
}
} else {
p = attr.getButtonImagePoint();
gc.drawImage(img, x, y);
}
- private void drawButtonText(GC gc, Rectangle rect, TizenButtonAttribute attr, int state) {
+ private void drawButtonText(GC gc, Rectangle rect, int state, TizenButtonAttribute attr) {
if (null == attr || null == attr.getText()) {
return;
}
y = p.y;
}
- if (null != attr.getForeGroundcolor(state)) {
- gc.setForeground(attr.getForeGroundcolor(state));
- } else if (null != parent.getForeground()) {
- gc.setForeground(parent.getForeground());
+ if (isFocus && parent.isEnabled()) {
+ gc.setForeground(TizenResourceManager.PUSH_BUTTON_OUTLINE_FOCUSED_COLOR);
} else {
- gc.setForeground(TizenResourceManager.BLACK_COLOR);
+ if (null != attr.getForeGroundcolor(state)) {
+ gc.setForeground(attr.getForeGroundcolor(state));
+ } else if (null != parent.getForeground()) {
+ gc.setForeground(parent.getForeground());
+ } else {
+ gc.setForeground(TizenResourceManager.BLACK_COLOR);
+ }
}
- if (state == STATE_PUSH) {
+ if (state == STATE_PRESSED) {
x += 1;
y += 1;
}
public class TizenRadioButtonRenderer extends TizenAbstractButtonRenderer {
public static final int SELECTED = 0;
public static final int SELECTED_HOVER = 1;
- public static final int UNSELECTED = 2;
- public static final int UNSELECTED_HOVER = 3;
- public static final int SELECTED_DISABLE = 4;
- public static final int UNSELECTED_DISABLE = 5;
+ public static final int SELECTED_DISABLE = 2;
+ public static final int SELECTED_FOCUSED = 3;
+ public static final int NORMAL = 4;
+ public static final int NORML_HOVER = 5;
+ public static final int NORMAL_DISABLE = 6;
+ public static final int NORMAL_FOCUSED = 7;
TizenRadioButtonRenderer(TizenButton parent, Composite parentComposite) {
super(parent, parentComposite);
private void setPushButtonDefaultColors() {
parent.attr.setForeGroundColor(SELECTED, TizenResourceManager.RADIO_BUTTON_SELECT_COLOR);
parent.attr.setForeGroundColor(SELECTED_HOVER, TizenResourceManager.RADIO_BUTTON_SELECT_COLOR);
- parent.attr.setForeGroundColor(SELECTED_DISABLE, TizenResourceManager.RADIO_BUTTON_DIMMED_FONT_COLOR);
- parent.attr.setForeGroundColor(UNSELECTED, TizenResourceManager.RADIO_BUTTON_NORMAL_FONT_COLOR);
- parent.attr.setForeGroundColor(UNSELECTED_HOVER, TizenResourceManager.RADIO_BUTTON_NORMAL_FONT_COLOR);
- parent.attr.setForeGroundColor(UNSELECTED_DISABLE, TizenResourceManager.RADIO_BUTTON_DIMMED_FONT_COLOR);
+ parent.attr.setForeGroundColor(SELECTED_DISABLE, TizenResourceManager.RADIO_BUTTON_DISABLE_FONT_COLOR);
+ parent.attr.setForeGroundColor(SELECTED_FOCUSED, TizenResourceManager.RADIO_BUTTON_NORMAL_FONT_COLOR);
+ parent.attr.setForeGroundColor(NORMAL, TizenResourceManager.RADIO_BUTTON_NORMAL_FONT_COLOR);
+ parent.attr.setForeGroundColor(NORML_HOVER, TizenResourceManager.RADIO_BUTTON_NORMAL_FONT_COLOR);
+ parent.attr.setForeGroundColor(NORMAL_DISABLE, TizenResourceManager.RADIO_BUTTON_DISABLE_FONT_COLOR);
+ parent.attr.setForeGroundColor(NORMAL_FOCUSED, TizenResourceManager.RADIO_BUTTON_NORMAL_FONT_COLOR);
}
+ /*
+ * FIXME: To simplify the branch statement.
+ * @author: paulhj.park@samsung.com
+ * @since: 2016-05-24
+ */
@Override
public Listener getMouseListener() {
return new Listener() {
switch (event.type) {
case SWT.MouseHover:
case SWT.MouseEnter:
- if (!isWidgetEnable) {
+ if (!isEnable) {
break;
}
- if (getButtonState() != SELECTED) {
- setButtonState(UNSELECTED_HOVER);
+ if (getButtonState() == SELECTED) {
+ setButtonState(SELECTED_HOVER);
+ } else if (getButtonState() == SELECTED_HOVER) {
+ setButtonState(SELECTED_HOVER);
+ } else if (getButtonState() == SELECTED_FOCUSED) {
+ setButtonState(SELECTED_HOVER);
+ } else if (getButtonState() == NORMAL) {
+ setButtonState(NORML_HOVER);
+ } else if (getButtonState() == NORML_HOVER) {
+ setButtonState(NORML_HOVER);
+ } else if (getButtonState() == NORMAL_FOCUSED) {
+ setButtonState(NORML_HOVER);
}
+
parent.redraw();
break;
case SWT.MouseExit:
- if (!isWidgetEnable) {
+ if (!isEnable) {
break;
}
- if (getButtonState() != SELECTED) {
- setButtonState(UNSELECTED);
+ if (getButtonState() == SELECTED_HOVER) {
+ if (isFocus()) {
+ setButtonState(SELECTED_FOCUSED);
+ } else {
+ setButtonState(SELECTED);
+ }
+ } else if (getButtonState() == NORML_HOVER) {
+ if (isFocus()) {
+ setButtonState(NORMAL_FOCUSED);
+ } else {
+ setButtonState(NORMAL);
+ }
}
parent.redraw();
break;
case SWT.MouseDown:
break;
case SWT.MouseUp:
- if (!isWidgetEnable) {
- break;
- }
- if (!isHover()) {
+ if (!isEnable) {
break;
}
if (getButtonState() == SELECTED) {
- setButtonState(UNSELECTED_HOVER);
- } else {
+ setButtonState(NORMAL);
+ } else if (getButtonState() == SELECTED_HOVER) {
+ setButtonState(NORML_HOVER);
+ } else if (getButtonState() == SELECTED_FOCUSED) {
+ setButtonState(NORMAL_FOCUSED);
+ } else if (getButtonState() == NORMAL) {
setButtonState(SELECTED);
+ } else if (getButtonState() == NORML_HOVER) {
+ setButtonState(SELECTED_HOVER);
+ } else if (getButtonState() == NORMAL_FOCUSED) {
+ setButtonState(SELECTED_FOCUSED);
}
parent.redraw();
selectRadio();
parent.attr.setBackGroundColor(SELECTED, color);
parent.attr.setBackGroundColor(SELECTED_HOVER, color);
parent.attr.setBackGroundColor(SELECTED_DISABLE, color);
- parent.attr.setBackGroundColor(UNSELECTED, color);
- parent.attr.setBackGroundColor(UNSELECTED_HOVER, color);
- parent.attr.setBackGroundColor(UNSELECTED_DISABLE, color);
+ parent.attr.setBackGroundColor(SELECTED_FOCUSED, color);
+ parent.attr.setBackGroundColor(NORMAL, color);
+ parent.attr.setBackGroundColor(NORML_HOVER, color);
+ parent.attr.setBackGroundColor(NORMAL_DISABLE, color);
+ parent.attr.setBackGroundColor(NORMAL_FOCUSED, color);
}
@Override
parent.attr.setForeGroundColor(SELECTED, color);
parent.attr.setForeGroundColor(SELECTED_HOVER, color);
parent.attr.setForeGroundColor(SELECTED_DISABLE, color);
- parent.attr.setForeGroundColor(UNSELECTED, color);
- parent.attr.setForeGroundColor(UNSELECTED_HOVER, color);
- parent.attr.setForeGroundColor(UNSELECTED_DISABLE, color);
+ parent.attr.setForeGroundColor(SELECTED_FOCUSED, color);
+ parent.attr.setForeGroundColor(NORMAL, color);
+ parent.attr.setForeGroundColor(NORML_HOVER, color);
+ parent.attr.setForeGroundColor(NORMAL_DISABLE, color);
+ parent.attr.setForeGroundColor(NORMAL_FOCUSED, color);
}
@Override
if (enabled) {
if (getButtonState() == SELECTED_DISABLE) {
setButtonState(SELECTED);
- } else if (getButtonState() == UNSELECTED_DISABLE) {
- setButtonState(UNSELECTED);
+ } else if (getButtonState() == NORMAL_DISABLE) {
+ setButtonState(NORMAL);
}
} else {
if (getButtonState() == SELECTED) {
setButtonState(SELECTED_DISABLE);
- } else if (getButtonState() == UNSELECTED) {
- setButtonState(UNSELECTED_DISABLE);
+ } else if (getButtonState() == NORMAL) {
+ setButtonState(NORMAL_DISABLE);
}
}
parent.redraw();
@Override
protected void setSelection(boolean selected) {
if (selected) {
- if (isWidgetEnable) {
+ if (isEnable) {
setButtonState(SELECTED);
} else {
setButtonState(SELECTED_DISABLE);
}
} else {
- if (isWidgetEnable) {
- setButtonState(UNSELECTED);
+ if (isEnable) {
+ setButtonState(NORMAL);
} else {
- setButtonState(UNSELECTED_DISABLE);
+ setButtonState(NORMAL_DISABLE);
}
}
parent.redraw();
@Override
protected boolean getSelection() {
- if (getButtonState() == SELECTED || getButtonState() == SELECTED_DISABLE) {
+ if (getButtonState() == SELECTED || getButtonState() == SELECTED_HOVER || getButtonState() == SELECTED_DISABLE || getButtonState() == SELECTED_FOCUSED) {
return true;
} else {
return false;
@Override
protected boolean setFocus() {
isFocus = true;
- if (getButtonState() == UNSELECTED) {
- setButtonState(UNSELECTED_HOVER);
+ if (!isEnable) {
+ return true;
+ }
+ if (getButtonState() == NORMAL) {
+ setButtonState(NORMAL_FOCUSED);
+ } else if (getButtonState() == SELECTED) {
+ setButtonState(SELECTED_FOCUSED);
}
parent.redraw();
return true;
@Override
protected boolean removeFocus() {
isFocus = false;
- if (getButtonState() == UNSELECTED_HOVER) {
- setButtonState(UNSELECTED);
+ if (!isEnable) {
+ return true;
+ }
+ if (getButtonState() == NORMAL_FOCUSED) {
+ setButtonState(NORMAL);
+ } else if (getButtonState() == SELECTED_FOCUSED) {
+ setButtonState(SELECTED);
}
parent.redraw();
return false;
if (parent == child) {
((Button) child).setButtonState(TizenCheckBoxButtonRenderer.SELECTED);
} else {
- ((Button) child).setButtonState(TizenCheckBoxButtonRenderer.UNSELECTED);
+ ((Button) child).setButtonState(TizenCheckBoxButtonRenderer.NORMAL);
}
((Button) child).redraw();
}
return TizenResourceManager.getInstance().radioSelectedHover;
case SELECTED_DISABLE:
return TizenResourceManager.getInstance().radioSelectedDisable;
- case UNSELECTED:
- return TizenResourceManager.getInstance().radioUnselected;
- case UNSELECTED_HOVER:
- return TizenResourceManager.getInstance().radioUnelectedHover;
- case UNSELECTED_DISABLE:
- return TizenResourceManager.getInstance().radioUnselectedDisable;
+ case SELECTED_FOCUSED:
+ return TizenResourceManager.getInstance().radioSelectedFocused;
+ case NORMAL:
+ return TizenResourceManager.getInstance().radioNormal;
+ case NORML_HOVER:
+ return TizenResourceManager.getInstance().radioNormalHover;
+ case NORMAL_DISABLE:
+ return TizenResourceManager.getInstance().radioNormalDisable;
+ case NORMAL_FOCUSED:
+ return TizenResourceManager.getInstance().radioNormalFocused;
default:
- return TizenResourceManager.getInstance().radioUnselected;
+ return TizenResourceManager.getInstance().radioNormal;
}
}
Rectangle rect = me.getClientArea();
int x = 0;
int y = 0;
- drawBackground(e.gc, rect, parent.getAttribute());
Image img = getImage(getButtonState());
if (null != img) {
Rectangle imgRect = img.getBounds();
}
if (null != parent.getText()) {
- e.gc.drawText(parent.getText(), x, y);
- }
- }
-
- private void drawBackground(GC gc, Rectangle rect, TizenButtonAttribute attr) {
- if (null != parent.getAttribute().getBackGroundcolor(getButtonState())) {
- gc.setBackground(parent.getAttribute().getBackGroundcolor(getButtonState()));
- } else if (null != parent.getBackground()) {
- gc.setBackground(parent.getBackground());
- } else {
- gc.setBackground(TizenResourceManager.WHITE_COLOR);
+ // This will draw the string on two lines, with a tab between World! and
+ // From, with the W underlined, and with a transparent background
+ e.gc.drawText(parent.getText(), x, y, SWT.DRAW_MNEMONIC | SWT.DRAW_DELIMITER
+ | SWT.DRAW_TAB | SWT.DRAW_TRANSPARENT);
}
- gc.fillRectangle(rect);
}
}
public static final Color PROGRESS_BAR_COLOR = getColorSafely(0, 138, 238);
/*Radio Button Font Color */
- public static final Color RADIO_BUTTON_NORMAL_FONT_COLOR = getColorSafely(70, 70, 70);
+ public static final Color RADIO_BUTTON_NORMAL_FONT_COLOR = getColorSafely(88, 88, 88);
public static final Color RADIO_BUTTON_SELECT_COLOR = getColorSafely(0, 138, 238);
- public static final Color RADIO_BUTTON_DIMMED_FONT_COLOR = getColorSafely(153, 153, 153);
+ public static final Color RADIO_BUTTON_DISABLE_FONT_COLOR = getColorSafely(153, 153, 153);
+ public static final Color RADIO_BUTTON_FOCUSED_FONT_COLOR = getColorSafely(0, 138, 238);
/* Push Button Color */
- public static final Color PUSH_BUTTON_NORMAL_FONT_COLOR = getColorSafely(70, 70, 70);
- public static final Color PUSH_BUTTON_PUSH_COLOR = getColorSafely(255, 255, 255);
- public static final Color PUSH_BUTTON_HOVER_COLOR = getColorSafely(0, 138, 238);
- public static final Color PUSH_BUTTON_DISABLE_FONT_COLOR = getColorSafely(153, 153, 153);
- public static final Color PUSH_BUTTON_FOCUS_FONT_COLOR = getColorSafely(0, 138, 238);
-
- public static final Color PUSH_BUTTON_NORMAL_BG_COLOR = getColorSafely(240, 240, 240);
- public static final Color PUSH_BUTTON_SELECT_BG_COLOR = getColorSafely(0, 138, 238);
- public static final Color PUSH_BUTTON_HOVER_BG_COLOR = getColorSafely(240, 240, 240);
- public static final Color PUSH_BUTTON_DISABLE_BG_COLOR = getColorSafely(206, 206, 206);
- public static final Color PUSH_BUTTON_FOCUS_BG_COLOR = getColorSafely(240, 240, 240);
-
- public static final Color PUSH_BUTTON_OUTLINE_NORMAL_COLOR = getColorSafely(170, 170, 170);
- public static final Color PUSH_BUTTON_OUTLINE_PUSH_COLOR = getColorSafely(0, 150, 221);
- public static final Color PUSH_BUTTON_OUTLINE_HOVER_COLOR = getColorSafely(0, 150, 221);
- public static final Color PUSH_BUTTON_OUTLINE_DISABLE_COLOR = getColorSafely(115, 115, 115);
- public static final Color PUSH_BUTTON_OUTLINE_FOCUS_COLOR = getColorSafely(0, 150, 221);
+ public static final Color PUSH_BUTTON_NORMAL_FONT_COLOR = getColorSafely(51, 51, 51);
+ public static final Color PUSH_BUTTON_FOCUSED_FONT_COLOR = getColorSafely(0, 150, 200);
+ public static final Color PUSH_BUTTON_HOVER_FONT_COLOR = getColorSafely(51, 51, 51);
+ public static final Color PUSH_BUTTON_PRESSED_FONT_COLOR = getColorSafely(255, 255, 255);
+ public static final Color PUSH_BUTTON_DIMMED_FONT_COLOR = getColorSafely(153, 153, 153);
+
+ public static final Color PUSH_BUTTON_NORMAL_BG_COLOR = getColorSafely(225, 225, 225);
+ public static final Color PUSH_BUTTON_FOCUSED_BG_COLOR = getColorSafely(225, 225, 225);
+ public static final Color PUSH_BUTTON_HOVER_BG_COLOR = getColorSafely(205, 233, 255);
+ public static final Color PUSH_BUTTON_PRESSED_BG_COLOR = getColorSafely(0, 138, 238);
+ public static final Color PUSH_BUTTON_DIMMED_BG_COLOR = getColorSafely(204, 204, 204);
+
+ public static final Color PUSH_BUTTON_OUTLINE_NORMAL_COLOR = getColorSafely(177, 177, 177);
+ public static final Color PUSH_BUTTON_OUTLINE_FOCUSED_COLOR = getColorSafely(0, 138, 238);
+ public static final Color PUSH_BUTTON_OUTLINE_HOVER_COLOR = getColorSafely(0, 138, 238);
+ public static final Color PUSH_BUTTON_OUTLINE_PRESSED_COLOR = getColorSafely(0, 138, 238);
+ public static final Color PUSH_BUTTON_OUTLINE_DIMMED_COLOR = getColorSafely(191, 191, 191);
+
public static final Color PUSH_BUTTON_DEFAULT_BUTTON_FOCUS_COLOR = getColorSafely(0, 150, 200);
/* Arrow Button Color */
final static ClassLoader loader = TizenResourceManager.class.getClassLoader();
/* CheckBox Button Image */
- public Image checkBoxSelected = getImageSafely("images/pro_checkbox_sel.png");//$NON-NLS-1$
- public Image checkBoxSelectedHover = getImageSafely("images/pro_checkbox_sel.png");//$NON-NLS-1$
- public Image checkBoxUnelectedHover = getImageSafely("images/pro_checkbox_bg.png");//$NON-NLS-1$
- public Image checkBoxUnselected = getImageSafely("images/pro_checkbox_bg.png");//$NON-NLS-1$
- public Image checkBoxUnselectedDisable = getImageSafely("images/pro_checkbox_bg.png");//$NON-NLS-1$
- public Image checkBoxSelectedDisable = getImageSafely("images/pro_checkbox_sel.png");//$NON-NLS-1$
+ public Image checkBoxSelected = getImageSafely("images/check_sel.png");//$NON-NLS-1$
+ public Image checkBoxSelectedHover = getImageSafely("images/check_sel_hover.png");//$NON-NLS-1$
+ public Image checkBoxSelectedDisable = getImageSafely("images/check_sel_disable.png");//$NON-NLS-1$
+ public Image checkBoxSelectedFocused = getImageSafely("images/check_sel_focused.png");//$NON-NLS-1$
+ public Image checkBoxNormal = getImageSafely("images/check_nor.png");//$NON-NLS-1$
+ public Image checkBoxNormalHover = getImageSafely("images/check_nor_hover.png");//$NON-NLS-1$
+ public Image checkBoxNormalDisable = getImageSafely("images/check_nor_disable.png");//$NON-NLS-1$
+ public Image checkBoxNormalFocused = getImageSafely("images/check_nor_focused.png");//$NON-NLS-1$
+ public Image checkBoxGrayed = getImageSafely("images/check_gray.png");//$NON-NLS-1$
+ public Image checkBoxGrayedHover = getImageSafely("images/check_gray_hover.png");//$NON-NLS-1$
+ public Image checkBoxGrayedDisable = getImageSafely("images/check_gray_disable.png");//$NON-NLS-1$
+ public Image checkBoxGrayedFocused = getImageSafely("images/check_gray_focused.png");//$NON-NLS-1$
/* Radio Button Image */
- public Image radioSelected = getImageSafely("images/pro_button_icon_sel.png");//$NON-NLS-1$
- public Image radioSelectedHover = getImageSafely("images/pro_button_icon_sel.png");//$NON-NLS-1$
- public Image radioUnelectedHover = getImageSafely("images/pro_button_icon_bg.png");//$NON-NLS-1$
- public Image radioUnselected = getImageSafely("images/pro_button_icon_bg.png");//$NON-NLS-1$
- public Image radioUnselectedDisable = getImageSafely("images/pro_button_icon_bg.png");//$NON-NLS-1$
- public Image radioSelectedDisable = getImageSafely("images/pro_button_icon_sel.png");//$NON-NLS-1$
+ public Image radioSelected = getImageSafely("images/radio_sel.png");//$NON-NLS-1$
+ public Image radioSelectedHover = getImageSafely("images/radio_sel_hover.png");//$NON-NLS-1$
+ public Image radioSelectedDisable = getImageSafely("images/radio_sel_disable.png");//$NON-NLS-1$
+ public Image radioSelectedFocused = getImageSafely("images/radio_sel_focused.png");//$NON-NLS-1$
+ public Image radioNormalHover = getImageSafely("images/radio_nor_hover.png");//$NON-NLS-1$
+ public Image radioNormal = getImageSafely("images/radio_nor.png");//$NON-NLS-1$
+ public Image radioNormalDisable = getImageSafely("images/radio_nor_disable.png");//$NON-NLS-1$
+ public Image radioNormalFocused = getImageSafely("images/radio_nor_focused.png");//$NON-NLS-1$
public static TizenResourceManager getInstance() {
if (null == instance) {