]> source.dussan.org Git - vaadin-framework.git/commitdiff
Testcase and fix for #2178 - Panel size in IE6
authorArtur Signell <artur.signell@itmill.com>
Fri, 24 Oct 2008 11:42:53 +0000 (11:42 +0000)
committerArtur Signell <artur.signell@itmill.com>
Fri, 24 Oct 2008 11:42:53 +0000 (11:42 +0000)
svn changeset:5711/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java
src/com/itmill/toolkit/tests/tickets/Ticket2178.java [new file with mode: 0644]

index 4d6707327e845337ea3d3f90f061c013688c9523..edc9a0fb128d3ee6850b9629bb95289f84d3c001 100644 (file)
@@ -69,6 +69,8 @@ public class IPanel extends SimplePanel implements Container,
 
     private int captionMarginLeft = -1;
 
+    private int contentMarginLeft = -1;
+
     public IPanel() {
         super();
         DOM.appendChild(getElement(), captionNode);
@@ -87,6 +89,7 @@ public class IPanel extends SimplePanel implements Container,
         DOM.sinkEvents(getElement(), Event.ONKEYDOWN);
         DOM.sinkEvents(contentNode, Event.ONSCROLL);
         contentNode.getStyle().setProperty("position", "relative");
+        DOM.setStyleAttribute(getElement(), "overflow", "hidden");
     }
 
     @Override
@@ -258,6 +261,8 @@ public class IPanel extends SimplePanel implements Container,
         if (BrowserInfo.get().isIE6() && width != null && !width.equals("")) {
             /*
              * IE6 requires overflow-hidden elements to have a width specified
+             * so we calculate the width of the content and caption nodes when
+             * no width has been specified.
              */
             /*
              * Fixes #1923 IPanel: Horizontal scrollbar does not appear in IE6
@@ -278,8 +283,7 @@ public class IPanel extends SimplePanel implements Container,
             Util.setWidthExcludingPadding(captionNode,
                     parentWidthExcludingPadding - getCaptionMarginLeft(), 26);
 
-            int contentMarginLeft = contentNode.getAbsoluteLeft()
-                    - getElement().getAbsoluteLeft();
+            int contentMarginLeft = getContentMarginLeft();
 
             Util.setWidthExcludingPadding(contentNode,
                     parentWidthExcludingPadding - contentMarginLeft, 2);
@@ -288,6 +292,10 @@ public class IPanel extends SimplePanel implements Container,
 
         if ((BrowserInfo.get().isIE() || BrowserInfo.get().isFF2())
                 && (width == null || width.equals(""))) {
+            /*
+             * IE and FF2 needs width to be specified for the root DIV so we
+             * calculate that from the sizes of the caption and layout
+             */
             int captionWidth = captionText.getOffsetWidth()
                     + getCaptionMarginLeft() + getCaptionPaddingHorizontal();
             int layoutWidth = ((Widget) layout).getOffsetWidth()
@@ -400,6 +408,13 @@ public class IPanel extends SimplePanel implements Container,
         return captionMarginLeft;
     }
 
+    private int getContentMarginLeft() {
+        if (contentMarginLeft < 0) {
+            detectContainerBorders();
+        }
+        return contentMarginLeft;
+    }
+
     private int getCaptionPaddingHorizontal() {
         if (captionPaddingHorizontal < 0) {
             detectContainerBorders();
@@ -441,6 +456,7 @@ public class IPanel extends SimplePanel implements Container,
                 26);
 
         captionMarginLeft = Util.measureMarginLeft(captionNode);
+        contentMarginLeft = Util.measureMarginLeft(contentNode);
 
     }
 
diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket2178.java b/src/com/itmill/toolkit/tests/tickets/Ticket2178.java
new file mode 100644 (file)
index 0000000..29bbdad
--- /dev/null
@@ -0,0 +1,107 @@
+package com.itmill.toolkit.tests.tickets;
+
+import com.itmill.toolkit.Application;
+import com.itmill.toolkit.ui.ComboBox;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.Panel;
+import com.itmill.toolkit.ui.Window;
+
+public class Ticket2178 extends Application {
+
+    public void init() {
+        Window w = new Window(getClass().getSimpleName());
+        setMainWindow(w);
+        // setTheme("tests-tickets");
+        createUI((OrderedLayout) w.getLayout());
+    }
+
+    private void createUI(OrderedLayout layout) {
+        OrderedLayout ol;
+        Panel p;
+        ComboBox cb;
+
+        ol = new OrderedLayout();
+        p = new Panel(ol);
+        p.setCaption("Combobox without width");
+        // p.setWidth("100px");
+        cb = new ComboBox();
+        // cb.setCaption("A combobox");
+        // cb.setWidth("100%");
+        p.addComponent(cb);
+        layout.addComponent(p);
+
+        ol = new OrderedLayout();
+        p = new Panel(ol);
+        p.setCaption("Combobox without width with caption");
+        // p.setWidth("100px");
+        cb = new ComboBox();
+        cb.setCaption("A combobox");
+        // cb.setWidth("100px");
+        p.addComponent(cb);
+        layout.addComponent(p);
+
+        ol = new OrderedLayout();
+        p = new Panel(ol);
+        p.setCaption("Combobox 100px wide");
+        // p.setWidth("100px");
+        cb = new ComboBox();
+        // cb.setCaption("A combobox");
+        cb.setWidth("100px");
+        p.addComponent(cb);
+        layout.addComponent(p);
+
+        ol = new OrderedLayout();
+        p = new Panel(ol);
+        p.setCaption("Combobox 100px wide with caption");
+        // p.setWidth("100px");
+        cb = new ComboBox();
+        cb.setCaption("A combobox");
+        cb.setWidth("100px");
+        p.addComponent(cb);
+        layout.addComponent(p);
+
+        ol = new OrderedLayout();
+        p = new Panel(ol);
+        p.setCaption("Combobox 500px wide");
+        // p.setWidth("500px");
+        cb = new ComboBox();
+        // cb.setCaption("A combobox");
+        cb.setWidth("500px");
+        p.addComponent(cb);
+        layout.addComponent(p);
+
+        ol = new OrderedLayout();
+        p = new Panel(ol);
+        p.setCaption("Combobox 500px wide with caption");
+        // p.setWidth("500px");
+        cb = new ComboBox();
+        cb.setCaption("A combobox");
+        cb.setWidth("500px");
+        p.addComponent(cb);
+        layout.addComponent(p);
+
+        ol = new OrderedLayout();
+        p = new Panel(ol);
+        p.setCaption("Combobox 100% wide inside 200px panel");
+        p.setWidth("200px");
+        ol.setWidth("100%");
+        cb = new ComboBox();
+        // cb.setCaption("A combobox");
+        cb.setWidth("100%");
+        // cb.setWidth("500px");
+        p.addComponent(cb);
+        layout.addComponent(p);
+
+        ol = new OrderedLayout();
+        p = new Panel(ol);
+        p.setCaption("Combobox 100% wide inside 200px panel with caption");
+        p.setWidth("200px");
+        ol.setWidth("100%");
+        cb = new ComboBox();
+        cb.setCaption("A combobox");
+        cb.setWidth("100%");
+        p.addComponent(cb);
+        layout.addComponent(p);
+
+    }
+}