Search in sources :

Example 71 with Component

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

the class SpinnerFocusTest method startup.

@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
    Action action = new Action() {

        @Override
        public String getDescription() {
            return null;
        }

        @Override
        public void perform(final Component source) {
            String msg = "Selected: " + spinner.getSelectedItem().toString();
            Alert.alert(msg, frame);
            spinner.requestFocus();
            System.out.println("Focus transferred to spinner");
        }
    };
    Action.getNamedActions().put("buttonAction", action);
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    frame = new Frame((Component) bxmlSerializer.readObject(getClass().getResource("spinner_focus_test.bxml")));
    frame.setTitle("Spinner Focus Test");
    frame.open(display);
    spinner = (Spinner) bxmlSerializer.getNamespace().get("spinner");
    spinner.requestFocus();
// action.setEnabled(false);
}
Also used : Action(org.apache.pivot.wtk.Action) Frame(org.apache.pivot.wtk.Frame) Component(org.apache.pivot.wtk.Component) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 72 with Component

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

the class LinkButtonTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BoxPane boxPane = new BoxPane();
    boxPane.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    boxPane.getStyles().put(Style.spacing, 8);
    boxPane.getComponentMouseListeners().add(new ComponentMouseListener() {

        @Override
        public boolean mouseMove(Component component, int x, int y) {
            System.out.println("BOX PANE " + x + ", " + y);
            return false;
        }

        @Override
        public void mouseOver(Component component) {
        // empty block
        }

        @Override
        public void mouseOut(Component component) {
        // empty block
        }
    });
    Image image = Image.load(getClass().getResource("go-home.png"));
    LinkButton linkButton = null;
    linkButton = new LinkButton("ABCDE");
    boxPane.add(linkButton);
    linkButton.getComponentMouseListeners().add(new ComponentMouseListener() {

        @Override
        public boolean mouseMove(Component component, int x, int y) {
            return true;
        }

        @Override
        public void mouseOver(Component component) {
        // empty block
        }

        @Override
        public void mouseOut(Component component) {
        // empty block
        }
    });
    linkButton = new LinkButton(image);
    boxPane.add(linkButton);
    linkButton = new LinkButton(new ButtonData(image, "12345"));
    boxPane.add(linkButton);
    window.setContent(boxPane);
    window.open(display);
}
Also used : BoxPane(org.apache.pivot.wtk.BoxPane) ButtonData(org.apache.pivot.wtk.content.ButtonData) Component(org.apache.pivot.wtk.Component) Image(org.apache.pivot.wtk.media.Image) ComponentMouseListener(org.apache.pivot.wtk.ComponentMouseListener) LinkButton(org.apache.pivot.wtk.LinkButton)

Example 73 with Component

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

the class TerraTooltipSkin method getPreferredSize.

@Override
public Dimensions getPreferredSize() {
    Dimensions size = Dimensions.ZERO;
    Tooltip tooltip = (Tooltip) getComponent();
    Component content = tooltip.getContent();
    if (content != null) {
        size = content.getPreferredSize();
    }
    return size.expand(padding);
}
Also used : Tooltip(org.apache.pivot.wtk.Tooltip) Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component)

Example 74 with Component

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

the class TerraVFSBrowserSkin method getFileAt.

@Override
public FileObject getFileAt(int x, int y) {
    FileObject file = null;
    VFSBrowser fileBrowser = (VFSBrowser) getComponent();
    Component component = fileBrowser.getDescendantAt(x, y);
    if (component == fileTableView) {
        Point location = fileTableView.mapPointFromAncestor(fileBrowser, x, y);
        int index = fileTableView.getRowAt(location.y);
        if (index != -1) {
            file = (FileObject) fileTableView.getTableData().get(index);
        }
    }
    return file;
}
Also used : FileObject(org.apache.commons.vfs2.FileObject) Point(org.apache.pivot.wtk.Point) Component(org.apache.pivot.wtk.Component) VFSBrowser(org.apache.pivot.wtk.VFSBrowser) Point(org.apache.pivot.wtk.Point)

Example 75 with Component

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

the class TerraExpanderSkin method getPreferredHeight.

@Override
public int getPreferredHeight(int width) {
    Expander expander = (Expander) getComponent();
    Component content = expander.getContent();
    int preferredHeight = titleBarTablePane.getPreferredHeight(-1);
    if (content != null && (expander.isExpanded() || expandTransition != null)) {
        // Title bar border is only drawn when content is non-null and
        // expander is expanded or expanding
        preferredHeight += 1;
        int contentWidth = -1;
        if (width >= 0) {
            contentWidth = Math.max(width - (2 + padding.getWidth()), 0);
        }
        int fullHeight = padding.getHeight() + content.getPreferredHeight(contentWidth);
        if (expandTransition == null) {
            preferredHeight += fullHeight;
        } else {
            float scale = expandTransition.getScale();
            preferredHeight += (int) (scale * fullHeight);
        }
    }
    preferredHeight += 2;
    return preferredHeight;
}
Also used : Expander(org.apache.pivot.wtk.Expander) Component(org.apache.pivot.wtk.Component) GradientPaint(java.awt.GradientPaint)

Aggregations

Component (org.apache.pivot.wtk.Component)209 Dimensions (org.apache.pivot.wtk.Dimensions)40 Point (org.apache.pivot.wtk.Point)38 GradientPaint (java.awt.GradientPaint)33 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)24 TextInput (org.apache.pivot.wtk.TextInput)21 Label (org.apache.pivot.wtk.Label)20 BoxPane (org.apache.pivot.wtk.BoxPane)18 Paint (java.awt.Paint)17 Button (org.apache.pivot.wtk.Button)15 PushButton (org.apache.pivot.wtk.PushButton)14 ScrollPane (org.apache.pivot.wtk.ScrollPane)14 TablePane (org.apache.pivot.wtk.TablePane)14 Window (org.apache.pivot.wtk.Window)14 IOException (java.io.IOException)13 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)13 Frame (org.apache.pivot.wtk.Frame)13 FlowPane (org.apache.pivot.wtk.FlowPane)12 ComponentStateListener (org.apache.pivot.wtk.ComponentStateListener)11 ComponentMouseButtonListener (org.apache.pivot.wtk.ComponentMouseButtonListener)10