home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / jËzyki_programowania / oberon / system1 / dialogrectangles.mod (.txt) < prev    next >
Oberon Text  |  1977-12-31  |  3KB  |  92 lines

  1. Syntax10.Scn.Fnt
  2. Syntax10i.Scn.Fnt
  3. StampElems
  4. Alloc
  5. 23 Dec 94
  6. Syntax10b.Scn.Fnt
  7. MODULE DialogRectangles;
  8.     (** Markus Knasm
  9. ller 29 Aug 94 - 
  10.     IMPORT DialogFrames, Dialogs, DialogTexts, Display, Display1, GraphicUtils, In, Input, Oberon, Printer, TextFrames, Texts, Viewers;
  11.     CONST MM = 1; W* = 30; H* = 20; black = 15;
  12.     TYPE
  13.         Item* = POINTER TO ItemDesc;
  14.         ItemDesc* = RECORD (Dialogs.ObjectDesc)
  15.         END;
  16.     PROCEDURE (r: Item) Draw* (x, y: INTEGER; f: Display.Frame);
  17.     (** displays the object at (x, y) in frame f *)
  18.         VAR mode, w, h, bx, by: INTEGER;
  19.     BEGIN
  20.         r.GetDim (bx, by, w, h); DEC (w); DEC (h);
  21.         IF r.selected THEN mode := Display.invert ELSE mode := Display.replace END;
  22.         Display1.Line (f, black, x, y, x + w, y, mode); Display1.Line (f, black, x, y, x, y + h, mode);
  23.         Display1.Line (f, black, x + w, y, x + w, y + h, mode); Display1.Line (f, black, x, y + h, x + w, y + h, mode);
  24.     END Draw;
  25.     PROCEDURE (r: Item) Print* (x, y: INTEGER);
  26.     (** prints the object at printer coordinates (x, y)  *)
  27.         VAR w, h, bx, by: INTEGER;
  28.     BEGIN
  29.         r.GetPDim (bx, by, w, h);
  30.         GraphicUtils.PrintBox (x, y, w, h);
  31.     END Print;
  32.     PROCEDURE (r: Item) Copy* (VAR dup: Dialogs.Object);
  33.     (** allocates dup and makes a deep copy of o. Before calling this methode dup should be equal NIL *)
  34.         VAR x: Item;
  35.     BEGIN
  36.         IF dup = NIL THEN NEW (x); dup := x ELSE x := dup(Item) END;
  37.         r.Copy^ (dup);
  38.     END Copy;
  39.     PROCEDURE (r: Item) Track (x, y: INTEGER; keys: SET; f: Display.Frame; p: Dialogs.Panel);
  40.         VAR keysum: SET; t: Texts.Text;
  41.     BEGIN
  42.         IF keys = {MM} THEN 
  43.             keysum := keys;
  44.             REPEAT 
  45.                 Input.Mouse(keys, x, y); keysum := keysum + keys;
  46.                 Oberon.DrawCursor(Oberon.Mouse, Oberon.Arrow, x, y)
  47.             UNTIL keys = {};
  48.             IF keysum = {MM} THEN 
  49.                 IF r.cmd[0] # 0X THEN
  50.                     DialogTexts.GetParText (r.par, r.panel, t); 
  51.                     r.CallCmd (f, Viewers.This (x, y), t)
  52.                 END
  53.             END
  54.         ELSE Oberon.DrawCursor(Oberon.Mouse, Oberon.Arrow, x, y)
  55.         END
  56.     END Track;
  57.     PROCEDURE (r: Item) Handle* (f: Display.Frame; VAR m: Display.FrameMsg);
  58.     (** handles messages which were sent to frame f *)
  59.     BEGIN
  60.         r.Handle^ (f, m);
  61.         WITH f: DialogFrames.Frame DO
  62.             WITH m: Oberon.InputMsg DO
  63.                 IF m.id = Oberon.track THEN r.Track (m.X, m.Y, m.keys, f, f.panel) END
  64.             ELSE
  65.             END
  66.         ELSE
  67.         END
  68.     END Handle;
  69.     PROCEDURE Insert*;
  70.     (** Insert ([name] [x y w h] | ^ ) inserts a circle - item in the panel containing the caret position *)
  71.         VAR x, y, x1, y1, w, h: INTEGER; l: Item; p: Dialogs.Panel; name: ARRAY 64 OF CHAR; 
  72.     BEGIN 
  73.         NEW (l);
  74.         DialogFrames.GetCaretPosition (p, x, y); 
  75.         IF (p # NIL) THEN 
  76.             l.Init; In.Open; In.Name (name);
  77.             IF ~In.Done THEN COPY ("", name); In.Open END;
  78.             l.SetName (name); 
  79.             In.Int (x1); In.Int (y1); In.Int (w); In.Int (h);
  80.             IF ~In.Done THEN x1 := x; y1 := y; w := W; h := H 
  81.             ELSE
  82.                 IF w < 0 THEN w := W END;
  83.                 IF h < 0 THEN h := H END
  84.             END;
  85.             l.SetDim (x1, y1, w, h, FALSE); p.Insert (l, TRUE) 
  86.         ELSE
  87.             Dialogs.res := Dialogs.noPanelSelected
  88.         END;
  89.         IF Dialogs.res # 0 THEN Dialogs.Error ("DialogRectangles") END;
  90.     END Insert;
  91. END DialogRectangles.
  92.