TiogaButtons.Mesa
Copyright © 1984, 1985 Xerox Corporation. All rights reserved.
Created by Rick Beach, May 2, 1985 2:32:00 pm PDT
DIRECTORY
Menus USING [MenuProc],
TextNode USING [Ref],
TiogaOps USING [Location, Ref],
TiogaFileOps USING [Ref],
ViewerClasses USING [ViewerRec, Viewer],
Rope USING [ROPE];
=
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 = Menus.MenuProc;
PROC [parent: REF ANY, clientData: REF ANY ← NIL,
mouseButton: Menus.MouseButton ← red, shift, control: BOOL ← FALSE] ;
parent will be a TiogaButton. WARNING: expecting to use existing Buttons.ButtonProcs or Menus.ClickProcs without concern for the TYPE of parent will result in NARROW faults.
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:
ROPE ←
NIL, format:
ROPE ←
NIL, looks:
ROPE ←
NIL, proc: TiogaButtonProc ←
NIL, clientData:
REF
ANY ←
NIL, fork:
BOOLEAN ←
TRUE]
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:
INT ←
INT.
LAST,
proc: TiogaButtonProc ←
NIL, clientData:
REF
ANY ←
NIL, fork:
BOOLEAN ←
TRUE]
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?
AppendToButton:
PROC [button: TiogaButton, rope:
ROPE ←
NIL, looks:
ROPE ←
NIL,
proc: TiogaButtonProc ←
NIL, clientData:
REF
ANY ←
NIL, fork:
BOOLEAN ←
TRUE]
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:
ROPE ←
NIL];
... 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