use of org.apache.pivot.wtk.Expander in project pivot by apache.
the class ExpanderSkin method install.
@Override
public void install(Component component) {
super.install(component);
Expander expander = (Expander) component;
expander.getExpanderListeners().add(this);
}
use of org.apache.pivot.wtk.Expander in project pivot by apache.
the class TerraExpanderSkin method getPreferredHeight.
@Override
public int getPreferredHeight(int width) {
Expander expander = (Expander) getComponent();
Component content = expander.getContent();
int preferredHeight = titleBarTablePane.getPreferredHeight(-1);
if (content != null && (expander.isExpanded() || expandTransition != null)) {
// Title bar border is only drawn when content is non-null and
// expander is expanded or expanding
preferredHeight += 1;
int contentWidth = -1;
if (width >= 0) {
contentWidth = Math.max(width - (2 + padding.getWidth()), 0);
}
int fullHeight = padding.getHeight() + content.getPreferredHeight(contentWidth);
if (expandTransition == null) {
preferredHeight += fullHeight;
} else {
float scale = expandTransition.getScale();
preferredHeight += (int) (scale * fullHeight);
}
}
preferredHeight += 2;
return preferredHeight;
}
use of org.apache.pivot.wtk.Expander in project pivot by apache.
the class TerraExpanderSkin method getPreferredSize.
@Override
public Dimensions getPreferredSize() {
Expander expander = (Expander) getComponent();
Component content = expander.getContent();
Dimensions titleBarSize = titleBarTablePane.getPreferredSize();
int preferredWidth = titleBarSize.width;
int preferredHeight = titleBarSize.height;
if (content != null) {
Dimensions contentSize = content.getPreferredSize();
preferredWidth = Math.max(contentSize.width + padding.getWidth(), preferredWidth);
if (expander.isExpanded() || expandTransition != null) {
// Title bar border is only drawn when expander is expanded
// or expanding
preferredHeight += 1;
int fullHeight = padding.getHeight() + contentSize.height;
if (expandTransition == null) {
preferredHeight += fullHeight;
} else {
float scale = expandTransition.getScale();
preferredHeight += (int) (scale * fullHeight);
}
}
}
preferredWidth += 2;
preferredHeight += 2;
return new Dimensions(preferredWidth, preferredHeight);
}
use of org.apache.pivot.wtk.Expander in project pivot by apache.
the class TerraExpanderSkin method getBaseline.
@Override
public int getBaseline(int width, int height) {
Expander expander = (Expander) getComponent();
Component content = expander.getContent();
int baseline = -1;
if (content != null) {
int titleBarWidth = Math.max(width - 2, 0);
int titleBarHeight = titleBarTablePane.getPreferredHeight(-1);
baseline = titleBarTablePane.getBaseline(titleBarWidth, titleBarHeight);
if (baseline != -1) {
// Account for top border
baseline += 1;
}
}
return baseline;
}
use of org.apache.pivot.wtk.Expander in project pivot by apache.
the class TerraExpanderSkin method install.
@Override
public void install(Component component) {
super.install(component);
Expander expander = (Expander) component;
expander.add(titleBarTablePane);
Image buttonData = expander.isExpanded() ? collapseImage : expandImage;
shadeButton = new ShadeButton(buttonData);
buttonBoxPane.add(shadeButton);
shadeButton.getButtonPressListeners().add(this);
Theme theme = currentTheme();
theme.setDefaultStyles(this);
titleChanged(expander, null);
collapsibleChanged(expander);
enabledChanged(expander);
}
Aggregations