Constrainers.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Eric Nickell, October 17, 1986 2:01:03 pm PDT
DIRECTORY
Icons, Menus, ViewerClasses, ViewerConstraints;
Constrainers: CEDAR DEFINITIONS
~ BEGIN
Viewer: TYPE = ViewerClasses.Viewer;
Constraint: TYPE ~ ViewerConstraints.Constraint;
Constrainer: TYPE ~ Viewer;
Constrainer Classes
ConstrainerClass: TYPE = REF ConstrainerClassRep;
ConstrainerClassRep: TYPE = RECORD [
destroy: ViewerClasses.DestroyProc ← NIL,
copy: ViewerClasses.CopyProc ← NIL,
set: ViewerClasses.SetProc ← NIL,
get: ViewerClasses.GetProc ← NIL,
init: ViewerClasses.InitProc ← NIL,
save: ViewerClasses.SaveProc ← NIL,
caption: ViewerClasses.CaptionProc ← NIL,
menu: Menus.Menu ← NIL,
icon: Icons.IconFlavor ← document
];
RegisterClass: PROC [viewerFlavor: ATOM, class: ConstrainerClassRep] RETURNS [same: ATOM];
GetClass: PROC [viewerFlavor: ATOM] RETURNS [class: ConstrainerClass];
Returns NIL if no such class.
Constrainers (Abutter facsimiles)
vanilla: ATOM;
The flavor of a standard, bland, common, ordinary, garden-variety ConstrainerClass. It differs from [] only in having a non-NIL save, which enumerates the children (but not grandchildren), calling their save's, if any.
SeriesElement: TYPE ~ RECORD [viewer: Viewer, spaceBefore: INTEGER ← 0, keepSizeFixed: BOOLTRUE];
Parallel: TYPE ~ LIST OF Series;
Series: TYPE ~ RECORD [
rigid: LIST OF SeriesElement,
end: SELECT kind: * FROM
none => [spaceAfter: INTEGER ← 0, setParentSize: BOOLFALSE],
parallel => [p: Parallel],
stretch => [se: SeriesElement],
ENDCASE
];
EdgeType: TYPE ~ ViewerConstraints.EdgeType;
Rules: TYPE ~ ARRAY EdgeType OF Series;
Create: PROC [viewerFlavor: ATOM, info: ViewerClasses.ViewerRec ← [], paint: BOOLTRUE] RETURNS [c: Constrainer];
Put client data in info.data; it won't stay there.
ViewerIsConstrainer: PROC [Viewer] RETURNS [BOOL];
GetClientData: PROC [Constrainer] RETURNS [REF ANY];
ScrollOffset: PROC [Constrainer] RETURNS [offTop: INTEGER];
Returns the amount of the constrainer scrolled off the top.
HScrollOffset: PROC [Constrainer] RETURNS [offLeft: INTEGER];
Returns the amount of the constrainer scrolled off the left.
SetLayout: PROC [c: Constrainer, rules: Rules, paint, eliminateOldConstraints: BOOLTRUE];
Abut: PROC [c: Constrainer, child1, child2: Viewer, edge: EdgeType, space: INTEGER ← 0, stretch: BOOLFALSE, paint: BOOLTRUE];
parentSide: Viewer; --pass this as child1 to abut against a side of the parent, rather than another Viewer.
Constrainers (Additional capabilities)
KeepSquare: PROC [v: Viewer, adjustEdge: EdgeType] RETURNS [c: Constraint];
Keeps v square by adjusting the specified edge.
Center: PROC [parent, child: Viewer, margin: INTEGER ← 0, horz: BOOLTRUE];
Centers child in the parent
Wrap: PROC [parent: Viewer, children: LIST OF Viewer, margin: INTEGER ← 0];
The children are placed left to right inside parent, but wrap to the next ``line'' when they would exceed the right edge of the parent. For best results, the height of all the children should be the same. No constraint is placed on the first child. It should therefore be positioned correctly. The other children are fully constrained, and should thus not have any other constraint placed on them.
END.