Multivalent API

multivalent
Class IScrollPane

java.lang.Object
  extended by multivalent.VObject
      extended by multivalent.Node
          extended by multivalent.INode
              extended by multivalent.IScrollPane
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Document, VMenu, VTextArea

public class IScrollPane
extends INode

An internal node that scrolls its content as necessary.

Dimensions are independent of its children's. Therefore, unlike other Nodes, dimensions should be set externally, either directly in pixels on bbox or in characters with setSizeChars(int,int). Otherwise, dimensions take all available space.

Does not lay out children, so should have single child, and perhaps visual layers as well. Methods can scroll to (x,y) position or to passed Node.

Contents are formatted on demand, at the first call to paint. Thus, the reformatting required by any amount of editing is batched. On the other hand, if any part of the node is to be painted, it must be entirely formatted; the scrollbars, for instance, require this to visually indicate the percentage of the document shown.

LATER

Version:
$Revision: 1.9 $ $Date: 2003/02/14 02:07:10 $

Field Summary
 boolean editable
          Is content editable?
protected  int hchars_
           
 java.awt.Rectangle ibbox
          Bounding box of content.
static java.lang.String MSG_FORMATTED
          Report that contents of pane have been formatted.
static java.lang.String MSG_SCROLL_TO
          Scroll document to point that shows arg.
protected  int wchars_
           
 
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
IScrollPane(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> attr, INode parent)
           
 
Method Summary
 boolean checkRep()
          Checks "representation invariant" (see MIT SE), and returns true iff object is valid, which should be always
 void dump(int level, int maxlevel)
          Dump more verbose than toString().
 int dx()
          Skip over border, padding to content area.
 int dy()
          Skip over border, padding to content area.
 boolean eventNode(java.awt.AWTEvent e, java.awt.Point rel)
          Internal nodes pass on to children.
 boolean formatNode(int width, int height, Context cx)
          If length of dimension set in characters or to dynamic (these mutually cancel each other out--last one set wins), use that to set corresponding bounding box dimension.
 VScrollbar getHsb()
           
 IScrollPane getIScrollPane()
          Chains up parent links.
 VScrollbar getVsb()
          Scrollbars, which uncharacteristically aren't reachable by walking the tree.
 void paintBeforeAfter(java.awt.Rectangle docclip, Context cx)
          If IScrollPane not valid when needs to be painted, format it now.
 void paintNode(java.awt.Rectangle docclip, Context cx)
          Paints contents in scrolled, clipped Graphics2D.
 void scrollBy(int dx, int dy)
          Scroll by a delta x and y.
 void scrollTo(int x, int y)
          Scroll to an absolute x and y.
 void scrollTo(Node node, int xoff, int yoff, boolean pickplace)
          Pickplace option described in VScrollbar.
 void setScrollbarShowPolicy(byte policy)
          Convenience method to set both scrollbars to same VScrollbar policy.
 void setSizeChars(int widthchars, int heightchars)
          Compute dimensions from number of characters of prevailing font.
 
Methods inherited from class multivalent.INode
addCategory, appendChild, breakAfter, breakBefore, childAt, childNum, clipboardNode, clone, contains, eventBeforeAfter, findDFS, formatBeforeAfter, getElementById, getFirstChild, getFirstLeaf, getLastChild, getLastLeaf, getNextSibling, getPreviousSibling, insertChildAt, isStruct, markDirtySubtreeDown, 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, getName, getNextLeaf, getNextNode, getNodeName, getObservers, getParentNode, getPrevLeaf, getPrevNode, getRelLocation, getRoot, getSticky, indexSticky, intersects, isLeaf, isValid, markDirty, markDirtySubtree, markDirtyTo, morphInto, reformat, 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
 

Field Detail

MSG_SCROLL_TO

public static final java.lang.String MSG_SCROLL_TO
Scroll document to point that shows arg.

"scrollTo": arg= Span start-of-span-if-set

"scrollTo": arg= Node Node

"scrollTo": arg= Integer absolute-position, in= Node node in tree (usually IScrollPane or Document)

"scrollTo": arg= String name-of-anchor, in= Node node in tree (usually IScrollPane or Document)

See Also:
Constant Field Values

MSG_FORMATTED

public static final java.lang.String MSG_FORMATTED
Report that contents of pane have been formatted.

"formattedPane": arg= IScrollPane instance

See Also:
Constant Field Values

ibbox

public java.awt.Rectangle ibbox
Bounding box of content.


editable

public boolean editable
Is content editable? This is the wrong way to do this, and will be changed in the future.


wchars_

protected int wchars_

hchars_

protected int hchars_
Constructor Detail

IScrollPane

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

getIScrollPane

public IScrollPane getIScrollPane()
Description copied from class: Node
Chains up parent links. @return null if none.

Overrides:
getIScrollPane in class Node

dx

public int dx()
Description copied from class: INode
Skip over border, padding to content area.

Overrides:
dx in class INode

dy

public int dy()
Description copied from class: INode
Skip over border, padding to content area.

Overrides:
dy in class INode

getVsb

public VScrollbar getVsb()
Scrollbars, which uncharacteristically aren't reachable by walking the tree. That may change.


getHsb

public VScrollbar getHsb()

setScrollbarShowPolicy

public void setScrollbarShowPolicy(byte policy)
Convenience method to set both scrollbars to same VScrollbar policy. Access scrollbars individually to set to different policies.


setSizeChars

public void setSizeChars(int widthchars,
                         int heightchars)
Compute dimensions from number of characters of prevailing font. To disable, set to 0.


formatNode

public boolean formatNode(int width,
                          int height,
                          Context cx)
If length of dimension set in characters or to dynamic (these mutually cancel each other out--last one set wins), use that to set corresponding bounding box dimension. Else maintain length, which should have been set externally beforehand. Sends MSG_FORMATTED.

Overrides:
formatNode in class INode
See Also:
FixedI

paintBeforeAfter

public void paintBeforeAfter(java.awt.Rectangle docclip,
                             Context cx)
If IScrollPane not valid when needs to be painted, format it now. Generally, formatting should be done lazily, on demand just before it needs to be painted (including in the IScrollPane subclass Document).

Overrides:
paintBeforeAfter in class INode

paintNode

public void paintNode(java.awt.Rectangle docclip,
                      Context cx)
Paints contents in scrolled, clipped Graphics2D.

Overrides:
paintNode in class INode

eventNode

public boolean eventNode(java.awt.AWTEvent e,
                         java.awt.Point rel)
Description copied from class: INode
Internal nodes pass on to children. Events are propogated from last child to first (and painted first to last), which means that later children have implicitly higher priority as they get first chance at setting a grab. Event passed on only if (x,y) within child's bounding box, or if TreeEvent.VALIDATE event. Event is translated to be in child's coordinate system (that is, (0,0) corresponds to the child's origin).

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

scrollBy

public void scrollBy(int dx,
                     int dy)
Scroll by a delta x and y. Positive x moves right; positive y moves down.


scrollTo

public void scrollTo(int x,
                     int y)
Scroll to an absolute x and y.


scrollTo

public void scrollTo(Node node,
                     int xoff,
                     int yoff,
                     boolean pickplace)
Pickplace option described in VScrollbar.

See Also:
VScrollbar

checkRep

public boolean checkRep()
Description copied from class: VObject
Checks "representation invariant" (see MIT SE), and returns true iff object is valid, which should be always.

Overrides:
checkRep in class INode

dump

public void dump(int level,
                 int maxlevel)
Description copied from class: Node
Dump more verbose than toString().

Overrides:
dump in class INode

Multivalent API