skin: set FormLayout
authorgiwoong.kim <giwoong.kim@samsung.com>
Thu, 25 Oct 2012 08:59:15 +0000 (17:59 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Thu, 25 Oct 2012 09:05:15 +0000 (18:05 +0900)
The FormLayout is applied to a Emulator window shell.

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/util/SkinUtil.java

index b183fe4..bb2c6df 100644 (file)
@@ -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);
 
index 91d0624..02b1f08 100644 (file)
@@ -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 ) {