Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Sheet


    @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
            && !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.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.getMaximumWidth());
                    preferredWidth = Math.max(preferredWidth, sheet.getMinimumWidth());
                }

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

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

        return consumed;
    }

    @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);
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();
        if (owner != null) {
            Bounds clientArea = owner.getClientArea();

            Point location = owner.mapPointToAncestor(owner.getDisplay(), clientArea.x,
                clientArea.y);
            int x = location.x;
            int y = location.y;

            switch (slideSource) {
                case NORTH:
                    x = location.x + (clientArea.width - getWidth()) / 2;
                    y = location.y;
                    break;
                case SOUTH:
                    x = location.x + (clientArea.width - getWidth()) / 2;
                    y = location.y + (clientArea.height - getHeight());
                    break;
                case WEST:
                    x = location.x;
                    y = location.y + (clientArea.height - getHeight()) / 2;
                    break;
                case EAST:
                    x = location.x + (clientArea.width - getWidth());
                    y = location.y + (clientArea.height - getHeight()) / 2;
                    break;
                default:
                    throw new IllegalStateException("slideSource is null or an unexpected value");
            }

            sheet.setLocation(x, y);
        }
    }
View Full Code Here

            super(stateTransitionDuration, stateTransitionRate, false, reversed);
        }

        @Override
        public void start(TransitionListener transitionListener) {
            Sheet sheet = (Sheet)getComponent();
            sheet.getDecorators().add(translationDecorator);

            dx = 0;
            dy = 0;

            super.start(transitionListener);
View Full Code Here

            super.start(transitionListener);
        }

        @Override
        public void stop() {
            Sheet sheet = (Sheet)getComponent();
            sheet.getDecorators().remove(translationDecorator);

            super.stop();
        }
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.