Package org.apache.pivot.wtk.skin.terra
Class TerraMenuSkin
- java.lang.Object
-
- org.apache.pivot.wtk.skin.ComponentSkin
-
- org.apache.pivot.wtk.skin.ContainerSkin
-
- 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.ComponentKeyListener
ComponentKeyListener.Adapter, ComponentKeyListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentListener
ComponentListener.Adapter, ComponentListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentMouseButtonListener
ComponentMouseButtonListener.Adapter, ComponentMouseButtonListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentMouseListener
ComponentMouseListener.Adapter, ComponentMouseListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentMouseWheelListener
ComponentMouseWheelListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentStateListener
ComponentStateListener.Adapter, ComponentStateListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentTooltipListener
ComponentTooltipListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ContainerListener
ContainerListener.Adapter, ContainerListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ContainerMouseListener
ContainerMouseListener.Adapter, ContainerMouseListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.Menu.SectionListener
Menu.SectionListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.MenuListener
MenuListener.Adapter, MenuListener.Listeners
-
-
Constructor Summary
Constructors Constructor Description TerraMenuSkin()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activeItemChanged(Menu menu, Menu.Item previousActiveItem)
Called when a menu's active item has changed.java.awt.Color
getActiveBackgroundColor()
java.awt.Color
getActiveColor()
java.awt.Color
getColor()
java.awt.Color
getDisabledColor()
java.awt.Font
getFont()
int
getMargin()
java.awt.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()
java.awt.Color
getSeparatorColor()
boolean
getShowKeyboardShortcuts()
void
install(Component component)
Must be implemented in every subclass in order to do component-specific operations at instantiation time, but every subclass must call this superclass method to setup the necessary listeners, etc.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)
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, java.lang.String previousName)
Called when a section's name has changed.void
paint(java.awt.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(java.awt.Color activeBackgroundColor)
void
setActiveBackgroundColor(java.lang.String activeBackgroundColor)
void
setActiveColor(java.awt.Color activeColor)
void
setActiveColor(java.lang.String activeColor)
void
setColor(java.awt.Color color)
void
setColor(java.lang.String color)
void
setDisabledColor(java.awt.Color disabledColor)
void
setDisabledColor(java.lang.String disabledColor)
void
setFont(java.awt.Font font)
void
setFont(java.lang.String font)
void
setFont(Dictionary<java.lang.String,?> font)
void
setMargin(int margin)
void
setMarginColor(java.awt.Color marginColor)
void
setSectionSpacing(int sectionSpacing)
void
setSeparatorColor(java.awt.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, setBackgroundColor, setBackgroundPaint, setBackgroundPaint, setBackgroundPaint
-
Methods inherited from class org.apache.pivot.wtk.skin.ComponentSkin
colorFromObject, colorFromObject, colorFromObject, colorFromObject, currentTheme, cursorChanged, decodeFont, defaultBackgroundColor, defaultForegroundColor, dragSourceChanged, dropTargetChanged, enabledChanged, focusedChanged, fontFromObject, getBaseline, getBaseline, getColor, getComponent, getFocusRectangleStroke, getHeight, getSize, getTextInputMethodListener, getThemeFont, getWidth, heightLimitsChanged, invalidateComponent, locationChanged, menuHandlerChanged, mouseClick, mouseDown, mouseMove, mouseOut, mouseOver, mouseUp, mouseWheel, nameChanged, parentChanged, preferredSizeChanged, repaintComponent, repaintComponent, repaintComponent, repaintComponent, repaintComponent, setDefaultStyles, setSize, sizeChanged, themeHasThickFocusRectangle, themeHasTransitionEnabled, themeIsDark, themeIsFlat, tooltipDelayChanged, tooltipTextChanged, tooltipTriggered, visibleChanged, widthLimitsChanged
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.pivot.wtk.ConstrainedVisual
setSize
-
-
-
-
Method Detail
-
install
public void install(Component component)
Description copied from class:ComponentSkin
Must be implemented in every subclass in order to do component-specific operations at instantiation time, but every subclass must call this superclass method to setup the necessary listeners, etc.- Specified by:
install
in interfaceSkin
- Overrides:
install
in classContainerSkin
- 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 interfaceSkin
- Overrides:
isFocusable
in classContainerSkin
- 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 interfaceConstrainedVisual
- Overrides:
getPreferredWidth
in classContainerSkin
- Parameters:
height
- The height by which to constrain the preferred width, or-1
for no constraint.- Returns:
- The preferred width given the height 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 interfaceConstrainedVisual
- Overrides:
getPreferredHeight
in classContainerSkin
- Parameters:
width
- The width by which to constrain the preferred height, or-1
for no constraint.- Returns:
- The preferred height given the width constraint.
-
getPreferredSize
public Dimensions getPreferredSize()
Description copied from interface:ConstrainedVisual
Returns the visual's unconstrained preferred size.- Specified by:
getPreferredSize
in interfaceConstrainedVisual
- Overrides:
getPreferredSize
in classComponentSkin
- Returns:
- The preferred size (width and height) of this component.
Depending on the component this can be a static value or derived (as for a container) from its subcomponents, etc.
The default implementation simply calls
ConstrainedVisual.getPreferredWidth(int)
andConstrainedVisual.getPreferredHeight(int)
.
-
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.
-
paint
public void paint(java.awt.Graphics2D graphics)
Description copied from interface:Visual
Paints the visual.- Specified by:
paint
in interfaceVisual
- Overrides:
paint
in classContainerSkin
- Parameters:
graphics
- The graphics context in which to paint the visual.
-
getFont
public java.awt.Font getFont()
-
setFont
public void setFont(java.awt.Font font)
-
setFont
public final void setFont(java.lang.String font)
-
setFont
public final void setFont(Dictionary<java.lang.String,?> font)
-
getColor
public java.awt.Color getColor()
-
setColor
public void setColor(java.awt.Color color)
-
setColor
public final void setColor(java.lang.String color)
-
getDisabledColor
public java.awt.Color getDisabledColor()
-
setDisabledColor
public void setDisabledColor(java.awt.Color disabledColor)
-
setDisabledColor
public final void setDisabledColor(java.lang.String disabledColor)
-
getActiveColor
public java.awt.Color getActiveColor()
-
setActiveColor
public void setActiveColor(java.awt.Color activeColor)
-
setActiveColor
public final void setActiveColor(java.lang.String activeColor)
-
getActiveBackgroundColor
public java.awt.Color getActiveBackgroundColor()
-
setActiveBackgroundColor
public void setActiveBackgroundColor(java.awt.Color activeBackgroundColor)
-
setActiveBackgroundColor
public final void setActiveBackgroundColor(java.lang.String activeBackgroundColor)
-
getMarginColor
public java.awt.Color getMarginColor()
-
setMarginColor
public void setMarginColor(java.awt.Color marginColor)
-
getMargin
public int getMargin()
-
setMargin
public void setMargin(int margin)
-
getSeparatorColor
public java.awt.Color getSeparatorColor()
-
setSeparatorColor
public void setSeparatorColor(java.awt.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 interfaceComponentKeyListener
- Overrides:
keyPressed
in classComponentSkin
- Parameters:
component
- Component that has the focus.keyCode
- The key code for the key that was pressed.keyLocation
- Location value for the key (left or right for shift keys, etc.).- 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 interfaceComponentKeyListener
- Overrides:
keyReleased
in classComponentSkin
- Parameters:
component
- Component that has the focus, that is receiving this key event.keyCode
- Code for the key that was released.keyLocation
- Location of the key.- 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 interfaceComponentKeyListener
- Overrides:
keyTyped
in classComponentSkin
- Parameters:
component
- Component that has the focus, that is receiving this key.character
- The decoded character that was typed.- 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 interfaceMenuListener
- Parameters:
menu
- The source of the event.index
- Where the menu section was inserted.
-
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 interfaceMenuListener
- Parameters:
menu
- The menu that changed.index
- The starting index of the removal.removed
- The actual menu sections that were removed from the menu.
-
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 interfaceMenu.SectionListener
- Parameters:
section
- The section that is changing.index
- The index where the item was inserted.
-
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 interfaceMenu.SectionListener
- Parameters:
section
- The section that has changed.index
- The starting index of the removed items.removed
- The sequence of the items that were removed.
-
nameChanged
public void nameChanged(Menu.Section section, java.lang.String previousName)
Description copied from interface:Menu.SectionListener
Called when a section's name has changed.- Specified by:
nameChanged
in interfaceMenu.SectionListener
- Parameters:
section
- The section that changed.previousName
- The previous name for this section.
-
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 interfaceMenuListener
- Parameters:
menu
- The menu that changed.previousActiveItem
- What the previously active menu item was.
-
-