aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Koivuviita <jouni.koivuviita@itmill.com>2008-01-03 12:37:20 +0000
committerJouni Koivuviita <jouni.koivuviita@itmill.com>2008-01-03 12:37:20 +0000
commit44f280461585b28278a222ced0e9ea4b0f59b903 (patch)
tree6d9beceb0a1a36c17c82878b3415f469ef9c688a /src
parenta9b2479f6422d560b4c91c3f2216aa08ab6a62c9 (diff)
downloadvaadin-framework-44f280461585b28278a222ced0e9ea4b0f59b903.tar.gz
vaadin-framework-44f280461585b28278a222ced0e9ea4b0f59b903.zip
Fixes #1221.
svn changeset:3352/svn branch:trunk
Diffstat (limited to 'src')
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java61
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java45
2 files changed, 67 insertions, 39 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java
index 313d45bbef..3c4e6f5459 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java
@@ -34,7 +34,7 @@ public class IExpandLayout extends ComplexPanel implements
public static final int ORIENTATION_VERTICAL = 0;
- // We are using minimun for expanded element to avoid "odd" situations where
+ // We are using minimum for expanded element to avoid "odd" situations where
// expanded element is 0 size
private static final int EXPANDED_ELEMENTS_MIN_WIDTH = 40;
@@ -60,7 +60,7 @@ public class IExpandLayout extends ComplexPanel implements
protected int topMargin = -1;
private String width;
private String height;
- private Element me;
+ private Element marginElement;
private Element breakElement;
private int bottomMargin = -1;
private boolean hasComponentSpacing;
@@ -87,10 +87,10 @@ public class IExpandLayout extends ComplexPanel implements
// DOM.setStyleAttribute(element, "overflow", "hidden");
if (orientationMode == ORIENTATION_HORIZONTAL) {
- me = DOM.createDiv();
+ marginElement = DOM.createDiv();
if (Util.isIE()) {
- DOM.setStyleAttribute(me, "zoom", "1");
- DOM.setStyleAttribute(me, "overflow", "hidden");
+ DOM.setStyleAttribute(marginElement, "zoom", "1");
+ DOM.setStyleAttribute(marginElement, "overflow", "hidden");
}
childContainer = DOM.createDiv();
if (Util.isIE()) {
@@ -102,13 +102,13 @@ public class IExpandLayout extends ComplexPanel implements
DOM.setStyleAttribute(breakElement, "overflow", "hidden");
DOM.setStyleAttribute(breakElement, "height", "0px");
DOM.setStyleAttribute(breakElement, "clear", "both");
- DOM.appendChild(me, childContainer);
- DOM.appendChild(me, breakElement);
- DOM.appendChild(element, me);
+ DOM.appendChild(marginElement, childContainer);
+ DOM.appendChild(marginElement, breakElement);
+ DOM.appendChild(element, marginElement);
} else {
childContainer = DOM.createDiv();
DOM.appendChild(element, childContainer);
- me = childContainer;
+ marginElement = childContainer;
}
setElement(element);
}
@@ -160,8 +160,9 @@ public class IExpandLayout extends ComplexPanel implements
public VerticalWidgetWrapper() {
setElement(DOM.createDiv());
- // this is mostly needed for IE, could be isolated
- DOM.setStyleAttribute(getContainerElement(), "overflow", "auto");
+ // Set to 'hidden' at first (prevent IE6 content overflows), and set
+ // to 'auto' later.
+ DOM.setStyleAttribute(getContainerElement(), "overflow", "hidden");
}
void setExpandedSize(int pixels) {
@@ -172,6 +173,7 @@ public class IExpandLayout extends ComplexPanel implements
fixedInnerSize = 0;
}
setHeight(fixedInnerSize + "px");
+ DOM.setStyleAttribute(getContainerElement(), "overflow", "auto");
}
void setAlignment(String verticalAlignment, String horizontalAlignment) {
@@ -327,14 +329,14 @@ public class IExpandLayout extends ComplexPanel implements
protected void handleMargins(UIDL uidl) {
final MarginInfo margins = new MarginInfo(uidl
.getIntAttribute("margins"));
- setStyleName(me, CLASSNAME + "-" + StyleConstants.MARGIN_TOP, margins
- .hasTop());
- setStyleName(me, CLASSNAME + "-" + StyleConstants.MARGIN_RIGHT, margins
- .hasRight());
- setStyleName(me, CLASSNAME + "-" + StyleConstants.MARGIN_BOTTOM,
- margins.hasBottom());
- setStyleName(me, CLASSNAME + "-" + StyleConstants.MARGIN_LEFT, margins
- .hasLeft());
+ setStyleName(marginElement,
+ CLASSNAME + "-" + StyleConstants.MARGIN_TOP, margins.hasTop());
+ setStyleName(marginElement, CLASSNAME + "-"
+ + StyleConstants.MARGIN_RIGHT, margins.hasRight());
+ setStyleName(marginElement, CLASSNAME + "-"
+ + StyleConstants.MARGIN_BOTTOM, margins.hasBottom());
+ setStyleName(marginElement, CLASSNAME + "-"
+ + StyleConstants.MARGIN_LEFT, margins.hasLeft());
}
public boolean hasChildComponent(Widget component) {
@@ -347,8 +349,8 @@ public class IExpandLayout extends ComplexPanel implements
if (pixels < 0) {
pixels = 0;
}
- DOM.setStyleAttribute(me, "height", pixels + "px");
- DOM.setStyleAttribute(me, "overflow", "hidden");
+ DOM.setStyleAttribute(marginElement, "height", pixels + "px");
+ DOM.setStyleAttribute(marginElement, "overflow", "hidden");
}
if (expandedWidget == null) {
@@ -379,7 +381,7 @@ public class IExpandLayout extends ComplexPanel implements
- DOM.getElementPropertyInt(getElement(), "offsetTop");
}
if (topMargin < 0) {
- // FIXME shouldn't happen
+ // FIXME shouldn't happen
return 0;
} else {
return topMargin;
@@ -388,8 +390,9 @@ public class IExpandLayout extends ComplexPanel implements
private int getBottomMargin() {
if (bottomMargin < 0) {
- bottomMargin = DOM.getElementPropertyInt(me, "offsetTop")
- + DOM.getElementPropertyInt(me, "offsetHeight")
+ bottomMargin = DOM
+ .getElementPropertyInt(marginElement, "offsetTop")
+ + DOM.getElementPropertyInt(marginElement, "offsetHeight")
- DOM.getElementPropertyInt(breakElement, "offsetTop");
if (bottomMargin < 0) {
// FIXME shouldn't happen
@@ -456,14 +459,14 @@ public class IExpandLayout extends ComplexPanel implements
}
final int marginTop = DOM.getElementPropertyInt(DOM
- .getFirstChild(me), "offsetTop")
+ .getFirstChild(marginElement), "offsetTop")
- DOM.getElementPropertyInt(element, "offsetTop");
- final Element lastElement = DOM.getChild(me,
- (DOM.getChildCount(me) - 1));
- final int marginBottom = DOM.getElementPropertyInt(me,
+ final Element lastElement = DOM.getChild(marginElement, (DOM
+ .getChildCount(marginElement) - 1));
+ final int marginBottom = DOM.getElementPropertyInt(marginElement,
"offsetHeight")
- + DOM.getElementPropertyInt(me, "offsetTop")
+ + DOM.getElementPropertyInt(marginElement, "offsetTop")
- (DOM.getElementPropertyInt(lastElement, "offsetTop") + DOM
.getElementPropertyInt(lastElement, "offsetHeight"));
size -= (marginTop + marginBottom);
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java
index 3dfb87e935..9884afe5c4 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java
@@ -29,6 +29,7 @@ public class ITabsheet extends ITabsheetBase implements
private final Element contentNode, deco;
private String height;
+ private String width;
private final TabListener tl = new TabListener() {
@@ -160,30 +161,49 @@ public class ITabsheet extends ITabsheetBase implements
}
public void setHeight(String height) {
+ if (this.height == null && height == null)
+ return;
+ String oldHeight = this.height;
this.height = height;
- iLayout();
+ if ((this.height != null && height == null)
+ || (this.height == null && height != null)
+ || !oldHeight.equals(height)) {
+ iLayout();
+ }
}
public void setWidth(String width) {
+ String oldWidth = this.width;
+ this.width = width;
if ("100%".equals(width)) {
// Allow browser to calculate width
super.setWidth("");
} else {
super.setWidth(width);
}
+ if ((this.width != null && width == null)
+ || (this.width == null && width != null)
+ || !oldWidth.equals(width))
+ // Run descendant layout functions
+ Util.runDescendentsLayout(this);
}
public void iLayout() {
if (height != null && height != "") {
- // save scroll position
+
+ // Save scroll position
int scrollTop = DOM.getElementPropertyInt(contentNode, "scrollTop");
int scrollLeft = DOM.getElementPropertyInt(contentNode,
"scrollLeft");
+
// Take content out of flow for a while
final String originalPositioning = DOM.getStyleAttribute(tp
.getElement(), "position");
DOM.setStyleAttribute(tp.getElement(), "position", "absolute");
+
+ // Set defaults for content element
DOM.setStyleAttribute(contentNode, "overflow", "hidden");
+ DOM.setStyleAttribute(contentNode, "height", "");
// Calculate target height
super.setHeight(height);
@@ -195,22 +215,27 @@ public class ITabsheet extends ITabsheetBase implements
+ DOM.getElementPropertyInt(deco, "offsetHeight")
- DOM.getElementPropertyInt(getElement(), "offsetTop");
- // Calculate content area height (don't allow negative values)
- int h = targetHeight - usedHeight;
- if (h < 0) {
- h = 0;
+ // Calculate needed content area height
+ int newHeight = targetHeight - usedHeight;
+ if (newHeight < 0) {
+ newHeight = 0;
}
// Set proper values for content element
- tp.setHeight(h + "px");
+ DOM.setStyleAttribute(contentNode, "height", newHeight + "px");
+ DOM.setStyleAttribute(contentNode, "overflow", "auto");
+
+ // Restore content to normal flow
DOM.setStyleAttribute(tp.getElement(), "position",
originalPositioning);
- DOM.setStyleAttribute(contentNode, "overflow", "auto");
- // restore scroll position
+
+ // Restore scroll position
DOM.setElementPropertyInt(contentNode, "scrollTop", scrollTop);
DOM.setElementPropertyInt(contentNode, "scrollLeft", scrollLeft);
+
} else {
- tp.setHeight("");
+ DOM.setStyleAttribute(contentNode, "height", "");
+ DOM.setStyleAttribute(contentNode, "overflow", "");
}
Util.runDescendentsLayout(this);
}