GraphTable.mesa, Copyright © 1985 by Xerox Corporation. All rights reserved.
Last Edited by:
Sweetsun Chen, October 22, 1985 5:05:11 pm PDT
DIRECTORY
Convert USING [RopeFromInt],
Graph USING [Entity, EntityGroup, EntityList, NestedEntities, NestedEntitiesList, Text, Texts, Viewer],
GraphPrivate USING [CallWithLock, EntityGroupList, GraphHandle, GraphProc, RemoveEntity, RemoveText, ShowEntity, ShowText],
GraphUtil USING [HandleNotNil],
TiogaOps USING [Break, InsertRope, LastChild, Lock, Nest, Ref, SelectPoint, SetLooks, SubtractLooks, Unlock, UnNest, ViewerDoc],
TiogaButtons USING [CreateButton, CreateButtonFromNode, CreateViewer, TiogaButton, TiogaButtonProc],
ViewerTools USING [SetContents];
GraphTable: CEDAR PROGRAM
IMPORTS Convert, GraphPrivate, GraphUtil, TiogaOps, TiogaButtons, ViewerTools
EXPORTS GraphPrivate = { OPEN Graph, GraphPrivate;
GraphButtonData: TYPE = REF GraphButtonDataRec;
GraphButtonDataRec: TYPE = RECORD[
handle: GraphHandle ← NIL,
ref: REF ANYNIL
];
MakeTable: PUBLIC PROC [handle: GraphHandle, lastHeight: INTEGER] = {
called by NewController, which should have made sure the following not nil: handle, handle.controller, etc.
IF GraphUtil.HandleNotNil[handle] THEN {
LockedMakeTable: PROC [root: TiogaOps.Ref] = {TopLevelTable[handle, root]};
b: TiogaButtons.TiogaButton;
handle.controller.table ← TiogaButtons.CreateViewer[
info: [
wy: handle.controller.panelHeight, ww: 2000, wh: 1000,
menu: NIL,
parent: handle.controller.viewer,
scrollable: TRUE,
border: FALSE,
caption: FALSE
]];
TiogaOps.CallWithLocks[LockedMakeTable, TiogaOps.ViewerDoc[viewer]];
TopLevelTable[handle, TiogaOps.ViewerDoc[viewer]];
b ← TiogaButtons.CreateButton[viewer: handle.controller.table, rope: ""];
b ← TiogaButtons.CreateButton[viewer: handle.controller.table, rope: "Texts:", looks: "lb"];
TiogaOps.SelectPoint[handle.controller.table, b.endLoc];
TiogaOps.Break[];
TiogaOps.Nest[];
TextsTable[handle, b.endLoc.node];
TiogaOps.UnNest[];
b ← TiogaButtons.CreateButton[viewer: handle.controller.table, rope: "Curves:", looks: "lb"];
TiogaOps.SelectPoint[handle.controller.table, b.endLoc];
TiogaOps.Break[];
TiogaOps.Nest[];
FOR egl: EntityGroupList ← handle.entityGroupList, egl.rest UNTIL egl = NIL DO
NELTable[handle, egl.first.ys, b.endLoc.node];
ENDLOOP;
};
}; -- MakeTable
TextsTable: PROC [handle: GraphHandle, parent: TiogaOps.Ref] = {
button: TiogaButtons.TiogaButton;
FOR ts: Texts ← handle.allTexts, ts.rest UNTIL ts = NIL DO
t: Text ← ts.first; -- error if nil.
TiogaOps.InsertRope[
IF t.text = NIL THEN Convert.RopeFromInt[t.id] ELSE t.text];
button ← TiogaButtons.CreateButtonFromNode[
node: TiogaOps.LastChild[parent],
start: , end: ,
proc: TextButtonProc,
clientData: NEW[GraphButtonDataRec ← [handle, t]]
];
TiogaOps.SelectPoint[handle.controller.table, button.endLoc];
TiogaOps.Break[];
ENDLOOP;
}; -- TextsTable
EntityListTable: PROC [handle: GraphHandle, entityList: EntityList, parent: TiogaOps.Ref] = {
button: TiogaButtons.TiogaButton;
FOR el: EntityList ← entityList, el.rest UNTIL el = NIL DO
entity: Entity ← el.first; -- error if nil.
TiogaOps.InsertRope[
IF entity.name = NIL THEN Convert.RopeFromInt[entity.id] ELSE entity.name];
button ← TiogaButtons.CreateButtonFromNode[
node: TiogaOps.LastChild[parent],
start: , end: ,
proc: EntityButtonProc,
clientData: NEW[GraphButtonDataRec ← [handle, entity]]
];
TiogaOps.SelectPoint[handle.controller.table, button.endLoc];
TiogaOps.Break[];
ENDLOOP;
}; -- EntityListTable
NELTable: PROC [handle: GraphHandle, nestedEntityList: NestedEntitiesList ← NIL, parent: TiogaOps.Ref] = {
FOR nel: NestedEntitiesList ← nestedEntityList, nel.rest UNTIL nel = NIL DO
ne: NestedEntities ← nel.first;
IF ne # NIL THEN {
lastChild: TiogaOps.Ref;
button: TiogaButtons.TiogaButton;
TiogaOps.SetLooks["b", caret];
TiogaOps.InsertRope[IF ne.name = NIL THEN "=>" ELSE ne.name];
TiogaOps.SubtractLooks["b", caret];
lastChild ← TiogaOps.LastChild[parent];
button ← TiogaButtons.CreateButtonFromNode[
node: lastChild,
start: , end: ,
proc: NestedEntitiesButtonProc,
clientData: NEW[GraphButtonDataRec ← [handle, ne]]
];
TiogaOps.SelectPoint[handle.controller.table, button.endLoc];
TiogaOps.Break[];
TiogaOps.Nest[];
EntityListTable[handle, ne.entityList, lastChild];
NELTable[handle, ne.children, lastChild];
TiogaOps.UnNest[];
};
ENDLOOP;
}; -- NELTable
EntityGroupButtonProc: TiogaButtons.TiogaButtonProc = { -- NOOP for now
handle: GraphHandle ← NARROW[ViewerOps.FetchProp[parent, $GraphController]];
group: EntityGroup ← NARROW[clientData];
some checking might be necessary.
SetIntField[controller.groupId, group.id];
Control[handle, resume, $Group];
SELECT moustButton FROM
red => IF control THEN Control[handle, display, $Group];
blue => IF control THEN Control[handle, remove, $Group];
ENDCASE;
}; -- EntityGroupButtonProc
NestedEntitiesButtonProc: TiogaButtons.TiogaButtonProc = { -- noop for now.
}; -- NestedEntitiesButtonProc
EntityButtonProc: TiogaButtons.TiogaButtonProc = {
data: GraphButtonData ← NARROW[clientData];
proc: GraphProc = {
entity: Entity ← NARROW[data.ref];
SELECT mouseButton FROM
red => {
ViewerTools.SetContents[handle.controller.entityId, Convert.RopeFromInt[entity.id]];
ShowEntity[handle, entity];
};
blue => RemoveEntity[handle, entity];
ENDCASE;
};
CallWithLock[data.handle, proc];
}; -- EntityButtonProc
TextButtonProc: TiogaButtons.TiogaButtonProc = {
data: GraphButtonData ← NARROW[clientData];
proc: GraphProc = {
t: Text ← NARROW[data.ref];
SELECT mouseButton FROM
red => {
ViewerTools.SetContents[handle.controller.textId, Convert.RopeFromInt[t.id]];
ShowText[handle, t];
};
blue => RemoveText[handle, t];
ENDCASE;
};
CallWithLock[data.handle, proc];
}; -- EntityButtonProc
AddTextButton: PUBLIC PROC [handle: GraphHandle ← NIL, text: Text ← NIL] RETURNS [b: TiogaButtons.TiogaButton ← NIL] = {
IF GraphUtil.HandleNotNil[handle] AND text # NIL THEN {
root: TiogaOps.Ref ← TiogaOps.ViewerDoc[handle.controller.table];
TiogaOps.Lock[root];
TiogaOps.SelectPoint[handle.controller.table,
[TiogaOps.LastChild[handle.controller.textsParent], -1]];
TiogaOps.Break[];
TiogaOps.InsertRope[
IF text.text = NIL THEN Convert.RopeFromInt[text.id] ELSE text.text];
[] ← TiogaButtons.CreateButtonFromNode[
node: TiogaOps.LastChild[handle.controller.textsParent], start: , end: ,
proc: TextButtonProc,
clientData: NEW[GraphButtonDataRec ← [handle, text]]
];
TiogaOps.Unlock[root];
};
}; -- AddTextButton
AddEntityButton: PUBLIC PROC [handle: GraphHandle ← NIL, entity: Entity ← NIL] RETURNS [b: TiogaButtons.TiogaButton ← NIL] = {
called when user sets a new entity on panel.
IF GraphUtil.HandleNotNil[handle] AND entity # NIL THEN {
root: TiogaOps.Ref ← TiogaOps.ViewerDoc[handle.controller.table];
group: EntityGroup ← entity.group;
TiogaOps.Lock[root];
TiogaOps.SelectPoint[handle.controller.table,
[TiogaOps.LastChild[group.node], -1]];
TiogaOps.Break[];
TiogaOps.Nest[];
TiogaOps.InsertRope[
IF entity.name = NIL THEN Convert.RopeFromInt[entity.id] ELSE entity.name];
[] ← TiogaButtons.CreateButtonFromNode[
node: TiogaOps.LastChild[group.node], start: , end: ,
proc: EntityButtonProc,
clientData: NEW[GraphButtonDataRec ← [handle, entity]]
];
TiogaOps.Unlock[root];
};
}; -- AddEntityButton
AddGroupButtons: PROC[handle: GraphHandle ← NIL, entityGroup: EntityGroup ← NIL] = {
firstGroup: EntityGroup ← handle.entityGroupList.first;
TiogaOps.SelectPoint[viewer, group.button.startLoc];
TiogaOps.InsertRope[Rope.Concat["Entity group # ", Convert.RopeFromInt[entityGroup.id]]];
TiogaOps.SelectPoint[viewer, b.endLoc];
TiogaOps.Break[];
TiogaOps.Nest[];
FOR el: EntityList ← entityGroup.entityList, el.rest UNTIL el = NIL DO
}; -- AddGroupButtons
}.
LOG.
SChen, created at October 9, 1985 6:57:10 pm PDT.