private int captionMarginLeft = -1;
+ private int contentMarginLeft = -1;
+
public IPanel() {
super();
DOM.appendChild(getElement(), captionNode);
DOM.sinkEvents(getElement(), Event.ONKEYDOWN);
DOM.sinkEvents(contentNode, Event.ONSCROLL);
contentNode.getStyle().setProperty("position", "relative");
+ DOM.setStyleAttribute(getElement(), "overflow", "hidden");
}
@Override
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
Util.setWidthExcludingPadding(captionNode,
parentWidthExcludingPadding - getCaptionMarginLeft(), 26);
- int contentMarginLeft = contentNode.getAbsoluteLeft()
- - getElement().getAbsoluteLeft();
+ int contentMarginLeft = getContentMarginLeft();
Util.setWidthExcludingPadding(contentNode,
parentWidthExcludingPadding - contentMarginLeft, 2);
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()
return captionMarginLeft;
}
+ private int getContentMarginLeft() {
+ if (contentMarginLeft < 0) {
+ detectContainerBorders();
+ }
+ return contentMarginLeft;
+ }
+
private int getCaptionPaddingHorizontal() {
if (captionPaddingHorizontal < 0) {
detectContainerBorders();
26);
captionMarginLeft = Util.measureMarginLeft(captionNode);
+ contentMarginLeft = Util.measureMarginLeft(contentNode);
}
--- /dev/null
+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);
+
+ }
+}