Search in sources :

Example 11 with TabPane

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

the class TerraTabPaneSkin method getPreferredWidth.

@Override
public int getPreferredWidth(int height) {
    int preferredWidth = 0;
    TabPane tabPane = (TabPane) getComponent();
    Component selectedTab = tabPane.getSelectedTab();
    Component corner = tabPane.getCorner();
    switch(tabOrientation) {
        case HORIZONTAL:
            {
                if (height != -1) {
                    if (corner != null) {
                        height = Math.max(height - Math.max(corner.getPreferredHeight(-1), Math.max(tabButtonPanorama.getPreferredHeight(-1) - 1, 0)), 0);
                    } else {
                        height = Math.max(height - (tabButtonPanorama.getPreferredHeight(-1) - 1), 0);
                    }
                    height = Math.max(height - (padding.top + padding.bottom + 2), 0);
                }
                preferredWidth = getPreferredTabWidth(height) + (padding.left + padding.right + 2);
                int buttonAreaPreferredWidth = tabButtonPanorama.getPreferredWidth(-1);
                if (corner != null) {
                    buttonAreaPreferredWidth += corner.getPreferredWidth(-1);
                }
                preferredWidth = Math.max(preferredWidth, buttonAreaPreferredWidth);
                break;
            }
        case VERTICAL:
            {
                if (height != -1) {
                    height = Math.max(height - (padding.top + padding.bottom + 2), 0);
                }
                if (selectedTab == null && selectionChangeTransition == null) {
                    preferredWidth = 1;
                } else {
                    preferredWidth = getPreferredTabWidth(height) + (padding.left + padding.right);
                    if (selectionChangeTransition != null) {
                        float scale = selectionChangeTransition.getScale();
                        preferredWidth = (int) (preferredWidth * scale);
                    }
                    preferredWidth += 2;
                }
                if (corner != null) {
                    preferredWidth += Math.max(corner.getPreferredWidth(-1), Math.max(tabButtonPanorama.getPreferredWidth(-1) - 1, 0));
                } else {
                    preferredWidth += Math.max(tabButtonPanorama.getPreferredWidth(-1) - 1, 0);
                }
                break;
            }
        default:
            {
                break;
            }
    }
    return preferredWidth;
}
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 12 with TabPane

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

the class TerraTabPaneSkin method getPreferredHeight.

@Override
public int getPreferredHeight(int width) {
    int preferredHeight = 0;
    TabPane tabPane = (TabPane) getComponent();
    Component selectedTab = tabPane.getSelectedTab();
    Component corner = tabPane.getCorner();
    switch(tabOrientation) {
        case HORIZONTAL:
            {
                if (width != -1) {
                    width = Math.max(width - (padding.left + padding.right + 2), 0);
                }
                if (selectedTab == null && selectionChangeTransition == null) {
                    preferredHeight = 1;
                } else {
                    preferredHeight = getPreferredTabHeight(width) + (padding.top + padding.bottom);
                    if (selectionChangeTransition != null) {
                        float scale = selectionChangeTransition.getScale();
                        preferredHeight = (int) (preferredHeight * scale);
                    }
                    preferredHeight += 2;
                }
                if (corner != null) {
                    preferredHeight += Math.max(corner.getPreferredHeight(-1), Math.max(tabButtonPanorama.getPreferredHeight(-1) - 1, 0));
                } else {
                    preferredHeight += Math.max(tabButtonPanorama.getPreferredHeight(-1) - 1, 0);
                }
                break;
            }
        case VERTICAL:
            {
                if (width != -1) {
                    if (corner != null) {
                        width = Math.max(width - Math.max(corner.getPreferredWidth(-1), Math.max(tabButtonPanorama.getPreferredWidth(-1) - 1, 0)), 0);
                    } else {
                        width = Math.max(width - (tabButtonPanorama.getPreferredWidth(-1) - 1), 0);
                    }
                    width = Math.max(width - (padding.left + padding.right + 2), 0);
                }
                preferredHeight = getPreferredTabHeight(width) + (padding.top + padding.bottom + 2);
                int buttonAreaPreferredHeight = tabButtonPanorama.getPreferredHeight(-1);
                if (corner != null) {
                    buttonAreaPreferredHeight += corner.getPreferredHeight(-1);
                }
                preferredHeight = Math.max(preferredHeight, buttonAreaPreferredHeight);
                break;
            }
        default:
            {
                break;
            }
    }
    return preferredHeight;
}
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 13 with TabPane

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

the class TerraTabPaneSkin method getPreferredTabWidth.

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

Aggregations

TabPane (org.apache.pivot.wtk.TabPane)13 GradientPaint (java.awt.GradientPaint)9 Point (org.apache.pivot.wtk.Point)9 Component (org.apache.pivot.wtk.Component)7 Dimensions (org.apache.pivot.wtk.Dimensions)3 Label (org.apache.pivot.wtk.Label)2 Line2D (java.awt.geom.Line2D)1 HashMap (org.apache.pivot.collections.HashMap)1 Vote (org.apache.pivot.util.Vote)1 Bounds (org.apache.pivot.wtk.Bounds)1 Button (org.apache.pivot.wtk.Button)1 ButtonStateListener (org.apache.pivot.wtk.ButtonStateListener)1 Keyboard (org.apache.pivot.wtk.Keyboard)1 RadioButton (org.apache.pivot.wtk.RadioButton)1 Sheet (org.apache.pivot.wtk.Sheet)1 SheetCloseListener (org.apache.pivot.wtk.SheetCloseListener)1 TabPaneListener (org.apache.pivot.wtk.TabPaneListener)1 TabPaneSelectionListener (org.apache.pivot.wtk.TabPaneSelectionListener)1