/*********************************************/
/*                                           */
/*       Designer (C) Ian OConnor 1993       */
/*                                           */
/*      Designer Produced C include file     */
/*                                           */
/*********************************************/

#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/screens.h>
#include <intuition/intuition.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <graphics/gfxbase.h>
#include <workbench/workbench.h>
#include <clib/exec_protos.h>
#include <clib/wb_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/utility_protos.h>
#include <string.h>

#include "aboutwin.h"


struct IntuiText Win0Texts[] =
	{
	1, 3, JAM1, 5, 3, &topaz8165, (UBYTE *)"DualTone MultiFrequency V2.2", &Win0Texts[1],
	2, 3, JAM1, 57, 20, &topaz81281, (UBYTE *)"Ecrit par Alain Bonnefoy", &Win0Texts[2],
	2, 3, JAM1, 57, 32, &topaz81281, (UBYTE *)"6, Allée Vincent Scotto", &Win0Texts[3],
	2, 3, JAM1, 57, 44, &topaz81281, (UBYTE *)"26000 VALENCE", &Win0Texts[4],
	2, 3, JAM1, 58, 55, &topaz81281, (UBYTE *)"FRANCE", &Win0Texts[5],
	1, 3, JAM1, 6, 68, &topaz81281, (UBYTE *)"Merci à:", &Win0Texts[6],
	1, 3, JAM1, 19, 79, &topaz81281, (UBYTE *)"Electronique RadioPlans", &Win0Texts[7],
	1, 3, JAM1, 38, 89, &topaz81281, (UBYTE *)"pour les tonalités", &Win0Texts[8],
	1, 3, JAM1, 18, 101, &topaz81281, (UBYTE *)"Ian OConnor pour Designer", &Win0Texts[9],
	1, 3, JAM1, 19, 113, &topaz81281, (UBYTE *)"Mattew Dillon pour Dice", &Win0Texts[10],
	1, 3, JAM1, 19, 125, &topaz81281, (UBYTE *)"Philippe Le Molaire", &Win0Texts[11],
	1, 3, JAM1, 40, 136, &topaz81281, (UBYTE *)"Pour son idée sur la", &Win0Texts[12],
	1, 3, JAM1, 40, 146, &topaz81281, (UBYTE *)"génération des tonalités", NULL
	};

struct Window *Win0 = NULL;
APTR Win0VisualInfo;

struct TextAttr topaz8165 = { (STRPTR)"topaz.font", 8, 1, 65 };
struct TextAttr topaz81281 = { (STRPTR)"topaz", 8, 128, 1 };

void RendWindowWin0( struct Window *Win, void *vi )
{
UWORD offx = Win->BorderLeft;
UWORD offy = Win->BorderTop;
if (Win != NULL) 
	{
	for( int loop=0;loop<13;loop++)
	if (Win0Texts[loop].ITextFont==NULL)
		Win0Texts[loop].ITextFont=Win->WScreen->Font;
	PrintIText( Win->RPort, Win0Texts, offx, offy);
	}
}

int OpenWindowWin0( struct Screen *Scr)
{
UWORD offx, offy;
if (Win0 == NULL)
	{
	offx = Scr->WBorLeft;
	offy = Scr->WBorTop + Scr->Font->ta_YSize+1;
	if (NULL != ( Win0VisualInfo = GetVisualInfoA( Scr, NULL)))
		{
		if (NULL != (Win0 = OpenWindowTags( NULL, WA_Left, 300,
						WA_Top, 20,
						WA_Width, 241+offx,
						WA_Height, 161+offy,
						WA_Title, "A propos de DTMF...",
						WA_MinWidth, 150,
						WA_MinHeight, 25,
						WA_MaxWidth, 1200,
						WA_MaxHeight, 1200,
						WA_DragBar, TRUE,
						WA_CloseGadget, TRUE,
						WA_Activate, TRUE,
						WA_SmartRefresh, TRUE,
						WA_AutoAdjust, TRUE,
						WA_IDCMP,580,
						TAG_END)))
			{
			RendWindowWin0(Win0, Win0VisualInfo );
			return( 0L );
			}
		}
	}
else
	{
	WindowToFront(Win0);
	ActivateWindow(Win0);
	return( 0L );
	}
return( 1L );
}

void CloseWindowWin0( void )
{
if (Win0 != NULL)
	{
	CloseWindow( Win0);
	Win0 = NULL;
	FreeVisualInfo( Win0VisualInfo);
	}
}

void StripIntuiMessages( struct MsgPort *mp, struct Window *win)
{
struct IntuiMessage *msg;
struct Node *succ;
msg = (struct IntuiMessage *)mp->mp_MsgList.lh_Head;
while (succ = msg->ExecMessage.mn_Node.ln_Succ)
	{
	if (msg->IDCMPWindow == win)
		{
		Remove(msg);
		ReplyMsg(msg);
		}
	msg = (struct IntuiMessage *)succ;
	}
}

void CloseWindowSafely( struct Window *win)
{
	Forbid();
	StripIntuiMessages( win->UserPort, win);
	win->UserPort = NULL;
	ModifyIDCMP( win, 0L);
	Permit();
	CloseWindow( win);
}

