]> source.dussan.org Git - vaadin-framework.git/commitdiff
some changes to support Sizeable
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 1 Feb 2008 11:29:59 +0000 (11:29 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 1 Feb 2008 11:29:59 +0000 (11:29 +0000)
svn changeset:3697/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IListSelect.java
src/com/itmill/toolkit/terminal/gwt/client/ui/INativeSelect.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITwinColSelect.java

index d2edbd3a2810370a329b519326f9aa729cc9e9b5..a4f5f8dafd6df22a090944e9977465cb9603aa78 100644 (file)
@@ -31,6 +31,8 @@ public class ICheckBox extends com.google.gwt.user.client.ui.CheckBox implements
 
     private ErrorMessage errorMessage;
 
+    private boolean isBlockMode = false;
+
     public ICheckBox() {
         setStyleName(CLASSNAME);
         addClickListener(new ClickListener() {
@@ -116,6 +118,25 @@ public class ICheckBox extends com.google.gwt.user.client.ui.CheckBox implements
                 break;
             }
         }
+    }
+
+    public void setWidth(String width) {
+        setBlockMode();
+        super.setWidth(width);
+    }
 
+    public void setHeight(String height) {
+        setBlockMode();
+        super.setHeight(height);
+    }
+
+    /**
+     * makes container element (span) to be block element to enable sizing.
+     */
+    private void setBlockMode() {
+        if (!isBlockMode) {
+            DOM.setStyleAttribute(getElement(), "display", "block");
+            isBlockMode = true;
+        }
     }
 }
index 18bd6e15a2999170b89048cc126449e2a499039e..0f07921cfb186bc9958bfe700a1adc1a3b32a07c 100644 (file)
@@ -78,4 +78,14 @@ public class IListSelect extends IOptionGroupBase {
         }
     }
 
+    public void setHeight(String height) {
+        select.setHeight(height);
+        super.setHeight(height);
+    }
+
+    public void setWidth(String width) {
+        select.setWidth(width);
+        super.setWidth(width);
+    }
+
 }
index d9081097951d3c078dec66651224640f3e97e736..24ee76c5038c53db09e9b16dd4c671a62e7f0ff5 100644 (file)
@@ -63,4 +63,14 @@ public class INativeSelect extends IOptionGroupBase {
         }
     }
 
+    public void setHeight(String height) {
+        select.setHeight(height);
+        super.setHeight(height);
+    }
+
+    public void setWidth(String width) {
+        select.setWidth(width);
+        super.setWidth(width);
+    }
+
 }
index de4165719ff8c2f0f2bca33be1d03b4b5dedb5ad..86e9981a17daea09f2aa664f593f5a6d6425c782 100644 (file)
@@ -7,6 +7,7 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
 import java.util.Iterator;\r
 import java.util.Vector;\r
 \r
+import com.google.gwt.user.client.DOM;\r
 import com.google.gwt.user.client.ui.FlowPanel;\r
 import com.google.gwt.user.client.ui.HTML;\r
 import com.google.gwt.user.client.ui.ListBox;\r
@@ -19,7 +20,7 @@ public class ITwinColSelect extends IOptionGroupBase {
     private static final String CLASSNAME = "i-select-twincol";\r
 \r
     private static final int VISIBLE_COUNT = 10;\r
-    \r
+\r
     private static final int DEFAULT_COLUMN_COUNT = 10;\r
 \r
     private final ListBox options;\r
@@ -30,6 +31,12 @@ public class ITwinColSelect extends IOptionGroupBase {
 \r
     private final IButton remove;\r
 \r
+    private FlowPanel buttons;\r
+\r
+    private Panel panel;\r
+\r
+    private boolean widthSet = false;\r
+\r
     public ITwinColSelect() {\r
         super(CLASSNAME);\r
         options = new ListBox();\r
@@ -40,7 +47,7 @@ public class ITwinColSelect extends IOptionGroupBase {
         selections.setVisibleItemCount(VISIBLE_COUNT);\r
         options.setStyleName(CLASSNAME + "-options");\r
         selections.setStyleName(CLASSNAME + "-selections");\r
-        final Panel buttons = new FlowPanel();\r
+        buttons = new FlowPanel();\r
         buttons.setStyleName(CLASSNAME + "-buttons");\r
         add = new IButton();\r
         add.setText(">>");\r
@@ -48,15 +55,15 @@ public class ITwinColSelect extends IOptionGroupBase {
         remove = new IButton();\r
         remove.setText("<<");\r
         remove.addClickListener(this);\r
-        final Panel p = ((Panel) optionsContainer);\r
-        p.add(options);\r
+        panel = ((Panel) optionsContainer);\r
+        panel.add(options);\r
         buttons.add(add);\r
         final HTML br = new HTML("<span/>");\r
         br.setStyleName(CLASSNAME + "-deco");\r
         buttons.add(br);\r
         buttons.add(remove);\r
-        p.add(buttons);\r
-        p.add(selections);\r
+        panel.add(buttons);\r
+        panel.add(selections);\r
     }\r
 \r
     protected void buildOptions(UIDL uidl) {\r
@@ -79,15 +86,14 @@ public class ITwinColSelect extends IOptionGroupBase {
                         optionUidl.getStringAttribute("key"));\r
             }\r
         }\r
-        optionsContainer.setWidth(null);\r
         if (getColumns() > 0) {\r
             options.setWidth(getColumns() + "em");\r
             selections.setWidth(getColumns() + "em");\r
-            optionsContainer.setWidth((getColumns()*2 + 3) + "em");\r
-        } else {\r
+            optionsContainer.setWidth((getColumns() * 2 + 3) + "em");\r
+        } else if (!widthSet) {\r
             options.setWidth(DEFAULT_COLUMN_COUNT + "em");\r
             selections.setWidth(DEFAULT_COLUMN_COUNT + "em");\r
-            optionsContainer.setWidth((DEFAULT_COLUMN_COUNT*2 + 2) + "em");\r
+            optionsContainer.setWidth((DEFAULT_COLUMN_COUNT * 2 + 2) + "em");\r
         }\r
         if (getRows() > 0) {\r
             options.setVisibleItemCount(getRows());\r
@@ -182,4 +188,28 @@ public class ITwinColSelect extends IOptionGroupBase {
         }\r
     }\r
 \r
+    public void setHeight(String height) {\r
+        super.setHeight(height);\r
+        setFullHeightInternals();\r
+    }\r
+\r
+    private void setFullHeightInternals() {\r
+        options.setHeight("100%");\r
+        selections.setHeight("100%");\r
+    }\r
+\r
+    public void setWidth(String width) {\r
+        super.setWidth(width);\r
+        if (!"".equals(width) && width != null) {\r
+            setRelativeInternalWidths();\r
+        }\r
+    }\r
+\r
+    private void setRelativeInternalWidths() {\r
+        DOM.setStyleAttribute(getElement(), "position", "relative");\r
+        buttons.setWidth("16%");\r
+        options.setWidth("42%");\r
+        selections.setWidth("42%");\r
+        widthSet = true;\r
+    }\r
 }\r