TiogaButtons.Mesa
Copyright ©1984 Xerox Corporation. All rights reserved.
Created by Rick Beach, August 31, 1984 1:59:36 pm PDT
DIRECTORY
Menus USING [MenuProc],
TextNode USING [Ref],
TiogaOps USING [Location, Offset, Ref],
TiogaFileOps USING [Ref],
ViewerClasses USING [ViewerRec, Viewer],
Rope USING [ROPE];
TiogaButtons: CEDAR DEFINITIONS = {
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
NodeItself: TiogaOps.Offset ~ -1;
TiogaButtonAtom: ATOM ~ $TiogaButtonList; -- here mainly for documentation
TiogaButtonsAtom: ATOM ~ $TiogaButtons; -- compiler won't let you import atoms!
TiogaButtonList: TYPE = LIST OF TiogaButton;
TiogaButtonProc: TYPE = Menus.MenuProc;
MenuProc: TYPE = PROC [parent: REF ANY, clientData: REF ANYNIL,
mouseButton: Menus.MouseButton ← red, shift, control: BOOLFALSE] ;
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.
LoadViewer: PROC [viewer: ViewerClasses.Viewer, fileName: ROPE];
Load 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];
Checks that viewer is a $TiogaButtons class viewer.
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: TiogaOps.Offset ← 0, end: TiogaOps.Offset ← LAST[TiogaOps.Offset], proc: TiogaButtonProc ← NIL, clientData: REF ANYNIL, fork: BOOLEANTRUE] RETURNS [button: TiogaButton];
Checks that node is within a $TiogaButtons viewer.
Creates a button from the node and the offsets provided. If the start, 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: ROPENIL, looks: ROPENIL, proc: TiogaButtonProc ← NIL, clientData: REF ANYNIL, fork: BOOLEANTRUE] RETURNS [TiogaButton];
Append the formatted rope to button.
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. Character properties would be a wonderful feature of Tioga, sigh...
Clients might find it necessary to manufacture their own button records via NEW[TiogaButtonRec] for some purposes.
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];
This crock is necessary because TiogaOps.PutProp uses too low an abstraction for adding properties to a node.
Type conversion routines supplied for the convenience of the client and the implementation.
TextNodeRef: PROC [node: TiogaOps.Ref] RETURNS [TextNode.Ref] ~ TRUSTED INLINE {
RETURN [LOOPHOLE[node]] };
TiogaOpsRef: PROC [node: TextNode.Ref] RETURNS [TiogaOps.Ref] ~ TRUSTED INLINE {
RETURN [LOOPHOLE[node]] };
TiogaFileOpsRef: PROC [node: TiogaOps.Ref] RETURNS [TiogaFileOps.Ref] ~ TRUSTED INLINE {
RETURN [LOOPHOLE[node]] };
TiogaOpsRefFromFileOps: PROC [node: TiogaFileOps.Ref] RETURNS [TiogaOps.Ref] ~ TRUSTED INLINE {
RETURN [LOOPHOLE[node]] };
}.