MJSContainers.mesa
Copyright © 1986, 1987 by Xerox Corporation. All rights reserved.
Cloned from Containers.mesa, Edited by McGregor on October 21, 1982 4:10 pm
Last Edited by: Maxwell, December 17, 1982 10:07 am
Last Edited by: Mike Spreitzer, January 9, 1987 9:10:34 pm PST
Last tweaked by Mike Spreitzer on March 16, 1988 4:20:59 pm PST
DIRECTORY Cursors, Icons, Menus, TIPUser, ViewerClasses;
MJSContainers: CEDAR DEFINITIONS =
BEGIN
Viewer: TYPE = ViewerClasses.Viewer;
ViewerRec: TYPE = ViewerClasses.ViewerRec;
MJSContainer: TYPE = Viewer;
Containers are just viewers that are convenient to hold other viewers.
MJSContainers differ from standard ones (date of divergance: July 11, 1983) in that:
MJSContainer is a subClass of Viewer. Clients may make their own subClass of MJSContainer (there is a standard subClass, VanillaMJSContainer, which may also be used), and thus MJSContainers have client data!
An MJSContainer may have a ChildAdjustProc.
MJSContainerClass: TYPE = REF MJSContainerClassRep;
MJSContainerClassRep:
TYPE =
RECORD [
notify: ViewerClasses.NotifyProc ← NIL,
paint: ViewerClasses.PaintProc ← NIL,
modify: ViewerClasses.ModifyProc ← NIL,
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,
adjust: ViewerClasses.AdjustProc ← NIL,
childAdjust: ChildAdjustProc ← NIL,
menu: Menus.Menu ← NIL,
tipTable: TIPUser.TIPTable ← NIL,
icon: Icons.IconFlavor ← document,
cursor: Cursors.CursorType ← textPointer,
dontAdjustIconic:
BOOL ←
TRUE
If this is TRUE, none of the procedures that react to viewer sizes & positions operate while the container is iconic (or a descendant of an iconic viewer).
];
ChildAdjustProc:
TYPE =
PROC [parent, child: Viewer]
RETURNS [viewerToPaint: Viewer ←
NIL, paintColumn:
BOOL ←
FALSE];
Hint that a child viewer's size may have changed; can err in either direction. Can move anything around, but don't paint; return values indicate what needs painting.
RegisterClass:
PROC [viewerFlavor:
ATOM, class: MJSContainerClass];
This must be called before you try to instantiate any of that class.
Module start code does:
RegisterClass[$VanillaMJSContainer, NEW [MJSContainerClassRep ← []]];
GetClass:
PROC [viewerFlavor:
ATOM]
RETURNS [class: MJSContainerClass];
Returns NIL if no such class.
Create:
PROC [viewerFlavor:
ATOM, info: ViewerRec ← [], paint:
BOOL ←
TRUE]
RETURNS [container: MJSContainer];
Creates a new, empty MJSContainer. Pass client data in info.data (it won't stay there).
ChildYBound:
PROC [container: MJSContainer, child: Viewer];
Constrain (child.wy + child.wh = container.ch) after next time container is painted.
ChildXBound:
PROC [container: MJSContainer, child: Viewer];
Constrain (child.wx + child.ww = container.cw) after next time container is painted.
FlushChildX,
FlushChildY:
PROC [child: Viewer]
RETURNS [changed:
BOOL];
Stretch child to indicated edge (without painting). Answer indicates work was needed to be done. Works for any kind of parent (and thus is not subject to the dontAdjustIconic prohibition of MJSContainers).
NoteSize:
PROC [container: MJSContainer, mayPaint:
BOOL]
RETURNS [change:
BOOL];
Considers notifying client of size change.
Does not propogate information `upward'.
Reports whether anything (client or bounded children) changed.
Paints if mayPaint AND change.
Do NOT call NoteSize from within a ViewerClasses.PaintProc!
Don't worry about calling this as a companion of Viewers calls --- Viewers takes care of that via the AdjustProc.
NoteChildSize:
PROC [child: Viewer]
RETURNS [viewerToPaint: Viewer, paintColumn:
BOOL];
Propogates size information up the viewers hierarchy, and reports lowest ancestor the painting of which covers changes.
Do NOT call from within a PaintProc or AdjustProc!
Viewers doesn't call this for you; you have to do it yourself.
ScrollOffset:
PROC [container: MJSContainer]
RETURNS [offTop:
INTEGER] ;
Returns the amount of the container scrolled off the top.
HScrollOffset:
PROC [container: MJSContainers.MJSContainer]
RETURNS [offLeft:
INTEGER] ;
Returns the amount of the container scrolled off the left.
GetClientData: PROC [container: MJSContainer] RETURNS [clientData: REF ANY];
IsMJSContainer: PROC [viewer: Viewer] RETURNS [BOOL];
END.