Search in sources :

Example 41 with Window

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

the class TerraPaletteSkin method mouseDown.

@Override
public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
    boolean consumed = super.mouseDown(component, button, x, y);
    Window window = (Window) getComponent();
    boolean maximized = window.isMaximized();
    if (button == Mouse.Button.LEFT && !maximized) {
        Bounds titleBarBounds = titleBarTablePane.getBounds();
        if (titleBarBounds.contains(x, y)) {
            dragOffset = new Point(x, y);
            Mouse.capture(component);
        } else {
            if (resizeHandle.isVisible() && x > resizeHandle.getX() && y > resizeHandle.getY()) {
                resizeOffset = new Point(getWidth() - x, getHeight() - y);
                Mouse.capture(component);
            }
        }
    }
    return consumed;
}
Also used : Window(org.apache.pivot.wtk.Window) Bounds(org.apache.pivot.wtk.Bounds) Point(org.apache.pivot.wtk.Point)

Example 42 with Window

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

the class TerraDialogSkin method mouseDown.

@Override
public boolean mouseDown(Container container, Mouse.Button button, int x, int y) {
    Dialog dialog = (Dialog) container;
    if (!dialog.isTopMost()) {
        Window rootOwner = dialog.getRootOwner();
        rootOwner.moveToFront();
    }
    return super.mouseDown(container, button, x, y);
}
Also used : Window(org.apache.pivot.wtk.Window) Dialog(org.apache.pivot.wtk.Dialog)

Example 43 with Window

use of org.apache.pivot.wtk.Window 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 44 with Window

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

the class BXMLExplorerDocument method load.

public void load(File f) throws IOException, SerializationException, ParserConfigurationException, SAXException {
    BXMLSerializer serializer = new BXMLSerializer();
    serializer.setLocation(f.toURI().toURL());
    try (FileInputStream in = new FileInputStream(f)) {
        Object obj = serializer.readObject(in);
        if (!(obj instanceof Component)) {
            throw new IllegalStateException("obj " + obj + " is of class " + obj.getClass() + " which is not a subtype of Component");
        }
        // create an inverse map so we can IDs for widgets
        widgetToID = new HashMap<>();
        for (String key : serializer.getNamespace()) {
            widgetToID.put(serializer.getNamespace().get(key), key);
        }
        // we can't add a Window into the component hierarchy, so fake it
        if (obj instanceof Window) {
            obj = new FakeWindow((Window) obj);
        }
        // create the explorer tree
        componentToTreeNode = new HashMap<>();
        // the root node is not visible
        final TreeBranch rootbranch = new TreeBranch("");
        rootbranch.add(analyseObjectTree(obj));
        treeView.setTreeData(rootbranch);
        treeView.expandAll();
        // add the loaded widget to the display
        this.loadedComponent = (Component) obj;
        playgroundCardPane.add((Component) obj);
    }
    try (FileInputStream in2 = new FileInputStream(f)) {
        CreateHighlightedXML xml = new CreateHighlightedXML();
        bxmlSourceTextPane.setDocument(xml.prettyPrint(in2));
    }
    this.file = f;
}
Also used : Window(org.apache.pivot.wtk.Window) TreeBranch(org.apache.pivot.wtk.content.TreeBranch) Component(org.apache.pivot.wtk.Component) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer) FileInputStream(java.io.FileInputStream)

Example 45 with Window

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

the class Windows method shutdown.

@Override
public boolean shutdown(boolean optional) {
    for (int i = display.getLength() - 1; i >= 0; i--) {
        Window window = (Window) display.get(i);
        window.close();
    }
    return false;
}
Also used : Window(org.apache.pivot.wtk.Window)

Aggregations

Window (org.apache.pivot.wtk.Window)45 Component (org.apache.pivot.wtk.Component)14 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)13 PushButton (org.apache.pivot.wtk.PushButton)9 BoxPane (org.apache.pivot.wtk.BoxPane)8 Button (org.apache.pivot.wtk.Button)7 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)6 Display (org.apache.pivot.wtk.Display)5 Border (org.apache.pivot.wtk.Border)4 Label (org.apache.pivot.wtk.Label)4 Sheet (org.apache.pivot.wtk.Sheet)4 TablePane (org.apache.pivot.wtk.TablePane)4 File (java.io.File)3 Bounds (org.apache.pivot.wtk.Bounds)3 Point (org.apache.pivot.wtk.Point)3 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 SerializationException (org.apache.pivot.serialization.SerializationException)2 Vote (org.apache.pivot.util.Vote)2 TaskExecutionException (org.apache.pivot.util.concurrent.TaskExecutionException)2