TiogaButtons.Mesa
Copyright © 1984, 1985 Xerox Corporation. All rights reserved.
Created by Rick Beach, May 2, 1985 2:32:00 pm PDT
Hal Murray, December 22, 1986 10:58:48 am PST
Willie-Sue, January 23, 1987 3:54:24 pm PST
DIRECTORY
TextNode USING [Ref],
TiogaOps USING [Location, Ref],
TiogaFileOps USING [Ref],
ViewerClasses USING [MouseButton, ViewerRec, Viewer],
Rope USING [ROPE];
TiogaButtons: CEDAR DEFINITIONS
= BEGIN
ROPE: TYPE ~ Rope.ROPE;
TiogaOps types are used in the interface so that clients may freely use the TiogaOps interface to modify the contents of a TiogaButtons document.
TiogaButton: TYPE = REF TiogaButtonRec;
TiogaButtonRec: TYPE = RECORD [
startLoc: TiogaOps.Location,
endLoc: TiogaOps.Location,
proc: TiogaButtonProc,
clientData: REF ANY,
fork: BOOLEAN];
Invariant for TiogaButtons: startLoc.node = endLoc.node
TiogaButtonList: TYPE = LIST OF TiogaButton;
TiogaButtonProc: TYPE = PROC [button: TiogaButton, clientData: REF ANYNIL,
mouseButton: ViewerClasses.MouseButton ← red, shift, control: BOOLFALSE];
button is the TiogaButton that was hit with <mouseButton, shift, control>
Create TiogaButtons from supplied information.
CreateViewer: PROC [info: ViewerClasses.ViewerRec] RETURNS [v: ViewerClasses.Viewer];
... creates a $TiogaButtons class viewer.
A top-level viewer will have Tioga menus displayed but will not be editable.
LoadViewer: PROC [viewer: ViewerClasses.Viewer, fileName: ROPE];
... loads an existing document into a TiogaButtons viewer
CreateButton: PROC [viewer: ViewerClasses.Viewer, rope: ROPENIL, format: ROPENIL, looks: ROPENIL, proc: TiogaButtonProc ← NIL, clientData: REF ANYNIL, fork: BOOLEANTRUE]
RETURNS [button: TiogaButton];
... creates a button as the last child of the document in viewer.
(Client must provide nesting through TiogaOps)
If proc is NIL then the node is created and a button record returned, but no button property will be applied to the node. This is useful for providing labels, spacing between buttons, or special formatting.
WrongViewerClass: ERROR;
CreateButtonFromNode: PROC [node: TiogaOps.Ref, start: INT ← 0, end: INTINT.LAST,
proc: TiogaButtonProc ← NIL, clientData: REF ANYNIL, fork: BOOLEANTRUE]
RETURNS [button: TiogaButton];
... creates a button from the node and the offsets provided. If the start and end offsets are defaulted then the button refers to the node itself.
If proc is NIL then the a button record returned, but no button property will be applied to the node. Why bother?
CreateButtonForEachNode: PROC [viewer: ViewerClasses.Viewer,
firstLevelOnly: BOOLFALSE, subtreeAsButton: BOOLTRUE,
proc: TiogaButtonProc ← NIL, clientData: REF ANYNIL, fork: BOOLEANTRUE];
... creates a TiogaButton for each node found in the TiogaButtons viewer
AppendToButton: PROC [button: TiogaButton, rope: ROPENIL, looks: ROPENIL,
proc: TiogaButtonProc ← NIL, clientData: REF ANYNIL, fork: BOOLEANTRUE]
RETURNS [TiogaButton];
... appends the formatted rope to an existing button and creates a new button for the appended text.
If proc is NIL then the rope is appended and a button record returned, but no button property will be applied to the node. This is useful for providing labels, spacing between buttons, or special formatting. Note that the format is set only when you create a node.
A curious feature of appending to a button created with proc nonNIL: that button will be for the entire node and will subsume any appended buttons. This might be useful for providing a target that will refer to the entire node contents. The feedback looks neat!
DeleteButton: PROC [button: TiogaButton];
... deletes the button.
If the button is an entire node, it simply vanishes.
If the button is only part of a node, then the other buttons are adjusted to compensate for the deleted text.
Clients might find it necessary to manufacture their own button records via NEW[TiogaButtonRec] for some purposes.
FindTiogaButton: PROC [this: ViewerClasses.Viewer, loc: TiogaOps.Location]
RETURNS [button: TiogaButton];
... returns the button at that location in the viewer, or NIL
GetRope: PROC [button: TiogaButton] RETURNS [rope: ROPE];
... provides the text of the button. Can be used in place of clientData for many purposes.
SetStyleFromRope: PROC [v: ViewerClasses.Viewer, styleRope: ROPE];
... sets a local style for the viewer via the StyleDef property
ChangeButtonLooks: PUBLIC PROC [button: TiogaButton,
addLooks, removeLooks: ROPENIL];
... change the looks for the button starting at the start offset
MarkViewerNotEdited: PROC [root: TiogaOps.Ref];
... marks all the viewers displaying this document as not edited
Type Conversion Routines (for the client and the implementation)
TextNodeRef: PROC [ref: REF] RETURNS [TextNode.Ref];
TiogaOpsRef: PROC [ref: REF] RETURNS [TiogaOps.Ref];
TiogaFileOpsRef: PROC [ref: REF] RETURNS [TiogaFileOps.Ref];
END.