Search in sources :

Example 86 with Component

use of org.apache.pivot.wtk.Component in project pivot by apache.

the class TerraSplitPaneSkin method limitSplitLocation.

private int limitSplitLocation(int splitLocation) {
    SplitPane splitPane = (SplitPane) getComponent();
    Component topLeft = splitPane.getTopLeft();
    Component bottomRight = splitPane.getBottomRight();
    int lower, upper;
    if (splitPane.getOrientation() == Orientation.HORIZONTAL) {
        lower = 0;
        upper = Math.max(getWidth() - splitterThickness, 0);
        if (topLeft != null) {
            int leftLimit = topLeft.getMinimumWidth();
            if (leftLimit >= 0) {
                lower = Math.min(leftLimit, upper);
            }
        }
        if (bottomRight != null) {
            int rightLimit = bottomRight.getMinimumWidth();
            if (rightLimit >= 0) {
                upper = Math.max(upper - rightLimit, lower);
            }
        }
    } else {
        lower = 0;
        upper = Math.max(getHeight() - splitterThickness, 0);
        if (topLeft != null) {
            int topLimit = topLeft.getMinimumHeight();
            if (topLimit >= 0) {
                lower = Math.min(topLimit, upper);
            }
        }
        if (bottomRight != null) {
            int bottomLimit = bottomRight.getMinimumHeight();
            if (bottomLimit >= 0) {
                upper = Math.max(upper - bottomLimit, lower);
            }
        }
    }
    if (splitLocation < lower) {
        return lower;
    } else if (splitLocation > upper) {
        return upper;
    }
    return splitLocation;
}
Also used : SplitPane(org.apache.pivot.wtk.SplitPane) Component(org.apache.pivot.wtk.Component)

Example 87 with Component

use of org.apache.pivot.wtk.Component in project pivot by apache.

the class TerraTabPaneSkin method getPreferredTabSize.

private Dimensions getPreferredTabSize() {
    int preferredTabWidth = 0;
    int preferredTabHeight = 0;
    TabPane tabPane = (TabPane) getComponent();
    for (Component tab : tabPane.getTabs()) {
        Dimensions preferredSize = tab.getPreferredSize();
        preferredTabWidth = Math.max(preferredTabWidth, preferredSize.width);
        preferredTabHeight = Math.max(preferredTabHeight, preferredSize.height);
    }
    return new Dimensions(preferredTabWidth, preferredTabHeight);
}
Also used : TabPane(org.apache.pivot.wtk.TabPane) Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component) Point(org.apache.pivot.wtk.Point) GradientPaint(java.awt.GradientPaint)

Example 88 with Component

use of org.apache.pivot.wtk.Component in project pivot by apache.

the class TerraTabPaneSkin method layout.

@Override
public void layout() {
    TabPane tabPane = (TabPane) getComponent();
    int width = getWidth();
    int height = getHeight();
    int tabX = 0;
    int tabY = 0;
    int tabWidth = 0;
    int tabHeight = 0;
    Component corner = tabPane.getCorner();
    Dimensions buttonPanoramaSize = tabButtonPanorama.getPreferredSize();
    switch(tabOrientation) {
        case HORIZONTAL:
            {
                int buttonPanoramaWidth = Math.min(width, buttonPanoramaSize.width);
                int buttonPanoramaHeight = buttonPanoramaSize.height;
                int buttonPanoramaY = 0;
                if (corner != null) {
                    int cornerWidth = Math.max(width - buttonPanoramaWidth - 2, corner.getPreferredWidth());
                    if (cornerWidth > width - 2) {
                        cornerWidth = Math.max(width - 2, 0);
                    }
                    if (buttonPanoramaWidth + 2 + cornerWidth > width) {
                        buttonPanoramaWidth = Math.max(width - 2 - cornerWidth, 0);
                    }
                    int cornerHeight = Math.max(corner.getPreferredHeight(-1), buttonPanoramaSize.height - 1);
                    int cornerX = width - cornerWidth;
                    int cornerY = Math.max(buttonPanoramaHeight - cornerHeight - 1, 0);
                    buttonPanoramaY = Math.max(cornerHeight - buttonPanoramaHeight + 1, 0);
                    corner.setLocation(cornerX, cornerY);
                    corner.setSize(cornerWidth, cornerHeight);
                }
                tabButtonPanorama.setLocation(0, buttonPanoramaY);
                tabButtonPanorama.setSize(buttonPanoramaWidth, buttonPanoramaHeight);
                tabX = padding.left + 1;
                tabY = padding.top + buttonPanoramaY + buttonPanoramaHeight;
                tabWidth = Math.max(width - (padding.left + padding.right + 2), 0);
                tabHeight = Math.max(height - (padding.top + padding.bottom + buttonPanoramaY + buttonPanoramaHeight + 1), 0);
                break;
            }
        case VERTICAL:
            {
                int buttonPanoramaWidth = buttonPanoramaSize.width;
                int buttonPanoramaHeight = Math.min(height, buttonPanoramaSize.height);
                int buttonPanoramaX = 0;
                if (corner != null) {
                    int cornerHeight = Math.max(height - buttonPanoramaHeight - 2, corner.getPreferredHeight());
                    if (cornerHeight > height - 2) {
                        cornerHeight = Math.max(height - 2, 0);
                    }
                    if (buttonPanoramaHeight + 2 + cornerHeight > height) {
                        buttonPanoramaHeight = Math.max(height - 2 - cornerHeight, 0);
                    }
                    int cornerWidth = Math.max(corner.getPreferredWidth(-1), buttonPanoramaSize.width - 1);
                    int cornerX = Math.max(buttonPanoramaWidth - cornerWidth - 1, 0);
                    int cornerY = height - cornerHeight;
                    buttonPanoramaX = Math.max(cornerWidth - buttonPanoramaWidth + 1, 0);
                    corner.setLocation(cornerX, cornerY);
                    corner.setSize(cornerWidth, cornerHeight);
                }
                tabButtonPanorama.setLocation(buttonPanoramaX, 0);
                tabButtonPanorama.setSize(buttonPanoramaWidth, buttonPanoramaHeight);
                tabX = padding.left + buttonPanoramaX + buttonPanoramaWidth;
                tabY = padding.top + 1;
                tabWidth = Math.max(width - (padding.left + padding.right + buttonPanoramaX + buttonPanoramaWidth + 1), 0);
                tabHeight = Math.max(height - (padding.top + padding.bottom + 2), 0);
                break;
            }
        default:
            {
                break;
            }
    }
    // Lay out the tabs
    for (Component tab : tabPane.getTabs()) {
        tab.setLocation(tabX, tabY);
        if (selectionChangeTransition != null && selectionChangeTransition.isRunning()) {
            clipDecorator.setSize(tabWidth, tabHeight);
            switch(tabOrientation) {
                case HORIZONTAL:
                    {
                        tab.setSize(tabWidth, getPreferredTabHeight(tabWidth));
                        break;
                    }
                case VERTICAL:
                    {
                        tab.setSize(getPreferredTabWidth(tabHeight), tabHeight);
                        break;
                    }
                default:
                    {
                        break;
                    }
            }
        } else {
            tab.setSize(tabWidth, tabHeight);
        }
    }
}
Also used : TabPane(org.apache.pivot.wtk.TabPane) Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component) Point(org.apache.pivot.wtk.Point) GradientPaint(java.awt.GradientPaint)

Example 89 with Component

use of org.apache.pivot.wtk.Component in project pivot by apache.

the class TerraTabPaneSkin method getPreferredTabHeight.

private int getPreferredTabHeight(int width) {
    int preferredTabHeight = 0;
    TabPane tabPane = (TabPane) getComponent();
    for (Component tab : tabPane.getTabs()) {
        preferredTabHeight = Math.max(preferredTabHeight, tab.getPreferredHeight(width));
    }
    return preferredTabHeight;
}
Also used : TabPane(org.apache.pivot.wtk.TabPane) Component(org.apache.pivot.wtk.Component) Point(org.apache.pivot.wtk.Point) GradientPaint(java.awt.GradientPaint)

Example 90 with Component

use of org.apache.pivot.wtk.Component in project pivot by apache.

the class TerraTabPaneSkin method setTabOrientation.

public void setTabOrientation(Orientation tabOrientation) {
    Utils.checkNull(tabOrientation, "tabOrientation");
    this.tabOrientation = tabOrientation;
    // Invalidate the tab buttons since their preferred sizes have changed
    for (Component tabButton : tabButtonBoxPane) {
        tabButton.invalidate();
    }
    tabButtonBoxPane.setOrientation(tabOrientation);
    switch(tabOrientation) {
        case HORIZONTAL:
            {
                tabButtonBoxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.LEFT);
                break;
            }
        case VERTICAL:
            {
                tabButtonBoxPane.getStyles().put(Style.verticalAlignment, VerticalAlignment.TOP);
                break;
            }
        default:
            {
                break;
            }
    }
}
Also used : Component(org.apache.pivot.wtk.Component)

Aggregations

Component (org.apache.pivot.wtk.Component)209 Dimensions (org.apache.pivot.wtk.Dimensions)40 Point (org.apache.pivot.wtk.Point)38 GradientPaint (java.awt.GradientPaint)33 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)24 TextInput (org.apache.pivot.wtk.TextInput)21 Label (org.apache.pivot.wtk.Label)20 BoxPane (org.apache.pivot.wtk.BoxPane)18 Paint (java.awt.Paint)17 Button (org.apache.pivot.wtk.Button)15 PushButton (org.apache.pivot.wtk.PushButton)14 ScrollPane (org.apache.pivot.wtk.ScrollPane)14 TablePane (org.apache.pivot.wtk.TablePane)14 Window (org.apache.pivot.wtk.Window)14 IOException (java.io.IOException)13 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)13 Frame (org.apache.pivot.wtk.Frame)13 FlowPane (org.apache.pivot.wtk.FlowPane)12 ComponentStateListener (org.apache.pivot.wtk.ComponentStateListener)11 ComponentMouseButtonListener (org.apache.pivot.wtk.ComponentMouseButtonListener)10