DIRECTORY Icons USING [IconFlavor, NewIconFromFile], Menus USING [AppendMenuEntry, CreateEntry, CreateMenu, Menu, MenuProc], PeanutWindow, Rope USING [Cat, ROPE], TypeScript USING [Create, PutChar, PutRope, TS], ViewerOps USING [DestroyViewer, PaintViewer]; PeanutWindowImpl: CEDAR MONITOR IMPORTS Icons, Menus, Rope, TypeScript, ViewerOps EXPORTS PeanutWindow = BEGIN OutputRope: PUBLIC ENTRY PROC [text: Rope.ROPE] = BEGIN ENABLE ANY => UNWIND; IF ~Destroyed[] THEN TypeScript.PutRope[peanutScript, text]; END; OutputChar: PUBLIC ENTRY PROC [char: CHAR] = BEGIN ENABLE ANY => UNWIND; IF ~Destroyed[] THEN TypeScript.PutChar[peanutScript, char]; END; SetNewMail: PUBLIC ENTRY PROC [newMail: BOOL] = BEGIN ENABLE ANY => UNWIND; newMailExists _ newMail; IF Destroyed[] THEN RETURN; peanutScript.icon _ IF newMailExists THEN newMailIcon ELSE noMailIcon; peanutScript.name _ Caption[newMailExists]; ViewerOps.PaintViewer[peanutScript, caption]; END; AddCommand: PUBLIC ENTRY PROC [name: Rope.ROPE, proc: Menus.MenuProc, data: REF ANY _ NIL, fork: BOOL _ TRUE, guarded: BOOL _ FALSE] = BEGIN ENABLE ANY => UNWIND; Menus.AppendMenuEntry[menu, Menus.CreateEntry[name, proc, data, NIL, fork, guarded]]; IF peanutScript#NIL THEN ViewerOps.PaintViewer[peanutScript, all]; END; Create: PUBLIC ENTRY PROC = BEGIN ENABLE ANY => UNWIND; peanutScript _ TypeScript.Create[[name: Caption[newMailExists], icon: IF newMailExists THEN newMailIcon ELSE noMailIcon, column: right, openHeight: 100]]; peanutScript.menu _ menu; END; Destroy: PUBLIC ENTRY PROC = BEGIN ENABLE ANY => UNWIND; IF ~Destroyed[] THEN ViewerOps.DestroyViewer[peanutScript]; peanutScript _ NIL; END; Destroyed: PROC RETURNS [BOOL] = INLINE BEGIN IF peanutScript=NIL THEN RETURN [TRUE] ELSE IF peanutScript.destroyed THEN {peanutScript_NIL; RETURN [TRUE]}; RETURN [FALSE]; END; Caption: PROC [newMail: BOOL] RETURNS [name: Rope.ROPE] = BEGIN name _ "Peanut"; IF newMail THEN BEGIN name _ Rope.Cat[name, " -- You have new mail"]; END ELSE BEGIN name _ Rope.Cat[name, " -- No new mail"]; END; END; peanutScript: TypeScript.TS _ NIL; menu: Menus.Menu _ Menus.CreateMenu[]; noMailIcon: Icons.IconFlavor _ Icons.NewIconFromFile["/Indigo/CedarViewers/Peanut/Peanut.icons", 0]; newMailIcon: Icons.IconFlavor _ Icons.NewIconFromFile["/Indigo/CedarViewers/Peanut/Peanut.icons", 4]; newMailExists: BOOL _ FALSE; END. |PeanutWindowImpl.mesa; Written by Scott McGregor, February 1983 Last edited by McGregor on February 28, 1983 2:03 pm Κψ– "Cedar" style˜Iproc– "Cedar" stylešœ?™?Kšœ4™4unitšΟk ˜ Jšœœ˜*Jšœœ<˜GJšœ ˜ Jšœœœ˜Jšœ œœ˜0Jšœ œ˜-—šœœ˜Jšœ*˜1Jšœ˜—Lš˜I modheader˜š Οn œœœœ œ˜7Mšœœœ˜Mšœœ(˜