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;
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;
// 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()) {
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);
}
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) {
fixedInnerSize = 0;
}
setHeight(fixedInnerSize + "px");
+ DOM.setStyleAttribute(getContainerElement(), "overflow", "auto");
}
void setAlignment(String verticalAlignment, String horizontalAlignment) {
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) {
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) {
- DOM.getElementPropertyInt(getElement(), "offsetTop");
}
if (topMargin < 0) {
- // FIXME shouldn't happen
+ // FIXME shouldn't happen
return 0;
} else {
return topMargin;
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
}
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);
private final Element contentNode, deco;
private String height;
+ private String width;
private final TabListener tl = new TabListener() {
}
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);
+ 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);
}