DIRECTORY DB, Icons USING [IconFlavor], IO, Menus USING[MenuProc, MenuEntry], MBQueue USING [Queue], NutButtons USING [ButtonFontInfo, Queue], Buttons, Rope, ViewerClasses; NutViewer: CEDAR DEFINITIONS = BEGIN OPEN DB; Viewer: TYPE = ViewerClasses.Viewer; ROPE: TYPE = Rope.ROPE; Queue: TYPE = NutButtons.Queue; EnumProc: TYPE = PROC[enum: REF ANY] RETURNS [label: Rope.ROPE]; CountProc: TYPE = PROC[v: Viewer, enum: REF ANY] RETURNS [INT]; ThumbProc: TYPE = PROC[v: Viewer, enum: REF ANY, where: NAT] RETURNS[REF ANY]; Initialize: PROC[parent: Viewer] RETURNS [nV: Viewer]; MakeLabel: PROC[name: ROPE, sib: Viewer, newLine: BOOL_ FALSE] RETURNS [nV: Viewer]; IsDefaultViewer: PROC[v: Viewer] RETURNS[BOOL]; SpawnViewer: PROC[eName, domain: ROPE, seg: Segment, parent: Viewer _ NIL] RETURNS[newV: Viewer]; ReplaceViewer: PROC[eName, domain: ROPE, seg: Segment, parent: Viewer _ NIL] RETURNS[newV: Viewer]; OneViewer: PROC[eName, domain: ROPE, seg: Segment, parent: Viewer _ NIL] RETURNS[newV: Viewer]; CreateDefaultViewer: PROC[eName, domain: ROPE, segment: DB.Segment, replace: Viewer _ NIL] RETURNS [newV: Viewer]; Message: PROC[v: ViewerClasses.Viewer, msg1, msg2, msg3, msg4: Rope.ROPE_ NIL]; Error: PROC[v: ViewerClasses.Viewer, msg1, msg2, msg3, msg4: Rope.ROPE_ NIL]; MessageRope: PROC[v: ViewerClasses.Viewer, msg: Rope.ROPE_ NIL]; MakeButton: PROC[q: Queue, name: ROPE, proc: Buttons.ButtonProc, sib: Viewer, data: REF ANY_ NIL, border: BOOL_ FALSE, width: INTEGER_ 0, guarded: BOOL_ FALSE, font: NutButtons.ButtonFontInfo _ NIL, newLine: BOOL_ FALSE, visible: BOOL_ TRUE] RETURNS [nV: Viewer]; MakeMenuEntry: PROC[q: Queue, name: ROPE, proc: Menus.MenuProc, clientData: REF ANY_ NIL, documentation: REF ANY_ NIL, fork: BOOL_ TRUE, guarded: BOOL_ FALSE] RETURNS[Menus.MenuEntry]; DBQueue: PROC RETURNS[Queue]; NextRightTextViewer: PROC[sib: Viewer, w: INTEGER] RETURNS [nV: Viewer]; DefaultFreezeProc: Menus.MenuProc; MakeTextViewer: PROC[sib: Viewer, w: INTEGER_ 0, fullLine: BOOL_ FALSE] RETURNS [nV: Viewer]; MakeTypescript: PROC[sib: Viewer] RETURNS [ts: Viewer]; GetTypescript: PROC[v: Viewer] RETURNS [out: IO.STREAM]; MakeRuler: PROC[sib: Viewer, h: INTEGER_ 1] RETURNS [r: Viewer]; MakeBigTextBox: PROC[sib: Viewer, contents: ROPE] RETURNS [nV: Viewer]; NextTextViewer: PROC[sib: Viewer] RETURNS [nV: Viewer] = INLINE { RETURN[MakeTextViewer[sib, , TRUE]]}; CreateMBWindow: PROC[ next, prev: EnumProc, -- to go forward and backward in the enumeration thumb: ThumbProc, -- to create an enumeration set to a particular position count: CountProc, -- to give total size of enumeration buttonProc: Buttons.ButtonProc, -- called with the thing associated with button info: ViewerClasses.ViewerRec_ [], -- allows client to fill in ViewerRec fields initialScroll: INT_ 0, -- what percentage of scroll to have for initial display q: MBQueue.Queue_ NIL] -- MBQueue under which to synchronize (doesn't yet work) RETURNS [viewer: Viewer]; END.  File: NutViewer.mesa Contents: Handy Squirrel procedures for building database application Viewers. Created by: Rick Cattell on 11-Dec-81 12:29:29 Last edited by: Cattell, July 5, 1983 4:48 pm Willie-Sue on: January 21, 1983 8:48 am Donahue, July 29, 1983 9:41 am Widom, June 15, 1984 1:27:02 pm PDT Butler, August 16, 1984 4:45:06 pm PDT Returns next or previous element of the enumeration Estimate size of enumeration. Used only for feedback so may be approximate. Use to set enumeration to particular position quickly; may return new enum. The where parameter is a percentage between 0 and 100. ******************************************************************* --- NutViewerImpl -- The following procedures and functions are used by the default display, edit, and query procedures for domains, relations, and the general default case ******************************************************************* Initializes a viewer so that MakeButton, MakeLabel, MakeTextViewer, etc., may be used. The argument nV returned is passed along through each call to keep track of sibling pos'n, e.g.: nV_ MakeLabel["Foo", nV]. The sib is a viewer to the left or above the label to be made, according to newLine. This will return TRUE iff the viewer was created by CreateDefaultViewer (which are also used bu the operations SpawnViewer, ReplaceViewer and OneViewer). Create a new Viewer for this entity and domain, replacing the last viewer spawned from the parent (if any) and sets the spawned property of the parent. This Viewer is a container labelled appropriately. Create a new Viewer for this entity and domain and replace the parent with it (if the parent does not have the old version bit set) Create a new Viewer for this entity and domain, either using the spawned viewer (if possible) or any other default viewer currently displaying or editing the given entity The procedure to perform all of the above options -- this one replaces the given viewer (if it is not NIL) with an empty Container (properly labelled and set to be used by the defaults) ************************************* -- NutViewerImpl -- Message procedures for interacting with user ************************************* If the top level viewer in which v is nested has a $Typescript property, then prints the concatenated values msg1 through msg4 on the stream that is the value of that property. Otherwise, if the Squirrel window is on the screen, prints the messages in the Squirrel window. Otherwise, sprint the messages in the Message area. Same as Message proc above, but blinks the screen first. Prints the given msg as with Message proc above, but without CR ******************************************************************* -- NutViewerMiscImpl.mesa -- Handy procedures for dealing with viewers. These procedures can be used by applications to created menus, buttons, labels, and text viewers which are automatically placed at the next x/y position in the parent viewer. In the case of menus and buttons, they are automatically given a top-level catch phrase for database errors and are synchronized with an MBQueue specified as argument. A default MBQueue may be used, or the synchronization and catch phrases may be omitted by passing a NIL MBQueue. Some examples of the use of these procedures: nV: Viewer_ Initialize[parent]; nV_ MakeButton[DBQueue[], "Name: ", SelectProc, nV]; (Makes button on top line) nV_ MakeTextViewer[sib: nV, fullLine: FALSE]; (Make text label on same line) []_ MakeTypeScript[nV]; (Make a typescript at the end of the window). ******************************************************************** Creates a new button, to the right or below sib, according to newLine. Creates a menu entry, suitable to use as follows: Menus.AppendMenuEntry[myMenu, MakeMenuEntry[...]]. Main purpose of this procedure is to allow menu items to be queued. Returns Squirrel's default Queue. E.g., can be used as follows: nV _ MakeButton[DBQueue[], "Foo", FooProc, nV]. Backwards compatible: creates a text viewer, next right on the same line as v Creates a text viewer, next right on the same line as v, or full width of next line if fullLine=TRUE The sib is sibling to create TS after, this must be last child of non-NIL sib.parent. This also sets a typescript property of the parent viewer (sib.parent) that can be later retreived by the procedure below Return the typescript property set by MakeTypescript Put a h-bit wide line after sib. We assume sib.parent#NIL. Makes editable text viewer taking rest of sib.parent's viewer, suitable for msg body or whatever. The sib is a sibling to create text box after, this must be last child of sib.parent. Again, we assume sib.parent#NIL. Backwards compatible: creates text viewer on line following sib, full width of sib.parent Client's buttonProc must be prepared to be called with an empty button (clientData and label NIL), as there will always be one screenheight of buttons even if they're not all occupied. It should do nothing in this case. Client's next proc should return [NIL, NIL] when there are no more items to enumerate. It may be called again after that, in which case it should continue to return [NIL, NIL]. Similarly for prev proc at beginning of list. Client's count procedure is used only for providing feedback in scroll bar, so it need not be exactly right. MBWindows will tolerate some inconsistency in the client's procedures, e.g. enumerating the same item twice when change from next to prev proc. Notice we do not need an initial REF ANY for the enumeration; it is created by calling the thumb procedure with where=initialScroll and enum=NIL. Note also that we allow the thumb procedure to create a new enumeration, while the next and prev procedures are expected to make any modification to the enum they are passed in place (they may modify it, because MBWindows has a REF to it). Note: if the MBWindow is nested inside another viewer, then the parent field should be set by passing a parent in the info field, and the client should call Containers.ChildYBound so that the MBWindow's size is set automatically with changes in the parent. See example below. ʘJ™Jšœ™JšœO™OJšœ.™.Jšœ™Jšœ™Jšœ'™'Jšœ™J™#J™&J˜šÏk ˜ Jšœ˜Jšœœ˜Jšœ˜Jšœœ˜!Jšœœ ˜J˜)J˜J˜J˜J˜—šœ œ œ˜J˜—Jšœœœ˜J˜Jšœœ˜$Jšœœœ˜Jšœœ˜J˜šÏnœœœœœœœ˜@Jšœ3™3J™—šž œœœœœœœ˜?JšœL™LJ˜—šž œœœœœ œœœœ˜NJšœK™KJšœ7™7J™—JšœC™CJšÏc™J™WJšœ?™?JšœC™CJ˜šž œœœ˜7JšœÒ™ÒJ˜—š ž œœœœœœ˜TJšœT™T—J™šžœœ œœ˜/Jšœ™™™—J˜š ž œœœ!œœ˜bJšœË™ËJ˜—š ž œœœ!œœ˜cJšœƒ™ƒJ˜—š ž œœœ!œœ˜_Jšœª™ª—J˜š žœœœ œœœ˜rJ™º—J˜Jšœ9™9JšŸ-™-Jšœ%™%J˜šžœœ7œœ˜PJšœM™MJšœP™PJšœQ™QJšœU™UJ˜—šžœœ7œœ˜NJšœ8™8J˜—šž œœ$œœ˜AJšœ?™?—J˜JšœC™CJšœ™Jšœ*™*JšœY™YJšœU™UJšœW™WJšœO™OJšœN™NJšœP™PJšœ™JšœO™OJšœL™LJšœE™EšœD™DJ˜—Jšž œœœ/œœœ œœ œœœ2œœœ˜ñšœ˜JšœF™FJ˜—šž œœœ$œœœœœœœœ œœœ˜¸Jšœ1™1Jšœ2™2JšœC™CJ˜—šžœœœ˜Jšœ@™@Jšœ/™/J˜—šžœœœœ˜HJšœM™MJ˜—J˜JšÏbœ˜"J˜J™š žœœœœœœ˜]JšœS™SJšœ™J™—šžœœœ˜7JšœÐ™ÐJ™—š ž œœ œœœ˜8J™4J˜—šž œœœœ ˜@Jšœ;™;J˜—šžœœœœ˜GJšœX™XJšœ`™`Jšœ ™ —J™šžœœœœ˜BJšœY™YJšœœ˜%—J˜J™šžœœ˜JšœŸ0˜GJšœŸ8˜JJšœŸ$˜6Jšœ Ÿ/˜OJšœ#Ÿ,˜OJšœœŸ8˜OJšœœŸ8˜OJšœ˜J˜—Jšœ¼™¼J˜Jšœ‚™‚J˜Jšœ”™”J˜J™Jšœ˜J˜J˜—…— °)Ü