From 7aa08f6753da9309e1bf516a497d5e5dacedb83e Mon Sep 17 00:00:00 2001 From: "giwoong.kim" Date: Thu, 25 Oct 2012 17:59:15 +0900 Subject: [PATCH] skin: set FormLayout The FormLayout is applied to a Emulator window shell. Signed-off-by: GiWoong Kim --- .../src/org/tizen/emulator/skin/EmulatorSkin.java | 29 ++++++------ .../src/org/tizen/emulator/skin/util/SkinUtil.java | 53 ++++++++++++---------- 2 files changed, 45 insertions(+), 37 deletions(-) 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 b183fe4..bb2c6df 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 @@ -66,6 +66,7 @@ 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.FormLayout; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; @@ -216,7 +217,9 @@ public class EmulatorSkin { } public long compose() { - this.lcdCanvas = new Canvas( shell, SWT.EMBEDDED ); + shell.setLayout(new FormLayout()); + + this.lcdCanvas = new Canvas(shell, SWT.EMBEDDED); //TODO: int x = config.getSkinPropertyInt(SkinPropertiesConstants.WINDOW_X, EmulatorConfig.DEFAULT_WINDOW_X); @@ -230,7 +233,7 @@ public class EmulatorSkin { // EmulatorConfig.DEFAULT_WINDOW_ROTATION ); // has to be portrait mode at first booting time short rotationId = EmulatorConfig.DEFAULT_WINDOW_ROTATION; - + composeInternal(lcdCanvas, x, y, resolutionW, resolutionH, scale, rotationId, false); logger.info("resolution : " + resolutionW + "x" + resolutionH + ", scale : " + scale); @@ -241,21 +244,19 @@ public class EmulatorSkin { int x, int y, int resolutionW, int resolutionH, int scale, short rotationId, boolean isOnUsbKbd) { - lcdCanvas.setBackground( shell.getDisplay().getSystemColor( SWT.COLOR_BLACK ) ); - - imageRegistry = ImageRegistry.getInstance(); - - shell.setBackground( shell.getDisplay().getSystemColor( SWT.COLOR_BLACK ) ); + shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK)); + shell.setLocation(x, y); - shell.setLocation( x, y ); + String emulatorName = SkinUtil.makeEmulatorName(config); + shell.setText(emulatorName); - String emulatorName = SkinUtil.makeEmulatorName( config ); - shell.setText( emulatorName ); + lcdCanvas.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK)); - if ( SwtUtil.isWindowsPlatform() ) { - shell.setImage( imageRegistry.getIcon( IconName.EMULATOR_TITLE_ICO ) ); + imageRegistry = ImageRegistry.getInstance(); + if (SwtUtil.isWindowsPlatform()) { + shell.setImage(imageRegistry.getIcon(IconName.EMULATOR_TITLE_ICO)); } else { - shell.setImage( imageRegistry.getIcon( IconName.EMULATOR_TITLE ) ); + shell.setImage(imageRegistry.getIcon(IconName.EMULATOR_TITLE)); } arrangeSkin(resolutionW, resolutionH, scale, rotationId); @@ -407,7 +408,7 @@ public class EmulatorSkin { SkinUtil.trimShell(shell, currentImage); } - /* not using a layout */ + /* arrange the lcd */ SkinUtil.adjustLcdGeometry(lcdCanvas, currentLcdWidth, currentLcdHeight, scale, rotationId, skinMode); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java index 91d0624..02b1f08 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java @@ -36,6 +36,8 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Region; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; @@ -113,39 +115,44 @@ public class SkinUtil { Canvas lcdCanvas, int resolutionW, int resolutionH, int scale, short rotationId, SkinMode mode) { - RotationType rotation = SkinRotation.getRotation(rotationId); float convertedScale = convertScale(scale); + int l = 0, t = 0, w = 0, h = 0; if (mode == SkinMode.GENERAL) { + RotationInfo rotation = RotationInfo.getValue(rotationId); + /* resoultion, that is lcd size in general skin mode */ - if (RotationInfo.LANDSCAPE == RotationInfo.getValue(rotationId) || - RotationInfo.REVERSE_LANDSCAPE == RotationInfo.getValue(rotationId)) { - lcdCanvas.setBounds(0, 0, - (int)(resolutionH * convertedScale), - (int)(resolutionW * convertedScale)); + if (RotationInfo.LANDSCAPE == rotation || + RotationInfo.REVERSE_LANDSCAPE == rotation) { + w = (int)(resolutionH * convertedScale); + h = (int)(resolutionW * convertedScale); } else { - lcdCanvas.setBounds(0, 0, - (int)(resolutionW * convertedScale), - (int)(resolutionH * convertedScale)); + w = (int)(resolutionW * convertedScale); + h = (int)(resolutionH * convertedScale); } + } else { + RotationType rotation = SkinRotation.getRotation(rotationId); - return; - } - - LcdType lcd = rotation.getLcd(); /* from dbi */ - RegionType region = lcd.getRegion(); + LcdType lcd = rotation.getLcd(); /* from dbi */ + RegionType region = lcd.getRegion(); - Integer left = region.getLeft(); - Integer top = region.getTop(); - Integer width = region.getWidth(); - Integer height = region.getHeight(); + Integer left = region.getLeft(); + Integer top = region.getTop(); + Integer width = region.getWidth(); + Integer height = region.getHeight(); - int l = (int) (left * convertedScale); - int t = (int) (top * convertedScale); - int w = (int) (width * convertedScale); - int h = (int) (height * convertedScale); + l = (int) (left * convertedScale); + t = (int) (top * convertedScale); + w = (int) (width * convertedScale); + h = (int) (height * convertedScale); + } - lcdCanvas.setBounds(l, t, w, h); + FormData data = new FormData(); + data.left = new FormAttachment(0, l); + data.top = new FormAttachment(0, t); + data.width = w; + data.height = h; + lcdCanvas.setLayoutData(data); } public static SkinRegion getHardKeyArea( int currentX, int currentY, short rotationId, int scale ) { -- 2.7.4