Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Menu$MenuItemSelectionListenerList


    @Override
    public int getPreferredHeight(int width) {
        int preferredHeight = 0;

        Menu menu = (Menu)getComponent();
        Menu.SectionSequence sections = menu.getSections();

        for (int i = 0, n = sections.getLength(); i < n; i++) {
            Menu.Section section = sections.get(i);

            for (Menu.Item item : section) {
View Full Code Here


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

        Menu menu = (Menu)getComponent();
        Menu.SectionSequence sections = menu.getSections();

        for (int i = 0, n = sections.getLength(); i < n; i++) {
            Menu.Section section = sections.get(i);

            for (Menu.Item item : section) {
View Full Code Here

        return new Dimensions(preferredWidth, preferredHeight);
    }

    @Override
    public void layout() {
        Menu menu = (Menu)getComponent();
        Menu.SectionSequence sections = menu.getSections();

        int width = getWidth();
        int itemY = 0;

        for (int i = 0, n = sections.getLength(); i < n; i++) {
View Full Code Here

    @Override
    public void paint(Graphics2D graphics) {
        super.paint(graphics);

        Menu menu = (Menu)getComponent();

        int width = getWidth();
        int height = getHeight();

        // Paint the margin
        if (marginColor != null) {
            graphics.setColor(marginColor);
            graphics.fillRect(0, 0, margin, height);
        }

        Menu.SectionSequence sections = menu.getSections();

        for (int i = 0, n = sections.getLength(); i < n; i++) {
            Menu.Section section = sections.get(i);

            if (section.getLength() > 0) {
View Full Code Here

    @Override
    public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
        boolean consumed = super.keyPressed(component, keyCode, keyLocation);

        Menu menu = (Menu)component;

        if (keyCode == Keyboard.KeyCode.UP) {
            menu.activatePreviousItem();
            consumed = true;
        } else if (keyCode == Keyboard.KeyCode.DOWN) {
            menu.activateNextItem();
            consumed = true;
        } else if (keyCode == Keyboard.KeyCode.LEFT) {
            // Close the window if this is not a top-level menu
            if (menu.getItem() != null) {
                Window window = menu.getWindow();
                window.close();
                consumed = true;
            }
        } else if (keyCode == Keyboard.KeyCode.RIGHT) {
            Menu.Item activeItem = menu.getActiveItem();

            // Press if the item has a sub-menu
            if (activeItem != null
                && activeItem.getMenu() != null) {
                activeItem.press();
                consumed = true;
            }
        } else if (keyCode == Keyboard.KeyCode.ENTER) {
            Menu.Item activeItem = menu.getActiveItem();

            // Press if the item does not have a sub-menu
            if (activeItem != null
                && activeItem.getMenu() == null) {
                activeItem.press();
View Full Code Here

    @Override
    public boolean keyReleased(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
        boolean consumed = super.keyReleased(component, keyCode, keyLocation);

        Menu menu = (Menu)component;

        if (keyCode == Keyboard.KeyCode.SPACE) {
            Menu.Item activeItem = menu.getActiveItem();

            // Press if the item does not have a sub-menu
            if (activeItem != null
                && activeItem.getMenu() == null) {
                activeItem.press();
View Full Code Here

    }

    @Override
    public void buttonPressed(Button button) {
        Menu.Item menuItem = (Menu.Item)getComponent();
        Menu menu = menuItem.getMenu();

        if (menu != null
            && !menuPopup.isOpen()) {
            Display display = menuItem.getDisplay();
            Point location = menuItem.mapPointToAncestor(display, getWidth(), 0);
View Full Code Here

            icon = (Image)button.getStyles().get("checkmarkImage");
        }

        // Update the image view
        Menu.Item menuItem = (Menu.Item)button;
        Menu menu = menuItem.getSection().getMenu();

        int margin = (Integer)menu.getStyles().get("margin");
        Insets padding = (Insets)getStyles().get("padding");

        imageView.setImage(icon);
        imageView.setPreferredWidth(margin - padding.left * 2);
        imageView.getStyles().put("opacity", button.isEnabled() ? 1.0f : 0.5f);

        // Update the labels
        textLabel.setText(text);

        Font font = (Font)menu.getStyles().get("font");
        textLabel.getStyles().put("font", font);
        keyboardShortcutLabel.getStyles().put("font", font.deriveFont(Font.ITALIC));

        Color color;
        if (button.isEnabled()) {
            if (highlighted) {
                color = (Color)menu.getStyles().get("activeColor");
            } else {
                color = (Color)menu.getStyles().get("color");
            }
        } else {
            color = (Color)menu.getStyles().get("disabledColor");
        }

        textLabel.getStyles().put("color", color);
        keyboardShortcutLabel.getStyles().put("color", color);

        boolean showKeyboardShortcuts = false;
        if (menu.getStyles().containsKey("showKeyboardShortcuts")) {
            showKeyboardShortcuts = (Boolean)menu.getStyles().get("showKeyboardShortcuts");
        }

        if (showKeyboardShortcuts) {
            keyboardShortcutLabel.setVisible(true);
            keyboardShortcutLabel.setText(keyboardShortcut == null ?
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.Menu$MenuItemSelectionListenerList

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.