-- File NoteEditorImpl.mesa -- Created by Donahue, October 27, 1982 11:37 am -- Last edited by: -- Donahue March 14, 1983 3:35 pm -- Cattell April 6, 1983 12:04 pm DIRECTORY Buttons: TYPE USING[ ButtonProc ], DB, DBEnvironment, NoteEditor, Menus, Rope: TYPE USING[ ROPE, Equal ], VFonts, ViewerClasses: TYPE USING[ Viewer ], ViewerOps: TYPE USING[ AddProp, FetchProp, PaintHint, PaintViewer ], ViewerTools: TYPE USING[ GetContents, SelPosRec, SetContents, SetSelection, InhibitUserEdits ], VTables: TYPE USING[ VTable, Create, GetTableEntry, GetEntryOffset, NullBorder, SetTableEntry, Install, SetEntryOffset ]; NoteEditorImpl: PROGRAM IMPORTS DB, ViewerOps, VTables, Rope, VFonts, ViewerTools EXPORTS NoteEditor = BEGIN OPEN DB, Rope, ViewerClasses, VTables; DisplayNote: PUBLIC PROC[ entity: Entity, parent: Viewer, segment: DB.Segment _ NIL, openHeight: NAT _ 0, openWidth: NAT _ 0, noEdits: BOOLEAN _ FALSE ] RETURNS[ NoteRow: VTable] = { NoteRel: Relation = DeclareRelation["Note", IF entity = NIL THEN segment ELSE SegmentOf[entity]]; NoteOfAttr: Attribute = DeclareAttribute[NoteRel, "of", AnyDomainType]; NoteIsAttr: Attribute = DeclareAttribute[NoteRel, "is", StringType]; noteRelship: Relship = IF entity = NIL THEN NIL ELSE NextRelship[RelationSubset[NoteRel, LIST[AttributeValue[NoteOfAttr, entity]]]]; text: ROPE = IF noteRelship = NIL THEN NIL ELSE GetFS[ noteRelship, NoteIsAttr ]; IF noEdits AND Rope.Equal[text,""] THEN RETURN[ NIL ]; NoteRow _ Create[ columns: 2, parent: parent ]; SetTableEntry[table: NoteRow, column: 0, name: "Notes", flavor: $Button, proc: SetHeight, border: NullBorder ]; GetTableEntry[ NoteRow, 0, 0 ].border _ TRUE; IF openHeight = 0 THEN openHeight _ 2*VFonts.FontHeight[]+5; IF openWidth = 0 THEN openWidth _ 40*VFonts.CharWidth['A]; SetTableEntry[ table: NoteRow, column: 1, flavor: $Text, border: NullBorder, h: openHeight, w: openWidth, useMaxSize: TRUE ]; GetTableEntry[ NoteRow, 0, 1 ].scrollable _ TRUE; ViewerTools.SetContents[ viewer: GetTableEntry[ NoteRow, 0, 1], contents: text, paint: FALSE ]; IF noEdits THEN { ViewerTools.InhibitUserEdits[ GetTableEntry[ NoteRow, 0, 1] ]; ViewerOps.AddProp[ NoteRow, $edits, NEW[ BOOLEAN _ FALSE ] ] }; Install[ NoteRow, FALSE ]; ViewerOps.AddProp[ NoteRow, $note, noteRelship ] }; SetHeight: Buttons.ButtonProc = TRUSTED { viewer: Viewer = NARROW[ parent, Viewer ]; NoteRow: VTable = viewer.parent; textViewer: Viewer = GetTableEntry[ table: NoteRow, column: 1 ]; text: ROPE = ViewerTools.GetContents[ textViewer ]; edits: REF ANY = ViewerOps.FetchProp[ NoteRow, $edits ]; textHeight: INT = textViewer.wh; textWidth: INT = textViewer.ww; SELECT mouseButton FROM Menus.MouseButton[red] => { ViewerTools.SetSelection[ viewer: GetTableEntry[ table: NoteRow, column: 1 ], selection: NIL ]; RETURN }; Menus.MouseButton[yellow] => SetTableEntry[ table: NoteRow, column: 1, flavor: $Text, border: NullBorder, useMaxSize: TRUE, w: textWidth, h: textHeight+2*VFonts.FontHeight[]+5 ]; Menus.MouseButton[blue] => IF textHeight <= 2*VFonts.FontHeight[] THEN RETURN ELSE SetTableEntry[ table: NoteRow, column: 1, flavor: $Text, border: NullBorder, useMaxSize: TRUE, w: textWidth, h: textHeight-2*VFonts.FontHeight[]+1 ]; ENDCASE; GetTableEntry[ table: NoteRow, column: 1 ].scrollable _ TRUE; IF edits # NIL THEN ViewerTools.InhibitUserEdits[ GetTableEntry[ table: NoteRow, column: 1 ] ]; ViewerTools.SetContents[ viewer: GetTableEntry[ table: NoteRow, column: 1 ], contents: text, paint: FALSE ]; Install[ NoteRow, FALSE ]; SetEntryOffset[ table: NoteRow, column: 0, yoff: GetEntryOffset[ table: NoteRow, column: 1 ].yoff ]; Install[ NoteRow.parent, FALSE ]; ViewerOps.PaintViewer[ NoteRow.parent.parent, ViewerOps.PaintHint[client] ] }; SaveNote: PUBLIC PROC[newEntity: Entity, viewer: Viewer, update: BOOLEAN _ FALSE] = { text: ROPE = ViewerTools.GetContents[ GetTableEntry[viewer, 0, 1] ]; NoteRel: Relation = DeclareRelation["Note", SegmentOf[newEntity]]; NoteOfAttr: Attribute = DeclareAttribute[NoteRel, "of", AnyDomainType]; NoteIsAttr: Attribute = DeclareAttribute[NoteRel, "is", StringType]; IF update THEN { noteRelship: Relship = V2E[ ViewerOps.FetchProp[ viewer, $note ] ]; IF noteRelship # NIL THEN { SetF[ noteRelship, NoteIsAttr, S2V[text] ]; RETURN } }; ViewerOps.AddProp[ viewer, $note, CreateRelship[r: NoteRel, init: LIST[AttributeValue[attribute: NoteOfAttr, lo: newEntity ], AttributeValue[attribute: NoteIsAttr, lo: S2V[text]]]]] }; END. ĘĘJšĘĪcĻœĪk œ žœžœFžœžœžœ&žœžœžœžœ?žœžœ^žœžœ‚žœžœ5žœžœžœ*Īn œžœžœjžœžœžœžœ žœJžœ žœžœ žœŌžœ žœžœžœžœ0žœ3žœžœžœžœžœžœ(žœ žœžœžœžœęžœžœžœ,žœžœ¯žœ5žœpžœ žœ žœužœžœžœžœ†žœŽžœ7žœžœ;žœ!žœžœ žœŸžœžœĸžœyžœ%žœžœ žœžœWžœ@žœžœ žœžœĶžœžœžžœaŸœžœžœ,žœžœžœŸžœžœQžœžœžœ9žœXžœ„žœ˜Ļ(—…—(ō