#include <exec/types.h>
#include <exec/exec.h>
#include <intuition/intuition.h>
#include <graphics/gfxbase.h>
#include <graphics/gfx.h>
#include <graphics/gfxmacros.h>

/********************************************
 *  PrettyWindows v1.0   by Thom Robertson  *
 ********************************************/

extern struct IntuitionBase *IntuitionBase;
extern struct GfxBase *GfxBase;

main() {

struct Window *win1,*win2,*win3;
int i;

char text[7][50] = {
{"This demo shows the usage of"},
{"PrettyWindows V1.0   by Thom Robertson"},
{"PrettyWindows is a set of 3 routines"},
{"which liven up your text windows."},
{"PrettyWindows is freely redistributable"},
{"code, written in LATTICE C 5.04 ."},
{"Press a key or click on this window"},
};


win1 = 0;
win2 = 0;
win3 = 0;
IntuitionBase = 0;
GfxBase = 0;

IntuitionBase = (struct IntuitionBase *) OpenLibrary(
                "intuition.library",0);
if (IntuitionBase == NULL) {
   printf("intuition won't open!\n");
   goto end;
   }

GfxBase = (struct GfxBase *) OpenLibrary("graphics.library",0);
if (GfxBase == NULL)  {
   printf("graph.lib. won't open!\n");
   goto end;
   }


/* do first window */

win1 = makewindow(0,20,20,600,160);
if (win1 == NULL)  {
   printf("Window 1 won't open!\n");
   goto end;
   }

prettywindow1(win1,2);

SetDrMd(win1->RPort,JAM1);
SetAPen(win1->RPort,0);

Move(win1->RPort,100,50);
Text(win1->RPort,text[0],strlen(text[0]));
Move(win1->RPort,100,80);
Text(win1->RPort,text[1],strlen(text[1]));

SetAPen(win1->RPort,1);
Move(win1->RPort,100,130);
Text(win1->RPort,text[6],strlen(text[6]));

getinput(win1);


/* do second window */

win2 = makewindow(0,10,10,450,110);
if (win2 == NULL)  {
   printf("Window 2 won't open!\n");
   goto end;
   }

prettywindow2(win2,0);

SetDrMd(win2->RPort,JAM1);
SetAPen(win2->RPort,1);

Move(win2->RPort,40,45);
Text(win2->RPort,text[2],strlen(text[2]));
Move(win2->RPort,40,60);
Text(win2->RPort,text[3],strlen(text[3]));

SetAPen(win2->RPort,3);
Move(win2->RPort,40,85);
Text(win2->RPort,text[6],strlen(text[6]));

getinput(win2);

/* do third window */

win3 = makewindow(0,150,80,450,110);
if (win3 == NULL)  {
   printf("Window 3 won't open!\n");
   goto end;
   }

prettywindow3(win3,3);

SetDrMd(win3->RPort,JAM1);
SetAPen(win3->RPort,2);

Move(win3->RPort,40,45);
Text(win3->RPort,text[4],strlen(text[4]));
Move(win3->RPort,40,60);
Text(win3->RPort,text[5],strlen(text[5]));

SetAPen(win3->RPort,1);
Move(win3->RPort,40,85);
Text(win3->RPort,text[6],strlen(text[6]));

getinput(win3);

end:

if (win1 != 0)
   CloseWindow(win1);
if (win2 != 0)
   CloseWindow(win2);
if (win3 != 0)
   CloseWindow(win3);
if (IntuitionBase != NULL)
   CloseLibrary(IntuitionBase);
if (GfxBase != NULL)
   CloseLibrary(GfxBase);



}  /* end of program */


getinput(win)
struct Window *win;
{

struct IntuiMessage *mess;
ULONG mclass;
USHORT mcode,mqual;
APTR maddr;
LONG Mx,My;

   while ((mess = GetMsg(win->UserPort))!= 0) 
      ReplyMsg(mess);

while (TRUE) {
   Wait((1<<win->UserPort->mp_SigBit));
   while ((mess = GetMsg(win->UserPort))!= 0) {

      mclass = mess->Class;
      mcode = mess->Code;
      maddr = mess->IAddress;
      mqual = mess->Qualifier;
      Mx = mess->MouseX;
      My = mess->MouseY;
      ReplyMsg(mess);

      if (mclass == RAWKEY || mclass == MOUSEBUTTONS)
         return(0); 



      }
   }


}





