Search in sources :

Example 6 with Expander

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

Example 7 with Expander

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

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