conga.gui
Class WidgetMenu

java.lang.Object
  |
  +--marimba.gui.Widget
        |
        +--marimba.gui.ContainerWidget
              |
              +--marimba.gui.GroupWidget
                    |
                    +--conga.gui.AbstractPopupMenu
                          |
                          +--conga.gui.WidgetMenu
All Implemented Interfaces:
java.awt.image.ImageObserver, PropertyObject, TimerClient, WidgetConstants

public class WidgetMenu
extends AbstractPopupMenu
implements TimerClient

An advanced popup menu, that replaces the popupmenu as used in marimba.gui. It is a lightweight menu, which means that no separate Window is used to show it. Main difference with the marimba.gui popup menu is that this popup menu supports cascading menus: a popup menu can be added to another popup menu.

Version:
2.00, 06/19/1998
Author:
Klaas Waslander

Fields inherited from class marimba.gui.GroupWidget
editing, fillMode, fillOptions, lineMode, lineOptions, patsrc, pattern, prevtx, prevty
 
Fields inherited from class marimba.gui.ContainerWidget
content
 
Fields inherited from class marimba.gui.Widget
adapter, background, clazz, defaultBackground, defaultFont, defaultForeground, defaultHilite, directGraphics, disabled, east, editor, focus, font, foreground, height, hilite, layoutMgr, name, north, nwidgets, parent, script, south, tip, transparent, tx, ty, valid, visible, wBackground, west, wFont, wForeground, wHilite, widgets, width, wScript, wTip, x, y
 
Fields inherited from interface marimba.gui.WidgetConstants
ALWAYS, ANYWHERE, APPLET, ASCENDING, BLINK, BLUE, BONGO_EVENT, BOTH, BOTTOM, BOXED, BUTTON, CENTER, CHAR, CHECK, COLLAPSE_EVENT, CONTENT, DESCENDING, DETACHED, DIAGONAL, DOWN, DRAG, EXCLUSIVE, EXPAND_EVENT, FILL, FILLED, GREEN, HORIZONTAL, INSIDE, INVISIBLE, JAVA_VERSION, JAVAOS, JDK10, JDK11, LAYERS, LEFT, LOWERED, MAC, MULTIPLE, NETCASTER, NETSCAPE, NEVER, NONE, NT, OPTIONAL, OS_ARCH, OS_NAME, OS_VERSION, OUTLINE, PAGE_DOWN, PAGE_EVENT, PAGE_UP, PATTERN, PC, PICTURE, PLAIN, PROPORTIONAL, RADIO, RAISED, RED, REST_EVENT, RIGHT, ROUNDED, SCALE, SCROLLBAR, SCROLLING, SOLID, SQUARE, TEXT_CHANGED_EVENT, TOP, TOPLEFT, TRUNCATE, UNDERLINE, UNIX, UP, VERTICAL, WAKE_EVENT, WIN95, WINDOWS, WORD
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
WidgetMenu()
          Constructs a new WidgetMenu with an empty label.
WidgetMenu(java.lang.String label)
          Constructs a new WidgetMenu with the specified label.
 
Method Summary
 void add(java.lang.String label)
          Add a menu item.
 void add(WidgetMenu menu)
          Add another WidgetMenu to this menu, this just adds a WidgetMenuItem with a WidgetMenu 'attached' to it.
 void add(WidgetMenuItem item)
          Add a menu item by giving the menu item directly.
 void addSeparator()
          Add a separator to this menu.
 void addSeparator(int index)
          Insert a separator at the specified position.
 void addWidgetMenuListener(WidgetMenuListener l)
          Add a WidgetMenu listener.
 void clear()
          Remove all menu items in this menu, the menu will be empty afterwards.
protected  void fireWidgetMenuCanceled()
          Notifies WidgetMenuListeners that this WidgetMenu is canceled.
protected  void fireWidgetMenuWillBecomeInvisible()
          Notifies WidgetMenuListeners that this popup menu will become invisible.
protected  void fireWidgetMenuWillBecomeVisible()
          Notifies WidgetMenuListeners that this popup menu will become visible.
 WidgetMenuItem getItem(int index)
          Get the item at the specified position.
 int getItemCount()
          Get the number of items in this menu.
 java.lang.String getLabel()
          Get the label of this menu.
 java.lang.String getMenuContent()
          Returns a string representation of the contents of this widget menu.
 long getMenuSpeed()
          Get the menu speed, which is the number of milliseconds before the new popup menu will popup.
 WidgetMenuItem getSelectedItem()
          The currently selected item.
 java.lang.String getText()
          Get the label of this menu.
 java.lang.Object getValue()
          Get the label value of this menu.
 boolean handleEvent(java.awt.Event evt)
          Handles keyboard events, in case this popup menu has keyboard focus.
 int indexOf(WidgetMenuItem item)
          Get the index of given item inside this menu.
 void insert(java.lang.String label, int index)
          Insert a menu item at the given position.
 void insert(WidgetMenuItem item, int index)
          Insert a menu item at the given position by giving the item directly.
 void popdown()
          Hides this widget popupmenu; it will make sure that the widget that had the focus (before this menu was popped up) re-gains the focus.
 void popup(Widget parent, int x, int y)
          Shows the popup menu at the x, y position relative to the given parent widget, the menu will have the preferred width after popping up.
 void popup(Widget parent, int x, int y, int width)
          Shows the popup menu at the x, y position relative to the given parent widget, with the given fixed width.
 void popupDirected(Widget parent, int direction, int alignment)
          Popup this popup menu in the given direction, with the given alignment.
 void remove(int index)
          Remove the menu item at the given position.
 void remove(java.lang.String label)
          Remove the first menu item that has the given label.
 void remove(WidgetMenuItem item)
          Remove a menu item by giving the item directly.
 void removeWidgetMenuListener(WidgetMenuListener l)
          Remove a WidgetMenu listener.
 void selectNextItem()
          Select the next item; if there is no selected item yet, it will result in the selection of the first item.
 void selectPreviousItem()
          Select previous item, if there is no selected item yet, it will result in the selection of the last item.
 void setLabel(java.lang.String label)
          Set the label of this menu.
 void setMenuContent(java.lang.String content)
          Set the content of this widget menu to that of the contents of the given formatted string.
 void setMenuSpeed(long menuSpeed)
          Set the menu speed.
 void setSelectedItem(int index)
          Set the current item to the index-th item, with index in [0 ..
 void setSelectedItem(WidgetMenuItem item)
          Select an item by giving the item directly.
 void setText(java.lang.String label)
          Set the label to the given one.
 void setValue(java.lang.Object obj)
          Set the label of this menu.
 
Methods inherited from class conga.gui.AbstractPopupMenu
focusInterest, getInitialPopupHeight, getMaxVisible, getPreferredSize, hasInheritedFont, isPoppedUp, layout, paint, setMaxVisible
 
Methods inherited from class marimba.gui.GroupWidget
getEditing, getEditor, getFillMode, getFillOptions, getLineMode, getLineOptions, getPattern, getPatternSource, getProperties, init, paramString, setEditing, setFillMode, setLineMode, setPattern, setProperties, update, updateArea, waitForPattern
 
Methods inherited from class marimba.gui.ContainerWidget
findInFocus, findWidget, firstInFocus, getChildProperties, getContent, newContent, nextInFocus, previousInFocus
 
Methods inherited from class marimba.gui.Widget
action, action, add, add, adjustFont, adjustFont, applyProperties, audioLoop, audioLoop, audioPlay, audioPlay, audioStop, audioStop, bounds, clearFocus, clearPopups, clone, contains, contains, createImage, createImage, currentFocus, destroy, disable, disable, enable, firstFocus, getAudioClip, getAudioClipAt, getBackground, getBounds, getCancelButton, getCursor, getDefaultButton, getDescription, getEncoding, getFocusColor, getFont, getFontMetrics, getForeground, getHilite, getImage, getKey, getKey, getKey, getLayoutMgr, getLocale, getLocation, getName, getParent, getPlayerFrame, getPlayerPanel, getPresentation, getSelBackground, getSelFocusColor, getSelForeground, getSize, getText, getTip, getTip, getTipFont, getValue, getWidget, getWidgetAt, getWidgetAt, getWidgetClass, getWidgetsAt, getWidgetsAt, getWidgetsAt, gotFocus, gotoPage, gotoPage, hasFocus, hide, imageUpdate, inheritFont, inside, inside, invalidate, isDisabled, isShowing, isTransparent, isVisible, keyDown, keyUp, list, list, locateWidget, locateWidgets, locateWidgets, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, overlap, paint, paintAll, postEvent, previousFocus, remove, remove, remove, removeAll, repaint, repaint, repaint, repaint, repaintParent, replace, replace, replace, requestFocus, resetCursor, reshape, reshape, resize, resize, rmove, rscroll, scroll, setAttach, setBackground, setBounds, setBounds, setCursor, setDisabled, setEditor, setEncoding, setFont, setForeground, setHilite, setLayoutMgr, setLocale, setLocation, setName, setSize, setSize, setText, setTip, setTipFont, setTransparent, setValue, setVisible, show, show, size, start, stop, sync, tick, toBack, toBack, toFront, toFront, toString, validate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface marimba.util.TimerClient
tick
 

Constructor Detail

WidgetMenu

public WidgetMenu()
Constructs a new WidgetMenu with an empty label.

WidgetMenu

public WidgetMenu(java.lang.String label)
Constructs a new WidgetMenu with the specified label.
Parameters:
label - the label to be added to this menu
Method Detail

getMenuContent

public java.lang.String getMenuContent()
Returns a string representation of the contents of this widget menu. This method is especially meant for usage in getProperties of widgets that use a WidgetMenu.
Returns:
a formatted item string, for example: "One, Two, SubMenu->[SubItem1, SubItem2], Three"
See Also:
setMenuContent(java.lang.String)

setMenuContent

public void setMenuContent(java.lang.String content)
Set the content of this widget menu to that of the contents of the given formatted string. This method is especially meant for usage in setProperties of widgets that use a WidgetMenu.
Parameters:
content - a formatted item string, for example: "One, Two, SubMenu->[SubItem1, SubItem2], Three"
See Also:
getMenuContent()

addWidgetMenuListener

public void addWidgetMenuListener(WidgetMenuListener l)
Add a WidgetMenu listener.
Parameters:
l - the WidgetMenuListener to add

removeWidgetMenuListener

public void removeWidgetMenuListener(WidgetMenuListener l)
Remove a WidgetMenu listener. param l the WidgetMenuListener to remove

fireWidgetMenuWillBecomeVisible

protected void fireWidgetMenuWillBecomeVisible()
Notifies WidgetMenuListeners that this popup menu will become visible.

fireWidgetMenuWillBecomeInvisible

protected void fireWidgetMenuWillBecomeInvisible()
Notifies WidgetMenuListeners that this popup menu will become invisible.

fireWidgetMenuCanceled

protected void fireWidgetMenuCanceled()
Notifies WidgetMenuListeners that this WidgetMenu is canceled.

getLabel

public java.lang.String getLabel()
Get the label of this menu.

setLabel

public void setLabel(java.lang.String label)
Set the label of this menu.
Parameters:
label - the label for this menu

getValue

public java.lang.Object getValue()
Get the label value of this menu.
Overrides:
getValue in class Widget
See Also:
getLabel()

setValue

public void setValue(java.lang.Object obj)
Set the label of this menu.
Overrides:
setValue in class Widget
Parameters:
obj - the label for this menu
See Also:
setLabel(java.lang.String)

getText

public java.lang.String getText()
Get the label of this menu.
Overrides:
getText in class Widget
See Also:
getLabel()

setText

public void setText(java.lang.String label)
Set the label to the given one.
Overrides:
setText in class Widget
Parameters:
label - the label for this menu
See Also:
setLabel(java.lang.String)

getMenuSpeed

public long getMenuSpeed()
Get the menu speed, which is the number of milliseconds before the new popup menu will popup. Default setting is 400 milliseconds.
See Also:
setMenuSpeed(long)

setMenuSpeed

public void setMenuSpeed(long menuSpeed)
Set the menu speed.
Parameters:
menuSpeed - the number of milliseconds after which submenus will (dis)appear.
See Also:
getMenuSpeed()

popup

public void popup(Widget parent,
                  int x,
                  int y)
Shows the popup menu at the x, y position relative to the given parent widget, the menu will have the preferred width after popping up.
Overrides:
popup in class AbstractPopupMenu
Parameters:
parent - the widget which defines the coordinate space
x - the x coordinate position to popup the menu
y - the y coordinate position to popup the menu
See Also:
popupDirected(marimba.gui.Widget, int, int)

popup

public void popup(Widget parent,
                  int x,
                  int y,
                  int width)
Shows the popup menu at the x, y position relative to the given parent widget, with the given fixed width.
Overrides:
popup in class AbstractPopupMenu
Parameters:
parent - the widget which defines the coordinate space
x - the x coordinate position to popup the menu
y - the y coordinate position to popup the menu
width - the fixed width that the popup menu will have after popping up
See Also:
popupDirected(marimba.gui.Widget, int, int)

popupDirected

public void popupDirected(Widget parent,
                          int direction,
                          int alignment)
Popup this popup menu in the given direction, with the given alignment. Both direction and alignment apply relative to the parent of this popup menu.
Overrides:
popupDirected in class AbstractPopupMenu
Parameters:
direction - UP, DOWN, LEFT or RIGHT
alignment - LEFT, CENTER or RIGHT
See Also:
popup(marimba.gui.Widget, int, int)

popdown

public void popdown()
Hides this widget popupmenu; it will make sure that the widget that had the focus (before this menu was popped up) re-gains the focus.
Overrides:
popdown in class AbstractPopupMenu
See Also:
popup(marimba.gui.Widget, int, int)

addSeparator

public void addSeparator()
Add a separator to this menu.

addSeparator

public void addSeparator(int index)
Insert a separator at the specified position.

add

public void add(java.lang.String label)
Add a menu item.
See Also:
#select

add

public void add(WidgetMenuItem item)
Add a menu item by giving the menu item directly.
See Also:
#select

add

public void add(WidgetMenu menu)
Add another WidgetMenu to this menu, this just adds a WidgetMenuItem with a WidgetMenu 'attached' to it.
See Also:
WidgetMenuItem.setSubMenu(conga.gui.WidgetMenu)

insert

public void insert(java.lang.String label,
                   int index)
Insert a menu item at the given position.

insert

public void insert(WidgetMenuItem item,
                   int index)
Insert a menu item at the given position by giving the item directly. If null is specified, nothing will happen, if the index is out of range the index is automatically adjusted to the first or last item.

remove

public void remove(java.lang.String label)
Remove the first menu item that has the given label. If there is no menu item with that label, nothing happens.

remove

public void remove(WidgetMenuItem item)
Remove a menu item by giving the item directly.

remove

public void remove(int index)
Remove the menu item at the given position. If the index is out of range, it will automatically be adjusted to the first or last item!

clear

public void clear()
Remove all menu items in this menu, the menu will be empty afterwards.

getItemCount

public int getItemCount()
Get the number of items in this menu.

getItem

public WidgetMenuItem getItem(int index)
Get the item at the specified position.

getSelectedItem

public WidgetMenuItem getSelectedItem()
The currently selected item. If none is selected, null is returned.

selectNextItem

public void selectNextItem()
Select the next item; if there is no selected item yet, it will result in the selection of the first item.
See Also:
getSelectedItem()

selectPreviousItem

public void selectPreviousItem()
Select previous item, if there is no selected item yet, it will result in the selection of the last item.
See Also:
getSelectedItem()

indexOf

public int indexOf(WidgetMenuItem item)
Get the index of given item inside this menu. Returns -1 if item is not found.
Returns:
-1 if given item was not found in this menu
See Also:
setSelectedItem(int)

setSelectedItem

public void setSelectedItem(int index)
Set the current item to the index-th item, with index in [0 .. getItemCount()-1]. If an invalid number is given, the first item becomes the current one.
See Also:
getSelectedItem(), indexOf(conga.gui.WidgetMenuItem), add(java.lang.String)

setSelectedItem

public void setSelectedItem(WidgetMenuItem item)
Select an item by giving the item directly.

handleEvent

public boolean handleEvent(java.awt.Event evt)
Handles keyboard events, in case this popup menu has keyboard focus.
Overrides:
handleEvent in class AbstractPopupMenu
Following copied from class: marimba.gui.Widget
Parameters:
evt - the event that needs to be handled by the widget
See Also:
Widget.postEvent(java.awt.Event)