#include "exec/types.h"
#include "intuition/intuition.h"

struct IntuitionBase *IntuitionBase;
struct Window *wind0, *wind1;
struct Screen *Scrn;

struct IntuiMessage *mesg;

#define INTUITION_REV 29

main()
{
 ULONG flags,mclass;
 SHORT x,y,w,h,d;
 USHORT mode;
 UBYTE *name,c0,c1;
 VOID OpenALL();
 VOID CreateMes();
 struct IntuiText prompt,yprompt,nprompt;

 OpenALL();

 
 /* ======open een hires custom-screen======*/

 name="Requests now being taken";
 y=0;
 w=640;
 h=200;
 d=3;
 c0=0x00;
 c1=0x01;
 mode=HIRES;

 Scrn=(struct Screen *)
         make_screen(y,w,h,d,c0,c1,mode,name);


 
 /* ======open window====== */

 name="Window 1";
 x=20;
 y=20;
 w=400;
 h=150;
 flags=ACTIVATE|WINDOWSIZING|WINDOWDEPTH|WINDOWDRAG|WINDOWCLOSE|SMART_REFRESH;
 c0=-0x01;
 c1=-0x01;

 wind0=(struct Window *)
         make_window(x,y,w,h,name,flags,c0,c1,Scrn,NULL);

 /* ======Build and display a requester====== */

 CreateMes(&prompt,45,25,"Stop The Music!");
 CreateMes(&yprompt,3,3,"YES");
 CreateMes(&nprompt,3,3,"NO");

 AutoRequest(wind0,&prompt,&yprompt,&nprompt,NULL,NULL,250,100);

 /* ======close de windows in volgorde====== */

 Wait(1<<wind0->UserPort->mp_SigBit);

 while((mesg=(struct IntuiMessage *)
     GetMsg(wind0->UserPort))!=NULL)
  {
   mclass=mesg->Class;
   ReplyMsg(mesg);
  }
  if(mclass==CLOSEWINDOW)
   {
     CloseWindow(wind0);
     CloseScreen(Scrn);

   }
}
 VOID OpenALL()
 {
 /* ======open Intuition====== */

 IntuitionBase=(struct IntuitionBase *)
            OpenLibrary("intuition.library",INTUITION_REV);

 if(IntuitionBase==NULL)
   exit(FALSE);
 }

 VOID CreateMes(x,left,top,mesg)
 struct IntuiText *x;
 SHORT left,top;
 UBYTE *mesg;

 {
  x->FrontPen=2;
  x->BackPen=3;
  x->DrawMode=JAM2;
  x->LeftEdge=left;
  x->TopEdge=top;
  x->ITextFont=NULL;
  x->IText=mesg;
  x->NextText=NULL;
 }
 

make_window(x,y,w,h,name,flags,color0,color1,screen,gadg)
SHORT x,y,w,h;
UBYTE *name,color0,color1;
ULONG flags;
struct Screen *screen;
struct Gadget *gadg;

{
 struct NewWindow NewWindow;

 NewWindow.LeftEdge = x;
 NewWindow.TopEdge = y;
 NewWindow.Width = w;
 NewWindow.Height = h;
 NewWindow.DetailPen = color0;
 NewWindow.BlockPen = color1;
 NewWindow.Title = name;
 NewWindow.Flags = flags;
 NewWindow.IDCMPFlags = CLOSEWINDOW;
 NewWindow.Type = CUSTOMSCREEN;
 NewWindow.FirstGadget = gadg;
 NewWindow.CheckMark = NULL;
 NewWindow.Screen = screen;
 NewWindow.BitMap = NULL;
 NewWindow.MinWidth = 1;
 NewWindow.MinHeight = 1;
 NewWindow.MaxWidth = 640;
 NewWindow.MaxHeight = 200;

 return(OpenWindow(&NewWindow));

}
make_screen(y,w,h,d,color0,color1,mode,name)
SHORT y,w,h,d;
UBYTE color0,color1,*name;
USHORT mode;
{
 struct NewScreen NewScreen;

 NewScreen.LeftEdge = 0;
 NewScreen.TopEdge = y;
 NewScreen.Width = w;
 NewScreen.Height = h;
 NewScreen.Depth = d;
 NewScreen.DetailPen = color0;
 NewScreen.BlockPen = color1;
 NewScreen.ViewModes = mode;
 NewScreen.Type = CUSTOMSCREEN;
 NewScreen.Font = NULL;
 NewScreen.DefaultTitle = name;
 NewScreen.Gadgets = NULL;
 NewScreen.CustomBitMap = NULL;

 return(OpenScreen(&NewScreen));
}



