-- TiogaViewerClassImpl.mesa; Written by S. McGregor
-- Edited by McGregor on August 30, 1983 2:52 pm
DIRECTORY
EditSpan USING [InsertBoxNode, InsertListNode, InsertBranchNode, InsertTextNode],
Menus USING [AppendMenuEntry, CreateEntry, CreateMenu, Menu, MenuProc],
TiogaDisplayTable USING [New],
TiogaDocument USING [TiogaDocumentData, TiogaDocumentDataRec],
TiogaNode USING [ItemClassID, Ref, RefBranchNode, RefTextNode],
TiogaNodeOps USING [DocFromNode, FromRope, LookupItemID],
TiogaPaint USING [TiogaPaint],
TiogaTreeOps USING [Parent],
TIPUser USING [TIPTable],
TreeCheck USING [Verify],
ViewerClasses,
ViewerOps USING [CreateViewer, PaintViewer, RegisterViewerClass];
TiogaViewerClassImpl: CEDAR MONITOR
IMPORTS EditSpan, Menus, TiogaDisplayTable, TiogaNodeOps, TiogaPaint, TiogaTreeOps, --TreeCheck,-- ViewerOps =
BEGIN OPEN TiogaDocument, ViewerClasses;
TiogaNotify: NotifyProc =
BEGIN
END;
TiogaInputModify: ModifyProc =
BEGIN
END;
TiogaInit: InitProc =
BEGIN
tdd: TiogaDocumentData ← NARROW[self.data];
IF tdd#NIL THEN ERROR; -- not prepared for re-init yet
tdd ← NEW[TiogaDocumentDataRec];
tdd.displayTable ← TiogaDisplayTable.New[100]; -- initial allocate of 100 rectangles. Be smarter later
self.data ← tdd;
HackDocument[tdd];
tdd.displayTable.objects[0].startPos ← [[tdd.text, NIL], 0];
END;
HackDocument:
PROC [tdd: TiogaDocumentData] =
BEGIN
hack together a test document
root: TiogaNode.RefBranchNode;
node: TiogaNode.Ref;
boxClass: TiogaNode.ItemClassID ← TiogaNodeOps.LookupItemID[$TestBox, FALSE];
listClass: TiogaNode.ItemClassID ← TiogaNodeOps.LookupItemID[$TestList, FALSE];
text: TiogaNode.RefTextNode ← TiogaNodeOps.FromRope["This is a test of the default text class for Tioga 2. This test message is verbose so that it will overflow a single line on the screen, testing nodes split across multiple display rectangles."];
root ← TiogaNodeOps.DocFromNode[text];
node ← EditSpan.InsertBoxNode[root, text, boxClass]; -- box goes after the text
node ← EditSpan.InsertBoxNode[root, node, boxClass]; -- second box
node ← EditSpan.InsertListNode[root, node, listClass]; -- list goes after the second box
node ← TiogaTreeOps.Parent[node]; -- this is the branch node for the first set of contents
node ← EditSpan.InsertBranchNode[root, node]; -- second branch
node ← EditSpan.InsertBoxNode[root, node, boxClass, child]; -- box as first child of new branch
node ← EditSpan.InsertListNode[root, node, listClass]; -- list goes after the second box
text ← EditSpan.InsertTextNode[root, node]; -- text goes after the list
text.rope ← "More text, that goes on and on to further test out line breaking and what not. This is not the last sentence. This one isn't either. Finally, this is the last sentence";
TreeCheck.Verify[root];
tdd.text ← root;
END;
TiogaSet: SetProc =
BEGIN
END;
TiogaGet: GetProc =
BEGIN
END;
TiogaSave: SaveProc =
BEGIN
END;
TiogaDestroy: DestroyProc =
BEGIN
END;
TiogaScroll: ScrollProc =
BEGIN
END;
ClearAndPaint: Menus.MenuProc =
BEGIN
self: ViewerClasses.Viewer ← NARROW[parent];
tdd: TiogaDocumentData ← NARROW[self.data];
tdd.displayTable.objects[0].startPos.path.node ← tdd.text;
ViewerOps.PaintViewer[NARROW[parent], client];
END;
LoadFileAndPaint: Menus.MenuProc =
BEGIN
ViewerOps.PaintViewer[NARROW[parent], client];
END;
tiogaMenu: Menus.Menu ← Menus.CreateMenu[];
tiogaTIP: TIPUser.TIPTable;
tiogaClass: ViewerClass ←
NEW[ViewerClassRec ← [
paint: TiogaPaint.TiogaPaint,
notify: TiogaNotify,
modify: TiogaInputModify,
init: TiogaInit,
set: TiogaSet,
get: TiogaGet,
save: TiogaSave,
destroy: TiogaDestroy,
scroll: TiogaScroll,
menu: tiogaMenu,
tipTable: tiogaTIP
]];
Menus.AppendMenuEntry[tiogaMenu, Menus.CreateEntry["ClearAndPaint", ClearAndPaint]];
Menus.AppendMenuEntry[tiogaMenu, Menus.CreateEntry["LoadFileAndPaint", LoadFileAndPaint]];
ViewerOps.RegisterViewerClass [$Document, tiogaClass];
[] ← ViewerOps.CreateViewer[$Document, [name: "No Name"]];
END.