Syntax10.Scn.Fnt Syntax10i.Scn.Fnt StampElems Alloc 3 May 95 Syntax10b.Scn.Fnt MODULE DialogListBoxes; (** Markus Knasm ller 12 Oct 94 - (* based on PopupElems MF 27.1.92 /MH/CM/MAH/HM *) IMPORT DialogFrames, Dialogs, DialogTexts, Display, Display1, Files, GraphicUtils, In, Input, Oberon, TextFrames, Texts, Viewers; CONST W* = 50; H* = 70; MR = 0; MM = 1; ML = 2; cancel = {MM, MR, ML}; CR = 0DX; ehm = 4; evm = 3; (*element: horizontal margin, vertical margin*) mhm = 5; mvm = 2; white = 0; grey1 = 12; grey2 = 13; grey3 = 14; black = 15; TYPE Item* = POINTER TO ItemDesc; ItemDesc* = RECORD(Dialogs.ObjectDesc) menu-: Texts.Text; (** displayed text *) n-: INTEGER; (** number of lines in the text *) lsp, dsc: INTEGER; selline*: INTEGER; (** most recently selected cmd *) startcmd: INTEGER; (* first displayed cmd *) END; PROCEDURE Max (x, y: INTEGER): INTEGER; BEGIN IF x > y THEN RETURN x ELSE RETURN y END END Max; PROCEDURE Min (x, y: INTEGER): INTEGER; BEGIN IF x < y THEN RETURN x ELSE RETURN y END END Min; PROCEDURE (b: Item) Draw* (x, y: INTEGER; f: Display.Frame); (** displays the object at (x, y) in frame f *) VAR bx, by, w, h, mode: INTEGER; BEGIN b.GetDim (bx, by, w, h); IF b.selected THEN mode := Display.invert ELSE mode := Display.replace END; GraphicUtils.DrawMenu (f, b.menu, b.startcmd, b.selline, x, y, w, h, mode, b.n, b.lsp, b.dsc); END Draw; PROCEDURE (b: Item) Print* (x, y: INTEGER); (** prints the object at printer coordinates (x, y) *) VAR ox, oy, ow, oh: INTEGER; BEGIN b.GetPDim (ox, oy, ow, oh); GraphicUtils.PrintBox (x, y, ow, oh) END Print; PROCEDURE (b: Item) Init*; (** initialies the object, should be called after allocating the object with NEW *) BEGIN b.Init^; b.menu := TextFrames.Text (""); b.selline := 0; b.startcmd := 0; END Init; PROCEDURE (b: Item) SetMenu* (t: Texts.Text); (** sets the menu of the object to t and redraws the object *) BEGIN b.selline := 0; b.menu := t; b.Restore END SetMenu; PROCEDURE (b: Item) Track (x, y: INTEGER; keys: SET; f: Display.Frame; p: Dialogs.Panel); VAR keysum: SET; dummy: ARRAY 6 OF CHAR; bx, by, w, h: INTEGER; t: Texts.Text; BEGIN IF (keys = {MM}) OR (keys = {ML}) OR (keys = {MR}) THEN b.GetDim (bx, by, w, h); bx := f.X + bx; by := f.Y + f.H + by; GraphicUtils.TrackMenu (f, b.menu, bx, by, w, h, b.n, b.lsp, b.dsc, b.startcmd, b.selline); IF b.selline >= 0 THEN b.Restore; IF b.cmd[0] # 0X THEN DialogTexts.GetParText (b.par, b.panel, t); b.CallCmd (f, Viewers.This (x, y), t) END END ELSE Oberon.DrawCursor(Oberon.Mouse, Oberon.Arrow, x, y) END END Track; PROCEDURE (b: Item) Handle* (f: Display.Frame; VAR m: Display.FrameMsg); (** handles messages which were sent to frame f *) BEGIN b.Handle^ (f, m); WITH f: DialogFrames.Frame DO WITH m: Oberon.InputMsg DO IF m.id = Oberon.track THEN b.Track (m.X, m.Y, m.keys, f, f.panel) END ELSE END ELSE END END Handle; PROCEDURE (b: Item) Copy* (VAR dup: Dialogs.Object); (** allocates dup and makes a deep copy of o. Before calling this methode dup should be equal NIL *) VAR x: Item; BEGIN IF dup = NIL THEN NEW (x); dup := x ELSE x := dup(Item) END; b.Copy^ (dup); x.menu := TextFrames.Text (""); x.selline := b.selline; x.startcmd := b.startcmd; END Copy; PROCEDURE Insert*; (** Insert (name [x y w h]| ^ ) inserts a listbox - item in the panel containing the caret position *) VAR x, y, x1, y1, w, h: INTEGER; l: Item; p: Dialogs.Panel; name: ARRAY 64 OF CHAR; BEGIN NEW (l); In.Open; In.Name (name); DialogFrames.GetCaretPosition (p, x, y); IF (p # NIL) THEN l.Init; In.Open; In.Name (name); IF ~In.Done THEN COPY ("", name); In.Open END; l.SetName (name); In. Int (x1); In.Int (y1); In.Int (w); In.Int (h); IF ~ In.Done THEN x1 := x; y1 := y; w := W; h := H ELSE IF w < 0 THEN w := W END; IF h < 0 THEN h := H END; END; l.SetDim (x1, y1, w, h, FALSE); p.Insert (l, FALSE) ELSE Dialogs.res := Dialogs.noPanelSelected END; IF Dialogs.res # 0 THEN Dialogs.Error ("DialogListBoxes") END; END Insert; END DialogListBoxes.