home *** CD-ROM | disk | FTP | other *** search
Oberon Text | 1994-11-15 | 3.7 KB | 82 lines |
- Syntax10.Scn.Fnt
- ParcElems
- Alloc
- Syntax10b.Scn.Fnt
- Syntax10i.Scn.Fnt
- (* This is a Demo-Programm for the DisplayPat Module *)
- (* Text in bold shows the necessary parts to display patterns, desinged with *)
- (* the EditPat. Start it with PatDemo.Open . *)
- MODULE PatDemo; (* V0.6 (C) 4 Nov 94 by Ralf Degner *)
- IMPORT
- Display, DisplayPat, MenuViewers, TextFrames, Oberon, Texts, Fonts;
- (* load the Demo.Pal colors ( Colors.Open Demo.Pal ) or edit Colors here *)
- (* if you are using Windows, edit colors, loading will have no success *)
- CONST
- black=Display.white; red=1; green=2; blue=3; yellow=4;
- white=11; lightgray=12; midgray=13; darkgray=14;
- PatObject: DisplayPat.Object;
- W: Texts.Writer;
- PROCEDURE DrawPats(f: Display.Frame);
- VAR F: Fonts.Font;
- BEGIN
- (* single Smily in black with yellow backgroung, original colors *)
- PatObject.CopyPatternC(f, DisplayPat.OriCol, 0, f.X+40, f.Y+40, Display.paint);
- (* red sign on white groung, original colors *)
- PatObject.CopyPatternC(f, DisplayPat.OriCol, 2, f.X+80, f.Y+40, Display.paint);
- (* same sign, but all in color 2 (green) *)
- PatObject.CopyPatternC(f, 2, 2, f.X+120, f.Y+40, Display.paint);
- (* not happy smily, original color *)
- PatObject.CopyPatternC(f, DisplayPat.OriCol, 3, f.X+160, f.Y+40, Display.paint);
- (* fill frame with smily in original colors *)
- PatObject.ReplPatternN(f, DisplayPat.OriCol, 0, f.X, f.Y+120, f.W, f.H-100, 0, 0, Display.replace);
- (* OK button with 4 color and width 40 *)
- PatObject.CopyPatternC(f, DisplayPat.OriCol, 1, f.X+200, f.Y+40, Display.replace);
- (* not happy smily, original color *)
- PatObject.CopyPatternC(f, DisplayPat.OriCol, 3, f.X+160, f.Y+40, Display.replace);
- (* a text centered to the frame with font Syntax20b *)
- F:=Fonts.This("Syntax20b.Scn.Fnt");
- Texts.WriteString(W, "This is the PatDemo !!!");
- DisplayPat.PlotText(f, Display.white, F, W.buf, f.X+(f.W-DisplayPat.TextLength(F, W.buf)) DIV 2, f.Y+80, Display.paint);
- (* a text at the botton of the frame with font Syntax12 *)
- F:=Fonts.This("Syntax12.Scn.Fnt");
- Texts.WriteString(W, "(C) 1994 by Ralf Degner ________ E-Mail: degner@pallas.amp.uni-hannover.de");
- DisplayPat.PlotText(f, Display.white, F, W.buf, f.X, f.Y+4, Display.paint);
- END DrawPats;
- PROCEDURE Handler(f: Display.Frame; VAR m: Display.FrameMsg);
- BEGIN
- WITH m: MenuViewers.ModifyMsg DO
- IF m.H#0 THEN
- Display.ReplConst(Display.black, f.X, m.Y, f.W, m.H, Display.replace);
- f.Y:=m.Y;f.H:=m.H;
- DrawPats(f);
- END;
- | m: Oberon.InputMsg DO
- IF m.id=Oberon.track THEN
- Oberon.DrawCursor(Oberon.Mouse, Oberon.Arrow, m.X, m.Y);
- END;
- ELSE
- END;
- END Handler;
- PROCEDURE Open*;
- VAR
- f: Display.Frame;
- x, y: INTEGER;
- tf: TextFrames.Frame;
- v: MenuViewers.Viewer;
- BEGIN
- NEW(PatObject);
- PatObject.Install("Demo.Pat", TRUE);
- (* set colors *)
- PatObject.ColorMap[15]:=black;PatObject.ColorMap[1]:=red;PatObject.ColorMap[2]:=green;
- PatObject.ColorMap[3]:=blue;PatObject.ColorMap[4]:=yellow;PatObject.ColorMap[11]:=white;
- PatObject.ColorMap[12]:=lightgray;PatObject.ColorMap[13]:=midgray;PatObject.ColorMap[14]:=darkgray;
- NEW(f);
- f.handle:=Handler;
- Oberon.AllocateUserViewer(Oberon.Mouse.X, x, y);
- tf:=TextFrames.NewMenu("PatDemo", "System.Close");
- v:=MenuViewers.New(tf, f, TextFrames.menuH, x, y);
- END Open;
- BEGIN
- Texts.OpenWriter(W);
- END PatDemo.
-