Search in sources :

Example 41 with Component

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

the class WindowSkin method getPreferredWidth.

@Override
public int getPreferredWidth(int height) {
    Window window = (Window) getComponent();
    Component content = window.getContent();
    return (content != null) ? content.getPreferredWidth(height) : 0;
}
Also used : Window(org.apache.pivot.wtk.Window) Component(org.apache.pivot.wtk.Component)

Example 42 with Component

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

the class WindowSkin method getPreferredHeight.

@Override
public int getPreferredHeight(int width) {
    Window window = (Window) getComponent();
    Component content = window.getContent();
    return (content != null) ? content.getPreferredHeight(width) : 0;
}
Also used : Window(org.apache.pivot.wtk.Window) Component(org.apache.pivot.wtk.Component)

Example 43 with Component

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

the class WindowSkin method getPreferredSize.

@Override
public Dimensions getPreferredSize() {
    Window window = (Window) getComponent();
    Component content = window.getContent();
    return (content != null) ? content.getPreferredSize() : Dimensions.ZERO;
}
Also used : Window(org.apache.pivot.wtk.Window) Component(org.apache.pivot.wtk.Component)

Example 44 with Component

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

the class WindowSkin method layout.

@Override
public void layout() {
    Window window = (Window) getComponent();
    Component content = window.getContent();
    if (content != null) {
        content.setSize(window.getSize());
    }
}
Also used : Window(org.apache.pivot.wtk.Window) Component(org.apache.pivot.wtk.Component)

Example 45 with Component

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

the class BoxPaneSkin method getPreferredHeight.

@Override
public int getPreferredHeight(int width) {
    BoxPane boxPane = (BoxPane) getComponent();
    int preferredHeight = 0;
    Orientation orientation = boxPane.getOrientation();
    if (orientation == Orientation.HORIZONTAL) {
        // Preferred height is the maximum preferred height of all components
        for (int i = 0, n = boxPane.getLength(); i < n; i++) {
            Component component = boxPane.get(i);
            if (component.isVisible()) {
                preferredHeight = Math.max(preferredHeight, component.getPreferredHeight());
            }
        }
    } else {
        int widthUpdated = width;
        // Include padding in constraint
        if (widthUpdated != -1) {
            widthUpdated = Math.max(widthUpdated - padding.getWidth(), 0);
        }
        // Preferred height is the sum of the preferred heights of all
        // components
        int j = 0;
        for (int i = 0, n = boxPane.getLength(); i < n; i++) {
            Component component = boxPane.get(i);
            if (component.isVisible()) {
                preferredHeight += component.getPreferredHeight(fill ? widthUpdated : -1);
                j++;
            }
        }
        // Include spacing
        if (j > 1) {
            preferredHeight += spacing * (j - 1);
        }
    }
    // Include top and bottom padding values
    preferredHeight += padding.getHeight();
    return preferredHeight;
}
Also used : BoxPane(org.apache.pivot.wtk.BoxPane) Orientation(org.apache.pivot.wtk.Orientation) 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