MJSContainers.mesa; Edited by McGregor on October 21, 1982 4:10 pm
Last Edited by: Maxwell, December 17, 1982 10:07 am
Last Edited by: Spreitzer, April 14, 1985 11:53:24 am 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).
MJSContainers have an additional Class procedure: NoteSizeChanged. This proc gets called when cw or ch changes, and can request painting after it is done.
The size change notification, as well as bounded child adjustment, is done by a forked process.
MJSContainers have client data!
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,
menu: Menus.Menu ← NIL,
tipTable: TIPUser.TIPTable ← NIL,
icon: Icons.IconFlavor ← document,
cursor: Cursors.CursorType ← textPointer,
NoteSizeChanged: SizeChangeNotifyProc ← NIL];
SizeChangeNotifyProc: TYPE = PROC [container: MJSContainer, cw, ch: BOOL] RETURNS [paint: BOOLTRUE];
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: BOOLTRUE] 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] = INLINE
{container.class.set[self: container, data: child, op: $YBound]} ;
Constrain (child.wy + child.wh = container.wh) after next time container is painted.
ChildXBound: PROC [container: MJSContainer, child: Viewer] = INLINE
{container.class.set[self: container, data: child, op: $XBound]} ;
Constrain (child.wx + child.ww = container.ww) 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.
NoteSize: PROC [container: MJSContainer, mayPaint: BOOL] RETURNS [change: BOOL];
Considers notifying client of size change.
Reports whether anything (client or bounded children) changed.
Paints if mayPaint AND change.
Do NOT call NoteSize from within a ViewerClasses.PaintProc!.
ScrollOffset: PROC [container: MJSContainer] RETURNS [offTop: INTEGER] ;
Returns the amount of the container scrolled off the top.
GetClientData: PROC [container: MJSContainer] RETURNS [clientData: REF ANY];
IsMJSContainer: PROC [viewer: Viewer] RETURNS [BOOL];
END.