GRAY_BTN_PUSH(100, 110, 144),
GRAY_BTN_DISABLE(208, 208, 208),
+ BLUE_BTN(147, 188, 208),
+
TABLE_VIEWER_BG(240, 240, 240),
LINK_MENU_FONT(255, 255, 255),
CREATE_VM_COMBO_FONT(41,41,41),
MODIFY_ITEM_TITLE(41, 41, 41),
MODIFY_ITEM_LINE(208, 212, 215),
- DEFAULT_FONT(41, 41, 41);
+ DEFAULT_FONT(41, 41, 41),
+
+ // TODO I guess .. little brighter than MESSAGE_BOX_CONTENTS_FONT
+ TEXTBOX_DISABLE(160, 160, 160);
public static ColorResources GRAY_BTN_FONT = WHITE;
public static ColorResources CONTENT_FONT = MESSAGE_BOX_CONTENTS_FONT;
GRAY_BTN_PUSH_RT("9p_btn_push_rt"),
GRAY_BTN_PUSH_T("9p_btn_push_t"),
+ // blue 9 patch button
+ BLUE_BTN_HOVER_B("9p_blue_btn_hover_b"),
+ BLUE_BTN_HOVER_L("9p_blue_btn_hover_l"),
+ BLUE_BTN_HOVER_LB("9p_blue_btn_hover_lb"),
+ BLUE_BTN_HOVER_LT("9p_blue_btn_hover_lt"),
+ BLUE_BTN_HOVER_R("9p_blue_btn_hover_r"),
+ BLUE_BTN_HOVER_RB("9p_blue_btn_hover_rb"),
+ BLUE_BTN_HOVER_RT("9p_blue_btn_hover_rt"),
+ BLUE_BTN_HOVER_T("9p_blue_btn_hover_t"),
+ BLUE_BTN_NORMAL_B("9p_blue_btn_normal_b"),
+ BLUE_BTN_NORMAL_L("9p_blue_btn_normal_l"),
+ BLUE_BTN_NORMAL_LB("9p_blue_btn_normal_lb"),
+ BLUE_BTN_NORMAL_LT("9p_blue_btn_normal_lt"),
+ BLUE_BTN_NORMAL_R("9p_blue_btn_normal_r"),
+ BLUE_BTN_NORMAL_RB("9p_blue_btn_normal_rb"),
+ BLUE_BTN_NORMAL_RT("9p_blue_btn_normal_rt"),
+ BLUE_BTN_NORMAL_T("9p_blue_btn_normal_t"),
+
// text input box
TEXT_INPUT_BOX_HOVER_B("9p_text_input_box_hover_b"),
TEXT_INPUT_BOX_HOVER_L("9p_text_input_box_hover_l"),
ICON_TITLE_PROCESSOR("icon_title_processor"),
ICON_TITLE_TREE_EXPANDED("icon_title_tree_expanded"),
ICON_TITLE_TREE_CLOSED("icon_title_tree_closed"),
+ ICON_BLUE_BUTTON_OPEN("icon_blue_btn_open"),
// profile select button
BTN_PROFILE_MOBILE_SELECTED("btn_profile_mobile_selected"),
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.tizen.emulator.manager.ui.renewal.widgets.NinePatchResourceInfo;
/** Image should be disposed by caller */
public static Image getNinePatchButtonImage(int width, int height, NinePatchResourceInfo ninePatchImagesInfo) {
+ if (ninePatchImagesInfo == null) {
+ return null;
+ }
+
Image image = new Image(Display.getCurrent(), width, height);
GC gc = new GC(image);
gc.setInterpolation(SWT.NONE);
gc.setBackground(transparentColor);
gc.fillRectangle(0, 0, width, height);
+
+ // Draw Image
drawNinePatchImage(gc, width, height, ninePatchImagesInfo);
gc.dispose();
/** Image should be disposed by caller */
+ public static Image getBlueButtonImage(Image icon, int width, int height, NinePatchResourceInfo ninePatchImagesInfo) {
+
+ if (ninePatchImagesInfo == null) {
+ return null;
+ }
+
+ Image image = new Image(Display.getCurrent(), width, height);
+ GC gc = new GC(image);
+ gc.setInterpolation(SWT.NONE);
+
+ // First, fill background to make corner transparent.
+ Color transparentColor = ninePatchImagesInfo.getTransparentColor().getColor();
+ gc.setBackground(transparentColor);
+ gc.fillRectangle(0, 0, width, height);
+
+
+ // Draw Image
+ drawNinePatchImage(gc, width, height, ninePatchImagesInfo);
+
+ // Draw icon
+ if (icon != null) {
+ Rectangle rect = icon.getBounds();
+ gc.drawImage(icon, (width - rect.width) / 2, (height - rect.height) / 2);
+ }
+
+ gc.dispose();
+
+ // Make corner transparent
+ ImageData data = image.getImageData();
+ int cornerPixel = data.palette.getPixel(transparentColor.getRGB());
+ data.transparentPixel = cornerPixel;
+ Image cornerTransparentedImage = new Image(Display.getCurrent(), data);
+
+ // dispose original image
+ image.dispose();
+
+ return cornerTransparentedImage;
+ }
+
+
+ /** Image should be disposed by caller */
public static Image getComboPopupImage(int width, int height, NinePatchResourceInfo ninePatchImagesInfo) {
Image image = new Image(Display.getCurrent(), width, height);
GC gc = new GC(image);
import org.tizen.emulator.manager.ui.renewal.item.modify.common.RamSizeItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.common.SensorItem;
import org.tizen.emulator.manager.ui.renewal.item.modify.vm.DeviceTemplateItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.FileSharingItem;
import org.tizen.emulator.manager.vms.VMProperty;
import org.tizen.emulator.manager.vms.VMPropertyValue;
itemList.add(new ProcessorItem(deviceItem.getTreeRoot()));
itemList.add(new SensorItem(deviceItem.getTreeRoot(), null));
itemList.add(new ConnectivityItem(deviceItem.getTreeRoot(), null));
+ itemList.add(new FileSharingItem());
public class ConnectivityItem extends CheckBoxItem {
- private static final String TITLE = "Device";
- private static final String NAME = "device";
+ private static final String TITLE = "Connectivity";
+ private static final String NAME = "connectivity";
// private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_DEVICE;
private static final int NUM_COLUMN = 3;
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * JiHye Kim <jihye424.kim@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.item.modify.common;
+
+import java.io.File;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.IconItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.widgets.BlueButton;
+import org.tizen.emulator.manager.ui.renewal.widgets.TextBox;
+
+
+
+public abstract class FileDialogItem extends ModifyDialogItem {
+
+ protected TextBox textBox;
+ protected String filePath;
+ private BlueButton fileDialogButton;
+
+ private final static int BUTTON_SPACE = 5;
+ private final static int BUTTON_WIDTH = 32;
+ private final static int BUTTON_HEIGHT = ModifyItem.WIDGET_HEIGHT;
+
+ private DirectoryDialog dd;
+
+ public FileDialogItem(String name, String title) {
+ super(name, title);
+ }
+
+
+ protected void create(Composite parent, String title,
+ ImageResources iconResource, int textBoxWidth) {
+ item = new ModifyItem();
+ item.init(parent);
+ item.setItemTitle(new IconItemTitle(item.getItemComp(), title, iconResource));
+ item.create();
+
+ makeBody(textBoxWidth);
+ }
+
+ private void makeBody(int textBoxWidth) {
+
+ item.setBodyLayoutForm();
+
+ createTextBox(textBoxWidth);
+ createFileDialogButton();
+ }
+
+
+ public void setTextBox(String path) {
+ if (path == null || path.isEmpty()) {
+ return;
+ }
+
+ String fileName = path.substring(path
+ .lastIndexOf(File.separator) + 1, path.length());
+ textBox.setText(fileName);
+ textBox.setToolTipText(path);
+ }
+
+
+ private void createTextBox(int textBoxWidth) {
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, ModifyItem.BODY_MARGIN_LEFT);
+ data.top = new FormAttachment(0, ModifyItem.WIDGET_TOP);
+ data.width = textBoxWidth;
+ data.height = ModifyItem.WIDGET_HEIGHT;
+ textBox = new TextBox(item.getBody(), SWT.NONE);
+ textBox.setLayoutData(data);
+
+ }
+
+ private void createFileDialogButton() {
+ FormData data = new FormData();
+ data.left = new FormAttachment(textBox, BUTTON_SPACE);
+ data.top = new FormAttachment(0, ModifyItem.WIDGET_TOP);
+ data.width = BUTTON_WIDTH;
+ data.height = BUTTON_HEIGHT;
+ fileDialogButton = new BlueButton(item.getBody(), SWT.PUSH);
+ fileDialogButton.setIcon(ImageResources.ICON_BLUE_BUTTON_OPEN);
+ fileDialogButton.setLayoutData(data);
+
+ addButtonListener();
+ }
+
+
+ private void addButtonListener() {
+ fileDialogButton.addListener(SWT.Selection, new Listener(){
+ @Override
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Selection) {
+ if (dd == null) {
+ dd = new DirectoryDialog(
+ getDialog().getShell(), SWT.OPEN);
+ dd.setText("Select directory");
+ }
+ String path = dd.open();
+ if (path != null) {
+ filePath = path;
+ setTextBox(filePath);
+ fileSelected();
+ }
+ }
+ }
+ });
+ }
+
+ public abstract void fileSelected();
+}
}
item.getItemComp().moveAbove(null); // move to top
}
+
+ @Override
+ public int getHeight() {
+ return item.getHeight();
+ }
}
@Override
public void changeItem(ModifyDialogItem srcDialogItem) {
- if (textBox == null || textBox.isDisposed()) {
+ if (textInputBox == null || textInputBox.isDisposed()) {
return;
}
- textBox.setText(value);
+ textInputBox.setText(value);
}
// set image
drawProfileImage();
+ imageCanvas.setToolTipText(currentProfile);
}
public abstract class TextInputBoxItem extends ModifyDialogItem {
- protected TextInputBox textBox;
+ protected TextInputBox textInputBox;
protected String value = "";
makeBody(textBoxWidth);
-
}
data.widthHint = textBoxWidth;
data.grabExcessVerticalSpace = true;
data.verticalAlignment = SWT.CENTER;
- textBox = new TextInputBox(item.getBody(), SWT.NONE);
- textBox.setLayoutData(data);
+ textInputBox = new TextInputBox(item.getBody(), SWT.NONE);
+ textInputBox.setLayoutData(data);
- textBox.setText(value);
+ textInputBox.setText(value);
addTextListener();
}
private void addTextListener() {
- textBox.getTextWidget().addModifyListener(new ModifyListener() {
+ textInputBox.getTextWidget().addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
package org.tizen.emulator.manager.ui.renewal.item.modify.comp;
+import java.io.File;
import java.util.HashMap;
import java.util.Map;
return templateValue != null;
}
+ public String getFileSharingPath() {
+ if (isVMValue()) {
+ return vmValue.fileSharePath;
+ }
+
+ return "";
+ }
+
+ public void setFileSharingPath(String path) {
+ if (isVMValue()) {
+ vmValue.fileSharePath = path;
+ vmValue.fileSharePathName = path.substring(path
+ .lastIndexOf(File.separator) + 1, path.length());
+ }
+ }
+
public DeviceTemplate getDeivceTemplate() {
if (isVMValue()) {
return vmValue.device;
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * JiHye Kim <jihye424.kim@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.item.modify.vm;
+
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.FileDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+
+public class FileSharingItem extends FileDialogItem {
+
+ private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_FILESHARING;
+ private static final String NAME="fileSharing";
+ private static final String TITLE="File Sharing";
+ private final int TEXT_BOX_WIDTH = 233;
+
+ private String sharingPath;
+
+ public FileSharingItem() {
+ super(NAME, TITLE);
+ }
+
+
+ @Override
+ public void create(Composite parent) {
+ create(parent, getTitle(), TITLE_ICON_RESOURCE, TEXT_BOX_WIDTH);
+ if (sharingPath == null || sharingPath.isEmpty()) {
+ setTextBox("(select sharing path...)");
+
+ } else {
+ setTextBox(sharingPath);
+ }
+ }
+
+
+ @Override
+ public void setInitialValue(PropertyValue value) {
+ sharingPath = value.getFileSharingPath();
+ }
+
+ @Override
+ public void setValue(PropertyValue value) {
+ if (sharingPath == null || sharingPath.isEmpty()) {
+ return;
+ }
+
+ value.setFileSharingPath(sharingPath);
+ }
+
+ @Override
+ public ModifyDialogItem cloneItem() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void fileSelected() {
+ sharingPath = filePath;
+ }
+
+}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * JiHye Kim <jihye424.kim@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.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.ColorResources;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.renewal.resources.PatchImageResources;
+
+public class BlueButton extends NinePatchButton {
+
+ private static NinePatchResourceMap ninePatchResourceMap;
+ private ImageResources icon;
+ private Image iconImage = null;
+
+ public BlueButton(Composite parent, int style) {
+ super(parent, style);
+ initNinePatchResourceMap();
+ }
+
+ public void setIcon(ImageResources imageResource) {
+ icon = imageResource;
+ }
+
+ @Override
+ public void drawPushImage(GC gc, WSTATE state, int width, int height) {
+ Image image = null;
+ if (iconImage == null && icon != null) {
+ iconImage = icon.getImage();
+ }
+
+
+ switch(state) {
+ case HOVER:
+ if (hoverImage == null) {
+ hoverImage = PatchImageResources.getBlueButtonImage(iconImage, width, height,
+ getNinePatchResourceMap().get(state));
+ }
+ image = hoverImage;
+ break;
+ case PUSH:
+ if (pushImage == null) {
+ pushImage = PatchImageResources.getBlueButtonImage(iconImage, width, height,
+ getNinePatchResourceMap().get(state));
+ }
+ image = pushImage;
+ break;
+ case DISABLE_ON:
+ if (disableImage == null) {
+ disableImage = PatchImageResources.getBlueButtonImage(iconImage, width, height,
+ getNinePatchResourceMap().get(state));
+ }
+ image = disableImage;
+ break;
+ default:
+ if (normalImage == null) {
+ normalImage = PatchImageResources.getBlueButtonImage(iconImage, width, height,
+ getNinePatchResourceMap().get(WSTATE.NORMAL));
+ }
+ image = normalImage;
+ break;
+ }
+
+ if (image == null) {
+ return;
+ }
+
+ Rectangle rect = image.getBounds();
+ gc.drawImage(image, rect.x, rect.y);
+
+ }
+
+
+ private static void initNinePatchResourceMap() {
+ ninePatchResourceMap = new NinePatchResourceMap();
+ ninePatchResourceMap.setImages(WSTATE.NORMAL, ColorResources.BLUE_BTN,
+ ColorResources.RED,
+ ImageResources.BLUE_BTN_NORMAL_LT,
+ ImageResources.BLUE_BTN_NORMAL_T,
+ ImageResources.BLUE_BTN_NORMAL_RT,
+ ImageResources.BLUE_BTN_NORMAL_R,
+ ImageResources.BLUE_BTN_NORMAL_RB,
+ ImageResources.BLUE_BTN_NORMAL_B,
+ ImageResources.BLUE_BTN_NORMAL_LB,
+ ImageResources.BLUE_BTN_NORMAL_L);
+
+ ninePatchResourceMap.setImages(WSTATE.HOVER, ColorResources.BLUE_BTN,
+ ColorResources.RED,
+ ImageResources.BLUE_BTN_HOVER_LT,
+ ImageResources.BLUE_BTN_HOVER_T,
+ ImageResources.BLUE_BTN_HOVER_RT,
+ ImageResources.BLUE_BTN_HOVER_R,
+ ImageResources.BLUE_BTN_HOVER_RB,
+ ImageResources.BLUE_BTN_HOVER_B,
+ ImageResources.BLUE_BTN_HOVER_LB,
+ ImageResources.BLUE_BTN_HOVER_L);
+
+ ninePatchResourceMap.setImages(WSTATE.PUSH, ColorResources.BLUE_BTN,
+ ColorResources.RED,
+ ImageResources.BLUE_BTN_HOVER_LT,
+ ImageResources.BLUE_BTN_HOVER_T,
+ ImageResources.BLUE_BTN_HOVER_RT,
+ ImageResources.BLUE_BTN_HOVER_R,
+ ImageResources.BLUE_BTN_HOVER_RB,
+ ImageResources.BLUE_BTN_HOVER_B,
+ ImageResources.BLUE_BTN_HOVER_LB,
+ ImageResources.BLUE_BTN_HOVER_L);
+ }
+
+ @Override
+ public NinePatchResourceMap getNinePatchResourceMap() {
+ return ninePatchResourceMap;
+ }
+}
return fontColors.get(state.getId());
}
- protected Image nomalImage = null;
+ protected Image normalImage = null;
protected Image hoverImage = null;
protected Image pushImage = null;;
protected Image disableImage = null;
image = pushImage;
break;
default:
- if (nomalImage == null) {
+ if (normalImage == null) {
// nomalImage = PatchImageResources.getNomalButton(width);
}
- image = nomalImage;
+ image = normalImage;
break;
}
i = s.getId();
WidgetHelper.tryDispose(images.get(i), colors.get(i), fontColors.get(i), fonts.get(i));
}
- WidgetHelper.tryDispose(nomalImage, hoverImage, pushImage, disableImage);
+ WidgetHelper.tryDispose(normalImage, hoverImage, pushImage, disableImage);
}
};
@Override
public void drawPushImage(GC gc, WSTATE state, int width, int height) {
Image image = null;
+
switch(state) {
case HOVER:
if (hoverImage == null) {
image = disableImage;
break;
default:
- if (nomalImage == null) {
- nomalImage = PatchImageResources.getNinePatchButtonImage(width, height,
+ if (normalImage == null) {
+ normalImage = PatchImageResources.getNinePatchButtonImage(width, height,
getNinePatchResourceMap().get(WSTATE.NORMAL));
}
- image = nomalImage;
+ image = normalImage;
break;
}
+ if (image == null) {
+ return;
+ }
+
Rectangle rect = image.getBounds();
gc.drawImage(image, rect.x, rect.y);
+
}
}
--- /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.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Canvas;
+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 TextBox extends NinePatchBox {
+
+ private static NinePatchResourceMap ninePatchResourceMap;
+
+ private final int TEXT_MARGIN_HEIGHT = 2;
+ private final int TEXT_MARGIN_WIDTH = 6;
+
+ private String text = "";
+ private Canvas canvas;
+
+ public TextBox(Composite parent, int style) {
+ super(parent, style);
+ initNinePatchResourceMap();
+ initBox();
+ createCanvas();
+ }
+
+
+ @Override
+ public void setToolTipText(String text) {
+ super.setToolTipText(text);
+ canvas.setToolTipText(text);
+ }
+
+
+ @Override
+ public NinePatchResourceMap getNinePatchResourceMap() {
+ return ninePatchResourceMap;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ canvas.redraw();
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ private void initBox() {
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = TEXT_MARGIN_HEIGHT;
+ layout.marginWidth = TEXT_MARGIN_WIDTH;
+ layout.numColumns = 1;
+ this.setLayout(layout);
+ }
+
+
+ private void createCanvas() {
+ GridData data = new GridData();
+ data.grabExcessHorizontalSpace = true;
+ data.grabExcessVerticalSpace = true;
+ data.horizontalAlignment = SWT.FILL;
+ data.verticalAlignment = SWT.FILL;
+
+ canvas = new Canvas(this, SWT.NONE);
+ canvas.setLayoutData(data);
+
+ addCanvasListener();
+ }
+
+
+ private void addCanvasListener() {
+ canvas.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+
+ GC gc = e.gc;
+ gc.setForeground(ColorResources.TEXTBOX_DISABLE.getColor());
+ gc.setFont(FontResources.CONTENT.getFont());
+
+ int itemHeight = ((Composite)e.widget).getBounds().height;
+ Point textExt = gc.textExtent(text);
+ int posY = (itemHeight - textExt.y) / 2;
+
+ int posX = 0;
+ int itemWidth = ((Composite)e.widget).getBounds().width;
+ posX = (itemWidth - textExt.x)/ 2;
+ gc.drawText(text, posX, posY);
+ }
+
+ });
+ }
+
+
+
+
+ private static void initNinePatchResourceMap() {
+ ninePatchResourceMap = new NinePatchResourceMap();
+ ninePatchResourceMap.setImages(WSTATE.NORMAL, ColorResources.WHITE,
+ ColorResources.BLACK,
+ ImageResources.TEXT_INPUT_BOX_NORMAL_LT,
+ ImageResources.TEXT_INPUT_BOX_NORMAL_T,
+ ImageResources.TEXT_INPUT_BOX_NORMAL_RT,
+ ImageResources.TEXT_INPUT_BOX_NORMAL_R,
+ ImageResources.TEXT_INPUT_BOX_NORMAL_RB,
+ ImageResources.TEXT_INPUT_BOX_NORMAL_B,
+ ImageResources.TEXT_INPUT_BOX_NORMAL_LB,
+ ImageResources.TEXT_INPUT_BOX_NORMAL_L);
+ }
+}