Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Sheet


        display.getStyles().put("backgroundColor", new Color(0, 127, 127));
        window1.setContent(new Label("Hello Bar"));
        window1.open(display);

        Sheet sheet = new Sheet();
        sheet.setContent(new Label("Hello Foo"));
        sheet.open(window1);

        Frame window1a = new Frame();
        window1a.setTitle("Window 1 A");
        window1a.setPreferredSize(160, 120);
        window1a.open(window1);
View Full Code Here


    @Override
    public void install(Component component) {
        super.install(component);

        Sheet sheet = (Sheet)component;
        sheet.getSheetStateListeners().add(this);

        // Attach the drop-shadow decorator
        dropShadowDecorator = new DropShadowDecorator(3, 3, 3);
        sheet.getDecorators().add(dropShadowDecorator);

        sheet.add(resizeHandle);
    }
View Full Code Here

    @Override
    public int getPreferredWidth(int height) {
        int preferredWidth = 0;

        Sheet sheet = (Sheet)getComponent();
        Component content = sheet.getContent();

        if (content != null) {
            if (height != -1) {
                height = Math.max(height - (padding.top + padding.bottom + 2), 0);
            }
View Full Code Here

    @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.left + padding.right + 2), 0);
            }
View Full Code Here

    @Override
    public Dimensions getPreferredSize() {
        int preferredWidth = 0;
        int preferredHeight = 0;

        Sheet sheet = (Sheet)getComponent();
        Component content = sheet.getContent();

        if (content != null) {
            Dimensions preferredContentSize = content.getPreferredSize();
            preferredWidth = preferredContentSize.width;
            preferredHeight = preferredContentSize.height;
View Full Code Here

    @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);

        Component content = sheet.getContent();
        if (content != null) {
            content.setLocation(padding.left + 1, padding.top + 1);

            int contentWidth = Math.max(width - (padding.left + padding.right + 2), 0);
            int contentHeight = Math.max(height - (padding.top + padding.bottom + 2), 0);
View Full Code Here

    @Override
    public boolean mouseMove(Component component, int x, int y) {
        boolean consumed = super.mouseMove(component, x, y);

        if (Mouse.getCapturer() == component) {
            Sheet sheet = (Sheet)getComponent();
            Display display = sheet.getDisplay();

            Point location = sheet.mapPointToAncestor(display, x, y);

            // Pretend that the mouse can't move off screen (off the display)
            location = new Point(Math.min(Math.max(location.x, 0), display.getWidth() - 1),
                Math.min(Math.max(location.y, 0), display.getHeight() - 1));

            if (resizeOffset != null) {
                // Resize the frame
                int preferredWidth = -1;
                int preferredHeight = -1;
                boolean preferredWidthSet = component.isPreferredWidthSet();
                boolean preferredHeightSet = component.isPreferredHeightSet();
                boolean noPreferredSet = !(preferredWidthSet || preferredHeightSet);

                if (preferredWidthSet || noPreferredSet) {
                    preferredWidth = Math.max(location.x - sheet.getX() + resizeOffset.x, 2);
                    preferredWidth = Math.min(preferredWidth, sheet.getMaximumPreferredWidth());
                    preferredWidth = Math.max(preferredWidth, sheet.getMinimumPreferredWidth());
                }

                if (preferredHeightSet || noPreferredSet) {
                    preferredHeight = Math.max(location.y - sheet.getY() + resizeOffset.y,
                        resizeHandle.getHeight() + 7);
                    preferredHeight = Math.min(preferredHeight, sheet.getMaximumPreferredHeight());
                    preferredHeight = Math.max(preferredHeight, sheet.getMinimumPreferredHeight());
                }

                sheet.setPreferredSize(preferredWidth, preferredHeight);
            }
        } else {
            Cursor cursor = null;
            Bounds resizeHandleBounds = resizeHandle.getBounds();
View Full Code Here

        return consumed;
    }

    @Override
    public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
        Sheet sheet = (Sheet)component;
        Window owner = sheet.getOwner();
        owner.moveToFront();

        boolean consumed = super.mouseDown(component, button, x, y);

        if (resizable && button == Mouse.Button.LEFT) {
View Full Code Here

    @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);
        }
View Full Code Here

    public void sheetClosed(Sheet sheet) {
        // No-op
    }

    public void alignToOwner() {
        Sheet sheet = (Sheet)getComponent();

        Window owner = sheet.getOwner();
        Bounds clientArea = owner.getClientArea();

        Point location = owner.mapPointToAncestor(owner.getDisplay(), clientArea.x, clientArea.y);
        sheet.setLocation(location.x + (clientArea.width - getWidth()) / 2, location.y);
    }
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.Sheet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.