DIRECTORY AMTypes, List, Rope, ViewerClasses, VFonts; ViewRec: CEDAR DEFINITIONS IMPORTS VFonts = BEGIN NotARecord: ERROR; NoSelectedProc: ERROR; AlreadyHandled: ERROR; BadID: ERROR [id: Id]; NotFound: ERROR [name: Path]; ROPE: TYPE = Rope.ROPE; Viewer: TYPE = ViewerClasses.Viewer; TypedVariable: TYPE = AMTypes.TypedVariable; Type: TYPE = AMTypes.Type; RecordViewer: TYPE = REF RecordViewerRep; RecordViewerRep: TYPE; BindingList: TYPE = LIST OF Binding; Binding: TYPE = RECORD [ name: Id, it: SELECT type: BindingType FROM Value => [val: TypedVariable, visible, editable: BOOLEAN _ FALSE], Editable => [editable: BOOLEAN _ FALSE], Notify => [notify: NotifyClientProc, clientData: REF ANY _ NIL], TryRecognizer => [recognizer: Recognizer], Group => [sublist, altSublist: BindingList _ NIL], ENDCASE]; Id: TYPE = REF ANY; --actually UNION [ROPE, REF TEXT, REF INT (origin 1)]; Path: TYPE = LIST OF Id; --outermost first BindingType: TYPE = {Value, Editable, Notify, TryRecognizer, Group}; NotifyClientProc: TYPE = PROC [clientData: REF ANY]; NotifyList: TYPE = LIST OF NotifyRequest; NotifyRequest: TYPE = RECORD [proc: NotifyClientProc, clientData: REF ANY]; Int: TYPE = REF INT; CreateOptions: TYPE = RECORD [ procFont: VFonts.Font _ NIL, --NIL means use Viewers default doitFont: VFonts.Font _ NIL, --for the Doit button in Proc's args rec stateFont: VFonts.Font _ NIL, --for the State label in Proc's args rec nameFont: VFonts.Font _ NIL, --for first half of name:value pairs labelFont: VFonts.Font _ NIL, --for the label of the RecordViewer bordElts: BOOLEAN _ FALSE, --draw border around every Name-Value pair bordRecs: BOOLEAN _ TRUE, --border a Value if it is a RECORD bordProcs: BOOLEAN _ TRUE, --border PROCEDUREs bordDoit: BOOLEAN _ TRUE, --border the Doit button in a Proc's args rec bordState: BOOLEAN _ FALSE, --border the State label in a Proc's args vSep: CARDINAL _ 2, --spacing between lines of stuff hSep: CARDINAL _ 5, --spacing between things on a line vPad: CARDINAL _ 3, --height of Value boxes, beyond font height hPad: CARDINAL _ 13, --width of Value boxes, beyond string width nvSep: CARDINAL _ 3, --seperation between Name and Value vStilts: CARDINAL _ 1, --artificially raise the Name Label this much feedBackHeight: CARDINAL _ 40, --how high the FeedBack Window is minRecordWidth: CARDINAL _ 100, --lower bound for RECORDs defaultTargetWidth: CARDINAL _ 400, doAllRecords: BOOLEAN _ FALSE, --if TRUE, every record is judged simple enough to attempt to display; components will still be judged individually other: List.AList _ NIL --passed to complex handlers ]; OtherStuffProc: TYPE = PROC [in: Viewer] RETURNS [stuff: LIST OF Viewer]; DoitProc: TYPE = PROC [rv: RecordViewer, data: REF ANY]; ViewTV: PROC [rec: TypedVariable, specs: BindingList _ NIL, label: ROPE _ NIL, otherStuff: OtherStuffProc _ NIL, toDo: DoitProc _ NIL, toDoData: REF ANY _ NIL, parent: RecordViewer _ NIL, sample: BOOLEAN _ TRUE, holdOff: BOOLEAN _ FALSE, highlightSelectedProc: BOOLEAN _ TRUE, createOptions: CreateOptions _ [], viewerInit: ViewerClasses.ViewerRec _ [], paint: BOOLEAN _ TRUE] RETURNS [rv: RecordViewer]; ViewRef: PROC [rec: REF ANY, specs: BindingList _ NIL, label: ROPE _ NIL, otherStuff: OtherStuffProc _ NIL, toDo: DoitProc _ NIL, toDoData: REF ANY _ NIL, parent: RecordViewer _ NIL, sample: BOOLEAN _ TRUE, holdOff: BOOLEAN _ FALSE, highlightSelectedProc: BOOLEAN _ TRUE, createOptions: CreateOptions _ [], viewerInit: ViewerClasses.ViewerRec _ [], paint: BOOLEAN _ TRUE] RETURNS [rv: RecordViewer]; ViewInterface: PROC [name: ROPE, specs: BindingList _ NIL, label: ROPE _ NIL, otherStuff: OtherStuffProc _ NIL, toDo: DoitProc _ NIL, toDoData: REF ANY _ NIL, parent: RecordViewer _ NIL, sample: BOOLEAN _ TRUE, holdOff: BOOLEAN _ FALSE, highlightSelectedProc: BOOLEAN _ TRUE, createOptions: CreateOptions _ [], viewerInit: ViewerClasses.ViewerRec _ [], paint: BOOLEAN _ TRUE] RETURNS [RecordViewer]; ViewSelf: PROC; BindAllOfATypeFromTVs: PROC [ recType: Type, handle: TypedVariable, name: ROPE _ NIL, visible, editable: BOOLEAN _ FALSE] RETURNS [BindingList]; BindAllOfATypeFromRefs: PROC [rec, handle: REF ANY, name: ROPE _ NIL, visible, editable: BOOLEAN _ FALSE] RETURNS [BindingList]; BindingListAppend: PROC [a, b: BindingList] RETURNS [c: BindingList]; GetEltHandle: PROC [rv: RecordViewer, name: Path] RETURNS [eh: REF ANY]; SampleRV: PROC [rv: RecordViewer]; RedisplayElt: PROC [eh: REF ANY]; CallSelectedProc: PROC [in: RecordViewer] RETURNS [refused: BOOLEAN]; DisplayMessage: PROC [rv: RecordViewer, msg: ROPE]; clearMessagePlace: READONLY ROPE; TestAndResetUserAbort: PROC [rv: RecordViewer, threshold: CARDINAL _ 100] RETURNS [abort: CARDINAL --will be 0 or >= threshold--]; TestUserAbort: PROC [rv: RecordViewer] RETURNS [abort: CARDINAL]; SetUserAbort: PROC [rv: RecordViewer, newLevel: CARDINAL _ 100]; IncrementUserAbort: PROC [rv: RecordViewer, deltaLevel: INTEGER]; ProcessAbort: PROC [rv: RecordViewer] RETURNS [found: BOOLEAN]; RVQuaViewer: PROC [RecordViewer] RETURNS [Viewer]; ViewerIsRV: PROC [Viewer] RETURNS [BOOLEAN]; ViewerQuaRV: PROC [Viewer] RETURNS [RecordViewer]; Help: PROC; RegisterRecognizerByType: PROC [r: Recognizer, end: AddPlace, type: Type--unreduced--, reductions: Reductions]; RegisterRecognizerBeforeReductions: PROC [r: Recognizer, end: AddPlace, applyBefore: Reductions]; RegisterRecognizerToApplyAfterAll: PROC [r: Recognizer, end: AddPlace]; Reductions: TYPE = {EquivalenceClass, StripSubranges, TypeClass}; AddPlace: TYPE = {Front, Back--of list of others already there--}; Recognizer: TYPE = PROC [t: Type--unreduced--, onlyRecognize: BOOLEAN--don't bother to produce the handler and handlerData--] RETURNS [IKnowYou: BOOLEAN, handler: Handler, handlerData: REF ANY _ NIL]; Handler: TYPE = REF ANY; --actually UNION {SimpleHandler, ComplexHandler} SimpleHandler: TYPE = REF SimpleHandlerRep; SimpleHandlerRep: TYPE = RECORD [ Parse: ParseProc, --NIL => read-only operation UnParse: UnParseProc, Max: MaxProc, Butt: ButtProc _ NIL, --NIL => no meaning for Right (Blue) mouse button. blueDoc: ROPE _ NIL --tells what can be done with Right Button ]; ParseProc: TYPE = PROC [asRope: ROPE, tv: TypedVariable, targType: Type, handlerData: REF ANY] RETURNS [ok: BOOLEAN]; UnParseProc: TYPE = PROC [tv: TypedVariable, targType: Type, handlerData: REF ANY] RETURNS [asRope: ROPE]; MaxProc: TYPE = PROC [tv: TypedVariable, targType: Type, handlerData: REF ANY] RETURNS [maxWidthNeeded: INTEGER, lines: REAL _ 1]; ButtProc: TYPE = PROC [tv: TypedVariable, targType: Type, handler: SimpleHandler, handlerData: REF ANY, shift: BOOLEAN] RETURNS [new: TypedVariable, msg: ROPE _ NIL]; ComplexHandler: TYPE = REF ComplexHandlerRep; ComplexHandlerRep: TYPE = RECORD [ producer: ComplexProducer, updater: Updater]; ComplexProducer: TYPE = PROC [tv: TypedVariable, context: Context, handlerData: REF ANY] RETURNS [v: Viewer, clientData: REF ANY]; Updater: TYPE = PROC [tv: TypedVariable, v: Viewer, handlerData, clientData: REF ANY]; Context: TYPE = RECORD [ main: Viewer, for: RecordViewer, name: ROPE, createOptions: CreateOptions, notifies: NotifyList]; FinishPendingBusiness: PROC RETURNS [okToProceed: BOOLEAN]; SetPendingBusiness: PROC [proc: FinishProc _ NIL, data: REF ANY _ NIL]; FinishProc: TYPE = PROC [data: REF ANY] RETURNS [okToProceed: BOOLEAN]; RecognizeRope, RecognizeNumber, RecognizeEnumerations: Recognizer; BehaviorOptions: TYPE = RECORD [ delayParms: DelayParms _ [] --controls delay in sampling process ]; DelayParms: TYPE = RECORD [ min: REAL _ 40, max: REAL _ 3000, offset: REAL _ 0, dActive: REAL _ 0, dExtant: REAL _ 0, dElt: REAL _ 0, dMicroseconds: REAL _ 4E-3, interp: ParmInterpretation _ Milliseconds, priority: DelayPriority _ Normal]; ParmInterpretation: TYPE = {ScanLines, Milliseconds}; DelayPriority: TYPE = {Normal, Background, Foreground}; delayed: READONLY REAL; --running average of sample time, weights are z**n z: REAL; behavior: BehaviorOptions; SetBehavior: PROC [newBehavior: BehaviorOptions _ []]; END. ήFILE: [Ivy]ViewRec>ViewRec.Mesa last edited by Spreitzer March 11, 1983 12:10 pm Last Edited by: Maxwell, November 16, 1982 3:28 pm Errors: raised by the create procs if not handed a record raised by CallSelectedProc raised by registration procs raised by create procs and GetEltHandle. raised by GetEltHandle. Familiar Types: New Types: these control layout, which is done at create time: Creating RecordViewers: This is it: Create a RecordViewer on "rec". "specs" says some random things about components: a Value binding will cause that component to be initialized to the given value; furhtermore, this prevents that component from making the record it is part of too complicated to handle. Setting "visible" FALSE will prevent the bound component from appearing on the screen. Setting "editable" FALSE will ensure that it will not be editable. a Notify binding causes ViewRec to call the given NotifyClientProc whenever ViewRec changes the value of that component (and maybe some other times as well). Group bindings are the method by which components of nested records are addressed. the "altSublist" applies to the return record of procedures; the "sublist" applies to embedded records and the argument record of procedures. if the last char of "label" is CR, it will be the sole occupant of the first line. The OtherStuffProc produces a set of viewers to put at the beginning of the RecordViewer. The DoitProc is called when CONTROL-RETURN is typed in a Value Viewer by the User; toDoData is passed to it. the "parent" is independant of the Viewers ancestry; used for finding feedBack. "sample" causes this RecordViewer to be put on a list of RV's to be sampled in the background to keep its display up to date. "holdOff" makes procs uncallable. "highlightSelectedProc" causes current Proc Button to display Black on Grey. "viewerInit" is for the usual Viewers initing stuff, with the additional use of ww: the RecordViewer lays itself out to the inner width of the Viewer created, unless ww#0 and viewerInit.parent=NIL, in which case ww is used, or unless ww=0 and (viewerInit.parent#NIL OR iconic), in which case createOptions.minRecordViewerWidth is used. if "paint", then painted when done. ViewRef is just like ViewTV, except it takes a REF to the record. makes a top-level RecordViewer on an Interface Record from a DEFINITIONs module invokes ViewInterface on ViewRec BindingList manipulations: returns a binding list where everything in "recType" whose type = type of "handle", and whose name = "name", gets bound to "handle", with visible and editable flags; IF name = NIL, THEN the name test is ignored. uses the type of referent of "rec", and the referent of "handle", in call on BindAllOfATypeFromTVs maybe alters last CONS cell in "a": Things to do with RecordViewers once they have been created: RAISES NotFound[tail(i)[name]] when lost at i'th step. ensures that the current values are displayed puts a message in feedBack window (or MessageWindow if no fb); this message is appended to the others already there, unless it is: this message will clear out wherever messages are going to. Calls Process.Abort on the running proc, if any. SIMULA-style coersions between CLASSes: For the fun of it: opens a viewer on the document Introducing new ways of displaying things: Upon user action in a Complex Viewer, first call this proc to get permission to handle it. For Wizardly experimentation: for experimenting with how to schedule the sampling process these are the bits actually used to set them all at once Κ ‡˜J˜Jšœ*™*Jšœ0™0Jšœ2™2J˜codešΟk ˜ K˜+—K˜K˜šΠbxœœ ˜K˜Kšœ ˜K˜—Kš˜K˜šΟl™K˜šœ œ˜Kšœ1™1—K˜šœœ˜Kšœ™—K˜˜K™—K˜šœœ ˜K™(—K™šœ œ˜K™—K™—K™šŸ™K˜Kšœœœ˜Kšœœ˜$Kšœœ˜,Kšœœ˜K˜—K˜šŸ ™ K˜Kšœœœ˜)Kšœœ˜K˜Kšœ œœœ ˜$šœ œœ˜Kšœ ˜ šœœ˜!Kšœ1œœ˜BKšœœœ˜(Kšœ1œœœ˜@Kšœ*˜*Kšœ-œ˜2Kšœ˜ ——K˜KšœœœœΟc6˜JK˜Kšœœœœ ˜*K˜Kšœ œ3˜DK˜Kš Οnœœœœœ˜4K˜Kšœ œœœ˜)Kš œœœ&œœ˜KK˜Kšœœœœ˜K˜Kšœ3™3šœœœ˜Kšœœ ˜™>K™CK˜šœœœ˜!K™;——K˜Kš ‘œœœœ œ œ˜‚Kš‘ œœœ œ˜AKš‘ œœœ˜@Kš‘œœ œ˜AK˜š‘ œœœ œ˜?K™0—K˜—K˜šŸ'™'K™Kš‘ œœœ ˜2Kš‘ œœ œœ˜,Kš‘ œœ œ˜2K˜—K˜šŸ™K˜š‘œœ˜ Kšœ™—K˜—K˜šŸ*™*K˜Kš‘œœ*  œ˜oKš‘"œœ9˜aKš‘!œœ ˜GK˜Kšœ œ1˜AKšœ œ #œ˜BK˜Kš‘ œœœ   œ 7œœ œ!œœœ˜ΘK˜Kš œ œœœ  œ%˜IK˜Kšœœœ˜+šœœœ˜!Kšœ ˜.K˜K˜ Kšœœ 2˜HKšœ œœ *˜>K˜—K˜Kš‘ œœœ œ2œœœœ˜uKš‘ œœœ2œœœ œ˜jKš‘œœœ2œœœœ œ˜‚Kš‘œœœJœœ œœœœ˜¦K˜Kšœœœ˜-šœœœ˜"Kšœ˜Kšœ˜—K˜Kš‘œœœ4œœœœœ˜‚K˜Kš ‘œœœ9œœ˜VK˜šœ œœ˜K˜ K˜Kšœœ˜ K˜K˜—K˜š‘œœœœ˜;K™Z—K˜š ‘œœœœœœ˜GK˜Kš‘ œœœœœœœ˜G—K˜Kš‘ œ‘œ‘œ ˜BK˜—K™šŸ™K˜šœœœ˜ Kšœ $˜@K˜K˜—Kšœ;™;šœ œœ˜Kšœœ˜Kšœœ˜Kšœœ˜Kšœ œ˜Kšœ œ˜Kšœœ˜Kšœœ˜K˜*K˜"K˜—Kšœœ˜5Kšœœ$˜7K˜Kšœ œœ 2˜JKšœœ˜K˜˜Kšœ ™ —K˜š‘ œœ%˜6Kšœ™—K˜—K˜Kšœ˜K˜—…—¨: