Examples of MenuItemState


Examples of org.apache.harmony.awt.state.MenuItemState

        int checkMarkWidth = itemHeight;

        gr.setFont(f);
        for (int index=0; index < s.getItemCount(); index++) {

            MenuItemState is = s.getItem(index);
            String label = is.getText();
            if (!label.equals("-")) {
                int dy = verticalPadding * 2 + itemHeight;
                y += dy;

                if (!is.isEnabled()) {
                    gr.setColor(SystemColor.textInactiveText);
                } else if (index == s.getSelectedItemIndex()) {
                    gr.setColor(SystemColor.textHighlight);
                    gr.fillRect(spacing, y - dy, w - 2*spacing, dy);
                    gr.setColor(SystemColor.textHighlightText);

                } else {
                    gr.setColor(SystemColor.menuText);
                }

                gr.drawString(label, leftMargin + spacing + checkMarkWidth,
                        y - verticalPadding - fm.getDescent() );

                if (is.isMenu()) {
                    int sz = dy/4;
                    int base = y - dy/2 - 1;
                    int dx = w - spacing - rightMargin - sz - 2;
                    int px[] = new int[] { dx, dx + sz, dx };
                    int py[] = new int[] { base - sz, base, base + sz };
                    gr.fillPolygon(px, py, px.length);
                }
                if (is.isChecked()) {
                    int sz = dy/6;
                    int dx = spacing + sz + leftMargin;
                    int base = y - verticalPadding - fm.getDescent();

                    int px[] = new int[] { dx, dx - sz, dx - sz, dx,
View Full Code Here

Examples of org.apache.harmony.awt.state.MenuItemState

        int arrowSpaceWidth = itemHeight + rightMargin;

        for (int index=0; index < s.getItemCount(); index++) {

            int dx = 0, dy = 0;
            MenuItemState is = s.getItem(index);
            String label = is.getText();
            if (!label.equals("-")) {
                dy = verticalPadding * 2 + itemHeight;
                dx = fm.stringWidth(label);
            } else {
                // separator
                dy = verticalPadding * 2 + separatorHeight;
                dx = 2 * separatorMargin;
            }
            h += dy;
            w = Math.max(w, dx);
            is.setItemBounds(spacing, h - dy, w - 2 * spacing, dy);
        }
        h += spacing;
        w += spacing + checkMarkWidth + leftMargin +
                rightMargin + arrowSpaceWidth + spacing;

        for (int index=0; index < s.getItemCount(); index++) {
            MenuItemState is = s.getItem(index);
            is.getItemBounds().width = w;
        }

        return new Dimension(w, h);
    }
View Full Code Here

Examples of org.apache.harmony.awt.state.MenuItemState

        int checkMarkWidth = itemHeight;

        gr.setFont(f);
        for (int index=0; index < s.getItemCount(); index++) {

            MenuItemState is = s.getItem(index);
            String label = is.getText();
            if (!label.equals("-")) { //$NON-NLS-1$
                int dy = verticalPadding * 2 + itemHeight;
                y += dy;

                if (!is.isEnabled()) {
                    gr.setColor(SystemColor.textInactiveText);
                } else if (index == s.getSelectedItemIndex()) {
                    gr.setColor(SystemColor.textHighlight);
                    gr.fillRect(spacing, y - dy, w - 2*spacing, dy);
                    gr.setColor(SystemColor.textHighlightText);

                } else {
                    gr.setColor(SystemColor.menuText);
                }

                gr.drawString(label, leftMargin + spacing + checkMarkWidth,
                        y - verticalPadding - fm.getDescent() );

                if (is.isMenu()) {
                    int sz = dy/4;
                    int base = y - dy/2 - 1;
                    int dx = w - spacing - rightMargin - sz - 2;
                    int px[] = new int[] { dx, dx + sz, dx };
                    int py[] = new int[] { base - sz, base, base + sz };
                    gr.fillPolygon(px, py, px.length);
                }
                if (is.isChecked()) {
                    int sz = dy/6;
                    int dx = spacing + sz + leftMargin;
                    int base = y - verticalPadding - fm.getDescent();

                    int px[] = new int[] { dx, dx - sz, dx - sz, dx,
View Full Code Here

Examples of org.apache.harmony.awt.state.MenuItemState

        int arrowSpaceWidth = itemHeight + rightMargin;

        for (int index=0; index < s.getItemCount(); index++) {

            int dx = 0, dy = 0;
            MenuItemState is = s.getItem(index);
            String label = is.getText();
            if (!label.equals("-")) { //$NON-NLS-1$
                dy = verticalPadding * 2 + itemHeight;
                dx = fm.stringWidth(label);
            } else {
                // separator
                dy = verticalPadding * 2 + separatorHeight;
                dx = 2 * separatorMargin;
            }
            h += dy;
            w = Math.max(w, dx);
            is.setItemBounds(spacing, h - dy, w - 2 * spacing, dy);
        }
        h += spacing;
        w += spacing + checkMarkWidth + leftMargin +
                rightMargin + arrowSpaceWidth + spacing;

        for (int index=0; index < s.getItemCount(); index++) {
            MenuItemState is = s.getItem(index);
            is.getItemBounds().width = w;
        }

        return new Dimension(w, h);
    }
View Full Code Here

Examples of org.apache.harmony.awt.state.MenuItemState

        FontMetrics fm = s.getFontMetrics(f);
        int lineHeight = getItemHeight(fm);
        int lines = 0;
        int lineWidth = 0;
        for (int i=0; i<s.getItemCount(); i++) {
            MenuItemState is = s.getItem(i);
            int itemWidth = getItemWidth(fm, is);
            if (itemWidth >= width) {
                lines += (lineWidth == 0 ? 1 : 2);
                lineWidth = 0;
                is.setItemBounds(0, lines * lineHeight, itemWidth, lineHeight);
                continue;
            }
            if (lineWidth + itemWidth > width) {
                lines ++;
                lineWidth = itemWidth;
                is.setItemBounds(0, lines * lineHeight, itemWidth, lineHeight);
                continue;
            }
            is.setItemBounds(lineWidth, lines * lineHeight, itemWidth, lineHeight);
            lineWidth += itemWidth;
        }
        if (lineWidth > 0) {
            lines ++;
        }
View Full Code Here

Examples of org.apache.harmony.awt.state.MenuItemState

        g.setFont(s.getFont());
        g.setColor(SystemColor.menuText);
        int selected = s.getSelectedItemIndex();
        for (int i=0; i<s.getItemCount(); i++) {
            MenuItemState is = s.getItem(i);
            Rectangle item = is.getItemBounds();
            Rectangle text = is.getTextBounds();

            if (!is.isEnabled()) {
                g.setColor(SystemColor.textInactiveText);
            } else if (i == selected) {
                g.setColor(SystemColor.textHighlight);
                g.fillRect(item.x, item.y, item.width, item.height);
                g.setColor(SystemColor.textHighlightText);
            } else {
                g.setColor(SystemColor.menuText);
            }
            g.drawString(is.getText(), item.x + text.x, item.y + text.y);
        }
    }
View Full Code Here

Examples of org.apache.harmony.awt.state.MenuItemState

    }

    public static int getItemIndex(MenuBarState s, Point p) {

        for (int i=0; i<s.getItemCount(); i++) {
            MenuItemState is = s.getItem(i);
            Rectangle bounds = is.getItemBounds();
            if (bounds.contains(p)) {
                return i;
            }
        }
View Full Code Here

Examples of org.apache.harmony.awt.state.MenuItemState

    public static Point getItemLocation(MenuBarState s, int index) {
        if (index < 0 || index >= s.getItemCount()) {
            return new Point(-1, -1);
        }

        MenuItemState is = s.getItem(index);
        Rectangle bounds = is.getItemBounds();
        Point where = new Point(bounds.x, bounds.y + bounds.height);
        Point screenPos = s.getLocationOnScreen();
        where.translate(screenPos.x, screenPos.y);
        return where;
    }
View Full Code Here

Examples of org.apache.harmony.awt.state.MenuItemState

        g.setFont(s.getFont());
        g.setColor(SystemColor.menuText);
        int selected = s.getSelectedItemIndex();
        for (int i=0; i<s.getItemCount(); i++) {
            MenuItemState is = s.getItem(i);
            Rectangle item = is.getItemBounds();
            Rectangle text = is.getTextBounds();

            if (!is.isEnabled()) {
                g.setColor(SystemColor.textInactiveText);
            } else if (i == selected) {
                g.setColor(SystemColor.textHighlight);
                g.fillRect(item.x, item.y, item.width, item.height);
                g.setColor(SystemColor.textHighlightText);
            } else {
                g.setColor(SystemColor.menuText);
            }
            g.drawString(is.getText(), item.x + text.x, item.y + text.y);
        }
    }
View Full Code Here

Examples of org.apache.harmony.awt.state.MenuItemState

    }

    public static int getItemIndex(MenuBarState s, Point p) {

        for (int i=0; i<s.getItemCount(); i++) {
            MenuItemState is = s.getItem(i);
            Rectangle bounds = is.getItemBounds();
            if (bounds.contains(p)) {
                return i;
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.