/**
* Constructor
*/
- public EmulatorSdlSkin(EmulatorSkinState state, EmulatorFingers finger, EmulatorConfig config, SkinInformation skinInfo, boolean isOnTop) {
+ public EmulatorSdlSkin(EmulatorSkinState state, EmulatorFingers finger,
+ EmulatorConfig config, SkinInformation skinInfo, boolean isOnTop) {
super(state, finger, config, skinInfo, isOnTop);
}
this.runnable = new Runnable() {
public void run() {
- // logger.info("update lcd framebuffer");
+ // logger.info("update display framebuffer");
if(lcdCanvas.isDisposed() == false) {
lcdCanvas.redraw();
}
/**
* Constructor
*/
- public EmulatorShmSkin(EmulatorSkinState state, EmulatorFingers finger, EmulatorConfig config, SkinInformation skinInfo, boolean isOnTop) {
+ public EmulatorShmSkin(EmulatorSkinState state, EmulatorFingers finger,
+ EmulatorConfig config, SkinInformation skinInfo, boolean isOnTop) {
super(state, finger, config, skinInfo, isOnTop);
this.paletteData = new PaletteData(RED_MASK, GREEN_MASK, BLUE_MASK);
}
import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
import org.tizen.emulator.skin.comm.sock.data.BooleanData;
import org.tizen.emulator.skin.comm.sock.data.KeyEventData;
-import org.tizen.emulator.skin.comm.sock.data.LcdStateData;
+import org.tizen.emulator.skin.comm.sock.data.DisplayStateData;
import org.tizen.emulator.skin.comm.sock.data.MouseEventData;
import org.tizen.emulator.skin.config.EmulatorConfig;
import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
+import org.tizen.emulator.skin.custom.CustomProgressBar;
+import org.tizen.emulator.skin.custom.KeyWindow;
import org.tizen.emulator.skin.dbi.ColorsType;
import org.tizen.emulator.skin.dbi.KeyMapType;
import org.tizen.emulator.skin.dbi.RgbType;
import org.tizen.emulator.skin.util.SkinRotation;
import org.tizen.emulator.skin.util.SkinUtil;
import org.tizen.emulator.skin.util.SwtUtil;
-import org.tizen.emulator.skin.window.ControlPanel;
-import org.tizen.emulator.skin.window.CustomProgressBar;
/**
*
private boolean isOnKbd;
private Menu contextMenu;
- private MenuItem panelItem; /* key window menu */
- public ControlPanel keyWindow;
+ private MenuItem keyWindowItem; /* key window menu */
+ public KeyWindow keyWindow;
public Color colorPairTag;
public Canvas pairTagCanvas;
public CustomProgressBar bootingProgress;
/* toggle a key window */
public void setIsControlPanel(boolean value) {
isControlPanel = value;
- panelItem.setSelection(isControlPanel);
+ keyWindowItem.setSelection(isControlPanel);
logger.info("Select Key Window : " + isControlPanel);
}
}
try {
- keyWindow = new ControlPanel(this, shell, colorPairTag,
+ keyWindow = new KeyWindow(this, shell, colorPairTag,
communicator, keyMapList);
SkinUtil.setTopMost(keyWindow.getShell(), isOnTop);
/* Key Window menu */
if (skinInfo.isPhoneShape() == false) { //TODO:
- panelItem = new MenuItem(menu, SWT.CHECK);
- panelItem.setText("&Key Window");
- panelItem.setSelection(isControlPanel);
+ keyWindowItem = new MenuItem(menu, SWT.CHECK);
+ keyWindowItem.setText("&Key Window");
+ keyWindowItem.setSelection(isControlPanel);
- panelItem.addSelectionListener(new SelectionAdapter() {
+ keyWindowItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- final boolean isControlPanel = panelItem.getSelection();
+ final boolean isControlPanel = keyWindowItem.getSelection();
setIsControlPanel(isControlPanel);
if (isControlPanel == true) {
SkinUtil.setTopMost(shell, isOnTop);
}
- LcdStateData lcdStateData =
- new LcdStateData(currentState.getCurrentScale(), rotationId);
+ DisplayStateData lcdStateData =
+ new DisplayStateData(currentState.getCurrentScale(), rotationId);
communicator.sendToQEMU(SendCommand.CHANGE_LCD_STATE, lcdStateData);
}
};
SkinUtil.setTopMost(shell, isOnTop);
}
- LcdStateData lcdStateData =
- new LcdStateData(scale, currentState.getCurrentRotationId());
+ DisplayStateData lcdStateData =
+ new DisplayStateData(scale, currentState.getCurrentRotationId());
communicator.sendToQEMU(SendCommand.CHANGE_LCD_STATE, lcdStateData);
}
--- /dev/null
+/**
+ *
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * HyunJun Son
+ *
+ * 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.skin.comm.sock.data;
+
+import java.io.IOException;
+
+/**
+ *
+ *
+ */
+public class DisplayStateData extends AbstractSendData {
+
+ int scale;
+ short rotation;
+
+ public DisplayStateData(int scale, short rotation) {
+ this.scale = scale;
+ this.rotation = rotation;
+ }
+
+ @Override
+ protected void write() throws IOException {
+ writeInt(scale);
+ writeShort(rotation);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("DisplayStateData [scale=");
+ builder.append(scale);
+ builder.append(", rotation=");
+ builder.append(rotation);
+ builder.append("]");
+ return builder.toString();
+ }
+
+}
+++ /dev/null
-/**
- *
- *
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- * HyunJun Son
- *
- * 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.skin.comm.sock.data;
-
-import java.io.IOException;
-
-/**
- *
- *
- */
-public class LcdStateData extends AbstractSendData {
-
- int scale;
- short rotation;
-
- public LcdStateData(int scale, short rotation) {
- this.scale = scale;
- this.rotation = rotation;
- }
-
- @Override
- protected void write() throws IOException {
- writeInt(scale);
- writeShort(rotation);
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("LcdStateData [scale=");
- builder.append(scale);
- builder.append(", rotation=");
- builder.append(rotation);
- builder.append("]");
- return builder.toString();
- }
-
-}
--- /dev/null
+/**
+ *
+ *
+ * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@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.skin.custom;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.MouseTrackAdapter;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+
+public class CustomButton extends Canvas {
+ /* state */
+ private int mouse = 0;
+ private boolean hit = false;
+
+ /* image - 0 : normal, 1 : hover, 2 : pushed */
+ private Image imageButton[];
+
+ private int width;
+ private int height;
+ private String text;
+ private int textPositionX;
+ private int textPositionY;
+ private static Color white;
+ private static Color gray;
+
+ public CustomButton(Composite parent, int style,
+ Image imageNormal, Image imageHover, Image imagePushed) {
+ super(parent, style);
+
+ this.imageButton = new Image[3];
+ imageButton[0] = imageNormal;
+ imageButton[1] = imageHover;
+ imageButton[2] = imagePushed;
+
+ this.width = imageNormal.getImageData().width;
+ this.height = imageNormal.getImageData().height;
+
+ this.text = null;
+ textPositionX = width / 2;
+ textPositionY = height / 2;
+ white = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
+ gray = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
+
+ this.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ switch (mouse) {
+ case 0: /* default state */
+ if (imageButton[0] != null) {
+ e.gc.drawImage(imageButton[0], 0, 0);
+ }
+
+ if (text != null) {
+ e.gc.setForeground(white);
+ e.gc.drawText(text,
+ textPositionX, textPositionY, true);
+ }
+
+ break;
+ case 1: /* mouse over */
+ if (imageButton[1] != null) {
+ e.gc.drawImage(imageButton[1], 0, 0);
+ }
+
+ if (text != null) {
+ e.gc.setForeground(white);
+ e.gc.drawText(text,
+ textPositionX, textPositionY, true);
+ }
+
+ break;
+ case 2: /* mouse down */
+ if (imageButton[2] != null) {
+ e.gc.drawImage(imageButton[2], 0, 0);
+ }
+
+ if (text != null) {
+ e.gc.setForeground(gray);
+ e.gc.drawText(text,
+ textPositionX, textPositionY, true);
+ }
+
+ break;
+ default:
+ break;
+ }
+ }
+ });
+
+ this.addMouseMoveListener(new MouseMoveListener() {
+ @Override
+ public void mouseMove(MouseEvent e) {
+ if (!hit) {
+ return;
+ }
+
+ mouse = 2;
+
+ if (e.x < 0 || e.y < 0 ||
+ e.x > getBounds().width || e.y > getBounds().height) {
+ mouse = 0;
+ }
+
+ redraw();
+ }
+ });
+
+ this.addMouseTrackListener(new MouseTrackAdapter() {
+ @Override
+ public void mouseEnter(MouseEvent e) {
+ mouse = 1;
+
+ redraw();
+ }
+
+ @Override
+ public void mouseExit(MouseEvent e) {
+ mouse = 0;
+
+ redraw();
+ }
+ });
+
+ this.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ hit = true;
+ mouse = 2;
+
+ redraw();
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ hit = false;
+ mouse = 1;
+
+ if (e.x < 0 || e.y < 0 ||
+ e.x > getBounds().width || e.y > getBounds().height) {
+ mouse = 0;
+ }
+
+ redraw();
+
+ if (mouse == 1) {
+ notifyListeners(SWT.Selection, new Event());
+ }
+ }
+ });
+
+ this.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.keyCode == '\r' || e.character == ' ') {
+ Event event = new Event();
+ notifyListeners(SWT.Selection, event);
+ }
+ }
+ });
+ }
+
+ public void setText(String textValue) {
+ /* checking whether the text value is appropriate */
+ if (textValue == null || textValue.isEmpty()) {
+ return;
+ }
+
+ GC gc = new GC(this);
+ Point textSize = gc.textExtent(textValue);
+ Point originalSize = textSize;
+
+ while (textSize.x >= (width - 10)) {
+ textValue = textValue.substring(0, textValue.length() - 1);
+ textSize = gc.textExtent(textValue);
+ }
+
+ if (originalSize.x != textSize.x) {
+ textValue = textValue.substring(0, textValue.length() - 1);
+ textValue += "..";
+ textSize = gc.textExtent(textValue);
+ }
+
+ gc.dispose();
+
+ /* set text */
+ text = textValue;
+
+ textPositionX -= textSize.x / 2;
+ if (textPositionX < 0) {
+ textPositionX = 0;
+ }
+
+ textPositionY -= textSize.y / 2;
+ if (textPositionY < 0) {
+ textPositionY = 0;
+ }
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public Point getImageSize() {
+ return new Point(imageButton[0].getImageData().width,
+ imageButton[0].getImageData().height);
+ }
+}
\ No newline at end of file
--- /dev/null
+/**
+ *
+ *
+ * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@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.skin.custom;
+
+import java.util.logging.Logger;
+
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.skin.log.SkinLogger;
+
+public class CustomProgressBar extends Canvas {
+ private Logger logger =
+ SkinLogger.getSkinLogger(CustomProgressBar.class).getLogger();
+
+ private Composite parent;
+ private int selection;
+
+ public CustomProgressBar(final Composite parent, int style) {
+ super(parent, style);
+
+ this.parent = parent;
+ this.selection = 0;
+
+ this.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ e.gc.setBackground(
+ new Color(parent.getDisplay(), new RGB(0, 173, 239)));
+
+ Rectangle bounds = getBounds();
+ int width = (bounds.width * selection) / 100;
+ e.gc.fillRectangle(0, 0, width, bounds.height);
+
+ if (selection == -1) {
+ logger.info("progress : complete!");
+
+ parent.getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ dispose();
+ }
+ });
+ }
+ }
+ });
+
+ /* default is hidden */
+ parent.getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ setVisible(false);
+ }
+ });
+ }
+
+ public void setSelection(int value) {
+ parent.getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ setVisible(true);
+ }
+ });
+
+ if (value < 0) {
+ value = 0;
+ } else if (value > 100) {
+ value = 100;
+ }
+
+ selection = value;
+ logger.info("progress : " + selection);
+
+ parent.getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ redraw();
+
+ if (selection == 100) {
+ selection = -1;
+ }
+ }
+ });
+ }
+
+ public int getSelection() {
+ return selection;
+ }
+}
--- /dev/null
+/**
+ *
+ *
+ * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@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.skin.custom;
+
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.graphics.Region;
+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.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.skin.EmulatorSkin;
+import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType;
+import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
+import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
+import org.tizen.emulator.skin.comm.sock.data.KeyEventData;
+import org.tizen.emulator.skin.dbi.KeyMapType;
+import org.tizen.emulator.skin.layout.SkinPatches;
+import org.tizen.emulator.skin.util.SwtUtil;
+
+public class KeyWindow extends SkinWindow {
+ private static final String PATCH_IMAGES_PATH = "images/key-window/";
+ private static final int SHELL_MARGIN_BOTTOM = 3;
+ private static final int PAIRTAG_CIRCLE_SIZE = 8;
+ private static final int PAIRTAG_MARGIN_BOTTOM = 6;
+ private static final int BUTTON_DEFAULT_CNT = 4;
+ private static final int BUTTON_VERTICAL_SPACING = 7;
+
+ private EmulatorSkin skin;
+ private SkinPatches frameMaker;
+ private Image imageNormal; /* ImageButton image */
+ private Image imageHover; /* hovered ImageButton image */
+ private Image imagePushed; /* pushed ImageButton image */
+ private Image imageFrame; /* nine-patch image */
+ private Color colorFrame;
+ private Color colorPairTag;
+ private SocketCommunicator communicator;
+ private List<KeyMapType> keyMapList;
+
+ private PaintListener shellPaintListener;
+ private MouseMoveListener shellMouseMoveListener;
+ private MouseListener shellMouseListener;
+ private Listener shellCloseListener;
+
+ private boolean isGrabbedShell;
+ private Point grabPosition;
+
+ public KeyWindow(EmulatorSkin skin, Shell parent, Color colorPairTag,
+ SocketCommunicator communicator, List<KeyMapType> keyMapList) {
+ super(parent, SWT.RIGHT | SWT.CENTER);
+
+ this.skin = skin;
+ this.shell = new Shell(Display.getDefault(), SWT.NO_TRIM | SWT.RESIZE);
+ this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH);
+ this.colorPairTag = colorPairTag;
+
+ this.keyMapList = keyMapList;
+ this.communicator = communicator;
+ this.grabPosition = new Point(0, 0);
+
+ shell.setText(parent.getText());
+ shell.setImage(parent.getImage());
+
+ /* load image for HW key button */
+ ClassLoader loader = this.getClass().getClassLoader();
+ imageNormal = new Image(Display.getDefault(),
+ loader.getResourceAsStream(PATCH_IMAGES_PATH + "keybutton_nml.png"));
+ imageHover = new Image(Display.getDefault(),
+ loader.getResourceAsStream(PATCH_IMAGES_PATH + "keybutton_hover.png"));
+ imagePushed = new Image(Display.getDefault(),
+ loader.getResourceAsStream(PATCH_IMAGES_PATH + "keybutton_pushed.png"));
+
+ /* calculate the key window size */
+ int width = imageNormal.getImageData().width;
+ int height = (imageNormal.getImageData().height * BUTTON_DEFAULT_CNT) +
+ (BUTTON_VERTICAL_SPACING * (BUTTON_DEFAULT_CNT - 1)) +
+ (PAIRTAG_CIRCLE_SIZE + PAIRTAG_MARGIN_BOTTOM) +
+ SHELL_MARGIN_BOTTOM;
+
+ /* make a frame image */
+ this.imageFrame = frameMaker.getPatchedImage(width, height);
+ this.colorFrame = new Color(shell.getDisplay(), new RGB(38, 38, 38));
+
+// /* generate a pair tag color of key window */
+// int red = (int) (Math.random() * 256);
+// int green = (int) (Math.random() * 256);
+// int blue = (int) (Math.random() * 256);
+// this.colorPairTag = new Color(shell.getDisplay(), new RGB(red, green, blue));
+ this.colorPairTag = colorPairTag;
+
+ createContents();
+ trimPatchedShell(shell, imageFrame);
+ addKeyWindowListener();
+
+ shell.setBackground(colorFrame);
+ shell.setSize(imageFrame.getImageData().width,
+ imageFrame.getImageData().height);
+ }
+
+ protected void createContents() {
+ GridLayout shellGridLayout = new GridLayout(1, false);
+ shellGridLayout.marginLeft = shellGridLayout.marginRight = frameMaker.getPatchWidth();
+ shellGridLayout.marginTop = shellGridLayout.marginBottom = frameMaker.getPatchHeight();
+ shellGridLayout.marginWidth = shellGridLayout.marginHeight = 0;
+ shellGridLayout.horizontalSpacing = shellGridLayout.verticalSpacing = 0;
+
+ shell.setLayout(shellGridLayout);
+
+ /* make a pair tag circle */
+ Canvas pairTagCanvas = new Canvas(shell, SWT.NONE);
+ pairTagCanvas.setBackground(colorFrame);
+ pairTagCanvas.setLayoutData(new GridData(PAIRTAG_CIRCLE_SIZE,
+ PAIRTAG_CIRCLE_SIZE + PAIRTAG_MARGIN_BOTTOM));
+
+ pairTagCanvas.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ if (colorPairTag != null) {
+ e.gc.setBackground(colorPairTag);
+ e.gc.setAntialias(SWT.ON);
+ e.gc.fillOval(0, 0, PAIRTAG_CIRCLE_SIZE, PAIRTAG_CIRCLE_SIZE);
+ }
+ }
+ });
+
+ /* */
+ ScrolledComposite compositeScroll = new ScrolledComposite(shell, SWT.V_SCROLL);
+ compositeScroll.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1));
+
+ Composite compositeBase = new Composite(compositeScroll, SWT.NONE);
+ compositeBase.setBackground(colorFrame);
+
+ GridLayout compositeGridLayout = new GridLayout(1, false);
+ compositeGridLayout.marginLeft = compositeGridLayout.marginRight = 0;
+ compositeGridLayout.marginTop = compositeGridLayout.marginBottom = 0;
+ compositeGridLayout.marginWidth = compositeGridLayout.marginHeight = 0;
+ compositeGridLayout.horizontalSpacing = 0;
+ compositeGridLayout.verticalSpacing = BUTTON_VERTICAL_SPACING;
+ compositeBase.setLayout(compositeGridLayout);
+
+ if (keyMapList != null && keyMapList.isEmpty() == false) {
+ for (KeyMapType keyEntry : keyMapList) {
+ CustomButton HWKeyButton = new CustomButton(compositeBase, SWT.NONE,
+ imageNormal, imageHover, imagePushed);
+ HWKeyButton.setText(keyEntry.getEventInfo().getKeyName());
+ HWKeyButton.setToolTipText(keyEntry.getTooltip());
+ HWKeyButton.setBackground(colorFrame);
+ HWKeyButton.setLayoutData(new GridData(imageNormal.getImageData().width,
+ imageNormal.getImageData().height));
+
+ final int keycode = keyEntry.getEventInfo().getKeyCode();
+ HWKeyButton.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ KeyEventData keyEventData = new KeyEventData(
+ KeyEventType.PRESSED.value(), keycode, 0, 0);
+ communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData);
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ KeyEventData keyEventData = new KeyEventData(
+ KeyEventType.RELEASED.value(), keycode, 0, 0);
+ communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData);
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ /* do nothing */
+ }
+ });
+ }
+ }
+
+ compositeScroll.setContent(compositeBase);
+ compositeScroll.setExpandHorizontal(true);
+ compositeScroll.setExpandVertical(true);
+ compositeScroll.setMinSize(compositeBase.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ }
+
+ public static void trimPatchedShell(Shell shell, Image image) {
+ if (null == image) {
+ return;
+ }
+ ImageData imageData = image.getImageData();
+
+ int width = imageData.width;
+ int height = imageData.height;
+
+ Region region = new Region();
+ region.add(new Rectangle(0, 0, width, height));
+
+ int r = shell.getDisplay().getSystemColor(SWT.COLOR_MAGENTA).getRed();
+ int g = shell.getDisplay().getSystemColor(SWT.COLOR_MAGENTA).getGreen();
+ int b = shell.getDisplay().getSystemColor(SWT.COLOR_MAGENTA).getBlue();
+ int colorKey;
+
+ if (SwtUtil.isWindowsPlatform()) {
+ colorKey = r << 24 | g << 16 | b << 8;
+ } else {
+ colorKey = r << 16 | g << 8 | b;
+ }
+
+ for (int i = 0; i < width; i++) {
+ for (int j = 0; j < height; j++) {
+ int colorPixel = imageData.getPixel(i, j);
+ if (colorPixel == colorKey /* magenta */) {
+ region.subtract(i, j, 1, 1);
+ }
+ }
+ }
+
+ shell.setRegion(region);
+ }
+
+ private void addKeyWindowListener() {
+ shellPaintListener = new PaintListener() {
+ @Override
+ public void paintControl(final PaintEvent e) {
+ if (imageFrame != null) {
+ e.gc.drawImage(imageFrame, 0, 0);
+ }
+ }
+ };
+
+ shell.addPaintListener(shellPaintListener);
+
+ shellMouseMoveListener = new MouseMoveListener() {
+ @Override
+ public void mouseMove(MouseEvent e) {
+ if (isGrabbedShell == true && e.button == 0/* left button */) {
+ /* move a window */
+ Point previousLocation = shell.getLocation();
+ int x = previousLocation.x + (e.x - grabPosition.x);
+ int y = previousLocation.y + (e.y - grabPosition.y);
+
+ shell.setLocation(x, y);
+ return;
+ }
+ }
+ };
+
+ shell.addMouseMoveListener(shellMouseMoveListener);
+
+ shellMouseListener = new MouseListener() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ if (e.button == 1) { /* left button */
+ isGrabbedShell = false;
+ grabPosition.x = grabPosition.y = 0;
+
+ /* Let me check whether the key window was landed
+ * on docking area. */
+ Rectangle parentBounds = parent.getBounds();
+ Rectangle childBounds = shell.getBounds();
+
+ int heightOneThird = parentBounds.height / 3;
+
+ /* right-middle */
+ Rectangle attachBounds1 = new Rectangle(
+ (parentBounds.x + parentBounds.width) - 5,
+ parentBounds.y + heightOneThird,
+ 30, heightOneThird);
+ /* right-top */
+ Rectangle attachBounds2 = new Rectangle(
+ (parentBounds.x + parentBounds.width) - 5,
+ parentBounds.y,
+ 30, heightOneThird);
+ /* right-bottom */
+ Rectangle attachBounds3 = new Rectangle(
+ (parentBounds.x + parentBounds.width) - 5,
+ parentBounds.y + (heightOneThird * 2),
+ 30, heightOneThird);
+
+ if (childBounds.intersects(attachBounds1) == true) {
+ dock(SWT.RIGHT | SWT.CENTER, false, true);
+ } else if (childBounds.intersects(attachBounds2) == true) {
+ dock(SWT.RIGHT | SWT.TOP, false, true);
+ } else if (childBounds.intersects(attachBounds3) == true) {
+ dock(SWT.RIGHT | SWT.BOTTOM, false, true);
+ } else {
+ dock(SWT.NONE, false, true);
+ }
+ }
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ if (1 == e.button) { /* left button */
+ isGrabbedShell = true;
+ grabPosition.x = e.x;
+ grabPosition.y = e.y;
+ }
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ /* do nothing */
+ }
+ };
+
+ shell.addMouseListener(shellMouseListener);
+
+ shellCloseListener = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ logger.info("Key Window is closed");
+
+ if (skin.pairTagCanvas != null) {
+ skin.pairTagCanvas.setVisible(false);
+ }
+ skin.setIsControlPanel(false);
+ skin.keyWindow = null;
+
+ if (null != shellPaintListener) {
+ shell.removePaintListener(shellPaintListener);
+ }
+
+ if (null != shellMouseMoveListener) {
+ shell.removeMouseMoveListener(shellMouseMoveListener);
+ }
+
+ if (null != shellMouseListener) {
+ shell.removeMouseListener(shellMouseListener);
+ }
+
+ imageNormal.dispose();
+ imageHover.dispose();
+ imagePushed.dispose();
+ colorFrame.dispose();
+
+ frameMaker.freePatches();
+ }
+ };
+
+ shell.addListener(SWT.Close, shellCloseListener);
+ }
+
+ public Color getPairTagColor() {
+ return colorPairTag;
+ }
+}
--- /dev/null
+/**
+ *
+ *
+ * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@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.skin.custom;
+
+import java.util.logging.Logger;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.skin.log.SkinLogger;
+
+public class SkinWindow {
+ protected Logger logger = SkinLogger.getSkinLogger(
+ SkinWindow.class).getLogger();
+
+ protected Shell shell;
+ protected Shell parent;
+ private int dockPosition;
+
+ public SkinWindow(Shell parent, int dockPosition) {
+ this.parent = parent;
+ this.dockPosition = dockPosition;
+ }
+
+ public Shell getShell() {
+ return shell;
+ }
+
+ public void open(int dockValue) {
+ if (shell.isDisposed()) {
+ return;
+ }
+
+ dock(dockValue, true, true);
+
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!shell.getDisplay().readAndDispatch()) {
+ shell.getDisplay().sleep();
+ }
+ }
+ }
+
+ public void dock(int dockValue,
+ boolean correction, boolean enableLogger) {
+ int x = 0;
+ int y = 0;
+
+ Rectangle monitorBounds = Display.getDefault().getBounds();
+ Rectangle parentBounds = parent.getBounds();
+ Rectangle childBounds = shell.getBounds();
+
+ if (enableLogger == true) {
+ logger.info("host monitor display bounds : " + monitorBounds);
+ logger.info("current parent shell bounds : " + parentBounds);
+ logger.info("current child shell bounds : " + childBounds);
+ }
+
+ dockPosition = dockValue;
+
+ if (dockPosition == SWT.NONE){
+ logger.info("undock");
+ /* do nothing */
+
+ return;
+ } else if (dockPosition == (SWT.RIGHT | SWT.TOP)) {
+ x = parentBounds.x + parentBounds.width;
+ y = parentBounds.y;
+
+ /* correction of location */
+ /*if ((x + childBounds.width) >
+ (monitorBounds.x + monitorBounds.width)) {
+ x = parentBounds.x - childBounds.width;
+ }*/
+ } else if (dockPosition == (SWT.RIGHT | SWT.BOTTOM)) {
+ x = parentBounds.x + parentBounds.width;
+ y = parentBounds.y + parentBounds.height - childBounds.height;
+
+ /* correction of location */
+ /*int shift = (monitorBounds.x + monitorBounds.width) -
+ (x + childBounds.width);
+ if (shift < 0) {
+ x += shift;
+ parent.setLocation(parentBounds.x + shift, parentBounds.y);
+ }*/
+ } else { /* SWT.RIGHT | SWT.CENTER */
+ x = parentBounds.x + parentBounds.width;
+ y = parentBounds.y + (parentBounds.height / 2) -
+ (childBounds.height / 2);
+ }
+
+ /* correction of location */
+ if (correction == true) {
+ int shift = (monitorBounds.x + monitorBounds.width) -
+ (x + childBounds.width);
+ if (shift < 0) {
+ x += shift;
+ parent.setLocation(parentBounds.x + shift, parentBounds.y);
+ }
+ }
+
+ shell.setLocation(x, y);
+ }
+
+ public int getDockPosition() {
+ return dockPosition;
+ }
+}
import org.tizen.emulator.skin.config.EmulatorConfig;
import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
+import org.tizen.emulator.skin.custom.CustomButton;
+import org.tizen.emulator.skin.custom.CustomProgressBar;
import org.tizen.emulator.skin.image.ImageRegistry;
import org.tizen.emulator.skin.image.ImageRegistry.IconName;
import org.tizen.emulator.skin.log.SkinLogger;
import org.tizen.emulator.skin.util.SkinRotation;
import org.tizen.emulator.skin.util.SkinUtil;
import org.tizen.emulator.skin.util.SwtUtil;
-import org.tizen.emulator.skin.window.CustomProgressBar;
-import org.tizen.emulator.skin.window.ImageButton;
public class GeneralPurposeSkinComposer implements ISkinComposer {
private static final String PATCH_IMAGES_PATH = "images/emul-window/";
private EmulatorSkin skin;
private Shell shell;
private Canvas lcdCanvas;
- private ImageButton toggleButton;
+ private CustomButton toggleButton;
private EmulatorSkinState currentState;
private ImageRegistry imageRegistry;
loader.getResourceAsStream(PATCH_IMAGES_PATH + "arrow_pushed.png"));
/* create a toggle button of key window */
- toggleButton = new ImageButton(shell, SWT.DRAW_TRANSPARENT | SWT.NO_FOCUS,
+ toggleButton = new CustomButton(shell, SWT.DRAW_TRANSPARENT | SWT.NO_FOCUS,
imageNormal, imageHover, imagePushed);
toggleButton.setBackground(
new Color(shell.getDisplay(), new RGB(0x1f, 0x1f, 0x1f)));
import org.tizen.emulator.skin.config.EmulatorConfig;
import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
+import org.tizen.emulator.skin.custom.CustomProgressBar;
import org.tizen.emulator.skin.dbi.LcdType;
import org.tizen.emulator.skin.dbi.RegionType;
import org.tizen.emulator.skin.dbi.RotationType;
import org.tizen.emulator.skin.util.SkinRotation;
import org.tizen.emulator.skin.util.SkinUtil;
import org.tizen.emulator.skin.util.SwtUtil;
-import org.tizen.emulator.skin.window.CustomProgressBar;
public class PhoneShapeSkinComposer implements ISkinComposer {
private Logger logger = SkinLogger.getSkinLogger(
+++ /dev/null
-/**
- *
- *
- * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@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.skin.window;
-
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.graphics.Region;
-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.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.tizen.emulator.skin.EmulatorSkin;
-import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType;
-import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
-import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
-import org.tizen.emulator.skin.comm.sock.data.KeyEventData;
-import org.tizen.emulator.skin.dbi.KeyMapType;
-import org.tizen.emulator.skin.layout.SkinPatches;
-import org.tizen.emulator.skin.util.SwtUtil;
-
-public class ControlPanel extends SkinWindow {
- private static final String PATCH_IMAGES_PATH = "images/key-window/";
- private static final int SHELL_MARGIN_BOTTOM = 3;
- private static final int PAIRTAG_CIRCLE_SIZE = 8;
- private static final int PAIRTAG_MARGIN_BOTTOM = 6;
- private static final int BUTTON_DEFAULT_CNT = 4;
- private static final int BUTTON_VERTICAL_SPACING = 7;
-
- private EmulatorSkin skin;
- private SkinPatches frameMaker;
- private Image imageNormal; /* ImageButton image */
- private Image imageHover; /* hovered ImageButton image */
- private Image imagePushed; /* pushed ImageButton image */
- private Image imageFrame; /* nine-patch image */
- private Color colorFrame;
- private Color colorPairTag;
- private SocketCommunicator communicator;
- private List<KeyMapType> keyMapList;
-
- private PaintListener shellPaintListener;
- private MouseMoveListener shellMouseMoveListener;
- private MouseListener shellMouseListener;
- private Listener shellCloseListener;
-
- private boolean isGrabbedShell;
- private Point grabPosition;
-
- public ControlPanel(EmulatorSkin skin, Shell parent, Color colorPairTag,
- SocketCommunicator communicator, List<KeyMapType> keyMapList) {
- super(parent, SWT.RIGHT | SWT.CENTER);
-
- this.skin = skin;
- this.shell = new Shell(Display.getDefault(), SWT.NO_TRIM | SWT.RESIZE);
- this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH);
- this.colorPairTag = colorPairTag;
-
- this.keyMapList = keyMapList;
- this.communicator = communicator;
- this.grabPosition = new Point(0, 0);
-
- shell.setText(parent.getText());
- shell.setImage(parent.getImage());
-
- /* load image for HW key button */
- ClassLoader loader = this.getClass().getClassLoader();
- imageNormal = new Image(Display.getDefault(),
- loader.getResourceAsStream(PATCH_IMAGES_PATH + "keybutton_nml.png"));
- imageHover = new Image(Display.getDefault(),
- loader.getResourceAsStream(PATCH_IMAGES_PATH + "keybutton_hover.png"));
- imagePushed = new Image(Display.getDefault(),
- loader.getResourceAsStream(PATCH_IMAGES_PATH + "keybutton_pushed.png"));
-
- /* calculate the key window size */
- int width = imageNormal.getImageData().width;
- int height = (imageNormal.getImageData().height * BUTTON_DEFAULT_CNT) +
- (BUTTON_VERTICAL_SPACING * (BUTTON_DEFAULT_CNT - 1)) +
- (PAIRTAG_CIRCLE_SIZE + PAIRTAG_MARGIN_BOTTOM) +
- SHELL_MARGIN_BOTTOM;
-
- /* make a frame image */
- this.imageFrame = frameMaker.getPatchedImage(width, height);
- this.colorFrame = new Color(shell.getDisplay(), new RGB(38, 38, 38));
-
-// /* generate a pair tag color of key window */
-// int red = (int) (Math.random() * 256);
-// int green = (int) (Math.random() * 256);
-// int blue = (int) (Math.random() * 256);
-// this.colorPairTag = new Color(shell.getDisplay(), new RGB(red, green, blue));
- this.colorPairTag = colorPairTag;
-
- createContents();
- trimPatchedShell(shell, imageFrame);
- addControlPanelListener();
-
- shell.setBackground(colorFrame);
- shell.setSize(imageFrame.getImageData().width,
- imageFrame.getImageData().height);
- }
-
- protected void createContents() {
- GridLayout shellGridLayout = new GridLayout(1, false);
- shellGridLayout.marginLeft = shellGridLayout.marginRight = frameMaker.getPatchWidth();
- shellGridLayout.marginTop = shellGridLayout.marginBottom = frameMaker.getPatchHeight();
- shellGridLayout.marginWidth = shellGridLayout.marginHeight = 0;
- shellGridLayout.horizontalSpacing = shellGridLayout.verticalSpacing = 0;
-
- shell.setLayout(shellGridLayout);
-
- /* make a pair tag circle */
- Canvas pairTagCanvas = new Canvas(shell, SWT.NONE);
- pairTagCanvas.setBackground(colorFrame);
- pairTagCanvas.setLayoutData(new GridData(PAIRTAG_CIRCLE_SIZE,
- PAIRTAG_CIRCLE_SIZE + PAIRTAG_MARGIN_BOTTOM));
-
- pairTagCanvas.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- if (colorPairTag != null) {
- e.gc.setBackground(colorPairTag);
- e.gc.setAntialias(SWT.ON);
- e.gc.fillOval(0, 0, PAIRTAG_CIRCLE_SIZE, PAIRTAG_CIRCLE_SIZE);
- }
- }
- });
-
- /* */
- ScrolledComposite compositeScroll = new ScrolledComposite(shell, SWT.V_SCROLL);
- compositeScroll.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1));
-
- Composite compositeBase = new Composite(compositeScroll, SWT.NONE);
- compositeBase.setBackground(colorFrame);
-
- GridLayout compositeGridLayout = new GridLayout(1, false);
- compositeGridLayout.marginLeft = compositeGridLayout.marginRight = 0;
- compositeGridLayout.marginTop = compositeGridLayout.marginBottom = 0;
- compositeGridLayout.marginWidth = compositeGridLayout.marginHeight = 0;
- compositeGridLayout.horizontalSpacing = 0;
- compositeGridLayout.verticalSpacing = BUTTON_VERTICAL_SPACING;
- compositeBase.setLayout(compositeGridLayout);
-
- if (keyMapList != null && keyMapList.isEmpty() == false) {
- for (KeyMapType keyEntry : keyMapList) {
- ImageButton HWKeyButton = new ImageButton(compositeBase, SWT.NONE,
- imageNormal, imageHover, imagePushed);
- HWKeyButton.setText(keyEntry.getEventInfo().getKeyName());
- HWKeyButton.setToolTipText(keyEntry.getTooltip());
- HWKeyButton.setBackground(colorFrame);
- HWKeyButton.setLayoutData(new GridData(imageNormal.getImageData().width,
- imageNormal.getImageData().height));
-
- final int keycode = keyEntry.getEventInfo().getKeyCode();
- HWKeyButton.addMouseListener(new MouseListener() {
- @Override
- public void mouseDown(MouseEvent e) {
- KeyEventData keyEventData = new KeyEventData(
- KeyEventType.PRESSED.value(), keycode, 0, 0);
- communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData);
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- KeyEventData keyEventData = new KeyEventData(
- KeyEventType.RELEASED.value(), keycode, 0, 0);
- communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData);
- }
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- /* do nothing */
- }
- });
- }
- }
-
- compositeScroll.setContent(compositeBase);
- compositeScroll.setExpandHorizontal(true);
- compositeScroll.setExpandVertical(true);
- compositeScroll.setMinSize(compositeBase.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- }
-
- public static void trimPatchedShell(Shell shell, Image image) {
- if (null == image) {
- return;
- }
- ImageData imageData = image.getImageData();
-
- int width = imageData.width;
- int height = imageData.height;
-
- Region region = new Region();
- region.add(new Rectangle(0, 0, width, height));
-
- int r = shell.getDisplay().getSystemColor(SWT.COLOR_MAGENTA).getRed();
- int g = shell.getDisplay().getSystemColor(SWT.COLOR_MAGENTA).getGreen();
- int b = shell.getDisplay().getSystemColor(SWT.COLOR_MAGENTA).getBlue();
- int colorKey;
-
- if (SwtUtil.isWindowsPlatform()) {
- colorKey = r << 24 | g << 16 | b << 8;
- } else {
- colorKey = r << 16 | g << 8 | b;
- }
-
- for (int i = 0; i < width; i++) {
- for (int j = 0; j < height; j++) {
- int colorPixel = imageData.getPixel(i, j);
- if (colorPixel == colorKey /* magenta */) {
- region.subtract(i, j, 1, 1);
- }
- }
- }
-
- shell.setRegion(region);
- }
-
- private void addControlPanelListener() {
- shellPaintListener = new PaintListener() {
- @Override
- public void paintControl(final PaintEvent e) {
- if (imageFrame != null) {
- e.gc.drawImage(imageFrame, 0, 0);
- }
- }
- };
-
- shell.addPaintListener(shellPaintListener);
-
- shellMouseMoveListener = new MouseMoveListener() {
- @Override
- public void mouseMove(MouseEvent e) {
- if (isGrabbedShell == true && e.button == 0/* left button */) {
- /* move a window */
- Point previousLocation = shell.getLocation();
- int x = previousLocation.x + (e.x - grabPosition.x);
- int y = previousLocation.y + (e.y - grabPosition.y);
-
- shell.setLocation(x, y);
- return;
- }
- }
- };
-
- shell.addMouseMoveListener(shellMouseMoveListener);
-
- shellMouseListener = new MouseListener() {
- @Override
- public void mouseUp(MouseEvent e) {
- if (e.button == 1) { /* left button */
- isGrabbedShell = false;
- grabPosition.x = grabPosition.y = 0;
-
- /* Let me check whether the key window was landed
- * on docking area. */
- Rectangle parentBounds = parent.getBounds();
- Rectangle childBounds = shell.getBounds();
-
- int heightOneThird = parentBounds.height / 3;
-
- /* right-middle */
- Rectangle attachBounds1 = new Rectangle(
- (parentBounds.x + parentBounds.width) - 5,
- parentBounds.y + heightOneThird,
- 30, heightOneThird);
- /* right-top */
- Rectangle attachBounds2 = new Rectangle(
- (parentBounds.x + parentBounds.width) - 5,
- parentBounds.y,
- 30, heightOneThird);
- /* right-bottom */
- Rectangle attachBounds3 = new Rectangle(
- (parentBounds.x + parentBounds.width) - 5,
- parentBounds.y + (heightOneThird * 2),
- 30, heightOneThird);
-
- if (childBounds.intersects(attachBounds1) == true) {
- dock(SWT.RIGHT | SWT.CENTER, false, true);
- } else if (childBounds.intersects(attachBounds2) == true) {
- dock(SWT.RIGHT | SWT.TOP, false, true);
- } else if (childBounds.intersects(attachBounds3) == true) {
- dock(SWT.RIGHT | SWT.BOTTOM, false, true);
- } else {
- dock(SWT.NONE, false, true);
- }
- }
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- if (1 == e.button) { /* left button */
- isGrabbedShell = true;
- grabPosition.x = e.x;
- grabPosition.y = e.y;
- }
- }
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- /* do nothing */
- }
- };
-
- shell.addMouseListener(shellMouseListener);
-
- shellCloseListener = new Listener() {
- @Override
- public void handleEvent(Event event) {
- logger.info("Key Window is closed");
-
- if (skin.pairTagCanvas != null) {
- skin.pairTagCanvas.setVisible(false);
- }
- skin.setIsControlPanel(false);
- skin.keyWindow = null;
-
- if (null != shellPaintListener) {
- shell.removePaintListener(shellPaintListener);
- }
-
- if (null != shellMouseMoveListener) {
- shell.removeMouseMoveListener(shellMouseMoveListener);
- }
-
- if (null != shellMouseListener) {
- shell.removeMouseListener(shellMouseListener);
- }
-
- imageNormal.dispose();
- imageHover.dispose();
- imagePushed.dispose();
- colorFrame.dispose();
-
- frameMaker.freePatches();
- }
- };
-
- shell.addListener(SWT.Close, shellCloseListener);
- }
-
- public Color getPairTagColor() {
- return colorPairTag;
- }
-}
+++ /dev/null
-/**
- *
- *
- * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@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.skin.window;
-
-import java.util.logging.Logger;
-
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.emulator.skin.log.SkinLogger;
-
-public class CustomProgressBar extends Canvas {
- private Logger logger =
- SkinLogger.getSkinLogger(CustomProgressBar.class).getLogger();
-
- private Composite parent;
- private int selection;
-
- public CustomProgressBar(final Composite parent, int style) {
- super(parent, style);
-
- this.parent = parent;
- this.selection = 0;
-
- this.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- e.gc.setBackground(
- new Color(parent.getDisplay(), new RGB(0, 173, 239)));
-
- Rectangle bounds = getBounds();
- int width = (bounds.width * selection) / 100;
- e.gc.fillRectangle(0, 0, width, bounds.height);
-
- if (selection == -1) {
- logger.info("progress : complete!");
-
- parent.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- dispose();
- }
- });
- }
- }
- });
-
- /* default is hidden */
- parent.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- setVisible(false);
- }
- });
- }
-
- public void setSelection(int value) {
- parent.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- setVisible(true);
- }
- });
-
- if (value < 0) {
- value = 0;
- } else if (value > 100) {
- value = 100;
- }
-
- selection = value;
- logger.info("progress : " + selection);
-
- parent.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- redraw();
-
- if (selection == 100) {
- selection = -1;
- }
- }
- });
- }
-
- public int getSelection() {
- return selection;
- }
-}
+++ /dev/null
-/**
- *
- *
- * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@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.skin.window;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseTrackAdapter;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-
-public class ImageButton extends Canvas {
- /* state */
- private int mouse = 0;
- private boolean hit = false;
-
- /* image - 0 : normal, 1 : hover, 2 : pushed */
- private Image imageButton[];
-
- private int width;
- private int height;
- private String text;
- private int textPositionX;
- private int textPositionY;
- private static Color white;
- private static Color gray;
-
- public ImageButton(Composite parent, int style,
- Image imageNormal, Image imageHover, Image imagePushed) {
- super(parent, style);
-
- this.imageButton = new Image[3];
- imageButton[0] = imageNormal;
- imageButton[1] = imageHover;
- imageButton[2] = imagePushed;
-
- this.width = imageNormal.getImageData().width;
- this.height = imageNormal.getImageData().height;
-
- this.text = null;
- textPositionX = width / 2;
- textPositionY = height / 2;
- white = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
- gray = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
-
- this.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- switch (mouse) {
- case 0: /* default state */
- if (imageButton[0] != null) {
- e.gc.drawImage(imageButton[0], 0, 0);
- }
-
- if (text != null) {
- e.gc.setForeground(white);
- e.gc.drawText(text,
- textPositionX, textPositionY, true);
- }
-
- break;
- case 1: /* mouse over */
- if (imageButton[1] != null) {
- e.gc.drawImage(imageButton[1], 0, 0);
- }
-
- if (text != null) {
- e.gc.setForeground(white);
- e.gc.drawText(text,
- textPositionX, textPositionY, true);
- }
-
- break;
- case 2: /* mouse down */
- if (imageButton[2] != null) {
- e.gc.drawImage(imageButton[2], 0, 0);
- }
-
- if (text != null) {
- e.gc.setForeground(gray);
- e.gc.drawText(text,
- textPositionX, textPositionY, true);
- }
-
- break;
- default:
- break;
- }
- }
- });
-
- this.addMouseMoveListener(new MouseMoveListener() {
- @Override
- public void mouseMove(MouseEvent e) {
- if (!hit) {
- return;
- }
-
- mouse = 2;
-
- if (e.x < 0 || e.y < 0 ||
- e.x > getBounds().width || e.y > getBounds().height) {
- mouse = 0;
- }
-
- redraw();
- }
- });
-
- this.addMouseTrackListener(new MouseTrackAdapter() {
- @Override
- public void mouseEnter(MouseEvent e) {
- mouse = 1;
-
- redraw();
- }
-
- @Override
- public void mouseExit(MouseEvent e) {
- mouse = 0;
-
- redraw();
- }
- });
-
- this.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseDown(MouseEvent e) {
- hit = true;
- mouse = 2;
-
- redraw();
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- hit = false;
- mouse = 1;
-
- if (e.x < 0 || e.y < 0 ||
- e.x > getBounds().width || e.y > getBounds().height) {
- mouse = 0;
- }
-
- redraw();
-
- if (mouse == 1) {
- notifyListeners(SWT.Selection, new Event());
- }
- }
- });
-
- this.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- if (e.keyCode == '\r' || e.character == ' ') {
- Event event = new Event();
- notifyListeners(SWT.Selection, event);
- }
- }
- });
- }
-
- public void setText(String textValue) {
- /* checking whether the text value is appropriate */
- if (textValue == null || textValue.isEmpty()) {
- return;
- }
-
- GC gc = new GC(this);
- Point textSize = gc.textExtent(textValue);
- Point originalSize = textSize;
-
- while (textSize.x >= (width - 10)) {
- textValue = textValue.substring(0, textValue.length() - 1);
- textSize = gc.textExtent(textValue);
- }
-
- if (originalSize.x != textSize.x) {
- textValue = textValue.substring(0, textValue.length() - 1);
- textValue += "..";
- textSize = gc.textExtent(textValue);
- }
-
- gc.dispose();
-
- /* set text */
- text = textValue;
-
- textPositionX -= textSize.x / 2;
- if (textPositionX < 0) {
- textPositionX = 0;
- }
-
- textPositionY -= textSize.y / 2;
- if (textPositionY < 0) {
- textPositionY = 0;
- }
- }
-
- public String getText() {
- return text;
- }
-
- public Point getImageSize() {
- return new Point(imageButton[0].getImageData().width,
- imageButton[0].getImageData().height);
- }
-}
\ No newline at end of file
+++ /dev/null
-/**
- *
- *
- * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@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.skin.window;
-
-import java.util.logging.Logger;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.tizen.emulator.skin.log.SkinLogger;
-
-public class SkinWindow {
- protected Logger logger = SkinLogger.getSkinLogger(
- SkinWindow.class).getLogger();
-
- protected Shell shell;
- protected Shell parent;
- private int dockPosition;
-
- public SkinWindow(Shell parent, int dockPosition) {
- this.parent = parent;
- this.dockPosition = dockPosition;
- }
-
- public Shell getShell() {
- return shell;
- }
-
- public void open(int dockValue) {
- if (shell.isDisposed()) {
- return;
- }
-
- dock(dockValue, true, true);
-
- shell.open();
-
- while (!shell.isDisposed()) {
- if (!shell.getDisplay().readAndDispatch()) {
- shell.getDisplay().sleep();
- }
- }
- }
-
- public void dock(int dockValue,
- boolean correction, boolean enableLogger) {
- int x = 0;
- int y = 0;
-
- Rectangle monitorBounds = Display.getDefault().getBounds();
- Rectangle parentBounds = parent.getBounds();
- Rectangle childBounds = shell.getBounds();
-
- if (enableLogger == true) {
- logger.info("host monitor display bounds : " + monitorBounds);
- logger.info("current parent shell bounds : " + parentBounds);
- logger.info("current child shell bounds : " + childBounds);
- }
-
- dockPosition = dockValue;
-
- if (dockPosition == SWT.NONE){
- logger.info("undock");
- /* do nothing */
-
- return;
- } else if (dockPosition == (SWT.RIGHT | SWT.TOP)) {
- x = parentBounds.x + parentBounds.width;
- y = parentBounds.y;
-
- /* correction of location */
- /*if ((x + childBounds.width) >
- (monitorBounds.x + monitorBounds.width)) {
- x = parentBounds.x - childBounds.width;
- }*/
- } else if (dockPosition == (SWT.RIGHT | SWT.BOTTOM)) {
- x = parentBounds.x + parentBounds.width;
- y = parentBounds.y + parentBounds.height - childBounds.height;
-
- /* correction of location */
- /*int shift = (monitorBounds.x + monitorBounds.width) -
- (x + childBounds.width);
- if (shift < 0) {
- x += shift;
- parent.setLocation(parentBounds.x + shift, parentBounds.y);
- }*/
- } else { /* SWT.RIGHT | SWT.CENTER */
- x = parentBounds.x + parentBounds.width;
- y = parentBounds.y + (parentBounds.height / 2) -
- (childBounds.height / 2);
- }
-
- /* correction of location */
- if (correction == true) {
- int shift = (monitorBounds.x + monitorBounds.width) -
- (x + childBounds.width);
- if (shift < 0) {
- x += shift;
- parent.setLocation(parentBounds.x + shift, parentBounds.y);
- }
- }
-
- shell.setLocation(x, y);
- }
-
- public int getDockPosition() {
- return dockPosition;
- }
-}