package org.tizen.emulator.manager.ui.renewal.widgets;
-import java.util.ArrayList;
-import java.util.List;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
private boolean showImage = true;
protected WSTATE state = WSTATE.NORMAL;
+
// index of list is WSTATE
- protected List<Image> images = null;
- protected List<Color> colors = null;
- protected List<Color> fontColors = null;
- protected List<Font> fonts = null;
+ protected final Image[] images;
+ protected final Color[] colors;
+ protected final Color[] fontColors;
+ protected final Font[] fonts;
WStateImageMap imageMap = new WStateImageMap();
}
this.style = style;
+ int numberOfState = WSTATE.values().length;
+ images = new Image[numberOfState];
+ colors = new Color[numberOfState];
+ fontColors = new Color[numberOfState];
+ fonts = new Font[numberOfState];
+
initButton();
addListeners();
}
protected void initButton() {
- images = new ArrayList<Image>();
- colors = new ArrayList<Color>();
- fontColors = new ArrayList<Color>();
- fonts = new ArrayList<Font>();
for (WSTATE s : WSTATE.values()) {
- colors.add(s.getId(), null);
- fontColors.add(s.getId(), Colors.get(ColorKind.GRAY_BTN_FONT));
- fonts.add(s.getId(), Fonts.get(FontKind.GRAY_BUTTON_FONT));
- images.add(s.getId(), null);
+ images[s.getId()] = null;
+ colors[s.getId()] = null;
+ fontColors[s.getId()] = Colors.get(ColorKind.GRAY_BTN_FONT);
+ fonts[s.getId()] = Fonts.get(FontKind.GRAY_BUTTON_FONT);
}
// fontColors.set(WSTATE.DISABLE_ON.getId(),
@Override
public void setFont(Font font) {
for (WSTATE s : WSTATE.values()) {
- fonts.set(s.getId(), font);
+ fonts[s.getId()] = font;
}
}
public void setFont(WSTATE state, Font font) {
- fonts.set(state.getId(), font);
+ fonts[state.getId()] = font;
}
public void setFontColor(Color color) {
for (WSTATE s : WSTATE.values()) {
- fontColors.set(s.getId(), color);
+ fontColors[s.getId()] = color;
}
}
public void setFontColor(WSTATE state, Color color) {
- fontColors.set(state.getId(), color);
+ fontColors[state.getId()] = color;
}
public void setImage(WSTATE state, Image image) {
- images.set(state.getId(), image);
+ images[state.getId()] = image;
}
public void setImage(WSTATE state, ImageKind imageResource) {
@Override
public void setBackground(Color color) {
for (WSTATE s : WSTATE.values()) {
- colors.set(s.getId(), color);
+ colors[s.getId()] = color;
}
}
public void setBackgroundColor(WSTATE state, Color color) {
- colors.set(state.getId(), color);
+ colors[state.getId()] = color;
}
public void setText(String text) {
}
public Image getImage() {
- return images.get(WSTATE.NORMAL.getId());
+ return images[WSTATE.NORMAL.getId()];
}
public Image getImage(WSTATE state) {
- return images.get(state.getId());
+ return images[state.getId()];
}
public Color getBackgroundColor(WSTATE state) {
- return colors.get(state.getId());
+ return colors[state.getId()];
}
public Color getFontColor(WSTATE state) {
- return fontColors.get(state.getId());
+ return fontColors[state.getId()];
}
protected Image normalImage = null;
}
public void setImages(Image normal, Image hover, Image pushed, Image disable) {
- images.set(WSTATE.NORMAL.getId(), normal);
- images.set(WSTATE.HOVER.getId(), hover);
- images.set(WSTATE.PUSH.getId(), pushed);
- images.set(WSTATE.DISABLE_ON.getId(), disable);
+ images[WSTATE.NORMAL.getId()] = normal;
+ images[WSTATE.HOVER.getId()] = hover;
+ images[WSTATE.PUSH.getId()] = pushed;
+ images[WSTATE.DISABLE_ON.getId()] = disable;
if (checkStyle(style, SWT.PUSH)) {
defaultPush = false;
public void setImages(Image normal, Image hover, Image pushed,
Image selected, Image selected_hover, Image selected_push, Image disable) {
- images.set(WSTATE.NORMAL.getId(), normal);
- images.set(WSTATE.HOVER.getId(), hover);
- images.set(WSTATE.PUSH.getId(), pushed);
- images.set(WSTATE.SELECTED.getId(), selected);
- images.set(WSTATE.SELECTED_HOVER.getId(), selected_hover);
- images.set(WSTATE.SELECTED_PUSH.getId(), selected_push);
- images.set(WSTATE.DISABLE_ON.getId(), disable);
+ images[WSTATE.NORMAL.getId()] = normal;
+ images[WSTATE.HOVER.getId()] = hover;
+ images[WSTATE.PUSH.getId()] = pushed;
+ images[WSTATE.SELECTED.getId()] = selected;
+ images[WSTATE.SELECTED_HOVER.getId()] = selected_hover;
+ images[WSTATE.SELECTED_PUSH.getId()] = selected_push;
+ images[WSTATE.DISABLE_ON.getId()] = disable;
if (checkStyle(style, SWT.PUSH)) {
defaultPush = false;
public void setImages(Image normal, Image hover, Image pushed,
Image selected, Image selected_hover, Image selected_push, Image disable_on, Image disable_off) {
- images.set(WSTATE.NORMAL.getId(), normal);
- images.set(WSTATE.HOVER.getId(), hover);
- images.set(WSTATE.PUSH.getId(), pushed);
- images.set(WSTATE.SELECTED.getId(), selected);
- images.set(WSTATE.SELECTED_HOVER.getId(), selected_hover);
- images.set(WSTATE.SELECTED_PUSH.getId(), selected_push);
- images.set(WSTATE.DISABLE_ON.getId(), disable_on);
- images.set(WSTATE.DISABLE_OFF.getId(), disable_off);
+ images[WSTATE.NORMAL.getId()] = normal;
+ images[WSTATE.HOVER.getId()] = hover;
+ images[WSTATE.PUSH.getId()] = pushed;
+ images[WSTATE.SELECTED.getId()] = selected;
+ images[WSTATE.SELECTED_HOVER.getId()] = selected_hover;
+ images[WSTATE.SELECTED_PUSH.getId()] = selected_push;
+ images[WSTATE.DISABLE_ON.getId()] = disable_on;
+ images[WSTATE.DISABLE_OFF.getId()] = disable_off;
if (checkStyle(style, SWT.PUSH)) {
defaultPush = false;
}
public void setForeground(Color normal, Color hover, Color pushed, Color disable) {
- fontColors.set(WSTATE.NORMAL.getId(), normal);
- fontColors.set(WSTATE.HOVER.getId(), hover);
- fontColors.set(WSTATE.PUSH.getId(), pushed);
- fontColors.set(WSTATE.DISABLE_ON.getId(), disable);
+ fontColors[WSTATE.NORMAL.getId()] = normal;
+ fontColors[WSTATE.HOVER.getId()] = hover;
+ fontColors[WSTATE.PUSH.getId()] = pushed;
+ fontColors[WSTATE.DISABLE_ON.getId()] = disable;
redraw();
}
public void setForeground(Color normal, Color hover, Color pushed,
Color selected, Color selected_hover, Color selected_push, Color disable) {
- fontColors.set(WSTATE.NORMAL.getId(), normal);
- fontColors.set(WSTATE.HOVER.getId(), hover);
- fontColors.set(WSTATE.PUSH.getId(), pushed);
- fontColors.set(WSTATE.SELECTED.getId(), selected);
- fontColors.set(WSTATE.SELECTED_HOVER.getId(), selected_hover);
- fontColors.set(WSTATE.SELECTED_PUSH.getId(), selected_push);
- fontColors.set(WSTATE.DISABLE_ON.getId(), disable);
+ fontColors[WSTATE.NORMAL.getId()] = normal;
+ fontColors[WSTATE.HOVER.getId()] = hover;
+ fontColors[WSTATE.PUSH.getId()] = pushed;
+ fontColors[WSTATE.SELECTED.getId()] = selected;
+ fontColors[WSTATE.SELECTED_HOVER.getId()] = selected_hover;
+ fontColors[WSTATE.SELECTED_PUSH.getId()] = selected_push;
+ fontColors[WSTATE.DISABLE_ON.getId()] = disable;
redraw();
}
public Point computeSize(int wHint, int hHint, boolean changed) {
int width = 0, height = 0;
- if (images.get(WSTATE.NORMAL.getId()) != null) {
- Rectangle bounds = images.get(WSTATE.NORMAL.getId()).getBounds();
+ if (images[WSTATE.NORMAL.getId()] != null) {
+ Rectangle bounds = images[WSTATE.NORMAL.getId()].getBounds();
height = bounds.height;
width = bounds.width;
if (checkStyle(style, SWT.RADIO)) {
int i = 0;
for (WSTATE s : WSTATE.values()) {
i = s.getId();
- WidgetHelper.tryDispose(images.get(i), colors.get(i), fontColors.get(i), fonts.get(i));
+ WidgetHelper.tryDispose(images[i], colors[i], fontColors[i], fonts[i]);
}
WidgetHelper.tryDispose(normalImage, hoverImage, pushImage, disableImage);
}
}
Rectangle rect = ((Canvas) e.widget).getClientArea();
- Image img = images.get(state.getId());
+ Image img = images[state.getId()];
if (img == null) {
img = imageMap.get(state);
}
- if (colors.get(state.getId()) != null) {
- e.gc.setBackground(colors.get(state.getId()));
+ if (colors[state.getId()] != null) {
+ e.gc.setBackground(colors[state.getId()]);
e.gc.fillRectangle(rect);
}
int fontHeight = e.gc.getFontMetrics().getHeight();
y = rect.y + (rect.height - fontHeight) / 2;
- if (fontColors.get(state.getId()) != null) {
- e.gc.setForeground(fontColors.get(state.getId()));
+ if (fontColors[state.getId()] != null) {
+ e.gc.setForeground(fontColors[state.getId()]);
}
- if (fonts.get(state.getId()) != null) {
- e.gc.setFont(fonts.get(state.getId()));
+ if (fonts[state.getId()] != null) {
+ e.gc.setFont(fonts[state.getId()]);
}
if (text != null) {