Syntax10.Scn.FntSyntax10i.Scn.Fnt0zStampElemsAlloc13 Mar 95Syntax10b.Scn.Fnt"4Syntax8.Scn.Fnt;d8FoldElemsNew#Syntax10.Scn.Fntzz BEGIN e.W := LONG(W)*LONG(Unit); e.H := LONG(H)*LONG(Unit); e.handle := Handle; e.percentage := percentage END Init; 8]8#Syntax10.Scn.Fnt VAR copy : IndicatorElem; BEGIN NEW(copy); Texts.CopyElem(e, copy); copy.percentage := e.percentage; RETURN copy END Clone; 8(8#Syntax10.Scn.Fnt VAR help: INTEGER; BEGIN Files.ReadInt(r, help); e.W := LONG(help)*LONG(Unit); Files.ReadInt(r, help); e.H := LONG(help)*LONG(Unit); Files.ReadInt(r, e.percentage); END Load; 8L8#Syntax10.Scn.Fnt BEGIN Files.WriteInt(r, SHORT(e.W DIV LONG(Unit))); Files.WriteInt(r, SHORT(e.H DIV LONG(Unit))); Files.WriteInt(r, e.percentage); END Store; 88#Syntax10.Scn.Fnt11 VAR w, W, H : INTEGER; BEGIN W := SHORT(e.W DIV LONG(Unit)); H := SHORT(e.H DIV LONG(Unit)); w := (e.percentage* W) DIV 100; Display.ReplConst(backgroundCol, x0 + w, y0 + 1, W - w - 1, H-2, Display.replace); Display.ReplConst(forgroundCol, x0 + 1, y0 + 1, w - 1, H - 2, Display.replace); Display.ReplConst(black, x0, y0, 1, H, Display.replace); Display.ReplConst(black, x0, y0, W, 1, Display.replace); Display.ReplConst(black, x0, y0 + H - 1, W, 1, Display.replace); Display.ReplConst(black, x0 + W - 1, y0 + 1 , 1, H - 2, Display.replace) END Draw; 8 8#Syntax10.Scn.Fnt%% BEGIN RETURN e.percentage END Get; 88#Syntax10.Scn.Fnt,, BEGIN e.percentage := percentage END Set; 88CSyntax10.Scn.Fnt3Syntax10b.Scn.Fnt VAR w: INTEGER; ew, eh, u: INTEGER; help: LONGINT; BEGIN u := Unit DIV TextPrinter.Unit; ew := SHORT(e.W DIV LONG(TextPrinter.Unit)); eh := SHORT(e.H DIV LONG(TextPrinter.Unit)); w := (e.percentage* ew) DIV 100; IF w < u THEN w := u END; Printer.ReplPattern(x0 + w, y0 + u, ew - w - u, eh - 2*u, 2); Printer.ReplConst(x0, y0, w, eh); Printer.ReplConst(x0 + w, y0, ew - w, u); Printer.ReplConst(x0 + w, y0 + eh - u, ew - w, u); Printer.ReplConst(x0 + ew - u, y0 + u, u, eh - 2*u) END Print; 8 *)8#Syntax10.Scn.Fnt VAR desc: INTEGER; beg: LONGINT; hostText: Texts.Text; parc: TextFrames.Parc; BEGIN WITH e: IndicatorElem DO WITH msg: Texts.CopyMsg DO msg.e := e.Clone() | msg: Texts.IdentifyMsg DO msg.mod := "Indicator"; msg.proc := "Alloc" | msg: Texts.FileMsg DO IF msg.id = Texts.load THEN e.Load(msg.r) ELSE e.Store(msg.r) END | msg: TextFrames.DisplayMsg DO IF ~msg.prepare THEN e.Draw( msg.X0, msg.Y0+ e.desc) ELSE e.desc := SHORT(-msg.Y0); msg.Y0 := 0; END | msg: TextPrinter.PrintMsg DO IF ~msg.prepare THEN e.Print(msg.X0, msg.Y0+ e.desc) ELSE e.desc := SHORT(-msg.Y0); msg.Y0 := 0; END ELSE END ELSE END END Handle; 8 8#Syntax10.Scn.FntSS VAR e : IndicatorElem; BEGIN NEW(e); e.Init(0, 0, 0); Texts.new := e END Alloc; 8  ,u8#Syntax10.Scn.Fntii VAR elem : IndicatorElem; BEGIN NEW(elem); elem.Init(W, H, percentage); RETURN elem END NewIndicator; 8 z8#Syntax10.Scn.Fntdd VAR w, h, percentage: INTEGER; msg: TextFrames.InsertElemMsg; BEGIN In.Open; In.Int(w); IF ~In.Done THEN RETURN END; In.Int(h); IF ~In.Done THEN RETURN END; In.Int(percentage); IF ~In.Done THEN RETURN END; msg.e := NewIndicator(w, h, percentage); IF Oberon.FocusViewer # NIL THEN Oberon.FocusViewer.handle(Oberon.FocusViewer, msg) END END Insert; 8  8#Syntax10.Scn.Fnt VAR percentage: INTEGER; beg, end, time: LONGINT; text: Texts.Text; R: Texts.Reader; BEGIN In.Open; In.Int(percentage); IF In.Done THEN Oberon.GetSelection(text, beg, end, time); IF time >= 0 THEN Texts.OpenReader(R, text, beg); Texts.ReadElem(R); IF (R.elem # NIL) & (R.elem IS IndicatorElem) THEN R.elem(IndicatorElem).Set(percentage); text.notify(text, Texts.replace, Texts.Pos(R), Texts.Pos(R) + 1) END END END END SetPercentage; 8MODULE Indicator; (** Christian Mayrhofer, Friedrich Traunmueller  *) IMPORT Display, Files, Fonts, In, Oberon, Printer, TextFrames, Texts, TextPrinter; CONST backgroundCol = 12; forgroundCol = 14; black = 15; Unit = TextFrames.Unit; TYPE IndicatorElem* = POINTER TO IndicatorElemDesc; IndicatorElemDesc* = RECORD ( Texts.ElemDesc) percentage : INTEGER; (* range: 0 to 100 *) desc: INTEGER END; PROCEDURE^ Handle*(e: Texts.Elem; VAR msg : Texts.ElemMsg); PROCEDURE (e: IndicatorElem) Init* (W, H, percentage: INTEGER); PROCEDURE (e: IndicatorElem) Clone* () : IndicatorElem; PROCEDURE (e: IndicatorElem) Load* (VAR r : Files.Rider); PROCEDURE (e: IndicatorElem) Store* (VAR r : Files.Rider); PROCEDURE (e: IndicatorElem) Draw* (x0, y0: INTEGER); PROCEDURE (e: IndicatorElem) Get* (): INTEGER; PROCEDURE (e: IndicatorElem) Set* (percentage : INTEGER ); PROCEDURE (e: IndicatorElem) Print* (x0, y0: INTEGER); PROCEDURE Handle* (e: Texts.Elem; VAR msg : Texts.ElemMsg); PROCEDURE Alloc*; PROCEDURE NewIndicator* (W, H, percentage: INTEGER): IndicatorElem; PROCEDURE Insert*; PROCEDURE SetPercentage*; END Indicator.