Multivalent API

multivalent.gui
Class VMenuButton

java.lang.Object
  extended by multivalent.VObject
      extended by multivalent.Node
          extended by multivalent.INode
              extended by multivalent.node.IParaBox
                  extended by multivalent.gui.VMenuButton
All Implemented Interfaces:
java.lang.Cloneable, EventListener, java.util.EventListener

public class VMenuButton
extends IParaBox
implements EventListener

Menu button widget that pops up associated VMenu when mouse pressed. Scripts can be associated with menu items (which are arbitrary child Nodes--not subclasses--of VMenu). If a script is associated with VMenuButton itself, then it functions as a button when clicked, executing that script and not popping up the menu; and a menubutton when pressed. If parent is VMenu, operates as cascade; else as pulldown. For a popupmenu, simply invoke post() in the VMenu.

VMenus can either be supplied as children (as in HTML), or can be made dynamic. Dynamic menus are constructed afresh each time they are posted, by instantiating an empty VMenu and passing around a semantic event with the message createWidget/dynamic-name. Common menus -- which may or may not actually exist in a given Browser -- are given in VMenu.

Can be given both a menu (either as a child or dynamically) and a script. In this case, a quick click executes the script, and a mouse press pops up the menu.

Version:
$Revision: 1.8 $ $Date: 2003/06/02 05:19:35 $

Field Summary
 
Fields inherited from class multivalent.INode
border, INSETS, INSETS_ZERO, margin, padding
 
Fields inherited from class multivalent.Node
align, ALIGN_INVALID, ATTR_ID, ATTR_SCRIPT, baseline, BASELINE, bbox, BOTH, BOTTOM, CENTER, CHAR, FILL, floats, INHERIT, JUSTIFY, LEFT, MAXNONSTRUCTDEPTH, MIDDLE, name_, NONE, observers_, parent_, PROBEWIDTH, RIGHT, sticky_, stickycnt_, TOP, valid_, valign
 
Fields inherited from class multivalent.VObject
attr_
 
Constructor Summary
VMenuButton(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> attr, INode parent)
           
VMenuButton(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> attr, INode parent, java.lang.String script)
           
 
Method Summary
 boolean breakAfter()
           
 boolean breakBefore()
           
 void event(java.awt.AWTEvent e)
           
 boolean eventNode(java.awt.AWTEvent e, java.awt.Point rel)
          Just post associated menu and get out of the way.
 boolean formatNode(int width, int height, Context cx)
          Takes witdh and height from max dimensions of associated VMenu's children.
 void paintNode(java.awt.Rectangle docclip, Context cx)
          Shows active child by drawing it directly.
 void post()
          Post associated menu on screen, under root.
 void setDynamic(java.lang.String name)
          Menus can be dynamically generated.
 
Methods inherited from class multivalent.node.IParaBox
reformat
 
Methods inherited from class multivalent.INode
addCategory, appendChild, checkRep, childAt, childNum, clipboardNode, clone, contains, dump, dx, dy, eventBeforeAfter, findDFS, formatBeforeAfter, getElementById, getFirstChild, getFirstLeaf, getLastChild, getLastLeaf, getNextSibling, getPreviousSibling, insertChildAt, isStruct, markDirtySubtreeDown, paintBeforeAfter, removeAllChildren, removeChild, removeChildAt, setChildAt, setName, size, structChildAt, structChildNum, structsize
 
Methods inherited from class multivalent.Node
addObserver, addSticky, addSticky, childNum, clipboardBeforeAfter, cmp, commonAncestor, commonAncestor, contains, deleteObserver, dump, dump, findBFS, findBFS, findBFS, findDFS, findDFS, findDFS, getAbsLocation, getActivesAt, getActivesAt, getActivesAt, getBbox, getBrowser, getDocument, getIScrollPane, getName, getNextLeaf, getNextNode, getNodeName, getObservers, getParentNode, getPrevLeaf, getPrevNode, getRelLocation, getRoot, getSticky, indexSticky, intersects, isLeaf, isValid, markDirty, markDirtySubtree, markDirtyTo, morphInto, remove, removeSticky, removeSticky, removeTidy, repaint, repaint, repaint, repaint, scrollTo, scrollTo, setParentNode, setValid, sizeSticky, spanChunky, spanChunky, structChildNum, toString
 
Methods inherited from class multivalent.VObject
attrEntrySetIterator, attrKeysIterator, clearAttributes, getAttr, getAttr, getAttributes, getGlobal, getValue, hasAttributes, putAttr, removeAttr, setAttributes
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VMenuButton

public VMenuButton(java.lang.String name,
                   java.util.Map<java.lang.String,java.lang.Object> attr,
                   INode parent)

VMenuButton

public VMenuButton(java.lang.String name,
                   java.util.Map<java.lang.String,java.lang.Object> attr,
                   INode parent,
                   java.lang.String script)
Method Detail

setDynamic

public void setDynamic(java.lang.String name)
Menus can be dynamically generated. Each time such a menu is to be posted, it is created from scratch by sending an empty VMenu around in the semantic event createMenu/name, at which time behaviors build its content.


formatNode

public boolean formatNode(int width,
                          int height,
                          Context cx)
Takes witdh and height from max dimensions of associated VMenu's children.

Overrides:
formatNode in class IParaBox
See Also:
FixedI

breakBefore

public boolean breakBefore()
Overrides:
breakBefore in class INode

breakAfter

public boolean breakAfter()
Overrides:
breakAfter in class INode

paintNode

public void paintNode(java.awt.Rectangle docclip,
                      Context cx)
Shows active child by drawing it directly.

Overrides:
paintNode in class IParaBox

post

public void post()
Post associated menu on screen, under root.


eventNode

public boolean eventNode(java.awt.AWTEvent e,
                         java.awt.Point rel)
Just post associated menu and get out of the way. If has script and click, treat as button; if no script or press and has menu, treat as menubutton.

Overrides:
eventNode in class IParaBox
See Also:
TreeEvent, SemanticEvent

event

public void event(java.awt.AWTEvent e)
Specified by:
event in interface EventListener

Multivalent API