skin: added SkinWindow file
authorgiwoong.kim <giwoong.kim@samsung.com>
Sun, 21 Oct 2012 06:41:01 +0000 (15:41 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Sun, 21 Oct 2012 06:43:01 +0000 (15:43 +0900)
I've added a base class that is type of skin's child window.

Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/window/ControlPanel.java [new file with mode: 0644]
tizen/src/skin/client/src/org/tizen/emulator/skin/window/SkinWindow.java [new file with mode: 0644]

index 1ef346452ad559df9e71f6a86c56cbe75b64b584..e19c8eaf57639977a1a7b0f68cb66d93e6974b9f 100644 (file)
@@ -92,7 +92,6 @@ import org.tizen.emulator.skin.dbi.RotationType;
 import org.tizen.emulator.skin.dialog.AboutDialog;
 import org.tizen.emulator.skin.dialog.DetailInfoDialog;
 import org.tizen.emulator.skin.dialog.RamdumpDialog;
-import org.tizen.emulator.skin.exception.ScreenShotException;
 import org.tizen.emulator.skin.image.ImageRegistry;
 import org.tizen.emulator.skin.image.ImageRegistry.IconName;
 import org.tizen.emulator.skin.image.ImageRegistry.ImageType;
@@ -103,6 +102,8 @@ 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;
 
 /**
  * 
@@ -164,6 +165,7 @@ public class EmulatorSkin {
        private boolean isOnTop;
        private boolean isOnUsbKbd;
 
+       private SkinWindow controlPanel;
        protected ScreenShotDialog screenShotDialog;
        private Menu contextMenu;
 
@@ -494,15 +496,24 @@ public class EmulatorSkin {
                                        removeCanvasListeners();
 
                                        if ( !isAboutToReopen ) {
-
+                                               /* close the screen shot window */
                                                if (null != screenShotDialog) {
                                                        Shell scShell = screenShotDialog.getShell();
-                                                       if ( !scShell.isDisposed() ) {
+                                                       if (!scShell.isDisposed()) {
                                                                scShell.close();
                                                        }
                                                        screenShotDialog = null;
                                                }
 
+                                               /* close the control panel window */
+                                               if (null != controlPanel) {
+                                                       Shell cpShell = controlPanel.getShell();
+                                                       if (!cpShell.isDisposed()) {
+                                                               cpShell.close();
+                                                       }
+                                                       controlPanel = null;
+                                               }
+
                                                // save config only for emulator close
                                                config.setSkinProperty( SkinPropertiesConstants.WINDOW_X, shell.getLocation().x );
                                                config.setSkinProperty( SkinPropertiesConstants.WINDOW_Y, shell.getLocation().y );
@@ -2121,18 +2132,42 @@ public class EmulatorSkin {
                return menu;
        }
 
-       private Menu createAdvancedMenu( final Shell shell ) {
+       private Menu createAdvancedMenu(final Shell shell) {
 
-               final Menu menu = new Menu( shell, SWT.DROP_DOWN );
+               final Menu menu = new Menu(shell, SWT.DROP_DOWN);
 
-               /* Screen shot menu */
-               final MenuItem screenshotItem = new MenuItem( menu, SWT.PUSH );
-               screenshotItem.setText( "&Screen Shot" );
-               screenshotItem.setImage( imageRegistry.getIcon( IconName.SCREENSHOT ) );
-               screenshotItem.addSelectionListener( new SelectionAdapter() {
+               /* 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;
+                               }
+
+                               try {
+                                       controlPanel = new ControlPanel(shell);
+                                       controlPanel.open();
+                               } finally {
+                                       controlPanel = null;
+                               }
+                       }
+               } );*/
 
+               /* Screen shot menu */
+               final MenuItem screenshotItem = new MenuItem(menu, SWT.PUSH);
+               screenshotItem.setText("&Screen Shot");
+               screenshotItem.setImage(imageRegistry.getIcon(IconName.SCREENSHOT));
+               screenshotItem.addSelectionListener(new SelectionAdapter() {
                        @Override
-                       public void widgetSelected( SelectionEvent e ) {
+                       public void widgetSelected(SelectionEvent e) {
+                               logger.info("ScreenShot Menu is selected");
+
                                openScreenShotWindow();
                        }
                } );
diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/window/ControlPanel.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/window/ControlPanel.java
new file mode 100644 (file)
index 0000000..fd08674
--- /dev/null
@@ -0,0 +1,41 @@
+/**
+ *
+ *
+ * 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.widgets.Shell;
+
+public class ControlPanel extends SkinWindow {
+
+       public ControlPanel(Shell parent) {
+               super(parent);
+       }
+
+       protected void createContents() {
+       }
+}
diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/window/SkinWindow.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/window/SkinWindow.java
new file mode 100644 (file)
index 0000000..f1cd301
--- /dev/null
@@ -0,0 +1,101 @@
+/**
+ *
+ *
+ * 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 {
+       private Logger logger = SkinLogger.getSkinLogger(
+                                       SkinWindow.class).getLogger();
+
+       protected Shell shell;
+       protected Shell parent;
+
+       public SkinWindow(Shell parent) {
+               this.shell = new Shell(Display.getDefault(),
+                               SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX);
+               this.parent = parent;
+
+               createContents();
+       }
+
+       public Shell getShell() {
+               return shell;
+       }
+
+       public void open() {
+               if (shell.isDisposed()) {
+                       return;
+               }
+
+               shell.pack();
+
+               setShellSize();
+               setShellPosition();
+
+               shell.open();
+
+               while (!shell.isDisposed()) {
+                       if (!shell.getDisplay().readAndDispatch()) {
+                               shell.getDisplay().sleep();
+                       }
+               }
+       }
+
+       protected void createContents() {
+       }
+
+       protected void setShellSize() {
+               shell.setSize(100, 300);
+       }
+
+       protected void setShellPosition() {
+               Rectangle monitorBound = Display.getDefault().getBounds();
+               logger.info("host monitor display bound : " + monitorBound);
+               Rectangle emulatorBound = parent.getBounds();
+               logger.info("current Emulator window bound : " + emulatorBound);
+               Rectangle panelBound = shell.getBounds();
+               logger.info("current Panel shell bound : " + panelBound);
+
+               /* location correction */
+               int x = emulatorBound.x + emulatorBound.width;
+               int y = emulatorBound.y;
+               if ((x + panelBound.width) > (monitorBound.x + monitorBound.width)) {
+                       x = emulatorBound.x - panelBound.width;
+               }
+
+               shell.setLocation(x, y);
+       }
+}