Search in sources :

Example 11 with Frame

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

the class TerraFrameSkin method getClientArea.

@Override
public Bounds getClientArea() {
    int width = getWidth();
    int height = getHeight();
    int titleBarHeight = titleBarTablePane.getHeight();
    Frame frame = (Frame) getComponent();
    boolean maximized = frame.isMaximized();
    Bounds clientArea;
    if (maximized && !getShowWindowControls()) {
        clientArea = new Bounds(0, 0, width, height);
    } else {
        clientArea = new Bounds(0, titleBarHeight + 2, width, height - (titleBarHeight + 2));
    }
    return clientArea;
}
Also used : Frame(org.apache.pivot.wtk.Frame) Bounds(org.apache.pivot.wtk.Bounds) Point(org.apache.pivot.wtk.Point) GradientPaint(java.awt.GradientPaint)

Example 12 with Frame

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

the class TerraFrameSkin method install.

@Override
public void install(Component component) {
    super.install(component);
    Frame frame = (Frame) getComponent();
    if (!themeIsFlat()) {
        // Attach the drop-shadow decorator
        dropShadowDecorator = new DropShadowDecorator(5, 5, 5);
        frame.getDecorators().add(dropShadowDecorator);
    }
    frame.add(titleBarTablePane);
    // Create the frame buttons
    minimizeButton = new FrameButton(minimizeImage);
    maximizeButton = new FrameButton(maximizeImage);
    closeButton = new FrameButton(closeImage);
    buttonBoxPane.add(minimizeButton);
    buttonBoxPane.add(maximizeButton);
    buttonBoxPane.add(closeButton);
    ButtonPressListener buttonPressListener = new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            Frame frameLocal = (Frame) getComponent();
            if (button == minimizeButton) {
                frameLocal.setVisible(false);
            } else if (button == maximizeButton) {
                frameLocal.moveToFront();
                frameLocal.setMaximized(!frameLocal.isMaximized());
            } else if (button == closeButton) {
                frameLocal.close();
            }
        }
    };
    minimizeButton.getButtonPressListeners().add(buttonPressListener);
    maximizeButton.getButtonPressListeners().add(buttonPressListener);
    closeButton.getButtonPressListeners().add(buttonPressListener);
    frame.add(resizeHandle);
    iconAdded(frame, null);
    titleChanged(frame, null);
    activeChanged(frame, null);
    maximizedChanged(frame);
    setShowMinimizeButton(false);
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) Frame(org.apache.pivot.wtk.Frame) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) DropShadowDecorator(org.apache.pivot.wtk.effects.DropShadowDecorator)

Example 13 with Frame

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

the class TerraFrameSkin method getPreferredHeight.

@Override
public int getPreferredHeight(int width) {
    int preferredHeight = 0;
    Frame frame = (Frame) getComponent();
    // Include title bar height plus top/bottom title bar borders
    preferredHeight += titleBarTablePane.getPreferredHeight() + 2;
    // Include menu bar height
    MenuBar menuBar = frame.getMenuBar();
    if (menuBar != null) {
        preferredHeight += menuBar.getPreferredHeight();
    }
    Component content = frame.getContent();
    if (content != null) {
        if (width != -1) {
            // Subtract padding and left/right content borders from constraint
            width -= (padding.left + padding.right) + 2;
            width = Math.max(width, 0);
        }
        preferredHeight += content.getPreferredHeight(width);
    }
    // Add padding, top/bottom content borders, and content bevel
    preferredHeight += (padding.top + padding.bottom) + (showContentBevel ? 1 : 0) + 2;
    return preferredHeight;
}
Also used : Frame(org.apache.pivot.wtk.Frame) MenuBar(org.apache.pivot.wtk.MenuBar) Component(org.apache.pivot.wtk.Component) Point(org.apache.pivot.wtk.Point) GradientPaint(java.awt.GradientPaint)

Example 14 with Frame

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

the class TerraFrameSkin method keyPressed.

@Override
public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
    boolean consumed = super.keyPressed(component, keyCode, keyLocation);
    Frame frame = (Frame) component;
    MenuBar menuBar = frame.getMenuBar();
    if (menuBar != null && keyCode == Keyboard.KeyCode.SPACE && Keyboard.isPressed(Keyboard.Modifier.ALT)) {
        MenuBar.Item activeItem = menuBar.getActiveItem();
        MenuBar.ItemSequence items = menuBar.getItems();
        if (activeItem == null && items.getLength() > 0) {
            items.get(0).setActive(true);
            consumed = true;
        }
    }
    return consumed;
}
Also used : Frame(org.apache.pivot.wtk.Frame) MenuBar(org.apache.pivot.wtk.MenuBar)

Example 15 with Frame

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

the class TerraFrameSkin method paint.

@Override
public void paint(Graphics2D graphics) {
    // Call the base class to paint the background
    super.paint(graphics);
    Frame frame = (Frame) getComponent();
    int width = getWidth();
    int height = getHeight();
    boolean maximized = frame.isMaximized();
    if (!maximized || getShowWindowControls()) {
        int titleBarHeight = titleBarTablePane.getHeight();
        // Draw the title area
        Color titleBarBackgroundColorLocal = frame.isActive() ? this.titleBarBackgroundColor : inactiveTitleBarBackgroundColor;
        Color titleBarBorderColorLocal = frame.isActive() ? this.titleBarBorderColor : inactiveTitleBarBorderColor;
        Color titleBarBevelColorLocal = frame.isActive() ? this.titleBarBevelColor : inactiveTitleBarBevelColor;
        if (!themeIsFlat()) {
            graphics.setPaint(new GradientPaint(width / 2f, 0, titleBarBevelColorLocal, width / 2f, titleBarHeight + 1, titleBarBackgroundColorLocal));
            graphics.fillRect(0, 0, width, titleBarHeight + 1);
            // Draw the border
            graphics.setPaint(titleBarBorderColorLocal);
            GraphicsUtilities.drawRect(graphics, 0, 0, width, titleBarHeight + 2);
            // Draw the content area
            Bounds contentAreaRectangle = new Bounds(0, titleBarHeight + 2, width, height - (titleBarHeight + 2));
            graphics.setPaint(contentBorderColor);
            GraphicsUtilities.drawRect(graphics, contentAreaRectangle.x, contentAreaRectangle.y, contentAreaRectangle.width, contentAreaRectangle.height);
            if (showContentBevel) {
                graphics.setPaint(contentBevelColor);
                GraphicsUtilities.drawLine(graphics, contentAreaRectangle.x + 1, contentAreaRectangle.y + 1, contentAreaRectangle.width - 2, Orientation.HORIZONTAL);
            }
        } else {
            graphics.setPaint(titleBarBackgroundColorLocal);
            graphics.fillRect(0, 0, width, titleBarHeight + 1);
        }
    }
}
Also used : Frame(org.apache.pivot.wtk.Frame) Color(java.awt.Color) Bounds(org.apache.pivot.wtk.Bounds) GradientPaint(java.awt.GradientPaint) Point(org.apache.pivot.wtk.Point) GradientPaint(java.awt.GradientPaint)

Aggregations

Frame (org.apache.pivot.wtk.Frame)29 Component (org.apache.pivot.wtk.Component)13 BoxPane (org.apache.pivot.wtk.BoxPane)9 Point (org.apache.pivot.wtk.Point)9 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)8 GradientPaint (java.awt.GradientPaint)7 MenuBar (org.apache.pivot.wtk.MenuBar)6 Button (org.apache.pivot.wtk.Button)5 Label (org.apache.pivot.wtk.Label)5 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)4 PushButton (org.apache.pivot.wtk.PushButton)4 Sheet (org.apache.pivot.wtk.Sheet)4 Bounds (org.apache.pivot.wtk.Bounds)3 ListView (org.apache.pivot.wtk.ListView)3 Color (java.awt.Color)2 IOException (java.io.IOException)2 Action (org.apache.pivot.wtk.Action)2 Checkbox (org.apache.pivot.wtk.Checkbox)2 Dimensions (org.apache.pivot.wtk.Dimensions)2 Display (org.apache.pivot.wtk.Display)2