com.extjs.gxt.ui.client.widget.menu
Class Menu

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.extjs.gxt.ui.client.widget.Component
              extended by com.extjs.gxt.ui.client.widget.BoxComponent
                  extended by com.extjs.gxt.ui.client.widget.Container<Component>
                      extended by com.extjs.gxt.ui.client.widget.menu.Menu
All Implemented Interfaces:
Observable, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.IsWidget
Direct Known Subclasses:
ColorMenu, DateMenu, ListMenu, RangeMenu, StartMenu

public class Menu
extends Container<Component>

A menu component.

Events:
BeforeShow : MenuEvent(container)
Fires before this menu is displayed. Listeners can cancel the action by calling BaseEvent.setCancelled(boolean).
Show : MenuEvent(container)
Fires after this menu is displayed.
BeforeHide : MenuEvent(container)
Fired before the menu is hidden. Listeners can cancel the action by calling BaseEvent.setCancelled(boolean).
Hide : MenuEvent(container)
Fires after this menu is hidden.
BeforeAdd : MenuEvent(container, item, index)
Fires before a item is added or inserted. Listeners can cancel the action by calling BaseEvent.setCancelled(boolean).
BeforeRemove : MenuEvent(container, item)
Fires before a item is removed. Listeners can cancel the action by calling BaseEvent.setCancelled(boolean).
Add : MenuEvent(container, item, index)
Fires after a item has been added or inserted.
Remove : MenuEvent(container, item)
Fires after a item has been removed.
Inherited Events:
BoxComponent Move
BoxComponent Resize
Component Enable
Component Disable
Component BeforeHide
Component Hide
Component BeforeShow
Component Show
Component Attach
Component Detach
Component BeforeRender
Component Render
Component BrowserEvent
Component BeforeStateRestore
Component StateRestore
Component BeforeStateSave
Component SaveState


Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
protected  Item activeItem
           
protected  BaseEventPreview eventPreview
           
protected  KeyNav<ComponentEvent> keyNav
           
protected  Item parentItem
           
protected  boolean plain
           
protected  boolean showSeparator
           
protected  El ul
           
 
Fields inherited from class com.extjs.gxt.ui.client.widget.Container
attachChildren, enableLayout, layoutExecuted, layoutNeeded, layoutOnAttach, layoutOnChange
 
Fields inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustSize, cacheSizes, ensureVisibilityOnSizing, height, lastSize, layer, shim, width
 
Fields inherited from class com.extjs.gxt.ui.client.widget.Component
afterRender, attachables, baseStyle, disabled, disabledStyle, disableTextSelection, dummy, focusable, hidden, mask, maskMessage, maskMessageStyleName, monitorWindowResize, rendered, resizeHandler, setElementRender, stateId, swallowEvents, toolTip, windowResizeDelay, windowResizeTask
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
Menu()
          Creates a new menu.
 
Method Summary
 boolean add(Component item)
          Adds a item to the menu.
protected  void afterRender()
          Called after the component has been rendered and is attached for the first time.
protected  void constrainScroll(int y)
           
protected  ComponentEvent createComponentEvent(com.google.gwt.user.client.Event event)
           
protected  ContainerEvent<Menu,Component> createContainerEvent(Component item)
           
protected  void createScrollers()
           
protected  void deactiveActiveItem()
           
protected  void doAutoSize()
           
 java.lang.String getDefaultAlign()
          Returns the default alignment.
 El getLayoutTarget()
          Returns the container's layout target.
 int getMaxHeight()
          Returns the max height of the menu or -1 if not set.
 int getMinWidth()
          Returns the menu's minimum width.
 Item getParentItem()
          Returns the menu's parent item.
 java.lang.String getSubMenuAlign()
          Returns the sub menu alignment.
 void hide()
          Hides the menu.
 Menu hide(boolean deep)
          Hides this menu and optionally all parent menus
 boolean insert(Component item, int index)
          Inserts an item into the menu.
 boolean isConstrainViewport()
          Returns true if constrain to viewport is enabled.
 boolean isEnableScrolling()
          Returns true if vertical scrolling is enabled.
 boolean isFocusOnShow()
          Returns true if the menu will be focused when displayed.
 boolean isVisible()
          Returns true if the component is visible.
protected  boolean onAutoHide(PreviewEvent pe)
           
protected  void onClick(ComponentEvent ce)
           
 void onComponentEvent(ComponentEvent ce)
          Any events a component receives will be forwarded to this method.
protected  void onDetach()
           
protected  void onEscape(PreviewEvent pe)
           
protected  void onHide()
           
protected  void onInsert(Component item, int index)
           
protected  void onKeyDown(ComponentEvent ce)
           
protected  void onKeyUp(ComponentEvent ce)
           
protected  void onLayoutExcecuted(Layout layout)
           
protected  void onMouseMove(ComponentEvent ce)
           
protected  void onMouseOut(ComponentEvent ce)
           
protected  void onMouseOver(ComponentEvent ce)
           
protected  void onRemove(Component item)
           
protected  void onRender(com.google.gwt.user.client.Element target, int index)
          Subclasses must override and ensure setElement is called for lazy rendered components.
protected  void onScroll(ClickRepeaterEvent ce)
           
protected  void onScrollerIn(El t)
           
protected  void onScrollerOut(El t)
           
protected  void onWindowResize(int width, int height)
           
 boolean remove(Component item)
          Removes a item from the menu.
protected  void scrollMenu(boolean top)
           
 void setActiveItem(Component c, boolean autoExpand)
          Sets the active item.
 void setConstrainViewport(boolean constrainViewport)
          Sets whether the menu should be constrained to the viewport when shown.
 void setDefaultAlign(java.lang.String defaultAlign)
          Sets the default El.alignTo(com.google.gwt.user.client.Element, java.lang.String, int[]) anchor position value for this menu relative to its element of origin (defaults to "tl-bl?").
 void setEnableScrolling(boolean enableScrolling)
          True to enable vertical scrolling of the children in the menu (defaults to true).
 void setFocusOnShow(boolean focusOnShow)
          True to set the focus on the menu when it is displayed.
 void setMaxHeight(int maxHeight)
          Sets the max height of the menu (defaults to -1).
 void setMinWidth(int minWidth)
          Sets he minimum width of the menu in pixels (defaults to 120).
 void setSubMenuAlign(java.lang.String subMenuAlign)
          The El.alignTo(com.google.gwt.user.client.Element, java.lang.String, int[]) anchor position value to use for submenus of this menu (defaults to "tl-tr-?").
 void show(com.google.gwt.user.client.Element elem, java.lang.String pos)
          Displays this menu relative to another element.
 void show(com.google.gwt.user.client.Element elem, java.lang.String pos, int[] offsets)
          Displays this menu relative to another element.
 void show(com.google.gwt.user.client.ui.Widget widget)
          Displays this menu relative to the widget using the default alignment.
 void showAt(int x, int y)
          Displays this menu at a specific xy position.
protected  Item tryActivate(int start, int step)
           
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Container
adjustIndex, adopt, disable, doAttachChildren, doDetachChildren, doLayout, doLayout, enable, findItem, getItem, getItemByItemId, getItemCount, getItems, getLayout, getWidget, indexOf, isLayoutNeeded, iterator, layout, layout, notifyHide, notifyShow, onAfterLayout, onAttach, onBeforeLayoutExcecuted, orphan, remove, removeAll, removeAll, scrollIntoView, setLayout, setLayoutNeeded, setLayoutOnChange, wrapWidget
 
Methods inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustPosition, adjustSize, getBounds, getHeight, getHeight, getPosition, getPositionEl, getResizeEl, getShadow, getShadowOffset, getShadowPosition, getSize, getWidth, getWidth, hideShadow, hideShim, hideUnders, isAutoHeight, isAutoWidth, isDeferHeight, isShim, onPosition, onResize, onShow, onUnload, setAutoHeight, setAutoWidth, setBounds, setBounds, setDeferHeight, setHeight, setHeight, setPagePosition, setPagePosition, setPixelSize, setPosition, setShadow, setShadowOffset, setShadowPosition, setShim, setSize, setSize, setWidth, setWidth, sync, syncSize
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addAttachable, addListener, addPlugin, addStyleName, addStyleOnOver, addWidgetListener, applyState, assertAfterRender, assertPreRender, beforeRender, blur, clearState, createObservable, createStyles, disableContextMenu, disableEvents, disableTextSelection, el, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, frame, getAriaSupport, getBaseStyle, getBorders, getContextMenu, getData, getElement, getFocusEl, getFocusSupport, getHideMode, getId, getItemId, getListeners, getModel, getObservable, getPlugins, getState, getStateId, getTabIndex, getTitle, getToolTip, getWindowResizeDelay, hasListeners, hasListeners, hideToolTip, initState, isDisabledEvents, isDisableTextSelection, isEnabled, isMasked, isMonitorWindowResize, isRendered, isStateful, isVisible, mask, mask, mask, onBrowserEvent, onDetachHelper, onDisable, onEnable, onEnsureDebugId, onHideContextMenu, onLoad, onRightClick, onShowContextMenu, previewEvent, recalculate, removeAllListeners, removeAttachagle, removeFromParent, removeListener, removeStyleName, removeStyleOnOver, removeSwallow, removeToolTip, removeWidgetListener, render, render, repaint, saveState, setAriaRole, setAriaState, setAriaSupport, setBorders, setContextMenu, setData, setEl, setElement, setElement, setEnabled, setFiresEvents, setHideMode, setId, setIntStyleAttribute, setItemId, setModel, setMonitorWindowResize, setParent, setStateful, setStateId, setStyleAttribute, setStyleName, setTabIndex, setTitle, setToolTip, setToolTip, setVisible, setWindowResizeDelay, setZIndex, show, sinkEvents, swallowEvent, swallowEvent, toString, unframe, unmask
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, setLayoutData
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, removeStyleDependentName, setElement, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, sinkBitlessEvent, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

keyNav

protected KeyNav<ComponentEvent> keyNav

parentItem

protected Item parentItem

eventPreview

protected BaseEventPreview eventPreview

plain

protected boolean plain

showSeparator

protected boolean showSeparator

ul

protected El ul

activeItem

protected Item activeItem
Constructor Detail

Menu

public Menu()
Creates a new menu.

Method Detail

add

public boolean add(Component item)
Adds a item to the menu.

Overrides:
add in class Container<Component>
Parameters:
item - the new item

getDefaultAlign

public java.lang.String getDefaultAlign()
Returns the default alignment.

Returns:
the default align

getLayoutTarget

public El getLayoutTarget()
Description copied from class: Container
Returns the container's layout target. Only applies to container's with layouts.

Overrides:
getLayoutTarget in class Container<Component>
Returns:
the layout target

getMaxHeight

public int getMaxHeight()
Returns the max height of the menu or -1 if not set.

Returns:
the max height in pixels

getMinWidth

public int getMinWidth()
Returns the menu's minimum width.

Returns:
the width

getParentItem

public Item getParentItem()
Returns the menu's parent item.

Returns:
the parent item

getSubMenuAlign

public java.lang.String getSubMenuAlign()
Returns the sub menu alignment.

Returns:
the alignment

hide

public void hide()
Hides the menu.

Overrides:
hide in class Component

hide

public Menu hide(boolean deep)
Hides this menu and optionally all parent menus

Parameters:
deep - true to close all parent menus
Returns:
this

insert

public boolean insert(Component item,
                      int index)
Inserts an item into the menu.

Overrides:
insert in class Container<Component>
Parameters:
item - the item to insert
index - the insert location

isConstrainViewport

public boolean isConstrainViewport()
Returns true if constrain to viewport is enabled.

Returns:
the constrain to viewport state

isEnableScrolling

public boolean isEnableScrolling()
Returns true if vertical scrolling is enabled.

Returns:
true for scrolling

isFocusOnShow

public boolean isFocusOnShow()
Returns true if the menu will be focused when displayed.

Returns:
true if focused

isVisible

public boolean isVisible()
Description copied from class: Component
Returns true if the component is visible.

Overrides:
isVisible in class Component

onComponentEvent

public void onComponentEvent(ComponentEvent ce)
Description copied from class: Component
Any events a component receives will be forwarded to this method. Subclasses should override as needed. The Component.onBrowserEvent(com.google.gwt.user.client.Event) method should not be overridden or modified.

Overrides:
onComponentEvent in class Component
Parameters:
ce - the base event

remove

public boolean remove(Component item)
Removes a item from the menu.

Overrides:
remove in class Container<Component>
Parameters:
item - the menu to remove
Returns:
true if the item was removed

setActiveItem

public void setActiveItem(Component c,
                          boolean autoExpand)
Sets the active item. The component must be of type Item to be activated. All other types are ignored.

Parameters:
c - the component to set active
autoExpand - true to auto expand the item

setConstrainViewport

public void setConstrainViewport(boolean constrainViewport)
Sets whether the menu should be constrained to the viewport when shown. Only applies when using showAt(int, int).

Parameters:
constrainViewport - true to constrain

setDefaultAlign

public void setDefaultAlign(java.lang.String defaultAlign)
Sets the default El.alignTo(com.google.gwt.user.client.Element, java.lang.String, int[]) anchor position value for this menu relative to its element of origin (defaults to "tl-bl?").

Parameters:
defaultAlign - the default align

setEnableScrolling

public void setEnableScrolling(boolean enableScrolling)
True to enable vertical scrolling of the children in the menu (defaults to true).

Parameters:
enableScrolling - true to for scrolling

setFocusOnShow

public void setFocusOnShow(boolean focusOnShow)
True to set the focus on the menu when it is displayed.

Parameters:
focusOnShow - true to focus

setMaxHeight

public void setMaxHeight(int maxHeight)
Sets the max height of the menu (defaults to -1). Only applies when setEnableScrolling(boolean) is set to true.

Parameters:
maxHeight - the max height

setMinWidth

public void setMinWidth(int minWidth)
Sets he minimum width of the menu in pixels (defaults to 120).

Parameters:
minWidth - the min width

setSubMenuAlign

public void setSubMenuAlign(java.lang.String subMenuAlign)
The El.alignTo(com.google.gwt.user.client.Element, java.lang.String, int[]) anchor position value to use for submenus of this menu (defaults to "tl-tr-?").

Parameters:
subMenuAlign - the sub alignment

show

public void show(com.google.gwt.user.client.Element elem,
                 java.lang.String pos)
Displays this menu relative to another element.

Parameters:
elem - the element to align to
pos - the El.alignTo(com.google.gwt.user.client.Element, java.lang.String, int[]) anchor position to use in aligning to the element (defaults to defaultAlign)

show

public void show(com.google.gwt.user.client.Element elem,
                 java.lang.String pos,
                 int[] offsets)
Displays this menu relative to another element.

Parameters:
elem - the element to align to
pos - the El.alignTo(com.google.gwt.user.client.Element, java.lang.String, int[]) anchor position to use in aligning to the element (defaults to defaultAlign)
offsets - the menu align offsets

show

public void show(com.google.gwt.user.client.ui.Widget widget)
Displays this menu relative to the widget using the default alignment.

Parameters:
widget - the align widget

showAt

public void showAt(int x,
                   int y)
Displays this menu at a specific xy position.

Parameters:
x - the x coordinate
y - the y coordinate

afterRender

protected void afterRender()
Description copied from class: Component
Called after the component has been rendered and is attached for the first time. At this time, the component will be part of the DOM which is required when retrieving location and offsets.

Overrides:
afterRender in class BoxComponent

constrainScroll

protected void constrainScroll(int y)

createComponentEvent

protected ComponentEvent createComponentEvent(com.google.gwt.user.client.Event event)
Overrides:
createComponentEvent in class BoxComponent

createContainerEvent

protected ContainerEvent<Menu,Component> createContainerEvent(Component item)
Overrides:
createContainerEvent in class Container<Component>

createScrollers

protected void createScrollers()

deactiveActiveItem

protected void deactiveActiveItem()

doAutoSize

protected void doAutoSize()

onAutoHide

protected boolean onAutoHide(PreviewEvent pe)

onClick

protected void onClick(ComponentEvent ce)

onDetach

protected void onDetach()
Overrides:
onDetach in class Component

onEscape

protected void onEscape(PreviewEvent pe)

onHide

protected void onHide()
Overrides:
onHide in class BoxComponent

onInsert

protected void onInsert(Component item,
                        int index)
Overrides:
onInsert in class Container<Component>

onKeyDown

protected void onKeyDown(ComponentEvent ce)

onKeyUp

protected void onKeyUp(ComponentEvent ce)

onLayoutExcecuted

protected void onLayoutExcecuted(Layout layout)
Overrides:
onLayoutExcecuted in class Container<Component>

onMouseMove

protected void onMouseMove(ComponentEvent ce)

onMouseOut

protected void onMouseOut(ComponentEvent ce)

onMouseOver

protected void onMouseOver(ComponentEvent ce)

onRemove

protected void onRemove(Component item)
Overrides:
onRemove in class Container<Component>

onRender

protected void onRender(com.google.gwt.user.client.Element target,
                        int index)
Description copied from class: Component
Subclasses must override and ensure setElement is called for lazy rendered components.

Overrides:
onRender in class Component
Parameters:
target - the target element
index - the insert location

onScroll

protected void onScroll(ClickRepeaterEvent ce)

onScrollerIn

protected void onScrollerIn(El t)

onScrollerOut

protected void onScrollerOut(El t)

onWindowResize

protected void onWindowResize(int width,
                              int height)
Overrides:
onWindowResize in class Component

scrollMenu

protected void scrollMenu(boolean top)

tryActivate

protected Item tryActivate(int start,
                           int step)