home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / useful / dev / obero / oberon-a / examples / libraries / intuition / easyintuition37.mod < prev    next >
Encoding:
Text File  |  1994-08-08  |  5.0 KB  |  180 lines

  1. (***************************************************************************
  2.  
  3.      $RCSfile: EasyIntuition37.mod $
  4.   Description: A port of easyintuition37.c from the RKM:Libraries, Ch 2.
  5.                "easyintuition37.c -- Simple Intuition program for V37"
  6.                "(Release 2) and later versions of the operating system."
  7.  
  8.    Created by: fjc (Frank Copeland)
  9.     $Revision: 1.3 $
  10.       $Author: fjc $
  11.         $Date: 1994/08/08 16:55:25 $
  12.  
  13.      Compiler: Oberon-A
  14.  
  15.   Log entries are at the end of the file.
  16.  
  17. ***************************************************************************)
  18.  
  19. MODULE EasyIntuition37;
  20.  
  21. (*
  22. ** $C= CaseChk       $I= IndexChk  $L= LongAdr   $N= NilChk
  23. ** $P- PortableCode  $R= RangeChk  $S= StackChk  $T= TypeChk
  24. ** $V= OvflChk       $Z= ZeroVars
  25. *)
  26.  
  27. IMPORT
  28.   E := Exec, U := Utility, D := Dos, G := Graphics, I := Intuition,
  29.   SYS := SYSTEM;
  30.  
  31. CONST
  32.  
  33. (* Position and sizes for our window *)
  34.  
  35.   winLeftEdge  =  20;
  36.   winTopEdge   =  20;
  37.   winWidth     = 400;
  38.   winMinWidth  =  80;
  39.   winHeight    = 150;
  40.   winMinHeight =  20;
  41.  
  42. (*------------------------------------*)
  43. PROCEDURE cleanExit (scrn : I.ScreenPtr; wind : I.WindowPtr);
  44.  
  45. BEGIN (* cleanExit *)
  46.   (* Close things in the reverse order of opening *)
  47.   IF wind # NIL THEN I.base.CloseWindow (wind) END;
  48.   IF scrn # NIL THEN IF I.base.CloseScreen (scrn) THEN END END;
  49. END cleanExit;
  50.  
  51. (*------------------------------------*)
  52. PROCEDURE handleIDCMP (win : I.WindowPtr) : BOOLEAN;
  53.  
  54.   VAR
  55.     done    : BOOLEAN;
  56.     message : I.IntuiMessagePtr;
  57.     class   : SET;
  58.  
  59. BEGIN (* handleIDCMP *)
  60.   done := FALSE; message := NIL;
  61.   (* Examine pending messages *)
  62.   LOOP
  63.     message := SYS.VAL (I.IntuiMessagePtr, E.base.GetMsg (win.userPort));
  64.     IF message = NIL THEN EXIT END;
  65.     class := message.class; (* get all the data we need from message *)
  66.  
  67.     (* When we're through with a message, reply *)
  68.     E.base.ReplyMsg (message);
  69.  
  70.     (* See what events occurred *)
  71.     IF I.idcmpCloseWindow IN class THEN done := TRUE END;
  72.   END; (* LOOP *)
  73.   RETURN done
  74. END handleIDCMP;
  75.  
  76. (*------------------------------------*)
  77. PROCEDURE main ();
  78.  
  79.   VAR
  80.     signalmask, signals : SET;
  81.     winsignal : SHORTINT;
  82.     done      : BOOLEAN;
  83.     pens      : ARRAY 1 OF E.UWORD;
  84.     screen1   : I.ScreenPtr;
  85.     window1   : I.WindowPtr;
  86.     tags      : ARRAY 19 OF U.TagItem;
  87.  
  88. BEGIN (* main *)
  89.   done := FALSE; pens [0] := -1; (* ~0 *)
  90.   screen1 := NIL; window1 := NIL;
  91.  
  92.   (* Open the screen *)
  93.   screen1 :=
  94.     I.base.OpenScreenTagsA (
  95.       NIL,
  96.       I.saPens,      SYS.ADR (pens),
  97.       I.saDisplayID, G.hiresKey,
  98.       I.saDepth,     2,
  99.       I.saTitle,     SYS.ADR ("Our Screen"),
  100.       U.tagDone );
  101.   IF screen1 = NIL THEN cleanExit (screen1, window1); HALT (D.returnWarn) END;
  102.  
  103.   (* ... and open the window *)
  104.   window1 :=
  105.     I.base.OpenWindowTagsA (
  106.       NIL,
  107.       (* Specify window dimensions and limits *)
  108.  
  109.       I.waLeft,           winLeftEdge,
  110.       I.waTop,            winTopEdge,
  111.       I.waWidth,          winWidth,
  112.       I.waHeight,         winHeight,
  113.       I.waMinWidth,       winMinWidth,
  114.       I.waMinHeight,      winMinHeight,
  115.       I.waMaxWidth,       -1, (* ~0 *)
  116.       I.waMaxHeight,      -1, (* ~0 *)
  117.  
  118.       (* Specify the system gadgets we want *)
  119.  
  120.       I.waCloseGadget,    E.LTRUE,
  121.       I.waSizeGadget,     E.LTRUE,
  122.       I.waDepthGadget,    E.LTRUE,
  123.       I.waDragBar,        E.LTRUE,
  124.  
  125.       (* Specify other attributes *)
  126.  
  127.       I.waActivate,       E.LTRUE,
  128.       I.waNoCareRefresh,  E.LTRUE,
  129.  
  130.       (* Specify the events we want to know about *)
  131.  
  132.       I.waIDCMP,          {I.idcmpCloseWindow},
  133.  
  134.       (* Attach the window to the open screen *)
  135.  
  136.       I.waCustomScreen,   screen1,
  137.       I.waTitle,          SYS.ADR ("EasyWindow"),
  138.       I.waScreenTitle,    SYS.ADR ("Our Screen - EasyWindow is Active"),
  139.  
  140.       U.tagDone );
  141.   IF window1 = NIL THEN cleanExit (screen1, window1); HALT (D.returnWarn) END;
  142.  
  143.   (* Set up the signals for the events we want to hear about ... *)
  144.   winsignal := window1.userPort.sigBit;
  145.   signalmask := {winsignal}; (* we are only waiting on IDCMP events. *)
  146.  
  147.   (* Here's the main input event loop where we wait for events.  *)
  148.   (* We have asked Intuition to send us CLOSEWINDOW IDCMP events *)
  149.   (* Exec will wake us if any event we are waiting for occurs.   *)
  150.   WHILE ~done DO
  151.     signals := E.base.Wait (signalmask);
  152.     (* An event occurred - now act on the signal(s) we received. *)
  153.     (* We were only waiting on one signal (winsignal) in our     *)
  154.     (* signalmask, so we actually know we received winsignal.    *)
  155.     IF winsignal IN signals THEN
  156.       done := handleIDCMP (window1)
  157.     END; (* IF *)
  158.   END; (* WHILE *)
  159.   cleanExit (screen1, window1); HALT (D.returnOk); (* Exit the program *)
  160. END main;
  161.  
  162. BEGIN (* EasyIntuition37 *)
  163.   main ();
  164. END EasyIntuition37.
  165.  
  166. (***************************************************************************
  167.  
  168.   $Log: EasyIntuition37.mod $
  169.   Revision 1.3  1994/08/08  16:55:25  fjc
  170.   Release 1.4
  171.  
  172.   Revision 1.2  1994/06/14  00:58:29  fjc
  173.   - Updated for release
  174.  
  175.   Revision 1.1  1994/01/24  12:30:40  fjc
  176.   - Initial revision
  177.  
  178. ***************************************************************************)
  179.  
  180.