skin: arrange the HW keys region in general skin
authorgiwoong.kim <giwoong.kim@samsung.com>
Tue, 30 Oct 2012 02:21:23 +0000 (11:21 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Tue, 30 Oct 2012 12:04:57 +0000 (21:04 +0900)
I've add a HW keys region to internal of general skin.
And disable the control panel menu.

Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java

index 357666c..f3562a8 100644 (file)
@@ -66,8 +66,14 @@ 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.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
 import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Decorations;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;
@@ -104,7 +110,6 @@ import org.tizen.emulator.skin.util.SkinRegion;
 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.SkinWindow;
 
 /**
@@ -248,7 +253,7 @@ public class EmulatorSkin {
                        int x, int y, int resolutionW, int resolutionH,
                        int scale, short rotationId, boolean isOnKbd) {
 
-               shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+               //shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
                shell.setLocation(x, y);
 
                String emulatorName = SkinUtil.makeEmulatorName(config);
@@ -385,7 +390,79 @@ public class EmulatorSkin {
                this.currentRotationId = rotationId;
                this.currentAngle = SkinRotation.getAngle( rotationId );
 
-               if (skinMode != SkinMode.GENERAL) {
+               if (skinMode == SkinMode.GENERAL) {
+                       /* folding button */
+                       Button foldingButton = new Button(shell, SWT.PUSH);
+                       foldingButton.setText(">");
+
+                       FormData dataFoldingButton = new FormData();
+                       dataFoldingButton.left = new FormAttachment(lcdCanvas, 0);
+                       dataFoldingButton.top = new FormAttachment(0, 0);
+                       foldingButton.setLayoutData(dataFoldingButton);
+
+                       foldingButton.addMouseListener(new MouseListener() {
+                               @Override
+                               public void mouseDown(MouseEvent e) {
+                                       /* do nothing */
+                               }
+
+                               @Override
+                               public void mouseUp(MouseEvent e) {
+                                       //TODO:
+                               }
+
+                               @Override
+                               public void mouseDoubleClick(MouseEvent e) {
+                                       /* do nothing */
+                               }
+                       });
+
+                       /* HW keys region */
+                       Decorations decoration = new Decorations(shell, SWT.BORDER);
+                       decoration.setLayout(new GridLayout(1, true));
+
+                       RotationType rotation = SkinRotation.getRotation(currentRotationId);
+                       List<KeyMapType> keyMapList = rotation.getKeyMapList().getKeyMap();
+
+                       // TODO: function
+                       if (keyMapList != null && keyMapList.isEmpty() == false) {
+                               for (KeyMapType keyEntry : keyMapList) {
+                                       Button hardKeyButton = new Button(decoration, SWT.FLAT);
+                                       hardKeyButton.setText(keyEntry.getEventInfo().getKeyName());
+                                       hardKeyButton.setToolTipText(keyEntry.getTooltip());
+
+                                       hardKeyButton.setLayoutData(new GridData(SWT.FILL,      SWT.FILL, true, false));
+
+                                       final int keycode = keyEntry.getEventInfo().getKeyCode();
+                                       hardKeyButton.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 */
+                                               }
+                                       });
+                               }
+                       }
+
+                       FormData dataDecoration = new FormData();
+                       dataDecoration.left = new FormAttachment(foldingButton, 0);
+                       dataDecoration.top = new FormAttachment(0, 0);
+                       decoration.setLayoutData(dataDecoration);
+               } else {
                        Image tempImage = null;
                        Image tempKeyPressedImage = null;
 
@@ -2091,7 +2168,7 @@ public class EmulatorSkin {
                final Menu menu = new Menu(shell, SWT.DROP_DOWN);
 
                /* Control Panel menu */
-               final MenuItem panelItem = new MenuItem(menu, SWT.PUSH);
+               /*final MenuItem panelItem = new MenuItem(menu, SWT.PUSH);
                panelItem.setText("&Control Panel");
                //panelItem.setImage(imageRegistry.getIcon(IconName.XXX));
                panelItem.addSelectionListener(new SelectionAdapter() {
@@ -2114,7 +2191,7 @@ public class EmulatorSkin {
                                        controlPanel = null;
                                }
                        }
-               } );
+               } );*/
 
                /* Screen shot menu */
                final MenuItem screenshotItem = new MenuItem(menu, SWT.PUSH);