From 9f5fd663b93132100cc144ee7d25b782471cdc8f Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Mon, 29 Oct 2007 13:59:15 +0000 Subject: [PATCH] IPanel height calculations altered (yet again). Seems to work more consistently across all browsers than previous (commented) version. svn changeset:2619/svn branch:trunk --- .../terminal/gwt/client/ui/IPanel.java | 54 ++++++++++--------- .../gwt/public/default/panel/panel.css | 6 ++- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java index 3c1a877dfe..8f894990fe 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java @@ -33,8 +33,12 @@ public class IPanel extends SimplePanel implements Paintable, DOM.appendChild(getElement(), contentNode); DOM.appendChild(getElement(), bottomDecoration); setStyleName(CLASSNAME); - DOM.setElementProperty(captionNode, "className", CLASSNAME + "-caption"); - DOM.setElementProperty(contentNode, "className", CLASSNAME + "-content"); + DOM + .setElementProperty(captionNode, "className", CLASSNAME + + "-caption"); + DOM + .setElementProperty(contentNode, "className", CLASSNAME + + "-content"); DOM.setElementProperty(bottomDecoration, "className", CLASSNAME + "-deco"); } @@ -71,7 +75,8 @@ public class IPanel extends SimplePanel implements Paintable, hasCaption = true; } else { DOM.setInnerText(captionNode, ""); - DOM.setElementProperty(captionNode, "className", CLASSNAME + "-nocaption"); + DOM.setElementProperty(captionNode, "className", CLASSNAME + + "-nocaption"); } // Add proper stylenames for all elements @@ -109,33 +114,34 @@ public class IPanel extends SimplePanel implements Paintable, if (height != null && height != "") { // need to fix containers height properly DOM.setStyleAttribute(getElement(), "height", height); - boolean hasChildren = getWidget() != null; - Element contentEl = null; - String origPositioning = null; - if (hasChildren) { - // remove children temporary form normal flow to detect proper - // size - contentEl = getWidget().getElement(); - origPositioning = DOM.getStyleAttribute(contentEl, "position"); - DOM.setStyleAttribute(contentEl, "position", "absolute"); - } - DOM.setStyleAttribute(contentNode, "height", ""); + //boolean hasChildren = getWidget() != null; + //Element contentEl = null; + //String origPositioning = null; if (hasChildren) { // remove + //children temporary form normal flow to detect proper // size + //contentEl = getWidget().getElement(); origPositioning = + //DOM.getStyleAttribute(contentEl, "position"); + //DOM.setStyleAttribute(contentEl, "position", "absolute"); } + //DOM.setStyleAttribute(contentNode, "height", ""); int availableH = + //DOM.getElementPropertyInt(getElement(), "clientHeight"); + // + //int usedH = DOM .getElementPropertyInt(bottomDecoration, + //"offsetTop") + DOM.getElementPropertyInt(bottomDecoration, + //"offsetHeight"); + + DOM.setStyleAttribute(contentNode, "height", "1px"); + DOM.setStyleAttribute(contentNode, "overflow", "hidden"); int availableH = DOM.getElementPropertyInt(getElement(), - "clientHeight"); - - int usedH = DOM - .getElementPropertyInt(bottomDecoration, "offsetTop") - + DOM.getElementPropertyInt(bottomDecoration, - "offsetHeight"); - int contentH = availableH - usedH; + "offsetHeight"); + DOM.setStyleAttribute(getElement(), "height", ""); + int usedH = DOM.getElementPropertyInt(getElement(), "offsetHeight"); + int contentH = availableH - usedH - 1; if (contentH < 0) contentH = 0; DOM.setStyleAttribute(contentNode, "height", contentH + "px"); - if (hasChildren) { + /*if (hasChildren) { DOM.setStyleAttribute(contentEl, "position", origPositioning); - } + }*/ DOM.setStyleAttribute(contentNode, "overflow", "auto"); - DOM.setStyleAttribute(getElement(), "height", ""); } else { DOM.setStyleAttribute(contentNode, "height", ""); } diff --git a/src/com/itmill/toolkit/terminal/gwt/public/default/panel/panel.css b/src/com/itmill/toolkit/terminal/gwt/public/default/panel/panel.css index 254faf3084..75fee0c567 100644 --- a/src/com/itmill/toolkit/terminal/gwt/public/default/panel/panel.css +++ b/src/com/itmill/toolkit/terminal/gwt/public/default/panel/panel.css @@ -167,10 +167,12 @@ } * html .i-panel-deco { - display: none; + height: 0; + overflow: hidden; } *+html .i-panel-deco { - display: none; + height: 0; + overflow: hidden; } /* Without caption */ -- 2.39.5