Search in sources :

Example 1 with Expander

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);
}
Also used : Expander(org.apache.pivot.wtk.Expander)

Example 2 with Expander

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;
}
Also used : Expander(org.apache.pivot.wtk.Expander) Component(org.apache.pivot.wtk.Component) GradientPaint(java.awt.GradientPaint)

Example 3 with Expander

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);
}
Also used : Expander(org.apache.pivot.wtk.Expander) Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component) GradientPaint(java.awt.GradientPaint)

Example 4 with Expander

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;
}
Also used : Expander(org.apache.pivot.wtk.Expander) Component(org.apache.pivot.wtk.Component) GradientPaint(java.awt.GradientPaint)

Example 5 with Expander

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);
}
Also used : Expander(org.apache.pivot.wtk.Expander) Theme(org.apache.pivot.wtk.Theme) Image(org.apache.pivot.wtk.media.Image)

Aggregations

Expander (org.apache.pivot.wtk.Expander)7 GradientPaint (java.awt.GradientPaint)5 Component (org.apache.pivot.wtk.Component)5 Dimensions (org.apache.pivot.wtk.Dimensions)1 Theme (org.apache.pivot.wtk.Theme)1 Image (org.apache.pivot.wtk.media.Image)1