Search in sources :

Example 51 with Component

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

the class CardPaneSkin method getBaseline.

@Override
public int getBaseline(int width, int height) {
    int baseline = -1;
    if (sizeToSelection) {
        CardPane cardPane = (CardPane) getComponent();
        Component selectedCard = cardPane.getSelectedCard();
        if (selectedCard != null) {
            int cardWidth = Math.max(width - padding.getWidth(), 0);
            int cardHeight = Math.max(height - padding.getHeight(), 0);
            baseline = selectedCard.getBaseline(cardWidth, cardHeight);
            if (baseline != -1) {
                baseline += padding.top;
            }
        }
    }
    return baseline;
}
Also used : CardPane(org.apache.pivot.wtk.CardPane) Component(org.apache.pivot.wtk.Component)

Example 52 with Component

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

the class CardPaneSkin method selectedIndexChanged.

@Override
public void selectedIndexChanged(CardPane cardPane, int previousSelectedIndex) {
    int selectedIndex = cardPane.getSelectedIndex();
    if (selectedIndex != previousSelectedIndex) {
        // This was not an indirect selection change
        if (selectedIndex != -1) {
            Component selectedCard = cardPane.get(selectedIndex);
            selectedCard.setVisible(true);
        }
        if (previousSelectedIndex != -1) {
            Component previousSelectedCard = cardPane.get(previousSelectedIndex);
            previousSelectedCard.setVisible(false);
        }
        if (selectedIndex == -1 || previousSelectedIndex == -1 || sizeToSelection) {
            invalidateComponent();
        }
    }
}
Also used : Component(org.apache.pivot.wtk.Component)

Example 53 with Component

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

the class StackPaneSkin method getPreferredHeight.

@Override
public int getPreferredHeight(int width) {
    int preferredHeight = 0;
    StackPane stackPane = (StackPane) getComponent();
    for (Component component : stackPane) {
        preferredHeight = Math.max(preferredHeight, component.getPreferredHeight(width));
    }
    preferredHeight += padding.getHeight();
    return preferredHeight;
}
Also used : Component(org.apache.pivot.wtk.Component) StackPane(org.apache.pivot.wtk.StackPane)

Example 54 with Component

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

the class StackPaneSkin method getPreferredWidth.

@Override
public int getPreferredWidth(int height) {
    int preferredWidth = 0;
    StackPane stackPane = (StackPane) getComponent();
    for (Component component : stackPane) {
        preferredWidth = Math.max(preferredWidth, component.getPreferredWidth(height));
    }
    preferredWidth += padding.getWidth();
    return preferredWidth;
}
Also used : Component(org.apache.pivot.wtk.Component) StackPane(org.apache.pivot.wtk.StackPane)

Example 55 with Component

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

the class StackPaneSkin method layout.

@Override
public void layout() {
    // Set the size of all components to match the size of the stack pane,
    // minus padding
    StackPane stackPane = (StackPane) getComponent();
    int width = Math.max(getWidth() - padding.getWidth(), 0);
    int height = Math.max(getHeight() - padding.getHeight(), 0);
    for (Component component : stackPane) {
        component.setLocation(padding.left, padding.top);
        component.setSize(width, height);
    }
}
Also used : Component(org.apache.pivot.wtk.Component) StackPane(org.apache.pivot.wtk.StackPane)

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