
       Copyright (C) 1993-95, Alex Iakovlev & Dimon Maslov





          GRAPHICS SUPPORT LIBRARY FOR MODULA-2 LANGUAGE

                           MultiGraph-2


                         Example programs







                              Moscow
                               1995



                             CONTENTS

    Introduction .......................................
    Chapter 1. How to draw a point .....................
    Chapter 2. How to draw a string ....................
    Chapter 3. How to create a window ..................
    Chapter 4. How to create a running line ............
    Chapter 5. How to show data ........................
    Chapter 6. How to create an interface ..............
    Chapter 7. Demonstration programs ..................

INTRODUCTION


This documentation contains some simple example programs. These
programs help to understand the architecture and functions of
MultiGraph-2 library. All these programs are complete Modula-2
modules, which can be compiled and run.

These examples are ordered from simplest to complex. Some
constructs, discussed in simple examples, are not discussed in
complex examples. Therefore, it is reasonable to learn these
examples in their natural order.

IMPORTANT NOTE: All the sources are written for TopSpeed
Modula-2 compiler and contain constructs, which can't be
compiled by standard Modula-2 compiler. For instance, we use
structured constants, strings concatenation and some
TopSpeed-specific library modules, because these extensions
permit to create well-structured and informative program
examples.

Chapter 1. HOW TO DRAW A POINT


The first example program draws a point. At first the program
initializes the 16-color graphics mode with pixel resolution
640 x 350, and then attempts to enter graphics mode. In case of
success it initializes the pixmap variable ("Scr.PagePixmap"),
gets current screen dimensions ("Scr.Dims") and sets the point
variable to be at the center of the screen. Then it calls the
procedure "Scr.Pt", which draws the white point (index 15
defines the white color in this mode). Then the program waits
for a key pressing. After key pressing the program terminates
graphics mode and exits.

MODULE Example1;
  IMPORT Terminal, Geo, Res, Scr;
  VAR
    vpm: Scr.PIXMAP;
    p: Geo.Point;
    w, h: CARDINAL;
    ch: CHAR;
  BEGIN
    Scr.SetMode4x640x350();
    IF Scr.InitGraph() = Res.done THEN
      vpm := Scr.PagePixmap();
      Scr.Dims(w, h);
      p.ix := w DIV 2;
      p.iy := h DIV 2;
      Scr.Pt(vpm, p, 15, Scr.copy);
      Terminal.Read(ch);
      Scr.TermGraph();
    ELSE
      Terminal.WriteString("Invalid Hardware!");
    END;
  END Example1.

Note, that this program draws a point with the aid of low-level
procedure "Scr.Pt". This task may be done by procedures at
screen and window levels too, but their interface is some more
complicated.

You may try to draw point in other position, or in other color.
If you set the raster function equal to "Scr.xor", the
resulting color will not be changed, because two raster
functions ("Scr.copy" and "Scr.xor") are equivalent on the
black background. To see effects of these changes we recommend
you to fill the screen by some non-zero color before the call
"Scr.Pt". The procedure "Scr.Clear" is the simplest way of the
screen filling.

Chapter 2. HOW TO DRAW A STRING


The second example program draws a string "Hello, User!" at the
center of the screen. Some control statements are similar to
ones from the first example. The "font" variable is initialized
as a pointer to the standard font number 0. Then the program
gets current character dimensions ("ScrOut.Dims") and
calculates the string beginning position "p" using screen and
character dimensions and string length.

A record, called attributes record, is used to control the
drawing process. The program contains the template attributes,
defined as structured constant "Attrs". This record contains
raster function, colors, marker attributes (they aren't used
in this example), fill attributes, and font pointer (NIL).
The font pointer is defined as NIL, because the language
doesn't support procedure calls within structured constants.
Hence the separate assignment statement is necessary to define
the font field as a pointer to the standard font number 0.

The program calls the procedure "ScrOut.String", which draws
the string at the center of the screen.

MODULE Example2;
  IMPORT Terminal, Strings, Geo, Res, Scr, ScrOut;
  CONST
    Text = "Hello, User!";
    Attrs =
      ScrOut.Attrs
      (
        Scr.copy,            (* --- raster function *)
        15,                  (* --- color *)
        0,                   (* --- not used *)
        ScrOut.dot,          (* --- not used *)
        0,                   (* --- not used *)
        ScrOut.fillStippled, (* --- fill style *)
        Geo.Point(0,0),      (* --- not used *)
        0,                   (* --- not used *)
        ScrOut.FONT(NIL)     (* --- pointer to font *)
      );
  VAR
    vpm: Scr.PIXMAP;
    p: Geo.Point;
    a: ScrOut.Attrs;
    font: ScrOut.FONT;
    w, h, sw, sh: CARDINAL;
    ch: CHAR;
  BEGIN
    Scr.SetMode4x640x350();
    IF Scr.InitGraph() = Res.done THEN
      vpm := Scr.PagePixmap();
      font := ScrOut.StdFont(0);
      ScrOut.Dims(font, sw, sh);
      Scr.Dims(w, h);
      p.ix := (w - Strings.Length(Text) * sw) DIV 2;
      p.iy := (h - sh) DIV 2;
      a := Attrs;
      a.font := font;
      ScrOut.String(vpm, a, p, Text);
      Terminal.Read(ch);
      Scr.TermGraph();
    ELSE
      Terminal.WriteString("Invalid Hardware!");
    END;
  END Example2.

To understand other features of attributes you may execute
some experiments. You may change colors, the fill style and
raster operation. To see effects of these changes more clearly
we recommend you to fill the screen by some non-zero color
before the call "ScrOut.String". The procedure "Scr.Clear"
is the simplest way of screen filling.

Chapter 3. HOW TO CREATE A WINDOW


The third example program creates and shows a window. The
window is defined by its attributes record, which contains the
window position (coordinates of its top left corner), window
dimensions and attributes of window frame and title. The window
frame attributes record contains the description of window
frame. The window title attributes record contains the
description of window title, in particular some text. All these
attributes are defined as structured constants "TitleAttrs",
"FrameAttrs" and "Attrs". Some fields in these constants are
initialized at run time, because they are calculated according
to screen dimensions and so on.

Window manager must be initialized before use with the aid of
"Win.Init" procedure, and must be terminated after use with the
aid of "Win.Term" procedure. The procedure "Win.New" creates
the hidden window, and the procedure "Win.Show" shows it on the
screen.

MODULE Example3;
  IMPORT Terminal, Geo, Res, Scr, ScrOut, Win;
  CONST
    FrameAttrs =
      Win.FrameAttrs
      (
        Win.frameText,       (* --- frame style *)
        Win.DoubleFrame,     (* --- frame characters *)
        0,                   (* --- foreground color *)
        15                   (* --- background color *)
      );
    TitleAttrs =
      Win.TitleAttrs
      (
        Win.titleText,       (* --- title style *)
        "This is a window!", (* --- title text *)
        0,                   (* --- foreground color *)
        15,                  (* --- background color *)
        ScrOut.FONT(NIL),    (* --- pointer to font *)
        2                    (* --- title/frame gap *)
      );
    Attrs =
      Win.Attrs
      (
        Geo.Point(0, 0),     (* --- base point *)
        0,                   (* --- width *)
        0,                   (* --- height *)
        FrameAttrs,          (* --- frame attributes *)
        TitleAttrs           (* --- title attributes *)
      );
  VAR
    u: Win.WINDOW;
    a: Win.Attrs;
    s: Res.Status;
    font: ScrOut.FONT;
    w, h: CARDINAL;
    ch: CHAR;
  BEGIN
    Scr.SetMode4x640x350();
    IF Scr.InitGraph() = Res.done THEN
      Scr.Dims(w, h);
      a := Attrs;
      a.basePt.ix := w DIV 4;
      a.basePt.iy := h DIV 4;
      a.wdt := w DIV 2;
      a.hgt := h DIV 2;
      font := ScrOut.StdFont(0);
      a.titleAttrs.titleFont := font;
      Win.Init();
      s := Win.New(a, u);
      s := Win.Show(u);
      Terminal.Read(ch);
      s := Win.Dispose(u);
      Win.Term();
      Scr.TermGraph();
    ELSE
      Terminal.WriteString("Invalid Hardware!");
    END;
  END Example3.

You may do some experiments with window, frame and title
attributes. Try other procedures from window manager, for
example, "Win.Move", "Win.Resize" and "Win.Hide".

Chapter 4. HOW TO CREATE A RUNNING LINE


The fourth example program demonstrates the special kind of
dialogue plex, which can be used to visualize long texts within
a narrow window. However, this program outputs short string
"Hello, User!" repeatedly.

The dialogue plex is a complex abstraction, which is used for
constructing of feasible interactive interfaces. Plex is
described by a text description in some simple language (see
the file DLG.DEF). Plex consists of a set of numbered boxes.
Box has parameters and items, and may be visualized as window.
Item has item name, item key and parameters. Item can contain
an information field, defined by underbars.

Our example program contains plex description string, named
"PlexDescription". This string defines a single box, that has
parameters (RunLine, Centered) and number 0. It means, that the
box is running line, centered at the screen. The box description
contains a short text, which will be visualized.

The plex attributes record contains some fields, controlling
the running line visualization. The window width in this case is
defined by a number of visible characters, and the window height
is equal to the character height plus corresponding vertical gaps.
This example program defines the number of visible characters to
be equal to zero; it makes the window width to be equal to the
screen width. The running step is a distance (in pixels) to shift
the line to the left at one call of "Dlg.Show".

Text colors define the black foreground characters on white
background. Frame and title window attributes define empty frame
and title.

The procedure "Dlg.New" creates the hidden running line window.
The procedure "Dlg.Show" shows the window and shifts its contents
to the left.

MODULE Example4;
  IMPORT
    Terminal, IO, Res, Scr, ScrOut, Win, Dlg;
  CONST
    EOL = 15C + 12C;
    PlexDescription =
      "#Box RunLine Centered 0" + EOL +
      "Hello, User! " + EOL +
      "#End";
    FrameAttrs =
      Win.FrameAttrs
      (
        Win.frameEmpty,      (* --- frame style *)
        "",                  (* --- not used *)
        0,                   (* --- not used *)
        0                    (* --- not used *)
      );
    TitleAttrs =
      Win.TitleAttrs
      (
        Win.titleEmpty,      (* --- title style *)
        "",                  (* --- not used *)
        0,                   (* --- not used *)
        0,                   (* --- not used *)
        ScrOut.FONT(NIL),    (* --- not used *)
        0                    (* --- not used *)
      );
    PlexAttrs =
      Dlg.Attrs
      (
        ScrOut.FONT(NIL),    (* --- pointer to font *)
        0,                   (* --- text color *)
        0,                   (* --- not used *)
        15,                  (* --- background color *)
        FrameAttrs,          (* --- frame attributes *)
        TitleAttrs,          (* --- title attributes *)
        0,                   (* --- left gap *)
        0,                   (* --- right gap *)
        5,                   (* --- top gap *)
        5,                   (* --- bottom gap *)
        0,                   (* --- means full screen width *)
        1                    (* --- step for running line *)
      );
  VAR
    x: Dlg.PLEX;
    a: Dlg.Attrs;
    e: Dlg.ErrParams;
    s: Res.Status;
    font: ScrOut.FONT;
    ch: CHAR;
  BEGIN
    Scr.SetMode4x640x350();
    IF Scr.InitGraph() = Res.done THEN
      a := PlexAttrs;
      font := ScrOut.StdFont(0);
      a.font := font;
      Win.Init();
      s := Dlg.New(PlexDescription, a, e, x);
      REPEAT s := Dlg.Show(x, 0) UNTIL IO.KeyPressed();
      Terminal.Read(ch);
      Dlg.Dispose(x);
      Win.Term();
      Scr.TermGraph();
    ELSE
      Terminal.WriteString("Invalid Hardware!");
    END;
  END Example4.
 
You may try other running texts, other window widths and other
colors. Exercise: combine the running line with the moving
window!

Chapter 5. HOW TO SHOW DATA


The fifth example program permits to visualize some important
features of the current graphics mode with the aid of dialogue
plex and interface procedures, corresponding to it.

Our example program contains plex description string, named
"PlexDescription". This string defines a single box, that has
parameters (Vertical, Centered) and number 0. It means,
that the box is similar to vertical menu, centered at the
screen. The box contains eight view items, and each item has
item name, item key and information field. Item names are drawn
within the box window as menu lines. Information fields (defined
by underbars) and item keys are used by interface procedure to
output some data.

Plex attributes record contains three colors - first color for
normal text (which isn't used in this example), second one for
item text, and third for background. Other four CARDINAL fields
are used to define gaps (in pixels) between texts and window
sides. Plex attributes in this example define double window
frame and empty window title. All the gaps are equal to 10.

The procedure "Dlg.New" creates the plex according to its
text description and attributes. The procedure "Dlg.Show"
shows the zero-numbered (and single) box of this plex. The
procedure "DlgInp.Show" scans items of this box and for each
item calls the interface procedure "Init", which fills the
corresponding information field with some data.

Let's look at the code of interface procedure Init. This
procedure is called by the procedure "DlgInp.Show", which
assigns two values to its two parameters. The meaning of these
parameters is extremely important to understand the functioning
of interface procedure. The first parameter is a pointer to
window, containing the current box, and the second parameter is
an item key, corresponding to the current item. Before the call
of interface procedure the calling procedure "DlgInp.Show"
sets the window viewport in the current box, which can be used
by interface procedure to position its output correctly.

MODULE Example5;
  IMPORT
    Terminal, Str, Geo, Res,
    Scr, ScrOut, Win, WinOut, Dlg, DlgInp;
  CONST
    EOL = 15C + 12C;
    PlexDescription =
      "#Box  Vertical Centered         0" + EOL +
      "#Item {Screen width  ____} View 1" + EOL +
      "#Item {Screen height ____} View 2" + EOL +
      "#Item {Page height   ____} View 3" + EOL +
      "#Item {Colors        ____} View 4" + EOL +
      "#Item {Palettes      ____} View 5" + EOL +
      "#Item {Red shades    ____} View 6" + EOL +
      "#Item {Green shades  ____} View 7" + EOL +
      "#Item {Blue shades   ____} View 8" + EOL +
      "#End";
    TextAttrs =
      ScrOut.Attrs
      (
        Scr.copy,            (* --- raster function *)
        10,                  (* --- color *)
        0,                   (* --- not used *)
        ScrOut.dot,          (* --- not used *)
        0,                   (* --- not used *)
        ScrOut.fillStippled, (* --- fill style *)
        Geo.Point(0,0),      (* --- not used *)
        0,                   (* --- not used *)
        ScrOut.FONT(NIL)     (* --- pointer to font *)
      );
    FrameAttrs =
      Win.FrameAttrs
      (
        Win.frameText,       (* --- frame style *)
        Win.DoubleFrame,     (* --- double frame *)
        15,                  (* --- foreground color *)
        0                    (* --- background color *)
      );
    TitleAttrs =
      Win.TitleAttrs
      (
        Win.titleEmpty,      (* --- title style *)
        "",                  (* --- not used *)
        0,                   (* --- not used *)
        0,                   (* --- not used *)
        ScrOut.FONT(NIL),    (* --- not used *)
        0                    (* --- not used *)
      );
    PlexAttrs =
      Dlg.Attrs
      (
        ScrOut.FONT(NIL),    (* --- pointer to font *)
        0,                   (* --- not used *)
        15,                  (* --- item color *)
        0,                   (* --- background color *)
        FrameAttrs,          (* --- frame attributes *)
        TitleAttrs,          (* --- title attributes *)
        10,                  (* --- left gap *)
        10,                  (* --- right gap *)
        10,                  (* --- top gap *)
        10,                  (* --- bottom gap *)
        0,                   (* --- not used *)
        0                    (* --- not used *)
      );
  VAR
    x: Dlg.PLEX;
    a: Dlg.Attrs;
    e: Dlg.ErrParams;
    s: Res.Status;
    font: ScrOut.FONT;
    ch: CHAR;
  PROCEDURE Data(key: CARDINAL): CARDINAL;
    VAR
      w, h: CARDINAL;
    BEGIN
      CASE key OF
      | 1: Scr.Dims(w, h); RETURN w;
      | 2: Scr.Dims(w, h); RETURN h;
      | 3: Scr.Dims(w, h); RETURN h + Scr.PageOrgsNmb() - 1;
      | 4: RETURN VAL(CARDINAL, Scr.ColorsNmb());
      | 5: RETURN Scr.PalettesNmb();
      | 6: RETURN Scr.PaletteShadesNmb(Scr.red);
      | 7: RETURN Scr.PaletteShadesNmb(Scr.green);
      | 8: RETURN Scr.PaletteShadesNmb(Scr.blue);
      END;
    END Data;
  PROCEDURE Init(u: Win.WINDOW; key: CARDINAL);
    VAR
      ok: BOOLEAN;
      str: ARRAY [0 .. 16] OF CHAR;
      attrs: ScrOut.Attrs;
      p: Geo.Point;
      v: Scr.View;
    BEGIN
      Str.CardToStr(VAL(LONGCARD, Data(key)), str, 10, ok);
      Win.Viewport(u, v);
      Geo.RectBasePt(v.port, p);
      attrs := TextAttrs;
      attrs.font := font;
      WinOut.String(u, attrs, p, str);
    END Init;
  BEGIN
    Scr.SetMode4x640x350();
    IF Scr.InitGraph() = Res.done THEN
      font := ScrOut.StdFont(0);
      a := PlexAttrs;
      a.font := font;
      Win.Init();
      s := Dlg.New(PlexDescription, a, e, x);
      s := Dlg.Show(x, 0);
      s := DlgInp.Show(x, 0, Init);
      Terminal.Read(ch);
      Dlg.Dispose(x);
      Win.Term();
      Scr.TermGraph();
    ELSE
      Terminal.WriteString("Invalid Hardware!");
    END;
  END Example5.

This program is a very wide field for experiments. Try slightly
different plex descriptions, slightly different interface
procedures. Be careful. If the plex description is invalid, the
procedure "Dlg.New" returns the corresponding error status,
and the variable "e:Dlg.ErrParams" contains data, sufficient
to locate the wrong substring in the plex description.

Chapter 6. HOW TO CREATE AN INTERFACE


The sixth example program demonstrates the architecture of
simple program, using a plex for the interface design. This
program draws the blue ellipse at the center of the screen,
outputs vertical menu with six items and permits user to
enlarge or diminish intensities of color shades with the aid
of this menu.

The plex description is analogues to one from the previous
example, but it has no information fields and all the items
have type "Call". This type is associated with items, which are
used for the active interface.

The plex attributes record is analogues to attributes records
from the previous example.

The interface attribute record is new. This record is used by
the procedure "DlgInp.Act" to define additional data for
interface control. There are cursor attributes, and shifts,
stack depth and hide flag for hierarchical menus. As our menu
has only single level, the last four fields may have any
values.

The procedure "ScrOut.FillElllipse" draws the filled ellipse
at the center of the screen. Then the procedure "Dlg.New" creates
the plex according to its text description and attributes.
Then the procedure "DlgInp.Act" activates the interface,
entering it via the box number 0, and using the interface
attributes record "FaceAttrs" and four interface procedures
"Init", "Call", "Wait" and "DlgInp.Get".

These four interface procedures define the dynamic behaviour
of the interface, and they must be supplied by user.

The procedure "Init" has precisely the same functionality, as
the procedure "Init" from the previous example. Because the box
has no information fields, this procedure is empty.

The procedure "DlgInp.Get" transalates key pressings and mouse
moves into device-independent actions, defined within the
definition module DLGINP.DEF. Actions are used to transfer from
one box to another, or from one item to another within the box,
or to call the interface procedure "Call". User may write
his/her own translating procedure. The procedure has one
procedural parameter, which must be a waiting procedure, and
returns an action.

The parameterless waiting procedure "Wait" is called at leaser
time, when user don't press keys or don't move a mouse. This
procedure is empty in our example.

The procedure "Call" is called by the procedure "DlgInp.Act",
when the latter receives the action "DlgInp.enter". The
procedure "Call" receives two values via its two parameters.
The first parameter is a pointer to window, containing the
current box, and the second parameter is an item key,
corresponding to the current item. The first parameter isn't
used in our example, but the second parameter is used to
determine, what shade (red, green, blue) must be incremented
or decremented.

MODULE Example6;
  IMPORT
    Terminal, Geo, Res,
    Scr, ScrOut, ScrOut, Win, Dlg, DlgInp;
  CONST
    EllipseColor = 1;
    EOL = 15C + 12C;
    PlexDescription =
      "#Box  Vertical Centered      0" + EOL +
      "#Item {Red   +}         Call 0" + EOL +
      "#Item {Red   -}         Call 1" + EOL +
      "#Item {Green +}         Call 2" + EOL +
      "#Item {Green -}         Call 3" + EOL +
      "#Item {Blue  +}         Call 4" + EOL +
      "#Item {Blue  -}         Call 5" + EOL +
      "#End";
    EllipseAttrs =
      ScrOut.Attrs
      (
        Scr.copy,            (* --- raster function *)
        EllipseColor,        (* --- color *)
        0,                   (* --- not used *)
        ScrOut.dot,          (* --- not used *)
        0,                   (* --- not used *)
        ScrOut.fillSolid,    (* --- fill style *)
        Geo.Point(0,0),      (* --- not used *)
        0,                   (* --- not used *)
        ScrOut.FONT(NIL)     (* --- not used *)
      );
    FrameAttrs =
      Win.FrameAttrs
      (
        Win.frameText,       (* --- frame style *)
        Win.DoubleFrame,     (* --- double frame *)
        15,                  (* --- foreground color *)
        0                    (* --- background color *)
      );
    TitleAttrs =
      Win.TitleAttrs
      (
        Win.titleEmpty,      (* --- title style *)
        "",                  (* --- not used *)
        0,                   (* --- not used *)
        0,                   (* --- not used *)
        ScrOut.FONT(NIL),    (* --- not used *)
        0                    (* --- not used *)
      );
    PlexAttrs =
      Dlg.Attrs
      (
        ScrOut.FONT(NIL),    (* --- pointer to font *)
        0,                   (* --- text color *)
        15,                  (* --- item color *)
        0,                   (* --- background color *)
        FrameAttrs,          (* --- frame attributes *)
        TitleAttrs,          (* --- title attributes *)
        10,                  (* --- left gap *)
        10,                  (* --- right gap *)
        10,                  (* --- top gap *)
        10,                  (* --- bottom gap *)
        0,                   (* --- not used *)
        0                    (* --- not used *)
      );
    FaceAttrs =
      DlgInp.Attrs
      (
        2,                   (* --- cursor color *)
        0,                   (* --- not used *)
        0,                   (* --- not used *)
        1,                   (* --- interface depth *)
        FALSE                (* --- not used *)
      );
  VAR
    x: Dlg.PLEX;
    a: Dlg.Attrs;
    e: Dlg.ErrParams;
    i: DlgInp.Attrs;
    center: Geo.Point;
    font: ScrOut.FONT;
    vpm: Scr.PIXMAP;
    w, h: CARDINAL;
    s: Res.Status;
  PROCEDURE Wait(); BEGIN END Wait;
  PROCEDURE Init(u: Win.WINDOW; key: CARDINAL); BEGIN END Init;
  PROCEDURE Call(u: Win.WINDOW; key: CARDINAL);
    CONST
      MaxShades = 256;
    VAR
      p: Scr.PureColor;
      sh, shInc: CARDINAL;
    BEGIN
      p := VAL(Scr.PureColor, key DIV 2);
      sh := Scr.PaletteShade(0, EllipseColor, p);
      shInc := MaxShades DIV Scr.PaletteShadesNmb(p);
      IF ODD(key) THEN
        IF sh >= shInc THEN DEC(sh, shInc) END;
      ELSE
        IF sh < MaxShades - shInc THEN INC(sh, shInc) END;
      END;
      Scr.SetPaletteShade(0, EllipseColor, p, sh);
    END Call;
  BEGIN
    Scr.SetMode4x640x350();
    IF Scr.InitGraph() = Res.done THEN
      font := ScrOut.StdFont(0);
      a := PlexAttrs;
      a.font := font;
      Win.Init();
      vpm := Scr.PagePixmap();
      Scr.Dims(w, h);
      center.ix := w DIV 2;
      center.iy := h DIV 2;
      ScrOut.FillEllipse(vpm, EllipseAttrs, center, w DIV 3, h DIV 3);
      s := Dlg.New(PlexDescription, a, e, x);
      i := FaceAttrs;
      s := DlgInp.Act(x, 0, i, Init, Call, Wait, DlgInp.Get);
      Dlg.Dispose(x);
      Win.Term();
      Scr.TermGraph();
    ELSE
      Terminal.WriteString("Invalid Hardware!");
    END;
  END Example6.

This program is a widest field for experiments! And exercise
(sorry to say, not so simple): try to define another plex so,
that it could show current values of color shades. Some help:
use information fields and interface procedure "Init" from the
previous example.

Chapter 7. DEMONSTRATION PROGRAMS


The MultiGraph-2 Library package contains two demonstration
programs in source form. The program SCRDEMO.MOD demonstrates the
screen level of the library. The program WINDEMO.MOD shows the
window level.

To run any demo you should type in the command "scrdemo" or
"windemo" and press "Enter". You'll see the menu of graphics modes,
supported by this demo. Press the letter of the desired mode and
see the demo.

The screen level demonstration program IS AUTOMATIC: it will show
functions of the library in the loop. Each function works during
approximately five seconds. You may press any key to jump to the
next function or hit "Escape" for exit.

The window level demonstration program is a bit more complicated -
it ENTERS AUTOMATIC MODE provided that You don't press any keys. If
you hit some key, the program ENTERS MANUAL MODE. Menu and running
line will be shown on top and bottom edges of the screen. You can
traverse this menu by arrows, select the function by "Enter" and
leave the current sub-menu by "Escape". Before run input/output
functions You must open at least one window. To open the window you
must select the item "Open" from sub-menu "Window" and then define
the window rectangle (for control keys see the submenu "Help"). If
some windows are already opened, each input/output function
primarily requests the window to use. You must select this window
by the crosshair cursor (for control keys see the submenu "Help").
Each output function works during approximately five seconds. You
may hit any key for exit from the current function. To exit from
the program you should select "Exit" from the main menu.
