home *** CD-ROM | disk | FTP | other *** search
- (***************************************************************************
-
- $RCSfile: EasyIntuition37.mod $
- Description: A port of easyintuition37.c from the RKM:Libraries, Ch 2.
- "easyintuition37.c -- Simple Intuition program for V37"
- "(Release 2) and later versions of the operating system."
-
- Created by: fjc (Frank Copeland)
- $Revision: 1.3 $
- $Author: fjc $
- $Date: 1994/08/08 16:55:25 $
-
- Compiler: Oberon-A
-
- Log entries are at the end of the file.
-
- ***************************************************************************)
-
- MODULE EasyIntuition37;
-
- (*
- ** $C= CaseChk $I= IndexChk $L= LongAdr $N= NilChk
- ** $P- PortableCode $R= RangeChk $S= StackChk $T= TypeChk
- ** $V= OvflChk $Z= ZeroVars
- *)
-
- IMPORT
- E := Exec, U := Utility, D := Dos, G := Graphics, I := Intuition,
- SYS := SYSTEM;
-
- CONST
-
- (* Position and sizes for our window *)
-
- winLeftEdge = 20;
- winTopEdge = 20;
- winWidth = 400;
- winMinWidth = 80;
- winHeight = 150;
- winMinHeight = 20;
-
- (*------------------------------------*)
- PROCEDURE cleanExit (scrn : I.ScreenPtr; wind : I.WindowPtr);
-
- BEGIN (* cleanExit *)
- (* Close things in the reverse order of opening *)
- IF wind # NIL THEN I.base.CloseWindow (wind) END;
- IF scrn # NIL THEN IF I.base.CloseScreen (scrn) THEN END END;
- END cleanExit;
-
- (*------------------------------------*)
- PROCEDURE handleIDCMP (win : I.WindowPtr) : BOOLEAN;
-
- VAR
- done : BOOLEAN;
- message : I.IntuiMessagePtr;
- class : SET;
-
- BEGIN (* handleIDCMP *)
- done := FALSE; message := NIL;
- (* Examine pending messages *)
- LOOP
- message := SYS.VAL (I.IntuiMessagePtr, E.base.GetMsg (win.userPort));
- IF message = NIL THEN EXIT END;
- class := message.class; (* get all the data we need from message *)
-
- (* When we're through with a message, reply *)
- E.base.ReplyMsg (message);
-
- (* See what events occurred *)
- IF I.idcmpCloseWindow IN class THEN done := TRUE END;
- END; (* LOOP *)
- RETURN done
- END handleIDCMP;
-
- (*------------------------------------*)
- PROCEDURE main ();
-
- VAR
- signalmask, signals : SET;
- winsignal : SHORTINT;
- done : BOOLEAN;
- pens : ARRAY 1 OF E.UWORD;
- screen1 : I.ScreenPtr;
- window1 : I.WindowPtr;
- tags : ARRAY 19 OF U.TagItem;
-
- BEGIN (* main *)
- done := FALSE; pens [0] := -1; (* ~0 *)
- screen1 := NIL; window1 := NIL;
-
- (* Open the screen *)
- screen1 :=
- I.base.OpenScreenTagsA (
- NIL,
- I.saPens, SYS.ADR (pens),
- I.saDisplayID, G.hiresKey,
- I.saDepth, 2,
- I.saTitle, SYS.ADR ("Our Screen"),
- U.tagDone );
- IF screen1 = NIL THEN cleanExit (screen1, window1); HALT (D.returnWarn) END;
-
- (* ... and open the window *)
- window1 :=
- I.base.OpenWindowTagsA (
- NIL,
- (* Specify window dimensions and limits *)
-
- I.waLeft, winLeftEdge,
- I.waTop, winTopEdge,
- I.waWidth, winWidth,
- I.waHeight, winHeight,
- I.waMinWidth, winMinWidth,
- I.waMinHeight, winMinHeight,
- I.waMaxWidth, -1, (* ~0 *)
- I.waMaxHeight, -1, (* ~0 *)
-
- (* Specify the system gadgets we want *)
-
- I.waCloseGadget, E.LTRUE,
- I.waSizeGadget, E.LTRUE,
- I.waDepthGadget, E.LTRUE,
- I.waDragBar, E.LTRUE,
-
- (* Specify other attributes *)
-
- I.waActivate, E.LTRUE,
- I.waNoCareRefresh, E.LTRUE,
-
- (* Specify the events we want to know about *)
-
- I.waIDCMP, {I.idcmpCloseWindow},
-
- (* Attach the window to the open screen *)
-
- I.waCustomScreen, screen1,
- I.waTitle, SYS.ADR ("EasyWindow"),
- I.waScreenTitle, SYS.ADR ("Our Screen - EasyWindow is Active"),
-
- U.tagDone );
- IF window1 = NIL THEN cleanExit (screen1, window1); HALT (D.returnWarn) END;
-
- (* Set up the signals for the events we want to hear about ... *)
- winsignal := window1.userPort.sigBit;
- signalmask := {winsignal}; (* we are only waiting on IDCMP events. *)
-
- (* Here's the main input event loop where we wait for events. *)
- (* We have asked Intuition to send us CLOSEWINDOW IDCMP events *)
- (* Exec will wake us if any event we are waiting for occurs. *)
- WHILE ~done DO
- signals := E.base.Wait (signalmask);
- (* An event occurred - now act on the signal(s) we received. *)
- (* We were only waiting on one signal (winsignal) in our *)
- (* signalmask, so we actually know we received winsignal. *)
- IF winsignal IN signals THEN
- done := handleIDCMP (window1)
- END; (* IF *)
- END; (* WHILE *)
- cleanExit (screen1, window1); HALT (D.returnOk); (* Exit the program *)
- END main;
-
- BEGIN (* EasyIntuition37 *)
- main ();
- END EasyIntuition37.
-
- (***************************************************************************
-
- $Log: EasyIntuition37.mod $
- Revision 1.3 1994/08/08 16:55:25 fjc
- Release 1.4
-
- Revision 1.2 1994/06/14 00:58:29 fjc
- - Updated for release
-
- Revision 1.1 1994/01/24 12:30:40 fjc
- - Initial revision
-
- ***************************************************************************)
-
-