multivalent.gui

Class VMenu

public class VMenu extends IScrollPane implements EventListener

Pure Multivalent menu widget. Like IVBox + IScrollPane. Connect to VMenuButton for pulldown or popup, invoke post()/unpost() externally for popup anywhere, or embed in document for List-type widget.

As children you can have any kind of node: VButton/VCheckButton/VRadioButton, IHBox for HTML OPTIONs, or VMenuButton for cascaded menus. In other words, there is no need for a separate group of MenuItem widgets. As mentioned on the package-wide description, since Multivalent widgets can have arbitrary content, having, say, a menu item with a image and text is easy.

If selected item has VScript in "script" attribute, it's executed upon selection.

Version: $Revision: 1.13 $ $Date: 2003/06/02 05:19:13 $

Field Summary
static StringCATEGORY_MEDIUM
Menu category (medium) for medium-specific options (where medium is PDF, HTML, LocalDirectory, ...).
static intMaxsize
Maximum number of items to show at once (more uses scrolling).
static StringMSG_CREATE_ANNO
Construct Anno menu by passing around to behaviors and letting them add (or delete) entiries.
static StringMSG_CREATE_BOOKMARK
Construct Bookmark menu by passing around to behaviors and letting them add (or delete) entiries.
static StringMSG_CREATE_EDIT
Construct Edit menu by passing around to behaviors and letting them add (or delete) entiries.
static StringMSG_CREATE_FILE
Construct File menu by passing around to behaviors and letting them add (or delete) entiries.
static StringMSG_CREATE_GO
Construct Go menu by passing around to behaviors and letting them add (or delete) entiries.
static StringMSG_CREATE_HELP
Construct Help menu by passing around to behaviors and letting them add (or delete) entiries.
static StringMSG_CREATE_LENS
Construct Lens menu by passing around to behaviors and letting them add (or delete) entiries.
static StringMSG_CREATE_STYLE
Construct Style menu by passing around to behaviors and letting them add (or delete) entiries.
static StringMSG_CREATE_VIEW
Construct View menu by passing around to behaviors and letting them add (or delete) entiries.
static StringVAR_MENUSTACK
Key into Root's globals to get ordered List<> of menus currently posted.
Constructor Summary
VMenu(String name, Map<String,Object> attr, INode parent)
Method Summary
NodeaddCategory(Node n, String category)
Immediate subtrees of menu are categories: named VSeparator's used to cluster items from disparate behaviors.
voidevent(AWTEvent e)
Posted with grab,
booleaneventBeforeAfter(AWTEvent e, Point rel)
Lets events pass through so disable behavior works.
booleanformatNode(int width, int height, Context cx)
Like a IVBox, except is max of children (which are menitems).
NodegetSelected()
voidinvoke()
Execute active item's script, if any.
voidpaintNode(Rectangle docclip, Context cx)
voidpost(int x, int y, Browser br)
Show on screen by disconnecting from (old) parent and adding to root (which is in absolutely positioned space).
voidrepaint(long ms, int x, int y, int w, int h)
voidsetSelected(Node n)
Use invoke() to execute any associated script.
voidunpost()
Unshow by removing from root and reconnecting to old parent (if any).

Field Detail

CATEGORY_MEDIUM

public static final String CATEGORY_MEDIUM
Menu category (medium) for medium-specific options (where medium is PDF, HTML, LocalDirectory, ...).

Maxsize

public static int Maxsize
Maximum number of items to show at once (more uses scrolling).

MSG_CREATE_ANNO

public static final String MSG_CREATE_ANNO
Construct Anno menu by passing around to behaviors and letting them add (or delete) entiries.

"createWidget/Anno": out= VMenu instance-under-construction.

MSG_CREATE_BOOKMARK

public static final String MSG_CREATE_BOOKMARK
Construct Bookmark menu by passing around to behaviors and letting them add (or delete) entiries.

"createWidget/Bookmark": out= VMenu instance-under-construction.

MSG_CREATE_EDIT

public static final String MSG_CREATE_EDIT
Construct Edit menu by passing around to behaviors and letting them add (or delete) entiries.

"createWidget/Edit": out= VMenu instance-under-construction.

MSG_CREATE_FILE

public static final String MSG_CREATE_FILE
Construct File menu by passing around to behaviors and letting them add (or delete) entiries.

"createWidget/File": out= VMenu instance-under-construction.

MSG_CREATE_GO

public static final String MSG_CREATE_GO
Construct Go menu by passing around to behaviors and letting them add (or delete) entiries.

"createWidget/Go": out= VMenu instance-under-construction.

MSG_CREATE_HELP

public static final String MSG_CREATE_HELP
Construct Help menu by passing around to behaviors and letting them add (or delete) entiries.

"createWidget/Help": out= VMenu instance-under-construction.

MSG_CREATE_LENS

public static final String MSG_CREATE_LENS
Construct Lens menu by passing around to behaviors and letting them add (or delete) entiries.

"createWidget/Lens": out= VMenu instance-under-construction.

MSG_CREATE_STYLE

public static final String MSG_CREATE_STYLE
Construct Style menu by passing around to behaviors and letting them add (or delete) entiries.

"createWidget/Style": out= VMenu instance-under-construction.

MSG_CREATE_VIEW

public static final String MSG_CREATE_VIEW
Construct View menu by passing around to behaviors and letting them add (or delete) entiries.

"createWidget/View": out= VMenu instance-under-construction.

VAR_MENUSTACK

public static final String VAR_MENUSTACK
Key into Root's globals to get ordered List<> of menus currently posted.

Constructor Detail

VMenu

public VMenu(String name, Map<String,Object> attr, INode parent)

Method Detail

addCategory

public Node addCategory(Node n, String category)
Immediate subtrees of menu are categories: named VSeparator's used to cluster items from disparate behaviors. If category doesn't exist, it's created. If category is null, item is appended to end of menu.

event

public void event(AWTEvent e)
Posted with grab,

eventBeforeAfter

public boolean eventBeforeAfter(AWTEvent e, Point rel)
Lets events pass through so disable behavior works.

formatNode

public boolean formatNode(int width, int height, Context cx)
Like a IVBox, except is max of children (which are menitems).

getSelected

public Node getSelected()

invoke

public void invoke()
Execute active item's script, if any.

paintNode

public void paintNode(Rectangle docclip, Context cx)

post

public void post(int x, int y, Browser br)
Show on screen by disconnecting from (old) parent and adding to root (which is in absolutely positioned space). Independent of mouse clicks. Menu is not necessarily posted, as when used a list widget embedded in content space. Subclasses can dynamically construct menu contents by overriding with construction code and calling super.post(int, int, Browser); the forward/backward buttons and bookmarks do this.

See Also: ForwardBack Bookmark

repaint

public void repaint(long ms, int x, int y, int w, int h)

setSelected

public void setSelected(Node n)
Use invoke() to execute any associated script.

unpost

public void unpost()
Unshow by removing from root and reconnecting to old parent (if any). Independent of mouse clicks.