use of org.apache.pivot.wtk.Expander in project pivot by apache.
the class TerraExpanderSkin method layout.
@Override
public void layout() {
Expander expander = (Expander) getComponent();
Component content = expander.getContent();
int width = getWidth();
int height = getHeight();
int titleBarHeight = titleBarTablePane.getPreferredHeight(-1);
titleBarTablePane.setSize(Math.max(width - 2, 0), titleBarHeight);
titleBarTablePane.setLocation(1, 1);
if (content != null) {
int contentWidth = Math.max(width - (2 + padding.getWidth()), 0);
int contentHeight = Math.max(height - (3 + padding.getHeight() + titleBarHeight), 0);
clipDecorator.setSize(contentWidth, contentHeight);
content.setSize(contentWidth, content.getPreferredHeight(contentWidth));
int contentX = 1 + padding.left;
int contentY = 2 + padding.top + titleBarHeight;
content.setLocation(contentX, contentY);
}
}
use of org.apache.pivot.wtk.Expander in project pivot by apache.
the class TerraExpanderSkin method getPreferredWidth.
@Override
public int getPreferredWidth(int height) {
Expander expander = (Expander) getComponent();
Component content = expander.getContent();
int preferredWidth = titleBarTablePane.getPreferredWidth(-1);
if (content != null) {
int contentHeight = -1;
if (height >= 0) {
int reservedHeight = 2 + padding.getHeight() + titleBarTablePane.getPreferredHeight(-1);
if (expander.isExpanded()) {
// Title bar border is only drawn when expander is expanded
reservedHeight += 1;
}
contentHeight = Math.max(height - reservedHeight, 0);
}
preferredWidth = Math.max(content.getPreferredWidth(contentHeight) + padding.getWidth(), preferredWidth);
}
preferredWidth += 2;
return preferredWidth;
}
Aggregations