File: GraphController.mesa, Copyright © 1985 by Xerox Corporation. All rights reserved.
Last Edited by:
Sweetsun Chen, October 21, 1985 9:00:48 pm PDT
DIRECTORY
Containers USING [Create],
Icons USING [IconFlavor, NewIconFromFile],
Graph USING [Viewer],
GraphCleanUp USING [CleanUpHandle],
GraphPrivate USING [ControllerRec, GraphHandle, ControllerMenus, GraphProc, Lock, MakePanel, MakeTable, Unlock],
GraphUtil USING [HandleFromViewer, HandleNotNil],
Rope USING [Concat],
TiogaMenuOps USING [Normalize],
TiogaOps USING [Jump, ViewerDoc],
ViewerEvents USING [EventProc, RegisterEventProc],
ViewerOps USING [AddProp, FetchProp, OpenIcon, TopViewer];
GraphController:
CEDAR
PROGRAM
IMPORTS Containers, Icons, GraphCleanUp, GraphPrivate, GraphUtil, Rope, ViewerEvents, ViewerOps
EXPORTS GraphPrivate = {
OPEN Graph, GraphPrivate;
(constant) variables
controllerIcon: Icons.IconFlavor ← Icons.NewIconFromFile["Graph.icons", 1];
ShowController:
PUBLIC GraphProc = {
Show up controller. Create it if it doesn't exist.
IF GraphUtil.HandleNotNil[handle]
THEN {
OPEN handle;
IF controller = NIL THEN NewController[handle]
ELSE {
IF controller.viewer.iconic
THEN
ViewerOps.OpenIcon[icon: controller.viewer, bottom: FALSE]
ELSE ViewerOps.TopViewer[controller.viewer];
};
};
}; -- ShowController
NewController: GraphProc = {
OPEN handle;
controller ← NEW[ControllerRec ← []];
controller.viewer ← Containers.Create[
info: [
name: graph.fileName.Concat[" Controller"],
iconic: TRUE,
icon: controllerIcon,
menu: (controller.menu ← ControllerMenus[]),
column: left,
scrollable: FALSE],
paint: FALSE];
ViewerOps.AddProp[controller.viewer, $GraphController, handle];
MakeTable[handle, MakePanel[handle]];
controller.panelVisible ← TRUE;
ViewerOps.SetOpenHeight[controller.viewer, 1000];
ViewerOps.PaintViewer[controller.viewer, all];
ViewerOps.OpenIcon[icon: controller.viewer];
}; -- NewController
IsController:
PUBLIC
PROC [viewer: Viewer]
RETURNS [
BOOL] = {
IF viewer = NIL THEN RETURN[FALSE];
RETURN[ViewerOps.FetchProp[viewer, $GraphController] # NIL];
}; -- IsController
to be added: GraphSearch.mesa
Next: ActionProc = {}; -- Next
Find: ActionProc = {}; -- Find
ControllerBeforeDestroy: ViewerEvents.EventProc = {
handle: GraphHandle ← GraphUtil.HandleFromViewer[viewer];
IF handle #
NIL
THEN
IF event = destroy
AND IsController[viewer]
AND before
THEN {
Lock[handle];
IF handle.controller # NIL THEN handle.controller^ ← [];
handle.controller ← NIL;
Unlock[handle];
};
}; -- ControllerBeforeDestroy
ControllerAfterDestroy: ViewerEvents.EventProc = {
handle: GraphHandle ← GraphUtil.HandleFromViewer[viewer];
IF handle #
NIL
THEN
IF event=destroy
AND IsController[viewer]
AND
NOT before
THEN {
Lock[handle];
IF handle.chart.viewer = NIL THEN handle ← GraphCleanUp.CleanUpHandle[handle, TRUE]
ELSE Unlock[handle];
};
}; -- ControllerAfterDestroy
TableOpen: ViewerEvents.EventProc = {
handle: GraphHandle ← NARROW[ViewerOps.FetchProp[viewer, $GraphTable]];
IF handle # NIL THEN IF event = open AND NOT before THEN
handle.waitingController ← FALSE;
}; -- TableOpen
Init:
PROC [] = {
[] ← ViewerEvents.RegisterEventProc[
proc: ControllerBeforeDestroy, event: destroy, before: TRUE];
[] ← ViewerEvents.RegisterEventProc[
proc: ControllerAfterDestroy, event: destroy, before: FALSE];
[] ← ViewerEvents.RegisterEventProc[
proc: TableOpen, event: open, before: FALSE];
};
Init[];
}.
CHANGE
LOG.
SChen, created at October 9, 1985 6:09:36 pm PDT.