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 voidactiveItemChanged(Menu menu, Menu.Item previousActiveItem)Called when a menu's active item has changed.java.awt.ColorgetActiveBackgroundColor()java.awt.ColorgetActiveColor()java.awt.ColorgetColor()java.awt.ColorgetDisabledColor()java.awt.FontgetFont()intgetMargin()java.awt.ColorgetMarginColor()intgetPreferredHeight(int width)Returns the visual's preferred height given the provided width constraint.DimensionsgetPreferredSize()Returns the visual's unconstrained preferred size.intgetPreferredWidth(int height)Returns the visual's preferred width given the provided height constraint.intgetSectionSpacing()java.awt.ColorgetSeparatorColor()booleangetShowKeyboardShortcuts()voidinstall(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.booleanisFocusable()By default, skins are focusable.voiditemInserted(Menu.Section section, int index)Called when a menu item has been inserted.voiditemsRemoved(Menu.Section section, int index, Sequence<Menu.Item> removed)Called when menu items have been removed.booleankeyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation)booleankeyReleased(Component component, int keyCode, Keyboard.KeyLocation keyLocation)SPACE'presses' the active menu item if it does not have a sub-menu.booleankeyTyped(Component component, char character)Select the next enabled menu item where the first character of the rendered text matches the typed key (case insensitive).voidlayout()If the component on which the skin is installed is a container, lays out the container's children.voidnameChanged(Menu.Section section, java.lang.String previousName)Called when a section's name has changed.voidpaint(java.awt.Graphics2D graphics)Paints the visual.voidsectionInserted(Menu menu, int index)Called when a menu section has been inserted.voidsectionsRemoved(Menu menu, int index, Sequence<Menu.Section> removed)Called when menu sections have been removed.voidsetActiveBackgroundColor(java.awt.Color activeBackgroundColor)voidsetActiveBackgroundColor(java.lang.String activeBackgroundColor)voidsetActiveColor(java.awt.Color activeColor)voidsetActiveColor(java.lang.String activeColor)voidsetColor(java.awt.Color color)voidsetColor(java.lang.String color)voidsetDisabledColor(java.awt.Color disabledColor)voidsetDisabledColor(java.lang.String disabledColor)voidsetFont(java.awt.Font font)voidsetFont(java.lang.String font)voidsetFont(Dictionary<java.lang.String,?> font)voidsetMargin(int margin)voidsetMarginColor(java.awt.Color marginColor)voidsetSectionSpacing(int sectionSpacing)voidsetSeparatorColor(java.awt.Color separatorColor)voidsetShowKeyboardShortcuts(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:ComponentSkinMust 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:
installin interfaceSkin- Overrides:
installin classContainerSkin- Parameters:
component- The component to which the skin is being attached.
-
isFocusable
public boolean isFocusable()
Description copied from class:ComponentSkinBy default, skins are focusable.- Specified by:
isFocusablein interfaceSkin- Overrides:
isFocusablein classContainerSkin- Returns:
false; by default, containers are not focusable.
-
getPreferredWidth
public int getPreferredWidth(int height)
Description copied from interface:ConstrainedVisualReturns the visual's preferred width given the provided height constraint.- Specified by:
getPreferredWidthin interfaceConstrainedVisual- Overrides:
getPreferredWidthin classContainerSkin- Parameters:
height- The height by which to constrain the preferred width, or-1for no constraint.- Returns:
- The preferred width given the height constraint.
-
getPreferredHeight
public int getPreferredHeight(int width)
Description copied from interface:ConstrainedVisualReturns the visual's preferred height given the provided width constraint.- Specified by:
getPreferredHeightin interfaceConstrainedVisual- Overrides:
getPreferredHeightin classContainerSkin- Parameters:
width- The width by which to constrain the preferred height, or-1for no constraint.- Returns:
- The preferred height given the width constraint.
-
getPreferredSize
public Dimensions getPreferredSize()
Description copied from interface:ConstrainedVisualReturns the visual's unconstrained preferred size.- Specified by:
getPreferredSizein interfaceConstrainedVisual- Overrides:
getPreferredSizein 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:SkinIf 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:VisualPaints the visual.- Specified by:
paintin interfaceVisual- Overrides:
paintin 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)
UPSelect the previous enabled menu item.
DOWNSelect the next enabled menu item.
LEFTClose the current sub-menu.
RIGHTOpen the sub-menu of the current menu item.
ENTER'presses' the active menu item if it does not have a sub-menu.- Specified by:
keyPressedin interfaceComponentKeyListener- Overrides:
keyPressedin 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:
trueto consume the event;falseto 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:
keyReleasedin interfaceComponentKeyListener- Overrides:
keyReleasedin 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:
trueto consume the event;falseto 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:
keyTypedin interfaceComponentKeyListener- Overrides:
keyTypedin classComponentSkin- Parameters:
component- Component that has the focus, that is receiving this key.character- The decoded character that was typed.- Returns:
trueto consume the event;falseto allow it to propagate.
-
sectionInserted
public void sectionInserted(Menu menu, int index)
Description copied from interface:MenuListenerCalled when a menu section has been inserted.- Specified by:
sectionInsertedin 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:MenuListenerCalled when menu sections have been removed.- Specified by:
sectionsRemovedin 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.SectionListenerCalled when a menu item has been inserted.- Specified by:
itemInsertedin 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.SectionListenerCalled when menu items have been removed.- Specified by:
itemsRemovedin 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.SectionListenerCalled when a section's name has changed.- Specified by:
nameChangedin 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:MenuListenerCalled when a menu's active item has changed.- Specified by:
activeItemChangedin interfaceMenuListener- Parameters:
menu- The menu that changed.previousActiveItem- What the previously active menu item was.
-
-