/***************************************************************************/
/*									   */
/* SmartIcon, release 1.0 - An Intuition object iconifier for the Amiga    */
/* Copyright (c) 1988 Gauthier H. Groult                                   */
/*									   */
/* Written in January 1988 by Gauthier H. Groult			   */
/*			      33, Boulevard Saint Denis,		   */
/*			      92400 Courbevoie				   */
/*			      France - Europe				   */
/*			      Tel: (16) 1 47 89 09 54                      */
/*			      email: mcvax!inria!litp!germinal!groult	   */
/*									   */
/* This source code is not in public domain, please do not distribute.	   */
/* The binary program is shareaware. Read docs files for details.	   */
/*									   */
/***************************************************************************/

#include <exec/types.h>
#include <intuition/intuition.h>
#include <string.h>

struct NewWindow theNewWindow =
   {
   265, 25,
   320, 170,
   0, 1,
   CLOSEWINDOW | MOUSEBUTTONS,
   WINDOWDRAG | WINDOWDEPTH | WINDOWCLOSE,
   NULL,
   NULL,
   "SmartIcon 1.0",
   NULL,
   NULL,
   0, 0,
   0, 0,
   WBENCHSCREEN
   };

extern	 VOID  Cleanup();

/* This code just opens the starting window and fill it with text.   */
/* This is straightforward, no tricks.				     */

VOID  DisplayWindow(), emit();

VOID
DisplayWindow()
{
   ULONG    class;
   struct   Window	   *theWindow;
   struct   IntuiMessage   *msg;

   theWindow = (struct Window *)OpenWindow(&theNewWindow);
   if (!theWindow)   Cleanup(30);

   SetAPen(theWindow->RPort, 1);
   SetBPen(theWindow->RPort, 1);
   SetDrMd(theWindow->RPort, JAM1);
   RectFill(theWindow->RPort, 3, 11, 316, 167);

   emit(theWindow, "SmartIcon 1.0",                         0, 20, 3, 1);
   emit(theWindow, "Copyright © 1988 Gauthier H. Groult",  15, 30, 3, 1);
   emit(theWindow, "This is a shareware program: if you",  15, 50, 2, 0);
   emit(theWindow, "decide to use it, please send $15 or", 15, 60, 2, 0);
   emit(theWindow, "100 FF to the following address:",     15, 70, 2, 0);
   emit(theWindow, "Gauthier H. Groult",                    0, 85, 2, 0);
   emit(theWindow, "33, Boulevard Saint Denis",             0, 95, 2, 0);
   emit(theWindow, "92400 Courbevoie",                      0, 105, 2, 0);
   emit(theWindow, "France - Europe",                       0, 115, 2, 0);
   emit(theWindow, "Read more about registering in the",   15, 130, 2, 0);
   emit(theWindow, "doc files along with this program.",    15, 140, 2, 0);
   emit(theWindow, "Click in this window to enjoy!",         0, 160, 3, 1);

   for(;;)
   {
   Wait(1<< theWindow->UserPort->mp_SigBit);
   while (msg = (struct IntuiMessage *)GetMsg(theWindow->UserPort))
	 {
	 class = msg->Class;
	 ReplyMsg(msg);

	 if (class == CLOSEWINDOW)
	    {
	    CloseWindow(theWindow);
	    Cleanup(0);
	    }
	 else if  (class == MOUSEBUTTONS)
		  {
		  CloseWindow(theWindow);
		  return;
		  }
	 }
   }
}

VOID
emit(window, OutText, htab, vtab, color, shadow)
struct	 Window   *window;
UBYTE	 *OutText;
USHORT	 htab, vtab, color, shadow;
{
   if (!htab)
      htab = ( window->Width -
	       TextLength(window->RPort, &OutText, strlen(OutText)) )/2;

   if (shadow)
      {
      SetAPen(window->RPort, 2);
      Move(window->RPort, htab, vtab+1);
      Text(window->RPort, OutText, strlen(OutText));
      }
   SetAPen(window->RPort, color);
   Move(window->RPort, htab, vtab);
   Text(window->RPort, OutText, strlen(OutText));
}

