Search in sources :

Example 21 with Menu

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

the class TerraMenuSkin method paint.

@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) {
            Menu.Item item = section.get(section.getLength() - 1);
            int separatorY = item.getY() + item.getHeight() + sectionSpacing / 2;
            // Paint the line
            graphics.setColor(separatorColor);
            graphics.drawLine(1, separatorY, width - 2, separatorY);
        }
    }
}
Also used : Item(org.apache.pivot.wtk.Menu.Item) Section(org.apache.pivot.wtk.Menu.Section) Menu(org.apache.pivot.wtk.Menu)

Aggregations

Menu (org.apache.pivot.wtk.Menu)21 Section (org.apache.pivot.wtk.Menu.Section)10 Item (org.apache.pivot.wtk.Menu.Item)8 Color (java.awt.Color)3 Display (org.apache.pivot.wtk.Display)3 Button (org.apache.pivot.wtk.Button)2 Component (org.apache.pivot.wtk.Component)2 Dimensions (org.apache.pivot.wtk.Dimensions)2 MenuPopup (org.apache.pivot.wtk.MenuPopup)2 Window (org.apache.pivot.wtk.Window)2 BasicStroke (java.awt.BasicStroke)1 Font (java.awt.Font)1 GradientPaint (java.awt.GradientPaint)1 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)1 Vote (org.apache.pivot.util.Vote)1 Action (org.apache.pivot.wtk.Action)1 Insets (org.apache.pivot.wtk.Insets)1 Keyboard (org.apache.pivot.wtk.Keyboard)1 MenuButton (org.apache.pivot.wtk.MenuButton)1 MenuHandler (org.apache.pivot.wtk.MenuHandler)1