From: giwoong.kim Date: Sun, 21 Oct 2012 06:41:01 +0000 (+0900) Subject: skin: added SkinWindow file X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1409^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=47f46f206cd88de78e1e5a032f6787d2764fc461;p=sdk%2Femulator%2Fqemu.git skin: added SkinWindow file I've added a base class that is type of skin's child window. Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java index 1ef346452a..e19c8eaf57 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -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 index 0000000000..fd08674462 --- /dev/null +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/window/ControlPanel.java @@ -0,0 +1,41 @@ +/** + * + * + * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * YeongKyoon Lee + * + * 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 index 0000000000..f1cd301663 --- /dev/null +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/window/SkinWindow.java @@ -0,0 +1,101 @@ +/** + * + * + * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * YeongKyoon Lee + * + * 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); + } +}