org.apache.pivot.wtk.skin.terra
Class TerraMenuSkin

java.lang.Object
  extended by org.apache.pivot.wtk.skin.ComponentSkin
      extended by org.apache.pivot.wtk.skin.ContainerSkin
          extended by org.apache.pivot.wtk.skin.terra.TerraMenuSkin
All Implemented Interfaces:
ComponentKeyListener, ComponentListener, ComponentMouseButtonListener, ComponentMouseListener, ComponentMouseWheelListener, ComponentStateListener, ComponentTooltipListener, ConstrainedVisual, ContainerListener, ContainerMouseListener, Menu.SectionListener, MenuListener, Skin, Visual

public class TerraMenuSkin
extends ContainerSkin
implements MenuListener, Menu.SectionListener

Menu skin.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.pivot.wtk.skin.ContainerSkin
ContainerSkin.IndexFocusTraversalPolicy
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.MenuListener
MenuListener.Adapter
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ContainerListener
ContainerListener.Adapter
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ContainerMouseListener
ContainerMouseListener.Adapter
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentListener
ComponentListener.Adapter
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentStateListener
ComponentStateListener.Adapter
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentMouseListener
ComponentMouseListener.Adapter
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentMouseButtonListener
ComponentMouseButtonListener.Adapter
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentKeyListener
ComponentKeyListener.Adapter
 
Constructor Summary
TerraMenuSkin()
           
 
Method Summary
 void activeItemChanged(Menu menu, Menu.Item previousActiveItem)
          Called when a menu's active item has changed.
 Color getActiveBackgroundColor()
           
 Color getActiveColor()
           
 Color getColor()
           
 Color getDisabledColor()
           
 Font getFont()
           
 int getMargin()
           
 Color getMarginColor()
           
 int getPreferredHeight(int width)
          Returns the visual's preferred height given the provided width constraint.
 Dimensions getPreferredSize()
          Returns the visual's unconstrained preferred size.
 int getPreferredWidth(int height)
          Returns the visual's preferred width given the provided height constraint.
 int getSectionSpacing()
           
 Color getSeparatorColor()
           
 boolean getShowKeyboardShortcuts()
           
 void install(Component component)
          Associates a skin with a component.
 boolean isFocusable()
          By default, skins are focusable.
 void itemInserted(Menu.Section section, int index)
          Called when a menu item has been inserted.
 void itemsRemoved(Menu.Section section, int index, Sequence<Menu.Item> removed)
          Called when menu items have been removed.
 boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation)
          UP Select the previous enabled menu item.
 boolean keyReleased(Component component, int keyCode, Keyboard.KeyLocation keyLocation)
          SPACE 'presses' the active menu item if it does not have a sub-menu.
 boolean keyTyped(Component component, char character)
          Select the next enabled menu item where the first character of the rendered text matches the typed key (case insensitive).
 void layout()
          If the component on which the skin is installed is a container, lays out the container's children.
 void nameChanged(Menu.Section section, String previousName)
          Called when a section's name has changed.
 void paint(Graphics2D graphics)
          Paints the visual.
 void sectionInserted(Menu menu, int index)
          Called when a menu section has been inserted.
 void sectionsRemoved(Menu menu, int index, Sequence<Menu.Section> removed)
          Called when menu sections have been removed.
 void setActiveBackgroundColor(Color activeBackgroundColor)
           
 void setActiveBackgroundColor(String activeBackgroundColor)
           
 void setActiveColor(Color activeColor)
           
 void setActiveColor(String activeColor)
           
 void setColor(Color color)
           
 void setColor(String color)
           
 void setDisabledColor(Color disabledColor)
           
 void setDisabledColor(String disabledColor)
           
 void setFont(Dictionary<String,?> font)
           
 void setFont(Font font)
           
 void setFont(String font)
           
 void setMargin(int margin)
           
 void setMarginColor(Color marginColor)
           
 void setSectionSpacing(int sectionSpacing)
           
 void setSeparatorColor(Color separatorColor)
           
 void setShowKeyboardShortcuts(boolean showKeyboardShortcuts)
           
 
Methods inherited from class org.apache.pivot.wtk.skin.ContainerSkin
componentInserted, componentMoved, componentsRemoved, focusTraversalPolicyChanged, getBackgroundColor, getBackgroundPaint, isOpaque, mouseDown, mouseMove, mouseUp, mouseWheel, setBackgroundColor, setBackgroundColor, setBackgroundPaint, setBackgroundPaint, setBackgroundPaint
 
Methods inherited from class org.apache.pivot.wtk.skin.ComponentSkin
cursorChanged, decodeFont, dragSourceChanged, dropTargetChanged, enabledChanged, focusedChanged, getBaseline, getBaseline, getComponent, getHeight, getWidth, heightLimitsChanged, invalidateComponent, locationChanged, menuHandlerChanged, mouseClick, mouseDown, mouseMove, mouseOut, mouseOver, mouseUp, mouseWheel, nameChanged, parentChanged, preferredSizeChanged, repaintComponent, repaintComponent, repaintComponent, repaintComponent, repaintComponent, setSize, sizeChanged, tooltipDelayChanged, tooltipTextChanged, tooltipTriggered, visibleChanged, widthLimitsChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TerraMenuSkin

public TerraMenuSkin()
Method Detail

install

public void install(Component component)
Description copied from interface: Skin
Associates a skin with a component.

Specified by:
install in interface Skin
Overrides:
install in class ContainerSkin
Parameters:
component - The component to which the skin is being attached.

isFocusable

public boolean isFocusable()
Description copied from class: ComponentSkin
By default, skins are focusable.

Specified by:
isFocusable in interface Skin
Overrides:
isFocusable in class ContainerSkin
Returns:
false; by default, containers are not focusable.

getPreferredWidth

public int getPreferredWidth(int height)
Description copied from interface: ConstrainedVisual
Returns the visual's preferred width given the provided height constraint.

Specified by:
getPreferredWidth in interface ConstrainedVisual
Overrides:
getPreferredWidth in class ContainerSkin
Parameters:
height - The height by which to constrain the preferred width, or -1 for no constraint.

getPreferredHeight

public int getPreferredHeight(int width)
Description copied from interface: ConstrainedVisual
Returns the visual's preferred height given the provided width constraint.

Specified by:
getPreferredHeight in interface ConstrainedVisual
Overrides:
getPreferredHeight in class ContainerSkin
Parameters:
width - The width by which to constrain the preferred height, or -1 for no constraint.

getPreferredSize

public Dimensions getPreferredSize()
Description copied from interface: ConstrainedVisual
Returns the visual's unconstrained preferred size.

Specified by:
getPreferredSize in interface ConstrainedVisual
Overrides:
getPreferredSize in class ComponentSkin

layout

public void layout()
Description copied from interface: Skin
If the component on which the skin is installed is a container, lays out the container's children.

Specified by:
layout in interface Skin

paint

public void paint(Graphics2D graphics)
Description copied from interface: Visual
Paints the visual.

Specified by:
paint in interface Visual
Overrides:
paint in class ContainerSkin
Parameters:
graphics - The graphics context in which to paint the visual.

getFont

public Font getFont()

setFont

public void setFont(Font font)

setFont

public final void setFont(String font)

setFont

public final void setFont(Dictionary<String,?> font)

getColor

public Color getColor()

setColor

public void setColor(Color color)

setColor

public final void setColor(String color)

getDisabledColor

public Color getDisabledColor()

setDisabledColor

public void setDisabledColor(Color disabledColor)

setDisabledColor

public final void setDisabledColor(String disabledColor)

getActiveColor

public Color getActiveColor()

setActiveColor

public void setActiveColor(Color activeColor)

setActiveColor

public final void setActiveColor(String activeColor)

getActiveBackgroundColor

public Color getActiveBackgroundColor()

setActiveBackgroundColor

public void setActiveBackgroundColor(Color activeBackgroundColor)

setActiveBackgroundColor

public final void setActiveBackgroundColor(String activeBackgroundColor)

getMarginColor

public Color getMarginColor()

setMarginColor

public void setMarginColor(Color marginColor)

getMargin

public int getMargin()

setMargin

public void setMargin(int margin)

getSeparatorColor

public Color getSeparatorColor()

setSeparatorColor

public void setSeparatorColor(Color separatorColor)

getSectionSpacing

public int getSectionSpacing()

setSectionSpacing

public void setSectionSpacing(int sectionSpacing)

getShowKeyboardShortcuts

public boolean getShowKeyboardShortcuts()

setShowKeyboardShortcuts

public void setShowKeyboardShortcuts(boolean showKeyboardShortcuts)

keyPressed

public boolean keyPressed(Component component,
                          int keyCode,
                          Keyboard.KeyLocation keyLocation)
UP Select the previous enabled menu item.
DOWN Select the next enabled menu item.
LEFT Close the current sub-menu.
RIGHT Open the sub-menu of the current menu item.
ENTER 'presses' the active menu item if it does not have a sub-menu.

Specified by:
keyPressed in interface ComponentKeyListener
Overrides:
keyPressed in class ComponentSkin
Returns:
true to consume the event; false to allow it to propagate.

keyReleased

public boolean keyReleased(Component component,
                           int keyCode,
                           Keyboard.KeyLocation keyLocation)
SPACE 'presses' the active menu item if it does not have a sub-menu.

Specified by:
keyReleased in interface ComponentKeyListener
Overrides:
keyReleased in class ComponentSkin
Returns:
true to consume the event; false to allow it to propagate.

keyTyped

public boolean keyTyped(Component component,
                        char character)
Select the next enabled menu item where the first character of the rendered text matches the typed key (case insensitive).

Specified by:
keyTyped in interface ComponentKeyListener
Overrides:
keyTyped in class ComponentSkin
Returns:
true to consume the event; false to allow it to propagate.

sectionInserted

public void sectionInserted(Menu menu,
                            int index)
Description copied from interface: MenuListener
Called when a menu section has been inserted.

Specified by:
sectionInserted in interface MenuListener

sectionsRemoved

public void sectionsRemoved(Menu menu,
                            int index,
                            Sequence<Menu.Section> removed)
Description copied from interface: MenuListener
Called when menu sections have been removed.

Specified by:
sectionsRemoved in interface MenuListener

itemInserted

public void itemInserted(Menu.Section section,
                         int index)
Description copied from interface: Menu.SectionListener
Called when a menu item has been inserted.

Specified by:
itemInserted in interface Menu.SectionListener

itemsRemoved

public void itemsRemoved(Menu.Section section,
                         int index,
                         Sequence<Menu.Item> removed)
Description copied from interface: Menu.SectionListener
Called when menu items have been removed.

Specified by:
itemsRemoved in interface Menu.SectionListener

nameChanged

public void nameChanged(Menu.Section section,
                        String previousName)
Description copied from interface: Menu.SectionListener
Called when a section's name has changed.

Specified by:
nameChanged in interface Menu.SectionListener

activeItemChanged

public void activeItemChanged(Menu menu,
                              Menu.Item previousActiveItem)
Description copied from interface: MenuListener
Called when a menu's active item has changed.

Specified by:
activeItemChanged in interface MenuListener