File: GraphController.mesa, Copyright © 1985 by Xerox Corporation. All rights reserved.
Last Edited by:
Sweetsun Chen, November 16, 1985 11:22:28 pm PST
DIRECTORY
Containers USING [Create],
Icons USING [IconFlavor, NewIconFromFile],
Graph USING [ControllerRec, GraphHandle, GraphProc, Viewer],
GraphCleanUp USING [CleanUpHandle],
GraphOps USING [Lock, Unlock],
GraphPrivate USING [ControllerMenus, MakeSpec, MakeTable, MakeXYValues],
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, GraphOps, GraphPrivate, GraphUtil, Rope, ViewerEvents, ViewerOps
EXPORTS GraphPrivate = {
OPEN Graph, GraphOps, 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"],
file: graph.fileName,
iconic: TRUE,
icon: controllerIcon,
menu: (controller.menu ← ControllerMenus[]),
column: left,
scrollable: FALSE],
paint: FALSE];
ViewerOps.AddProp[controller.viewer, $GraphController, handle];
MakeSpec[handle, 0, 0];
MakeRule[handle];
MakeXYValues[handle, 1000, 0];
MakeTable[handle, 1000, 0];
controller.specVisible ← 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.