3 The Trestle interface
4.3 The HVSplit interface
4.3.2 Adjusting the division of space
The division point after a child is the sum of the sizes of all children up to and including the child.
PROCEDURE Adjust(v: T; ch: VBT.T; totsz: INTEGER) RAISES {Split.NotAChild}; <* LL.sup = VBT.mu *>
Change the sizes of the children ofvso that the division point afterchis as close tototszas possible, and markvfor redisplay.
Adjustrespects the size constraints on the children, and resizes children near the division point in preference to children far from the division point. For example, a sufficiently small adjustment will be made by resizing onlychand its successor. An adjustment large enough to make one of these children reach its max or min size will also resize the neighbor of that child, and so forth.
Adjustis a no-op if the split is infeasible or non-adjustable.
PROCEDURE FeasibleRange(v: T; ch: VBT.T): Interval.T RAISES {Split.NotAChild}; <* LL.sup = VBT.mu *>
Return the interval of feasible positions for the division point afterch.
PROCEDURE AvailSize(v: T): CARDINAL; <* LL.sup = VBT.mu *>
Return the largest size of a child that can be inserted intovwithout makingv
infeasible.
If the split is infeasible,AvailSizereturns 0 andFeasibleRangereturns the empty interval. Both procedures assume the total size available is the total of all child sizes.
4.4 The PackSplit interface 57
4.4
The PackSplit interface
APackSplit.Tis a parent window whose children are packed into multiple rows or columns, depending on the axis of the split.
If the axis is horizontal, the children are packed into rows from west to east, moving south to a new row when the current row fills up. This is the normal style used in placing words in a paragraph.
If the axis is vertical, the children are packed into columns from north to south, moving east to a new column when the current column fills up. This is the normal style used in placing paragraphs in a newspaper article.
APackSplitalways gives its children their preferred height and width, even if this makes them extend outside the parent domain (in which case they will be clipped). If the axis is horizontal, the children in any given row have their north edges aligned, and all children that are first in their row have their west edges aligned with the west edge of the parent. A child will be horizontally clipped if its requested horizontal size exceeds the parent’s horizontal size; in this case the child will be alone in its row.
If the axis is vertical, the children in any given column have their west edges aligned, and all children that are first in their column have their north edge aligned with the north edge of the parent. A child will be vertically clipped if its requested vertical size exceeds the parent’s vertical size; in this case the child will be alone in its column. The size of a window is the extent of its domain in the axis of thePackSplit; its
cross-size is its extent in the other axis.
The range of desirable sizes and the preferred size of aPackSplitare just the default for aVBT. The shape method uses the size to determine the cross-size that is just large enough to pack in all the children at their preferred sizes, and returns as its range of desirable cross-sizes a singleton interval containing only this cross-size.
INTERFACE PackSplit;
IMPORT VBT, PaintOp, Pixmap, Axis; TYPE
T <: Public;
Private <: VBT.Split;
Public = Private OBJECT METHODS <* LL.sup <= VBT.mu *>
init(hv := Axis.T.Hor; hgap, vgap := 1.5;
txt: Pixmap.T := Pixmap.Solid; op: PaintOp.T := PaintOp.Bg; nwAlign := FALSE;
saveBits := FALSE): T END;
For a horizontalPackSplit,hgapis the gap to leave between children in each row;
vgapis the gap to leave between rows. For a verticalPackSplit,vgapis the gap to leave between children in each column;hgapis the gap to leave between columns. The gaps are specified in millimeters.
The area not covered by children is painted using the painting operationopand the texturetxt+delta, where deltais the origin unlessnwAlignis set toTRUE, in which casedeltawill be set to the northwest corner ofv.
If saveBits is TRUE, the implementation will try to save the children’s old bits when reshaping; if the children don’t use the old bits, it is more efficient to let
saveBitsdefault toFALSE.
PROCEDURE New( hv := Axis.T.Hor; hgap, vgap := 1.5;
txt: Pixmap.T := Pixmap.Solid; op: PaintOp.T := PaintOp.Bg; nwAlign := FALSE;
saveBits := FALSE): T; <* LL.sup <= VBT.mu *> New(...)is equivalent toNEW(T).init(...).
PROCEDURE Set( v: T;
txt: Pixmap.T;
op: PaintOp.T := PaintOp.BgFg;
nwAlign := FALSE); <* LL.sup = VBT.mu *>
Change the texture displayed byvand markvfor redisplay.
PROCEDURE Get( v: T;
VAR txt: Pixmap.T; VAR op: PaintOp.T; VAR nwAlign: BOOLEAN ); <* LL.sup = VBT.mu *>
Fetch the texture displayed byv.
PROCEDURE AxisOf(v: T): Axis.T; <* LL.sup <= VBT.mu *>
Return the axis ofv.
PROCEDURE HGap(v: T): REAL; <* LL.sup <= VBT.mu *>
Return thehgapofv.
PROCEDURE VGap(v: T): REAL; <* LL.sup <= VBT.mu *>
Return thevgapofv.