home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / languages / editpat.lha / PatDemo.Mod (.txt) < prev    next >
Encoding:
Oberon Text  |  1994-11-15  |  3.7 KB  |  82 lines

  1. Syntax10.Scn.Fnt
  2. ParcElems
  3. Alloc
  4. Syntax10b.Scn.Fnt
  5. Syntax10i.Scn.Fnt
  6. (* This is a Demo-Programm for the DisplayPat Module    *)
  7. (* Text in bold shows the necessary parts to display patterns, desinged with    *) 
  8. (* the EditPat. Start it with PatDemo.Open .    *)
  9. MODULE PatDemo; (* V0.6 (C) 4 Nov 94 by Ralf Degner *)
  10.     IMPORT
  11.         Display, DisplayPat, MenuViewers, TextFrames, Oberon, Texts, Fonts;
  12.     (* load the Demo.Pal colors ( Colors.Open Demo.Pal ) or edit Colors here *)
  13.     (* if you are using Windows, edit colors, loading will have no success        *)
  14.     CONST
  15.         black=Display.white; red=1; green=2; blue=3; yellow=4;
  16.         white=11; lightgray=12; midgray=13; darkgray=14;
  17.         PatObject: DisplayPat.Object;
  18.         W: Texts.Writer;
  19.     PROCEDURE DrawPats(f: Display.Frame);
  20.         VAR F: Fonts.Font;
  21.     BEGIN
  22.         (* single Smily in black with yellow backgroung, original colors *)
  23.         PatObject.CopyPatternC(f, DisplayPat.OriCol, 0, f.X+40, f.Y+40, Display.paint);
  24.         (* red sign on white groung, original colors *)
  25.         PatObject.CopyPatternC(f, DisplayPat.OriCol, 2, f.X+80, f.Y+40, Display.paint);
  26.         (* same sign, but all in color 2 (green) *)
  27.         PatObject.CopyPatternC(f, 2, 2, f.X+120, f.Y+40, Display.paint);
  28.         (* not happy smily, original color *)
  29.         PatObject.CopyPatternC(f, DisplayPat.OriCol, 3, f.X+160, f.Y+40, Display.paint);
  30.         (* fill frame with smily in original colors *)    
  31.         PatObject.ReplPatternN(f, DisplayPat.OriCol, 0, f.X, f.Y+120, f.W, f.H-100, 0, 0, Display.replace);
  32.         (* OK button with 4 color and width 40 *)
  33.         PatObject.CopyPatternC(f, DisplayPat.OriCol, 1, f.X+200, f.Y+40, Display.replace);
  34.         (* not happy smily, original color *)
  35.         PatObject.CopyPatternC(f, DisplayPat.OriCol, 3, f.X+160, f.Y+40, Display.replace);
  36.         (* a text centered to the frame with font Syntax20b *)
  37.         F:=Fonts.This("Syntax20b.Scn.Fnt");
  38.         Texts.WriteString(W, "This is the PatDemo !!!");
  39.         DisplayPat.PlotText(f, Display.white, F, W.buf, f.X+(f.W-DisplayPat.TextLength(F, W.buf)) DIV 2, f.Y+80, Display.paint);
  40.         (* a text at the botton of the frame with font Syntax12 *)
  41.         F:=Fonts.This("Syntax12.Scn.Fnt");
  42.         Texts.WriteString(W, "(C) 1994 by Ralf Degner ________ E-Mail: degner@pallas.amp.uni-hannover.de");
  43.         DisplayPat.PlotText(f, Display.white, F, W.buf, f.X, f.Y+4, Display.paint);
  44.     END DrawPats;
  45.     PROCEDURE Handler(f: Display.Frame; VAR m: Display.FrameMsg);
  46.     BEGIN
  47.         WITH m: MenuViewers.ModifyMsg DO
  48.             IF m.H#0 THEN
  49.                 Display.ReplConst(Display.black, f.X, m.Y, f.W, m.H, Display.replace);
  50.                 f.Y:=m.Y;f.H:=m.H;
  51.                 DrawPats(f);
  52.             END;
  53.         | m: Oberon.InputMsg DO
  54.             IF m.id=Oberon.track THEN
  55.                 Oberon.DrawCursor(Oberon.Mouse, Oberon.Arrow, m.X, m.Y);
  56.             END;
  57.         ELSE
  58.         END;
  59.     END Handler;
  60.     PROCEDURE Open*;
  61.         VAR
  62.             f: Display.Frame;
  63.             x, y: INTEGER;
  64.             tf: TextFrames.Frame;
  65.             v: MenuViewers.Viewer;
  66.     BEGIN
  67.         NEW(PatObject);
  68.         PatObject.Install("Demo.Pat", TRUE);
  69.             (* set colors *)
  70.             PatObject.ColorMap[15]:=black;PatObject.ColorMap[1]:=red;PatObject.ColorMap[2]:=green;
  71.             PatObject.ColorMap[3]:=blue;PatObject.ColorMap[4]:=yellow;PatObject.ColorMap[11]:=white;
  72.             PatObject.ColorMap[12]:=lightgray;PatObject.ColorMap[13]:=midgray;PatObject.ColorMap[14]:=darkgray;
  73.         NEW(f);
  74.         f.handle:=Handler;
  75.         Oberon.AllocateUserViewer(Oberon.Mouse.X, x, y);
  76.         tf:=TextFrames.NewMenu("PatDemo", "System.Close");
  77.         v:=MenuViewers.New(tf, f, TextFrames.menuH, x, y); 
  78.     END Open;
  79. BEGIN
  80.     Texts.OpenWriter(W);
  81. END PatDemo.
  82.