- Gray button widget is Added.
Change-Id: Iaec5498898ce2163941b106c439315ff94102774
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.emulator.manager.renewal.resources;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+public enum ColorResources {
+ // nine patch button
+ GRAY_BTN_NORMAL(149, 159, 164),
+ GRAY_BTN_HOVER(149, 159, 164),
+ GRAY_BTN_PUSH(100, 110, 144),
+ GRAY_BTN_DISABLE(208, 208, 208),
+
+ GRAY_BTN_FONT(255, 255, 255);
+
+ Color color;
+ int r,g,b;
+
+ ColorResources(int r, int g, int b) {
+ this.r = r;
+ this.g = g;
+ this.b = b;
+ }
+
+ public Color getColor() {
+ if (this.color == null) {
+ this.color = createColor(new RGB(r,g,b));
+ }
+ return color;
+ }
+
+ public Color getColorObject() {
+ return color;
+ }
+
+ private Color createColor(RGB rgb) {
+ Display display = Display.getCurrent();
+ if (display == null) {
+ throw new IllegalStateException();
+ }
+ return new Color(display, rgb);
+ }
+}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.renewal.resources;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.widgets.Display;
+import org.tizen.emulator.manager.EmulatorManager;
+
+public enum FontResources {
+ GRAY_BTN_FONT("btn_font", resizeDefaultFont(10)),
+
+ // * Toolbal Layout
+ // Main Title
+ TITLEBAR("titlebar", resizeDefaultFont(10)), //$NON-NLS-1$
+ // Device Name
+ COMBO("combo", resizeDefaultFont(9)), //$NON-NLS-1$
+ // Application Name
+ DROPDOWN("dropdown", resizeDefaultFont(9)), //$NON-NLS-1$
+ // Timer
+ TIMER("timer", resizeDefaultFont(12)), //$NON-NLS-1$
+
+ // * Tab Layout
+ TAB_BUTTON_FONT("tab_button_font", setDefaultFontStyleAndSize(SWT.BOLD, 9)), //$NON-NLS-1$
+
+ // * List Layout
+ VM_BUTTON_TITLE_FONT("vm_button_title_font", setDefaultFontStyleAndSize(SWT.BOLD, 8)), //$NON-NLS-1$
+ VM_BUTTON_FONT("vm_button_font", resizeDefaultFont(8)), //$NON-NLS-1$
+
+ // * Detail Layout
+ DETAIL_TOP_FONT("detail_top_font", setDefaultFontStyleAndSize(SWT.BOLD, 10)), //$NON-NLS-1$
+ DETAIL_TITLE_FONT("detail_title_font", resizeDefaultFont(9)), //$NON-NLS-1$
+ DETAIL_TITLE_FONT_BOLD("detail_title_font", setDefaultFontStyleAndSize(SWT.BOLD, 9)), //$NON-NLS-1$
+ DETAIL_LABEL_FONT("datail_label_font", resizeDefaultFont(8)), //$NON-NLS-1$
+
+ // * Nomal button
+ BUTTON_FONT("button_font", resizeDefaultFont(9)), //$NON-NLS-1$
+
+ // * Combo button
+ COMBO_BUTTON_FONT("combo_button_font", resizeDefaultFont(8)), //$NON-NLS-1$
+
+ // * About Dlg.
+ ABOUT_TITLE("about_title", resizeDefaultFont(12)), //$NON-NLS-1$
+ ABOUT_TEXT("about_text", resizeDefaultFont(9)), //$NON-NLS-1$
+ DIALOG_BUTTON_FONT("dialog_button_font", resizeDefaultFont(10)), //$NON-NLS-1$
+
+ // * Status bar
+ STATUS_BAR_FONT("status_bar_font", resizeDefaultFont(9)), //$NON-NLS-1$
+ STATUS_BAR_SUB_FONT("status_bar_sub_font", resizeDefaultFont(8)), //$NON-NLS-1$
+
+ // * Radio button
+ RADIO_BUTTON_FONT("radio_button_font", resizeDefaultFont(8)), //$NON-NLS-1$
+
+ // * Tree view
+ TREE_CREATE_FONT("tree_creaet_font", setDefaultFontStyleAndSize(SWT.BOLD, 9)), //$NON-NLS-1$
+ TREE_HEADER_FONT("tree_header_font", resizeDefaultFont(9)), //$NON-NLS-1$
+ TREE_ITEM_FONT("tree_item_font", resizeDefaultFont(8)), //$NON-NLS-1$
+
+ // * not support
+ TOOLTIP("tooltip", resizeDefaultFont(9)); //$NON-NLS-1$
+
+ String name;
+ Font font;
+ FontData[] data;
+ FontResources(String name, FontData[] data) {
+ this.name = name;
+ this.data = data;
+ }
+
+ public Font getFont() {
+ return getFont(name, data);
+ }
+
+ public Font getFont(String fontName, FontData[] fontData) {
+ if (this.font == null) {
+ this.font = new Font(Display.getCurrent(), fontData);
+ }
+ return font;
+ }
+
+ //private static FontRegistry fontRegistry = new FontRegistry();
+ private static Font defaultFont = null;
+ static {
+ defaultFont = getDADefaultFont();
+ }
+
+ public static FontData[] resizeDefaultFont(int size) {
+ if (defaultFont == null) {
+ defaultFont = getDADefaultFont();
+ }
+
+ if (EmulatorManager.isMac()) {
+ size = size + 2;
+ }
+
+ FontData[] fontData = defaultFont.getFontData();
+ for (int i = 0; i < fontData.length; i++) {
+ fontData[i].setHeight(size);
+ }
+ return fontData;
+ }
+
+ public static FontData[] setDefaultFontStyle(int style) {
+ if (defaultFont == null) {
+ defaultFont = getDADefaultFont();
+ }
+ FontData[] fontData = defaultFont.getFontData();
+ for (int i = 0; i < fontData.length; i++) {
+ fontData[i].setStyle(style);
+ }
+ return fontData;
+ }
+
+ public static FontData[] setDefaultFontStyleAndSize(int style, int size) {
+ if (defaultFont == null) {
+ defaultFont = getDADefaultFont();
+ }
+
+ if (EmulatorManager.isMac()) {
+ size = size + 2;
+ }
+
+ FontData[] fontData = defaultFont.getFontData();
+ for (int i = 0; i < fontData.length; i++) {
+ fontData[i].setStyle(style);
+ fontData[i].setHeight(size);
+ }
+ return fontData;
+ }
+
+ public static Font getDADefaultFont() {
+ if (defaultFont == null) {
+ String fontName = null;
+ if (EmulatorManager.isLinux()) {
+ fontName = "Dejavu Sans"; //$NON-NLS-1$
+ } else if (EmulatorManager.isWin()) {
+ fontName = "Verdana"; //$NON-NLS-1$
+ } else if (EmulatorManager.isMac()) {
+ fontName = "Lucida Grande"; //$NON-NLS-1$
+ } else {
+ defaultFont = Display.getCurrent().getSystemFont();
+ return defaultFont;
+ }
+ defaultFont = EmulatorManager.isMac()
+ ? new Font(Display.getCurrent(), new FontData[] { new FontData(fontName, 11, SWT.NORMAL) })
+ : new Font(Display.getCurrent(), new FontData[] { new FontData(fontName, 9, SWT.NORMAL) });
+ }
+
+ return defaultFont;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.renewal.resources;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.ImageLoader;
+import org.eclipse.swt.widgets.Display;
+import org.tizen.emulator.manager.logging.EMLogger;
+
+public enum ImageResources {
+
+ // gray 9 patch button
+ GRAY_BTN_DISABLE_B("9p_btn_disable_b"),
+ GRAY_BTN_DISABLE_L("9p_btn_disable_l"),
+ GRAY_BTN_DISABLE_LB("9p_btn_disable_lb"),
+ GRAY_BTN_DISABLE_LT("9p_btn_disable_lt"),
+ GRAY_BTN_DISABLE_R("9p_btn_disable_r"),
+ GRAY_BTN_DISABLE_RB("9p_btn_disable_rb"),
+ GRAY_BTN_DISABLE_RT("9p_btn_disable_rt"),
+ GRAY_BTN_DISABLE_T("9p_btn_disable_t"),
+ GRAY_BTN_HOVER_B("9p_btn_hover_b"),
+ GRAY_BTN_HOVER_L("9p_btn_hover_l"),
+ GRAY_BTN_HOVER_LB("9p_btn_hover_lb"),
+ GRAY_BTN_HOVER_LT("9p_btn_hover_lt"),
+ GRAY_BTN_HOVER_R("9p_btn_hover_r"),
+ GRAY_BTN_HOVER_RB("9p_btn_hover_rb"),
+ GRAY_BTN_HOVER_RT("9p_btn_hover_rt"),
+ GRAY_BTN_HOVER_T("9p_btn_hover_t"),
+ GRAY_BTN_NORMAL_B("9p_btn_normal_b"),
+ GRAY_BTN_NORMAL_L ("9p_btn_normal_l"),
+ GRAY_BTN_NORMAL_LB("9p_btn_normal_lb"),
+ GRAY_BTN_NORMAL_LT("9p_btn_normal_lt"),
+ GRAY_BTN_NORMAL_R("9p_btn_normal_r"),
+ GRAY_BTN_NORMAL_RB("9p_btn_normal_rb"),
+ GRAY_BTN_NORMAL_RT("9p_btn_normal_rt"),
+ GRAY_BTN_NORMAL_T("9p_btn_normal_t"),
+ GRAY_BTN_PUSH_B("9p_btn_push_b"),
+ GRAY_BTN_PUSH_L("9p_btn_push_l"),
+ GRAY_BTN_PUSH_LB("9p_btn_push_lb"),
+ GRAY_BTN_PUSH_LT("9p_btn_push_lt"),
+ GRAY_BTN_PUSH_R("9p_btn_push_r"),
+ GRAY_BTN_PUSH_RB("9p_btn_push_rb"),
+ GRAY_BTN_PUSH_RT("9p_btn_push_rt"),
+ GRAY_BTN_PUSH_T("9p_btn_push_t")
+
+
+// TAB_SELECTED_LEFT("tab_selected_left",ImageType.GIF), //$NON-NLS-1$
+// TAB_SELECTED_MIDDLE("tab_selected_middle"), //$NON-NLS-1$
+
+ ;
+
+ String name;
+ Image image;
+ ImageType type;
+
+ ImageResources(String name) {
+ this.name = name;
+ this.type = ImageType.PNG;
+ }
+
+ ImageResources(String name, ImageType type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public Image getImageObject() {
+ return image;
+ }
+
+ public Image getImage() {
+ if (this.image == null) {
+ switch(this.type) {
+ case GIF:
+ this.image = ImageRegistry.getGifImage(name);
+ break;
+ case PNG:
+ this.image = ImageRegistry.getPngImage(name);
+ }
+ }
+ return image;
+ }
+
+ public static Image getImage(String name, String extension) {
+ return ImageRegistry.getImage(name, extension);
+ }
+
+ // for gif animation
+ private ImageData[] frames = null;
+ public ImageData[] getImageData() {
+ if (this.frames == null) {
+ frames = ImageRegistry.getImageData(name, type.getType());
+ }
+
+ return frames;
+ }
+
+ public static ImageData[] getImageData(String name, String extension) {
+ return ImageRegistry.getImageData(name, extension);
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ public static void dispose() {
+ for (ImageResources r : ImageResources.values()) {
+ r.image = null;
+ }
+ ImageRegistry.dispose();
+ }
+}
+
+class ImageRegistry {
+ //private static final String ID = "org.tizen.dynamicanalyzer";
+ private static Map<String, Image> map = new HashMap<String, Image>();
+
+ public static void dispose() {
+ for (Image i : map.values()) {
+ i.dispose();
+ }
+ }
+
+ public static Image getImage(String name, String extension) {
+ Image i = map.get(name);
+ if (i == null) {
+ ClassLoader loader = ImageRegistry.class.getClassLoader();
+ if (loader != null) {
+ InputStream is = loader.getResourceAsStream("renewal/res/" + name + "." + extension); //$NON-NLS-1$ //$NON-NLS-2$
+ if (is != null) {
+ i = new Image(Display.getCurrent(), is);
+ map.put(name, i);
+ try {
+ is.close();
+ } catch (IOException e) {
+ EMLogger.getLogger().info(e.getMessage());
+ }
+ }
+ }
+ }
+ return i;
+ }
+
+ public static ImageData[] getImageData(String name, String extension) {
+ ClassLoader loader = ImageRegistry.class.getClassLoader();
+ ImageData[] frames = null;
+ if (loader != null) {
+ InputStream is = loader.getResourceAsStream("res/" + name + "." + extension); //$NON-NLS-1$ //$NON-NLS-2$
+ if (is != null) {
+ frames = new ImageLoader().load(is);
+ try {
+ is.close();
+ } catch (IOException e) {
+ EMLogger.getLogger().info(e.getMessage());
+ }
+ }
+ }
+ return frames;
+ }
+
+ public static Image getPngImage(String name) {
+ return getImage(name, "png"); //$NON-NLS-1$
+ }
+
+ public static Image getGifImage(String name) {
+ return getImage(name, "gif"); //$NON-NLS-1$
+ }
+}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.renewal.resources;
+
+public enum ImageType {
+ PNG("png"),GIF("gif"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ private String type;
+ ImageType(String type){
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.renewal.resources;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.tizen.emulator.manager.ui.renewal.widgets.NinePatchResourceInfo;
+
+public class PatchImageResources {
+
+ public static Image getButtonImage(int width, int height, NinePatchResourceInfo ninePatchImagesInfo) {
+ Image lt = ninePatchImagesInfo.getLeftTopImage().getImage();
+ Image t = ninePatchImagesInfo.getTopImage().getImage();
+ Image rt = ninePatchImagesInfo.getRightTopImage().getImage();
+ Image r = ninePatchImagesInfo.getRightImage().getImage();
+ Image rb = ninePatchImagesInfo.getRightBottomImage().getImage();
+ Image b = ninePatchImagesInfo.getBottomImage().getImage();
+ Image lb = ninePatchImagesInfo.getLeftBottomImage().getImage();
+ Image l = ninePatchImagesInfo.getLeftImage().getImage();
+
+ Image image = new Image(Display.getCurrent(), width, height);
+
+ GC gc = new GC(image);
+ gc.setInterpolation(SWT.NONE);
+ gc.setBackground(ninePatchImagesInfo.getBackground().getColor());
+ gc.fillRectangle(l.getImageData().width, t.getImageData().height,
+ width - l.getImageData().width - r.getImageData().width,
+ height - t.getImageData().height - b.getImageData().height);
+
+ // draw top
+ gc.drawImage(lt, 0, 0);
+ gc.drawImage(t, 0, 0, t.getImageData().width, t.getImageData().height,
+ lt.getImageData().width,
+ 0,
+ width - lt.getImageData().width - rt.getImageData().width,
+ rt.getImageData().height);
+ gc.drawImage(rt, width - rt.getImageData().width, 0);
+
+ // draw middle
+ gc.drawImage(l, 0, 0, l.getImageData().width, l.getImageData().height,
+ 0,
+ lt.getImageData().height,
+ l.getImageData().width,
+ height - lt.getImageData().height - lb.getImageData().height);
+ gc.drawImage(r, 0, 0, r.getImageData().width, r.getImageData().height,
+ width - r.getImageData().width,
+ rt.getImageData().height,
+ r.getImageData().width,
+ height - rt.getImageData().height - rb.getImageData().height);
+
+ // draw bottom
+ gc.drawImage(lb, 0, height - lb.getImageData().height);
+ gc.drawImage(b, 0, 0, b.getImageData().width, b.getImageData().height,
+ lb.getImageData().width,
+ height - b.getImageData().height,
+ width - lb.getImageData().width - rb.getImageData().width,
+ b.getImageData().height);
+ gc.drawImage(rb, width - rb.getImageData().width, height - rb.getImageData().height);
+ gc.dispose();
+ return image;
+ }
+
+}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.ui.renewal.widgets;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+
+public class ButtonResourceInfo {
+
+ private final Map<WSTATE, NinePatchResourceInfo> map
+ = new HashMap<WSTATE, NinePatchResourceInfo>();
+
+ private final WSTATE disableState = WSTATE.DISABLE_ON;
+
+ public void setNormalImage(ColorResources background,
+ ImageResources lt, ImageResources t,
+ ImageResources rt, ImageResources r,
+ ImageResources rb, ImageResources b,
+ ImageResources lb, ImageResources l) {
+ setImages(WSTATE.NORMAL, background, lt, t, rt, r, rb, b, lb, l);
+ }
+
+ public void setHoverImage(ColorResources background,
+ ImageResources lt, ImageResources t,
+ ImageResources rt, ImageResources r,
+ ImageResources rb, ImageResources b,
+ ImageResources lb, ImageResources l) {
+ setImages(WSTATE.HOVER, background, lt, t, rt, r, rb, b, lb, l);
+ }
+
+ public void setPushImage(ColorResources background,
+ ImageResources lt, ImageResources t,
+ ImageResources rt, ImageResources r,
+ ImageResources rb, ImageResources b,
+ ImageResources lb, ImageResources l) {
+ setImages(WSTATE.PUSH, background, lt, t, rt, r, rb, b, lb, l);
+ }
+
+ public void setDisableImage(ColorResources background,
+ ImageResources lt, ImageResources t,
+ ImageResources rt, ImageResources r,
+ ImageResources rb, ImageResources b,
+ ImageResources lb, ImageResources l) {
+ setImages(disableState, background, lt, t, rt, r, rb, b, lb, l);
+ }
+
+ private void setImages(WSTATE wState, ColorResources background,
+ ImageResources lt, ImageResources t,
+ ImageResources rt, ImageResources r,
+ ImageResources rb, ImageResources b,
+ ImageResources lb, ImageResources l) {
+ map.put(wState, new NinePatchResourceInfo(background, lt, t, rt, r, rb, b, lb, l));
+
+ }
+
+ public NinePatchResourceInfo getNormalImages() {
+ return map.get(WSTATE.NORMAL);
+ }
+
+ public NinePatchResourceInfo getHoverImages() {
+ return map.get(WSTATE.HOVER);
+ }
+
+ public NinePatchResourceInfo getPushImages() {
+ return map.get(WSTATE.PUSH);
+ }
+
+ public NinePatchResourceInfo getDisableImages() {
+ return map.get(disableState);
+ }
+
+ public void dispose() {
+ for (WSTATE key : map.keySet()) {
+ NinePatchResourceInfo resource = map.get(key);
+ resource.dispose();
+ }
+ }
+}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.ui.renewal.widgets;
+
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.renewal.resources.FontResources;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+
+public class GrayButton extends NinePatchButton {
+
+ static ButtonResourceInfo buttonResourceInfo;
+ static {
+ initButtonResourceInfo();
+ }
+
+ public GrayButton(Composite parent, int style) {
+ super(parent, style);
+ initFont();
+ }
+
+ protected void initFont() {
+ setButtonFont(FontResources.GRAY_BTN_FONT.getFont());
+ setButtonFontColor(ColorResources.GRAY_BTN_FONT.getColor());
+ }
+
+ private static void initButtonResourceInfo() {
+ buttonResourceInfo = new ButtonResourceInfo();
+ buttonResourceInfo.setNormalImage(ColorResources.GRAY_BTN_NORMAL,
+ ImageResources.GRAY_BTN_NORMAL_LT,
+ ImageResources.GRAY_BTN_NORMAL_T,
+ ImageResources.GRAY_BTN_NORMAL_RT,
+ ImageResources.GRAY_BTN_NORMAL_R,
+ ImageResources.GRAY_BTN_NORMAL_RB,
+ ImageResources.GRAY_BTN_NORMAL_B,
+ ImageResources.GRAY_BTN_NORMAL_LB,
+ ImageResources.GRAY_BTN_NORMAL_L);
+
+ buttonResourceInfo.setHoverImage(ColorResources.GRAY_BTN_HOVER,
+ ImageResources.GRAY_BTN_HOVER_LT,
+ ImageResources.GRAY_BTN_HOVER_T,
+ ImageResources.GRAY_BTN_HOVER_RT,
+ ImageResources.GRAY_BTN_HOVER_R,
+ ImageResources.GRAY_BTN_HOVER_RB,
+ ImageResources.GRAY_BTN_HOVER_B,
+ ImageResources.GRAY_BTN_HOVER_LB,
+ ImageResources.GRAY_BTN_HOVER_L);
+
+ buttonResourceInfo.setPushImage(ColorResources.GRAY_BTN_PUSH,
+ ImageResources.GRAY_BTN_PUSH_LT,
+ ImageResources.GRAY_BTN_PUSH_T,
+ ImageResources.GRAY_BTN_PUSH_RT,
+ ImageResources.GRAY_BTN_PUSH_R,
+ ImageResources.GRAY_BTN_PUSH_RB,
+ ImageResources.GRAY_BTN_PUSH_B,
+ ImageResources.GRAY_BTN_PUSH_LB,
+ ImageResources.GRAY_BTN_PUSH_L);
+
+ buttonResourceInfo.setDisableImage(ColorResources.GRAY_BTN_DISABLE,
+ ImageResources.GRAY_BTN_DISABLE_LT,
+ ImageResources.GRAY_BTN_DISABLE_T,
+ ImageResources.GRAY_BTN_DISABLE_RT,
+ ImageResources.GRAY_BTN_DISABLE_R,
+ ImageResources.GRAY_BTN_DISABLE_RB,
+ ImageResources.GRAY_BTN_DISABLE_B,
+ ImageResources.GRAY_BTN_DISABLE_LB,
+ ImageResources.GRAY_BTN_DISABLE_L);
+ }
+
+ @Override
+ public ButtonResourceInfo getButtonResourceInfo() {
+ return buttonResourceInfo;
+ }
+
+}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye1128.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.ui.renewal.widgets;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.TypedListener;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.renewal.resources.FontResources;
+
+public class ImageButton extends Canvas {
+ private final Composite parent;
+ private int style = 0;
+
+ protected WSTATE state = WSTATE.NORMAL;
+ // index of list is WSTATE
+ protected ArrayList<Image> images = null;
+ protected ArrayList<Color> colors = null;
+ protected ArrayList<Color> fontColors = null;
+ protected ArrayList<Font> fonts = null;
+
+ private String text = ""; //$NON-NLS-1$
+ protected boolean selected = false;
+ private boolean defaultPush = true;
+
+ private final int RADIO_IMAGE_SIZE = 16;
+ public ImageButton(Composite parent, int style) {
+ super(parent, SWT.DOUBLE_BUFFERED | style);
+ this.parent = parent;
+ if (style == SWT.NONE) {
+ style = SWT.PUSH;
+ }
+ this.style = style;
+
+ 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(), ColorResources.GRAY_BTN_NORMAL.getColor());
+ fontColors.add(s.getId(), ColorResources.GRAY_BTN_FONT.getColor());
+ fonts.add(s.getId(), FontResources.BUTTON_FONT.getFont());
+ images.add(s.getId(), null);
+ }
+
+// fontColors.set(WSTATE.DISABLE_ON.getId(),
+// ColorResources.BUTTON_DISABLE_FONT_COLOR.getColor());
+
+// if (checkStyle(style, SWT.RADIO)) {
+// this.setImages(ImageResources.RADIO_OFF.getImage(),
+// ImageResources.RADIO_OFF.getImage(),
+// ImageResources.RADIO_OFF.getImage(),
+// ImageResources.RADIO_ON.getImage(),
+// ImageResources.RADIO_ON.getImage(),
+// ImageResources.RADIO_ON.getImage(),
+// ImageResources.RADIO_OFF.getImage());
+// }
+ }
+
+ private void addListeners() {
+ addPaintListener(paintListener);
+ addListener(SWT.MouseDown, mouseListener);
+ addListener(SWT.MouseUp, mouseListener);
+ addListener(SWT.MouseEnter, mouseListener);
+ addListener(SWT.MouseExit, mouseListener);
+ addDisposeListener(disposeListener);
+ }
+
+ public void setPainListener(PaintListener listener) {
+ removePaintListener(paintListener);
+ this.paintListener = listener;
+ addPaintListener(paintListener);
+ }
+
+ private boolean checkStyle(int style, int bit) {
+ if ((style & bit) == 0) {
+ return false;
+ }
+ return true;
+ }
+
+ public void setFont(WSTATE state, Font font) {
+ fonts.set(state.getId(), font);
+ }
+
+ public void setFontColor(WSTATE state, Color color) {
+ fontColors.set(state.getId(), color);
+ }
+
+ public void setImage(WSTATE state, Image image) {
+ images.set(state.getId(), image);
+ }
+
+ @Override
+ public void setBackground(Color color) {
+ for (WSTATE s : WSTATE.values()) {
+ colors.set(s.getId(), color);
+ }
+ }
+
+ public void setBackgroundColor(WSTATE state, Color color) {
+ colors.set(state.getId(), color);
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ this.redraw();
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public Image getImage() {
+ return images.get(WSTATE.NORMAL.getId());
+ }
+
+ public Image getImage(WSTATE state) {
+ return images.get(state.getId());
+ }
+
+ public Color getBackgroundColor(WSTATE state) {
+ return colors.get(state.getId());
+ }
+
+ public Color getFontColor(WSTATE state) {
+ return fontColors.get(state.getId());
+ }
+
+ protected Image nomalImage = null;
+ protected Image hoverImage = null;
+ protected Image pushImage = null;;
+ protected Image disableImage = null;
+ public void drawPushImage(GC gc, WSTATE state, int width, int height) {
+ Image image = null;
+ switch(state) {
+ case HOVER:
+ if (hoverImage == null) {
+// hoverImage = PatchImageResources.getHoverButton(width);
+ }
+ image = hoverImage;
+ break;
+ case PUSH:
+ if (pushImage == null) {
+// pushImage = PatchImageResources.getPushedButton(width);
+ }
+ image = pushImage;
+ break;
+ default:
+ if (nomalImage == null) {
+// nomalImage = PatchImageResources.getNomalButton(width);
+ }
+ image = nomalImage;
+ break;
+ }
+
+ Rectangle rect = image.getBounds();
+ gc.drawImage(image, rect.x, rect.y);
+ }
+
+ 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);
+
+ if (checkStyle(style, SWT.PUSH)) {
+ defaultPush = false;
+ }
+ redraw();
+ }
+
+ 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);
+
+ if (checkStyle(style, SWT.PUSH)) {
+ defaultPush = false;
+ }
+ redraw();
+ }
+
+ 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);
+
+ if (checkStyle(style, SWT.PUSH)) {
+ defaultPush = false;
+ }
+ redraw();
+ }
+
+ 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);
+
+ 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);
+
+ redraw();
+ }
+
+ @Override
+ public Point computeSize(int wHint, int hHint, boolean changed) {
+ int width = 0, height = 0;
+
+ if (checkStyle(style, SWT.RADIO)
+ && images.get(WSTATE.NORMAL.getId()) != null) {
+ Rectangle bounds = images.get(WSTATE.NORMAL.getId()).getBounds();
+ width = bounds.width + 14;
+ height = bounds.height;
+ }
+
+ if (text != null) {
+ GC gc = new GC(this);
+ Point extent = gc.stringExtent(text);
+ gc.dispose();
+ width += extent.x;
+ height = Math.max(height, extent.y);
+ }
+
+ if (wHint != SWT.DEFAULT)
+ width = wHint;
+
+ if (hHint != SWT.DEFAULT)
+ height = hHint;
+
+ if (checkStyle(style, SWT.PUSH) && defaultPush) {
+ if (width < 13) {
+ width = 13;
+ }
+ if (height < 22) {
+ height = 22;
+ }
+ }
+
+ return new Point(width, height);
+ }
+
+ public void disposeWidget() {
+
+ }
+
+ private final DisposeListener disposeListener = new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent arg0) {
+ 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(nomalImage, hoverImage, pushImage, disableImage);
+ disposeWidget();
+ }
+ };
+
+ private PaintListener paintListener = new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ Rectangle rect = ((Canvas) e.widget).getClientArea();
+ Image img = images.get(state.getId());
+
+ if (colors.get(state.getId()) != null) {
+ e.gc.setBackground(colors.get(state.getId()));
+ e.gc.fillRectangle(rect);
+ }
+
+ int x = rect.x;
+ int y = rect.y;
+
+ if (checkStyle(style, SWT.RADIO)) {
+ y = rect.y + (rect.height - RADIO_IMAGE_SIZE) / 2;
+
+ } else if (defaultPush && checkStyle(style, SWT.PUSH)) {
+ drawPushImage(e.gc, state, rect.width, rect.height);
+ defaultPush = true;
+
+ } else if (img == null) {
+ return;
+ }
+
+ if (null != img) {
+ e.gc.drawImage(img, x, y);
+ }
+
+ if (checkStyle(style, SWT.RADIO)) {
+ x += RADIO_IMAGE_SIZE + 6;
+ } else {
+ Point extent = e.gc.stringExtent(text);
+ x += rect.x + ((rect.width - extent.x) / 2);
+ }
+
+ int fontHeight = e.gc.getFontMetrics().getHeight();
+ y = rect.y + (rect.height - fontHeight) / 2 - 1;
+
+ if (fontColors.get(state.getId()) != null) {
+ e.gc.setForeground(fontColors.get(state.getId()));
+ }
+
+ if (text != null) {
+ e.gc.drawText(text, x, y, true);
+ }
+ }
+ };
+
+ public void addSelectionListener(SelectionListener listener) {
+ addListener(SWT.Selection, new TypedListener(listener));
+ addListener(SWT.DefaultSelection, new TypedListener(listener));
+ }
+
+ public void removeSelectionListener(SelectionListener listener) {
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection, listener);
+ }
+
+ protected Listener mouseListener = new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ if (state == WSTATE.DISABLE_ON) {
+ return;
+ }
+
+ ImageButton button = (ImageButton) event.widget;
+ if (event.type == SWT.MouseDown) {
+ button.setFocus();
+ if (state != WSTATE.PUSH) {
+ if (state == WSTATE.SELECTED
+ || state == WSTATE.SELECTED_HOVER ) {
+ state = WSTATE.SELECTED_PUSH;
+ } else {
+ state = WSTATE.PUSH;
+ }
+ }
+ redraw();
+ } else if (event.type == SWT.MouseUp) {
+ Rectangle rect = button.getClientArea();
+ if (rect.contains(event.x, event.y)) {
+ if (checkStyle(style, SWT.RADIO)) {
+ selectRadio();
+ } else if (checkStyle(style, SWT.PUSH)) {
+ if (state == WSTATE.PUSH) {
+ state = WSTATE.HOVER;
+ } else if (state == WSTATE.SELECTED_PUSH) {
+ state = WSTATE.SELECTED_HOVER;
+ }
+ redraw();
+ } else if (checkStyle(style, SWT.TOGGLE)) {
+ if (isSelection()) {
+ setSelection(false);
+ state = WSTATE.HOVER;
+ } else {
+ setSelection(true);
+ state = WSTATE.SELECTED_HOVER;
+ }
+ redraw();
+ }
+ notifyListeners(SWT.Selection, new Event());
+ //notifyListeners(SWT.DefaultSelection, new Event());
+ }
+ } else if (event.type == SWT.MouseEnter) {
+ if ((state != WSTATE.HOVER) && (state != WSTATE.SELECTED_HOVER)) {
+ if (selected) {
+ state = WSTATE.SELECTED_HOVER;
+ } else {
+ state = WSTATE.HOVER;
+ }
+ redraw();
+ }
+ } else if (event.type == SWT.MouseExit) {
+ button.setSelection(selected);
+ }
+ }
+ };
+
+ public void setSelection(boolean selected) {
+ if (selected) {
+ state = (state == WSTATE.DISABLE_OFF) ? state : WSTATE.SELECTED;
+ this.selected = true;
+ } else {
+ state = state != WSTATE.DISABLE_ON ? WSTATE.NORMAL : WSTATE.DISABLE_ON;
+ this.selected = false;
+ }
+ redraw();
+ }
+
+ public boolean isSelection() {
+ return selected;
+ }
+
+ private void selectRadio() {
+ Control[] children = parent.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ Control child = children[i];
+ if (child instanceof ImageButton && child != this) {
+ ((ImageButton) child).setSelection(false);
+ }
+ }
+ setSelection(true);
+ }
+
+ @Override
+ public void setEnabled(boolean enable) {
+ super.setEnabled(enable);
+ state = (enable ? WSTATE.NORMAL : WSTATE.DISABLE_ON);
+ redraw();
+ }
+
+ public void setEnabled(boolean enable, boolean isOn) {
+ super.setEnabled(enable);
+ if (enable) {
+ state = isOn ? WSTATE.NORMAL : WSTATE.SELECTED;
+
+ } else {
+ state = isOn ? WSTATE.DISABLE_ON : WSTATE.DISABLE_OFF;
+ }
+ redraw();
+ }
+}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.emulator.manager.ui.renewal.widgets;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.PatchImageResources;
+
+
+public abstract class NinePatchButton extends ImageButton {
+
+ public final List<WSTATE> BUTTON_STATE =
+ Arrays.asList(WSTATE.NORMAL, WSTATE.HOVER, WSTATE.PUSH, WSTATE.DISABLE_ON);
+
+ public abstract ButtonResourceInfo getButtonResourceInfo();
+
+ public NinePatchButton(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ protected void setButtonFont(Font font) {
+ for (WSTATE wState : BUTTON_STATE) {
+ setFont(wState, font);
+ }
+ }
+
+ protected void setButtonFontColor(Color color) {
+ for (WSTATE wState : BUTTON_STATE) {
+ setFontColor(wState, color);
+ }
+ }
+
+ @Override
+ public void drawPushImage(GC gc, WSTATE state, int width, int height) {
+ Image image = null;
+ switch(state) {
+ case HOVER:
+ if (hoverImage == null) {
+ hoverImage = PatchImageResources.getButtonImage(width, height,
+ getButtonResourceInfo().getHoverImages());
+ }
+ image = hoverImage;
+ break;
+ case PUSH:
+ if (pushImage == null) {
+ pushImage = PatchImageResources.getButtonImage(width, height,
+ getButtonResourceInfo().getPushImages());
+ }
+ image = pushImage;
+ break;
+ case DISABLE_ON:
+ if (disableImage == null) {
+ disableImage = PatchImageResources.getButtonImage(width, height,
+ getButtonResourceInfo().getDisableImages());
+ }
+ image = disableImage;
+ break;
+ default:
+ if (nomalImage == null) {
+ nomalImage = PatchImageResources.getButtonImage(width, height,
+ getButtonResourceInfo().getNormalImages());
+ }
+ image = nomalImage;
+ break;
+ }
+
+ Rectangle rect = image.getBounds();
+ gc.drawImage(image, rect.x, rect.y);
+ }
+
+ @Override
+ public void disposeWidget() {
+ getButtonResourceInfo().dispose();
+ }
+}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.ui.renewal.widgets;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+
+public class NinePatchResourceInfo {
+
+ private final Map<String, ImageResources> map = new HashMap<String, ImageResources> ();
+ private final ColorResources background;
+
+ static final String LT = "lt";
+ static final String T = "t";
+ static final String RT = "rt";
+ static final String R = "r";
+ static final String RB = "rb";
+ static final String B = "b";
+ static final String LB = "lb";
+ static final String L = "l";
+
+ NinePatchResourceInfo(ColorResources background,
+ ImageResources lt, ImageResources t,
+ ImageResources rt, ImageResources r,
+ ImageResources rb, ImageResources b,
+ ImageResources lb, ImageResources l) {
+ this.background = background;
+ map.put(LT, lt);
+ map.put(T, t);
+ map.put(RT, rt);
+ map.put(R, r);
+ map.put(RB, rb);
+ map.put(B, b);
+ map.put(LB, lb);
+ map.put(L, l);
+ }
+
+ public ImageResources getLeftTopImage() {
+ return map.get(LT);
+ }
+
+ public ImageResources getTopImage() {
+ return map.get(T);
+ }
+
+ public ImageResources getRightTopImage() {
+ return map.get(RT);
+ }
+
+ public ImageResources getRightImage() {
+ return map.get(R);
+ }
+
+ public ImageResources getRightBottomImage() {
+ return map.get(RB);
+ }
+
+ public ImageResources getBottomImage() {
+ return map.get(B);
+ }
+
+ public ImageResources getLeftBottomImage() {
+ return map.get(LB);
+ }
+
+ public ImageResources getLeftImage() {
+ return map.get(L);
+ }
+
+ public ColorResources getBackground() {
+ return background;
+ }
+
+ public void dispose() {
+ if (map != null) {
+ for (String key : map.keySet()) {
+ ImageResources ir = map.get(key);
+ if (ir != null) {
+ Image obj = ir.getImageObject();
+ if (obj != null) {
+ obj.dispose();
+ }
+ }
+ }
+ }
+
+ if (background != null) {
+ Color obj = background.getColorObject();
+ if (obj != null) {
+ obj.dispose();
+ }
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.ui.renewal.widgets;
+
+public enum WSTATE {
+ NORMAL(0),
+ HOVER(1),
+ PUSH(2),
+ SELECTED(3),
+ SELECTED_HOVER(4),
+ SELECTED_PUSH(5),
+ DISABLE_ON(6),
+ DISABLE_OFF(7);
+
+ private int id;
+ WSTATE(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public static WSTATE getState(int id) {
+ for (WSTATE state : WSTATE.values()) {
+ if (state.id == id) {
+ return state;
+ }
+ }
+ return WSTATE.NORMAL;
+ }
+
+}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.ui.renewal.widgets;
+
+import org.eclipse.swt.widgets.Widget;
+
+class WidgetHelper {
+ public static void tryDispose(final Object... Disposables) {
+ if (null == Disposables) {
+ return;
+ }
+
+ for (Object obj : Disposables) {
+ if (null == obj) {
+ continue;
+ }
+ if (obj instanceof Widget) {
+ ((Widget) obj).dispose();
+ }
+ }
+ }
+}