home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / compiler / stjo2122 / tutorial / terminal.mod < prev    next >
Encoding:
Text File  |  1993-11-26  |  2.8 KB  |  105 lines

  1. MODULE Terminal;
  2.  
  3. IMPORT S:=SYSTEM, GemApp, Evnt, Graf, Menus, Rsrc, TermWin,
  4.        VC:=VDIControl;
  5.  
  6.  
  7. CONST
  8.     BOX        = 0; (* form/dialog *)
  9.     OK         = 4; (* BUTTON in tree BOX *)
  10.     INPUT1     = 5; (* BUTTON in tree BOX *)
  11.     OUTPUT1    = 6; (* BUTTON in tree BOX *)
  12.  
  13.     MENU       = 1; (* menu *)
  14.     DESK       = 3; (* TITLE in tree MENU *)
  15.     FILE       = 4; (* TITLE in tree MENU *)
  16.     WORK       = 5; (* TITLE in tree MENU *)
  17.     INFO       = 8; (* STRING in tree MENU *)
  18.     QUIT       = 17; (* STRING in tree MENU *)
  19.     INPUT2     = 19; (* STRING in tree MENU *)
  20.     OUTPUT2    = 20; (* STRING in tree MENU *)
  21.  
  22.     INPUTBOX   = 2; (* form/dialog *)
  23.     CIRCLE     = 2; (* BUTTON in tree INPUTBOX *)
  24.     RECT       = 3; (* BUTTON in tree INPUTBOX *)
  25.     XPOS       = 4; (* FTEXT in tree INPUTBOX *)
  26.     YPOS       = 5; (* FTEXT in tree INPUTBOX *)
  27.     RADIUS     = 6; (* FTEXT in tree INPUTBOX *)
  28.     WIDTH      = 7; (* FTEXT in tree INPUTBOX *)
  29.     HEIGHT     = 8; (* FTEXT in tree INPUTBOX *)
  30.     DRAW       = 9; (* BUTTON in tree INPUTBOX *)
  31.  
  32.  
  33. TYPE
  34.   MyApp     = POINTER TO MyAppDesc;
  35.   MyAppDesc = RECORD(GemApp.ApplDesc)
  36.               END;
  37.  
  38.  
  39. VAR i : LONGINT;
  40.     myApp : MyApp; (* type MyAppDesc cannot be used, because it won't
  41.                       have a type descriptor *)
  42.     number : INTEGER;
  43.  
  44.  
  45. PROCEDURE Exit;
  46.  BEGIN
  47.   myApp.Exit;
  48.  END Exit;
  49.  
  50.  
  51. PROCEDURE OpenOutput;
  52.   VAR terminal : TermWin.Viewer;
  53.  BEGIN
  54.   NEW(terminal); terminal.Init;
  55.   terminal.WriteString("Hello world!"); terminal.WriteLn;
  56.   terminal.WriteString("This is terminal window #");
  57.   terminal.WriteInt(number); INC(number);
  58.   terminal.WriteLn;
  59.   terminal.CursorOn;
  60.  END OpenOutput;
  61.  
  62.  
  63. PROCEDURE HandleEvent(VAR events : GemApp.Events);
  64.  BEGIN
  65.   IF TermWin.STRING IN events.events THEN
  66.     WITH events : TermWin.Events DO
  67.       events.viewer.WriteString("Received a string: ");
  68.       events.viewer.WriteString(events.string);
  69.       events.viewer.WriteLn;
  70.     END;
  71.     EXCL(events.events, TermWin.STRING);
  72.   END;
  73.  END HandleEvent;
  74.  
  75.  
  76. PROCEDURE(app: MyApp) Init;
  77.   (* initializes the application by opening a window *)
  78.   VAR menu : Menus.Menu;
  79.  BEGIN
  80.   app.Init^; (* must come first! *)
  81.   Graf.ChangeMouse( Graf.ARROW);
  82.   IF NOT Rsrc.Load("GEMDEMO.RSC") THEN
  83.     app.Exit
  84.   END;
  85.   NEW( menu); menu.Init( Rsrc.GetAddr(MENU) );
  86.   menu.Set( FILE, QUIT, Exit );
  87.   menu.Set( WORK, OUTPUT2, OpenOutput );
  88.   menu.Show;
  89.   GemApp.StoreEventHandler(HandleEvent);
  90.  END Init;
  91.  
  92.  
  93. PROCEDURE(app: MyApp) Exit;
  94.   (* closes the window. This is done automatically, but this is just
  95.      an example. The memory is also deallocated automatically *)
  96.  BEGIN
  97.   app.Exit^; (* must come last! *)
  98.  END Exit;
  99.  
  100.  
  101. BEGIN
  102.   NEW(myApp);
  103.   myApp.Init; myApp.Run; myApp.Exit
  104. END Terminal.
  105.