MODULE SmartWindow;

(** ------------------------------------------------------------------

            Commodore Amiga smart window demonstration module

      (c) Copyright 1986 Modula-2 Software Ltd.  All Rights Reserved
      (c) Copyright 1986 TDI Software, Inc.      All Rights Reserved

    ------------------------------------------------------------------ **)


(* VERSION FOR COMMODORE AMIGA

     Original Author : Paul Curtis, Modula-2 Software Ltd.  02-Jun-86

     Version         : 0.00a  02-Jun-86  Paul Curtis, Modula-2 Software Ltd.
                         Original from Intuition Manual.

  *)


FROM SYSTEM IMPORT NULL, ADR, BYTE;
FROM Libraries IMPORT OpenLibrary, CloseLibrary;
FROM Intuition IMPORT NewWindow, WindowPtr, IntuitionBase, IntuitionName,
  ScreenFlagSet, ScreenFlags, WindowFlagSet, WindowFlags, IDCMPFlagSet,
  IDCMPFlags, SmartRefresh;
FROM Windows IMPORT OpenWindow, CloseWindow;
FROM Tasks IMPORT Wait, SIGNAL, SignalSet;

VAR window: WindowPtr;
  newWindow: NewWindow;
  title: ARRAY [0..20] OF CHAR;
  signal: SignalSet;
  i: CARDINAL;

BEGIN
  title := "Modula-2/Amiga Window";
  IntuitionBase := OpenLibrary(IntuitionName,0);
  IF IntuitionBase # NULL THEN
    WITH newWindow DO
      LeftEdge := 20;
      TopEdge := 20;
      Width := 300;
      Height := 100;
      DetailPen := BYTE(0);
      BlockPen := BYTE(1);
      Title := ADR(title);
      Flags := WindowFlagSet{WindowClose,Activate} + SmartRefresh;
      IDCMPFlags := IDCMPFlagSet{CloseWindowFlag};
      Type := ScreenFlagSet{WBenchScreen};
      FirstGadget := NULL;
      CheckMark := NULL;
      Screen := NULL;
      BitMap := NULL;
      MinWidth := 0;
      MinHeight := 0;
      MaxWidth := 0;
      MaxHeight := 0;
    END;
    window := OpenWindow(newWindow);
    IF window # NULL THEN
      signal := SignalSet{};
      INCL(signal,SIGNAL(window^.UserPort^.mpSigBit));
      signal := Wait(signal);
      CloseWindow(window)
    END;
    CloseLibrary(IntuitionBase);
  END
END SmartWindow.
