/* Accordion does not render its children's captions */
}
@Override
public void layout() {
StackItem openTab = getWidget().getOpenStackItem();
if (openTab == null) {
return;
}
// WIDTH
if (!isUndefinedWidth()) {
openTab.setWidth("100%");
} else {
int maxWidth = 40;
for (StackItem si : getWidget().getStackItems()) {
int captionWidth = si.getCaptionWidth();
if (captionWidth > maxWidth) {
maxWidth = captionWidth;
}
}
int widgetWidth = openTab.getWidgetWidth();
if (widgetWidth > maxWidth) {
maxWidth = widgetWidth;
}
openTab.setWidth(maxWidth);
}
// HEIGHT
if (!isUndefinedHeight()) {
int usedPixels = 0;
for (StackItem item : getWidget().getStackItems()) {
if (item == openTab) {
usedPixels += item.getCaptionHeight();
} else {
// This includes the captionNode borders
usedPixels += Util.getRequiredHeight(item.getElement());
}
}
int rootElementInnerHeight = getLayoutManager().getInnerHeight(
getWidget().getElement());
int spaceForOpenItem = rootElementInnerHeight - usedPixels;
if (spaceForOpenItem < 0) {
spaceForOpenItem = 0;
}
openTab.setHeight(spaceForOpenItem);
} else {
openTab.setHeightFromWidget();
}
}