DIRECTORY Atom, BasicTime, Buttons, Commander, CommandTool, Convert, IO, MessageWindow, Process, Rope, UserProfile, ViewerOps; NewClockImpl: CEDAR PROGRAM IMPORTS Atom, BasicTime, Buttons, CommandTool, Convert, IO, MessageWindow, Process, Rope, UserProfile, ViewerOps ~ BEGIN ROPE: TYPE ~ Rope.ROPE; CurrentTime: PROC RETURNS [time: ROPE] ~ { unpacked: BasicTime.Unpacked ~ BasicTime.Unpack[time: BasicTime.Now[]]; hour: CARDINAL _ unpacked.hour; IF NOT military AND hour > 12 THEN hour _ hour-12; IF hour = 0 THEN hour _ 12; time _ IO.PutFR["%2g:%02g", IO.card[hour], IO.card[unpacked.minute]]; IF seconds THEN time _ IO.PutFR["%g:%02g", IO.rope[time], IO.card[unpacked.second]]; }; start: ROPE ~ "12:00"; seconds: BOOL _ FALSE; military: BOOL _ FALSE; style: ATOM _ $WhiteOnBlack; StyleInit: UserProfile.ProfileChangedProc = { style _ Atom.MakeAtom[UserProfile.Token["NewClock.ButtonStyle", "WhiteOnBlack"]]; seconds _ UserProfile.Boolean["NewClock.Seconds", FALSE]; military _ UserProfile.Boolean["NewClock.Military", FALSE]; }; UpdateButtonNow: Buttons.ButtonProc = { SELECT mouseButton FROM red => Buttons.ReLabel[button: NARROW[parent], newName: CurrentTime[]]; yellow => { clock: BOOL _ FALSE; Proc: TYPE ~ ViewerOps.EnumProc; p1: Proc ~ {IF Rope.Equal[v.name, "Clock"] THEN clock _ TRUE}; p2: Proc ~ {IF Rope.Equal[v.name, "Clock"] THEN ViewerOps.OpenIcon[v]}; ViewerOps.EnumerateViewers[p1]; IF NOT clock THEN [] _ CommandTool.DoCommand ["///Commands/Clock", NEW[Commander.CommandObject _ [IO.RIS[NIL], IO.ROS[], IO.ROS[], NIL]]]; ViewerOps.EnumerateViewers[p2]; }; blue => MessageWindow.Append[ Convert.RopeFromTime[from: BasicTime.Now[], includeDayOfWeek: TRUE], TRUE]; ENDCASE; }; UpdateButton: PROC [button: Buttons.Button] ~ { Buttons.SetDisplayStyle[button: button, style: style]; DO Buttons.ReLabel[button: button, newName: CurrentTime[]]; Process.Pause[ticks: Process.SecondsToTicks[IF seconds THEN 1 ELSE 30]]; ENDLOOP; }; UserProfile.CallWhenProfileChanges[StyleInit]; TRUSTED { Process.Detach[FORK UpdateButton[ Buttons.Create[ info: [name: IF seconds THEN "12:00:00" ELSE "12:00"], proc: UpdateButtonNow, paint: FALSE] ]]; }; END. ²NewClockImpl.mesa Copyright c 1986 by Xerox Corporation. All rights reserved. Eric Nickell, December 8, 1986 8:57:35 am PST Bloomenthal, December 8, 1986 11:21:22 pm PST Κη˜™Icodešœ Οmœ1™Kšœ žœžœ˜GK˜šžœžœžœ˜,Kšœ˜Kšžœžœžœžœžœžœžœžœžœ˜G—K˜K˜—šœ˜Kšœ>žœžœ˜K—Kšžœ˜—K˜K˜—š  œžœ˜/Kšœ6˜6šž˜Kšœ8˜8K–[Process.Seconds]šœ,žœ žœžœ˜HKšžœ˜—K˜K˜—Kšœ.˜.K˜–γ[info: ViewerClasses.ViewerRec _ [class: NIL, wx: 0, wy: 0, ww: 0, wh: 0, cx: 0, cy: 0, cw: 0, ch: 0, lock: [process: PROCESS#0B, count: 0B (0)], tipTable: NIL, name: NIL, file: NIL, label: NIL, menu: NIL, icon: 177777B?, column: left, caption: FALSE, scrollable: TRUE, hscrollable: FALSE, iconic: TRUE, border: TRUE, newVersion: FALSE, newFile: FALSE, visible: TRUE, offDeskTop: FALSE, destroyed: FALSE, init: FALSE, saveInProgress: FALSE, inhibitDestroy: FALSE, guardDestroy: FALSE, paintingWedged: FALSE, spare0: FALSE, spare1: FALSE, spare2: FALSE, spare3: FALSE, spare4: FALSE, spare5: FALSE, spare6: FALSE, position: 0, openHeight: 0, link: NIL, parent: NIL, sibling: NIL, child: NIL, props: NIL, data: NIL], font: ImagerFont.Font _ NIL, paint: BOOL _ TRUE]šžœ˜ šœžœ˜!šœ˜Kšœ žœ žœ žœ ˜6Kšœ˜Kšœžœ˜ Kšœ˜——Kšœ˜——K˜Kšžœ˜—…—t