Search in sources :

Example 16 with Sheet

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

the class TerraSheetSkin method getPreferredHeight.

@Override
public int getPreferredHeight(int width) {
    int preferredHeight = 0;
    Sheet sheet = (Sheet) getComponent();
    Component content = sheet.getContent();
    if (content != null) {
        if (width != -1) {
            width = Math.max(width - (padding.getWidth() + 2), 0);
        }
        preferredHeight = content.getPreferredHeight(width);
    }
    preferredHeight += (padding.getHeight() + 2);
    return preferredHeight;
}
Also used : Component(org.apache.pivot.wtk.Component) Sheet(org.apache.pivot.wtk.Sheet) Point(org.apache.pivot.wtk.Point)

Example 17 with Sheet

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

the class TerraSheetSkin method mouseDown.

@Override
public boolean mouseDown(Container container, Mouse.Button button, int x, int y) {
    Sheet sheet = (Sheet) container;
    if (!sheet.isTopMost()) {
        Window owner = sheet.getOwner();
        owner.moveToFront();
    }
    boolean consumed = super.mouseDown(container, button, x, y);
    if (resizable && button == Mouse.Button.LEFT) {
        Bounds resizeHandleBounds = resizeHandle.getBounds();
        if (resizeHandleBounds.contains(x, y)) {
            resizeOffset = new Point(getWidth() - x, getHeight() - y);
            Mouse.capture(container);
        }
    }
    return consumed;
}
Also used : Window(org.apache.pivot.wtk.Window) Bounds(org.apache.pivot.wtk.Bounds) Point(org.apache.pivot.wtk.Point) Sheet(org.apache.pivot.wtk.Sheet)

Example 18 with Sheet

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

the class TerraSheetSkin method keyPressed.

/**
 * {@link KeyCode#ENTER ENTER} Close the sheet with a 'result' of true.<br>
 * {@link KeyCode#ESCAPE ESCAPE} Close the sheet with a 'result' of false.
 */
@Override
public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
    boolean consumed = false;
    Sheet sheet = (Sheet) getComponent();
    if (keyCode == Keyboard.KeyCode.ENTER) {
        sheet.close(true);
        consumed = true;
    } else if (keyCode == Keyboard.KeyCode.ESCAPE) {
        sheet.close(false);
        consumed = true;
    } else {
        consumed = super.keyPressed(component, keyCode, keyLocation);
    }
    return consumed;
}
Also used : Sheet(org.apache.pivot.wtk.Sheet)

Example 19 with Sheet

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

the class TerraSheetSkin method layout.

@Override
public void layout() {
    int width = getWidth();
    int height = getHeight();
    Sheet sheet = (Sheet) getComponent();
    // Size/position resize handle
    resizeHandle.setSize(resizeHandle.getPreferredSize());
    resizeHandle.setLocation(width - resizeHandle.getWidth() - 2, height - resizeHandle.getHeight() - 2);
    resizeHandle.setVisible(resizable && !sheet.isMaximized() && (sheet.isPreferredWidthSet() || sheet.isPreferredHeightSet()));
    Component content = sheet.getContent();
    if (content != null) {
        content.setLocation(padding.left + 1, padding.top + 1);
        int contentWidth = Math.max(width - (padding.getWidth() + 2), 0);
        int contentHeight = Math.max(height - (padding.getHeight() + 2), 0);
        content.setSize(contentWidth, contentHeight);
    }
}
Also used : Component(org.apache.pivot.wtk.Component) Sheet(org.apache.pivot.wtk.Sheet) Point(org.apache.pivot.wtk.Point)

Example 20 with Sheet

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

the class TerraSheetSkin method getPreferredSize.

@Override
public Dimensions getPreferredSize() {
    Dimensions preferredSize = Dimensions.ZERO;
    Sheet sheet = (Sheet) getComponent();
    Component content = sheet.getContent();
    if (content != null) {
        preferredSize = content.getPreferredSize();
    }
    // Account for border in the size
    return preferredSize.expand(2).expand(padding);
}
Also used : Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component) Sheet(org.apache.pivot.wtk.Sheet)

Aggregations

Sheet (org.apache.pivot.wtk.Sheet)22 SheetCloseListener (org.apache.pivot.wtk.SheetCloseListener)11 Button (org.apache.pivot.wtk.Button)9 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)8 PushButton (org.apache.pivot.wtk.PushButton)8 Component (org.apache.pivot.wtk.Component)6 Point (org.apache.pivot.wtk.Point)6 File (java.io.File)5 FileBrowserSheet (org.apache.pivot.wtk.FileBrowserSheet)5 Frame (org.apache.pivot.wtk.Frame)4 ListView (org.apache.pivot.wtk.ListView)4 IOException (java.io.IOException)3 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)3 ArrayList (org.apache.pivot.collections.ArrayList)3 HashMap (org.apache.pivot.collections.HashMap)3 List (org.apache.pivot.collections.List)3 Bounds (org.apache.pivot.wtk.Bounds)3 BoxPane (org.apache.pivot.wtk.BoxPane)3 TaskAdapter (org.apache.pivot.wtk.TaskAdapter)3 Window (org.apache.pivot.wtk.Window)3