[Title] Add setGridLayoutData to the SWTUtil
authorho.namkoong <ho.namkoong@samsung.com>
Wed, 29 Aug 2012 13:09:08 +0000 (22:09 +0900)
committerho.namkoong <ho.namkoong@samsung.com>
Wed, 29 Aug 2012 13:09:08 +0000 (22:09 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I4f2f6b16f785087a61fcd7934ad6e5623a0987a3

org.tizen.common/src/org/tizen/common/util/SWTUtil.java

index 914be8e..5d0c0ed 100755 (executable)
@@ -42,7 +42,9 @@ import org.eclipse.swt.custom.ScrolledComposite;
 import org.eclipse.swt.events.VerifyEvent;
 import org.eclipse.swt.events.VerifyListener;
 import org.eclipse.swt.graphics.Resource;
+import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Table;
@@ -453,4 +455,33 @@ public class SWTUtil {
             }
         } while (!treeStack.isEmpty());
     }
+
+    /**
+     * set grid layout data of Control. 
+     * If values of  heightHint, widthHint, horizontalSpan, verticalSpan is -1, this method does not change value of them. 
+     *
+     * @param c target control to which grid layout data is set.
+     * @param heightHint height of the control
+     * @param widthHint width of the control
+     * @param horizontalSpan the number of column cells that control will take up.
+     * @param verticalSpan the number of row cells that control will take up.
+     * @param style style of the control
+     * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+     */
+    public static void setGridLayoutData(Control c, int heightHint, int widthHint, int horizontalSpan, int verticalSpan, int style) {
+        GridData gd = new GridData(style);
+        if(heightHint != -1) {
+            gd.heightHint = heightHint;
+        }
+        if(widthHint != -1) {
+            gd.widthHint = widthHint;
+        }
+        if(horizontalSpan != -1) {
+            gd.horizontalSpan = horizontalSpan;
+        }
+        if(verticalSpan != -1) {
+            gd.verticalSpan = verticalSpan;
+        }
+        c.setLayoutData(gd);
+    }
 }