DIRECTORY BasicTime USING [GMT, Unpack, Unpacked], Convert USING [RopeFromTime], FS USING [EnumerateForInfo, InfoProc], MessageWindow USING [Append, Blink, Clear], Rope USING [Concat, IsEmpty, ROPE], TiogaButtons USING [AppendToButton, CreateButton, CreateViewer, GetRope, SetStyleFromRope, TiogaButton, TiogaButtonProc], ViewerClasses USING [Viewer], ViewerOps USING [OpenIcon]; TestTiogaButtonsImpl: CEDAR PROGRAM IMPORTS BasicTime, Convert, FS, MessageWindow, Rope, TiogaButtons, ViewerOps = BEGIN ROPE: TYPE = Rope.ROPE; FirstOne: PROC ~ { v: ViewerClasses.Viewer ¬ TiogaButtons.CreateViewer[info: [name: "First One", iconic: FALSE]]; b: TiogaButtons.TiogaButton ¬ TiogaButtons.CreateButton[viewer: v, rope: "DoIt", format: "center", looks: "lb", proc: DisplayButton]; b ¬ TiogaButtons.CreateButton[viewer: v, rope: "First", proc: DisplayButton]; b ¬ TiogaButtons.AppendToButton[button: b, rope: " "]; b ¬ TiogaButtons.AppendToButton[button: b, rope: "Second", proc: DisplayButton]; b ¬ TiogaButtons.AppendToButton[button: b, rope: " "]; b ¬ TiogaButtons.AppendToButton[button: b, rope: "Third", proc: DisplayButton]; b ¬ TiogaButtons.CreateButton[viewer: v, rope: ""]; b ¬ TiogaButtons.AppendToButton[button: b, rope: "First", proc: DisplayButton]; b ¬ TiogaButtons.AppendToButton[button: b, rope: " "]; b ¬ TiogaButtons.AppendToButton[button: b, rope: "Second", proc: DisplayButton]; b ¬ TiogaButtons.AppendToButton[button: b, rope: " "]; b ¬ TiogaButtons.AppendToButton[button: b, rope: "Third", proc: DisplayButton]; }; DisplayButton: TiogaButtons.TiogaButtonProc ~ { MessageWindow.Append[Rope.Concat["Button contents ", TiogaButtons.GetRope[button]], TRUE]; MessageWindow.Blink[]; }; FSButtons: PROC [fPattern: ROPE] ~ { FSInfoProc: FS.InfoProc ~ { b: TiogaButtons.TiogaButton; b ¬ TiogaButtons.CreateButton[viewer: v, rope: " ", format: "table", proc: DisplayButton]; b ¬ TiogaButtons.AppendToButton[button: b, rope: Convert.RopeFromTime[created], looks: "bs", proc: DisplayTime, clientData: NEW[MyTimeRec ¬ [created]]]; b ¬ TiogaButtons.AppendToButton[button: b, rope: "\t"]; b ¬ TiogaButtons.AppendToButton[button: b, rope: fullFName, proc: DisplayFileName]; IF NOT attachedTo.IsEmpty THEN { b ¬ TiogaButtons.AppendToButton[button: b, rope: "\n"]; b ¬ TiogaButtons.AppendToButton[button: b, rope: attachedTo, looks: "s", proc: DisplayFileName]; }; RETURN [TRUE] }; v: ViewerClasses.Viewer ¬ TiogaButtons.CreateViewer[info: [name: "FSButtons", iconic: TRUE]]; TiogaButtons.SetStyleFromRope[v, fancyTableStyle]; [] ¬ TiogaButtons.CreateButton[viewer: v, rope: "Clear", format: "Center", looks: "lb", proc: ClearMsgWindow]; [] ¬ TiogaButtons.CreateButton[viewer: v, rope: "XEROX", format: "logo"]; [] ¬ TiogaButtons.CreateButton[viewer: v, rope: ""]; FS.EnumerateForInfo[fPattern, FSInfoProc]; ViewerOps.OpenIcon[v]; }; fancyTableStyle: ROPE ¬ "BeginStyle (Cedar) AttachStyle (table) \"fancy table\" { block 3 in restIndent 3 in flushLeft \".\" 8 congruent leaders tabStop } StyleRule EndStyle"; ClearMsgWindow: TiogaButtons.TiogaButtonProc ~ { MessageWindow.Clear; }; MyTime: TYPE ~ REF MyTimeRec; MyTimeRec: TYPE ~ RECORD[ time: BasicTime.GMT]; DisplayTime: TiogaButtons.TiogaButtonProc ~ { timeRef: MyTime ¬ NARROW[button.clientData]; unpacked: BasicTime.Unpacked ¬ BasicTime.Unpack[timeRef.time]; MessageWindow.Append[Rope.Concat["This file created on a ", SELECT unpacked.weekday FROM Monday => "Monday", Tuesday => "Tuesday", Wednesday => "Wednesday", Thursday => "Thursday", Friday => "Friday", Saturday => "Saturday", Sunday => "Sunday", ENDCASE => "unknown day!"], TRUE]; }; DisplayFileName: TiogaButtons.TiogaButtonProc ~ { MessageWindow.Append[Rope.Concat["File named ", TiogaButtons.GetRope[button]], TRUE]; }; END. j TestTiogaButtonsImpl.Mesa Copyright c1984, 1985, 1991 Xerox Corporation. All rights reserved. Rick Beach, April 27, 1985 1:52:42 pm PST Willie-Sue, January 23, 1987 3:56:25 pm PST Willie-s, December 20, 1991 2:59 pm PST Use formats and looks as you wish. This line of buttons has the curious feature that "First" creates a button that is the whole node. Use this technique to create a button, perhaps a bullet character from the Math font (look m), that selects the entire contents of the button. This line of buttons has an empty button without a proc. All the other buttons are appended to the empty button and are individual. Unlike the preceeding example, there is no way to select this node entirely. InfoProc: TYPE = PROC [fullFName, attachedTo: ROPE, created: BasicTime.GMT, bytes: INT, keep: CARDINAL] RETURNS [continue: BOOLEAN]; For fancy formatting of TiogaButtons, define your own style rules using the StyleDef property or TiogaOps.SetStyle and a style name other than the default style. PROC [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift, control: BOOL _ FALSE] ; Κ5–(cedarcode) style•NewlineDelimiter ™code™Kšœ Πemœ9™DK™)K™+K™'—K˜šΟk ˜ Kšœ žœžœ˜(Kšœžœ˜Kšžœžœ˜&Kšœžœ˜+Kšœžœžœ˜#Kšœ žœg˜yKšœžœ ˜Kšœ žœ ˜—K˜KšΠblœž ˜#KšžœE˜Lšœž˜K˜Kšžœžœžœ˜—˜šΟnœžœ˜K˜^K˜K™"K˜…K˜K™bK™^K™/K˜MK˜7K˜PK˜7K˜OK˜K™8K™JK™LK˜3K˜OK˜7K˜PK˜7K˜OK˜K˜—š  œ"˜/KšœTžœ˜ZK˜K˜K˜—š  œžœ žœ˜$š  œ˜Kš œžœžœžœžœ žœžœžœ žœ™„K˜K˜ZKšœ|žœ˜˜K˜7K˜Sšžœžœžœ˜ K˜7K˜`Kšœ˜—Kšžœžœ˜ K˜—KšœVžœ˜]K˜K˜2K˜nK˜IK˜4K˜K˜*K˜K˜K˜K˜K™‘K™Kšœžœš˜―K˜—š œ"˜0š žœ žœžœžœžœžœ™1Kšœ6žœžœ™E—K˜K˜K˜Kšœžœžœ ˜šœ žœžœ˜Kšœžœ˜K˜——š  œ"˜-Kšœžœ˜,K˜>šœ<žœž˜XK˜K˜K˜K˜K˜K˜K˜Kšžœžœ˜"—K˜K˜—š œ"˜1KšœOžœ˜UKšœ˜——K˜Kšžœ˜—…—°O