import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
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.dbi.RotationType;
import org.tizen.emulator.skin.dialog.AboutDialog;
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.SkinWindow;
+import org.tizen.emulator.skin.window.ControlPanel;
/**
*
private boolean isOnTop;
private boolean isOnKbd;
- private SkinWindow controlPanel; //not used yet
+ private ControlPanel controlPanel; //not used yet
protected ScreenShotDialog screenShotDialog;
private Menu contextMenu;
Menu scaleMenu = createScaleMenu( menu.getShell() );
scaleItem.setMenu( scaleMenu );
- new MenuItem( menu, SWT.SEPARATOR );
+ new MenuItem(menu, SWT.SEPARATOR);
+
+ /* HW Key Panel menu */
+ /*final MenuItem panelItem = new MenuItem(menu, SWT.PUSH);
+ panelItem.setText("&HW Key Panel");
+
+ panelItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ logger.info("HW Key Panel Menu is selected");
+
+ if (controlPanel != null) {
+ //TODO: move a window focus to controlPanel
+ return;
+ }
+
+ List<KeyMapType> keyMapList =
+ SkinUtil.getHWKeyMapList(currentState.getCurrentRotationId());
+
+ if (keyMapList == null) {
+ logger.info("keyMapList is null");
+ return;
+ } else if (keyMapList.isEmpty() == true) {
+ logger.info("keyMapList is empty");
+ return;
+ }
+
+ try {
+ controlPanel = new ControlPanel(shell, communicator, keyMapList);
+ controlPanel.open();
+ } finally {
+ controlPanel = null;
+ }
+ }
+ } );*/
/* Advanced menu */
final MenuItem advancedItem = new MenuItem( menu, SWT.CASCADE );
final Menu menu = new Menu(shell, SWT.DROP_DOWN);
- /* Control Panel menu */
- /*final MenuItem panelItem = new MenuItem(menu, SWT.PUSH);
- panelItem.setText("&Control Panel");
- //panelItem.setImage(imageRegistry.getIcon(IconName.XXX));
- panelItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- logger.info("Control Panel Menu is selected");
-
- if (controlPanel != null) {
- //TODO: move a window focus to controlPanel
- return;
- }
-
- RotationType rotation = SkinRotation.getRotation(currentRotationId);
- List<KeyMapType> keyMapList = rotation.getKeyMapList().getKeyMap();
-
- try {
- controlPanel = new ControlPanel(shell, communicator, keyMapList);
- controlPanel.open();
- } finally {
- controlPanel = null;
- }
- }
- } );*/
-
/* Screen shot menu */
final MenuItem screenshotItem = new MenuItem(menu, SWT.PUSH);
screenshotItem.setText("&Screen Shot");
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.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType;
import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
public class ControlPanel extends SkinWindow {
private SocketCommunicator communicator;
private List<KeyMapType> keyMapList;
+ private boolean isGrabbedShell;
+ private Point grabPosition;
public ControlPanel(Shell parent,
SocketCommunicator communicator, List<KeyMapType> keyMapList) {
super(parent);
- shell.setText("Control Panel");
+ this.shell = new Shell(Display.getDefault(), SWT.NO_TRIM);
+
this.keyMapList = keyMapList;
this.communicator = communicator;
+ this.grabPosition = new Point(0, 0);
createContents();
+ addControlPanelListener();
+
+ //shell.setSize(160, 100);
}
protected void createContents() {
- shell.setLayout(new GridLayout(1, true));
+ GridLayout gridLayout = new GridLayout(1, true);
+ gridLayout.marginLeft = gridLayout.marginRight = 0;
+ gridLayout.marginTop = gridLayout.marginBottom = 0;
+ gridLayout.marginWidth = gridLayout.marginHeight = 0;
+ gridLayout.horizontalSpacing = gridLayout.verticalSpacing = 0;
+
+ shell.setLayout(gridLayout);
+
+ 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.setLayout(gridLayout);
if (keyMapList != null && keyMapList.isEmpty() == false) {
for (KeyMapType keyEntry : keyMapList) {
- Button hardKeyButton = new Button(shell, SWT.FLAT);
- hardKeyButton.setText(keyEntry.getEventInfo().getKeyName());
- hardKeyButton.setToolTipText(keyEntry.getTooltip());
-
- hardKeyButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ Button HWKeyButton = new Button(compositeBase, SWT.FLAT);
+ HWKeyButton.setText(keyEntry.getEventInfo().getKeyName());
+ HWKeyButton.setToolTipText(keyEntry.getTooltip());
+ HWKeyButton.setSize(102, 28);
+ HWKeyButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
final int keycode = keyEntry.getEventInfo().getKeyCode();
- hardKeyButton.addMouseListener(new MouseListener() {
+ HWKeyButton.addMouseListener(new MouseListener() {
@Override
public void mouseDown(MouseEvent e) {
KeyEventData keyEventData = new KeyEventData(
}
}
+ compositeScroll.setContent(compositeBase);
+ compositeScroll.setExpandHorizontal(true);
+ compositeScroll.setExpandVertical(true);
+ compositeScroll.setMinSize(compositeBase.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ }
+
+ private void addControlPanelListener() {
+ MouseMoveListener shellMouseMoveListener = new MouseMoveListener() {
+ @Override
+ public void mouseMove(MouseEvent e) {
+ if (isGrabbedShell == true && e.button == 0) {
+ /* 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);
+
+ MouseListener shellMouseListener = new MouseListener() {
+ @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 mouseUp(MouseEvent e) {
+ if (e.button == 1) { /* left button */
+ isGrabbedShell = false;
+ grabPosition.x = grabPosition.y = 0;
+ }
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ /* do nothing */
+ }
+ };
+ shell.addMouseListener(shellMouseListener);
}
}
--- /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.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+
+public class ImageButton extends Canvas {
+ private int mouse = 0;
+ private boolean hit = false;
+
+ public ImageButton(Composite parent, int style) {
+ super(parent, style);
+
+ this.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ switch (mouse) {
+ case 0:
+ /* default state */
+ e.gc.drawString("Normal", 5, 5);
+ break;
+ case 1:
+ /* mouse over */
+ e.gc.drawString("Mouse over", 5, 5);
+ break;
+ case 2:
+ /* mouse down */
+ e.gc.drawString("Hit", 5, 5);
+ 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);
+ }
+ }
+ });
+ }
+
+}
\ No newline at end of file
protected Shell parent;
public SkinWindow(Shell parent) {
- this.shell = new Shell(Display.getDefault(),
- SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX);
-
this.parent = parent;
}
return;
}
- shell.pack();
-
- setShellSize();
setShellPosition();
-
shell.open();
while (!shell.isDisposed()) {
}
}
- protected void setShellSize() {
- //shell.setSize(100, 300);
- }
-
protected void setShellPosition() {
Rectangle monitorBound = Display.getDefault().getBounds();
logger.info("host monitor display bound : " + monitorBound);