TEXT: Change text's height
authorHyunJong Park <paulhj.park@samsung.com>
Mon, 30 May 2016 01:04:16 +0000 (10:04 +0900)
committerSangho Park <sangho.p@samsung.com>
Mon, 30 May 2016 05:53:30 +0000 (14:53 +0900)
- Change text's height of the computeSize function.

Change-Id: I38230157aff94bbda942ff3a7c72ed153ebbbf5e
Signed-off-by: HyunJong Park <paulhj.park@samsung.com>
bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TizenText.java

index 2131a14..934eac9 100644 (file)
@@ -64,15 +64,18 @@ public class TizenText extends Canvas {
     private static final int STATE_DISABLE = 3;
     protected OriginalText text = null;
     private int textState = STATE_NORMAL;
+    private static final int MARGIN = 5;
 
     public TizenText(Composite parent, int style) {
         super(parent, removeStyleOfContainer(style | SWT.DOUBLE_BUFFERED));
-        this.setLayout(new GridLayout(1, false));
+        this.setLayout(new FormLayout());
         text = new OriginalText(this, removeBorderStyle(style));
-        GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
-        gridData.grabExcessHorizontalSpace = true;
-        gridData.grabExcessVerticalSpace = true;
-        text.setLayoutData(gridData);
+        FormData layoutData = new FormData();
+        layoutData.top = new FormAttachment(0, MARGIN);
+        layoutData.bottom = new FormAttachment(100, -MARGIN);
+        layoutData.left = new FormAttachment(0, MARGIN);
+        layoutData.right = new FormAttachment(100, -MARGIN);
+        text.setLayoutData(layoutData);
         text.setFont(TizenResourceManager.NORMAL_FONT);
         addEventListener();
     }
@@ -166,12 +169,16 @@ public class TizenText extends Canvas {
     @Override
     public Point computeSize(int wHint, int hHint, boolean changed) {
         Point returnComputeSize = text.computeSize(wHint, hHint, changed);
+        int minHeight = (text.getFont().getFontData()[0].getHeight() * 2);
         String osName = System.getProperty("os.name").toLowerCase();//$NON-NLS-1$
-        if (osName.startsWith("mac")) {//$NON-NLS-1$
-            returnComputeSize.y += 15;
+        if (returnComputeSize.y < minHeight) {
+            returnComputeSize.y = minHeight + MARGIN;
         } else {
-            returnComputeSize.y += 10;
+            if (osName.startsWith("mac")) {//$NON-NLS-1$
+                returnComputeSize.y += MARGIN;
+            }
         }
+        returnComputeSize.x += MARGIN * 2;
         return returnComputeSize;
     }