/*
 *  Source machine generated by GadToolsBox V2.0b
 *  which is (c) Copyright 1991-1993 Jaba Development
 *
 *  GUI Designed by : -- Unnamed --
 */

#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <clib/exec_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 "GTBoxConv.h"

struct Screen         *Scr = NULL;
UBYTE                 *PubScreenName = NULL;
APTR                   VisualInfo = NULL;
struct Window         *Project0Wnd = NULL;
struct Gadget         *Project0GList = NULL;
struct Gadget         *Project0Gadgets[13];
UWORD                  Project0Left = 128;
UWORD                  Project0Top = 24;
UWORD                  Project0Width = 410;
UWORD                  Project0Height = 179;
UBYTE                 *Project0Wdt = (UBYTE *)"GTBox Converter V - By Fabio Rotondo.";

struct TextAttr topaz8 = {
	( STRPTR )"topaz.font", 8, 0x00, 0x01 };

struct IntuiText Project0IText[] = {
	2, 0, JAM1,63, 11, &topaz8, (UBYTE *)"Actions", &Project0IText[1],
	2, 0, JAM1,256, 11, &topaz8, (UBYTE *)"Options", &Project0IText[2],
	2, 0, JAM1,138, 146, &topaz8, (UBYTE *)"MAX POSSIBLE VALUES", NULL };

UWORD Project0GTypes[] = {
	BUTTON_KIND,
	BUTTON_KIND,
	BUTTON_KIND,
	CHECKBOX_KIND,
	CHECKBOX_KIND,
	CHECKBOX_KIND,
	TEXT_KIND,
	CHECKBOX_KIND,
	INTEGER_KIND,
	INTEGER_KIND,
	INTEGER_KIND,
	INTEGER_KIND,
	INTEGER_KIND
};

struct NewGadget Project0NGad[] = {
	29, 26, 123, 17, (UBYTE *)"Convert", NULL, GD_CONVERT, PLACETEXT_IN, NULL, NULL,
	26, 92, 126, 14, (UBYTE *)"QUIT", NULL, GD_QUIT, PLACETEXT_IN, NULL, NULL,
	29, 48, 122, 17, (UBYTE *)"About", NULL, GD_ABOUT, PLACETEXT_IN, NULL, NULL,
	349, 25, 26, 11, (UBYTE *)"Add Comments", NULL, GD_Add_Comments, PLACETEXT_LEFT, NULL, NULL,
	349, 37, 26, 11, (UBYTE *)"Add Gad Handler", NULL, GD_Add_Gad_Handler, PLACETEXT_LEFT, NULL, NULL,
	349, 49, 26, 11, (UBYTE *)"Show Operations", NULL, GD_Show_Ops, PLACETEXT_LEFT, NULL, NULL,
	127, 121, 256, 12, (UBYTE *)"Operations:", NULL, GD_Operations, PLACETEXT_LEFT, NULL, NULL,
	349, 61, 26, 11, (UBYTE *)"Gads And Bevels Only", NULL, GD_Gads_And_Bevs, PLACETEXT_LEFT, NULL, NULL,
	332, 76, 43, 13, (UBYTE *)"Window Number", NULL, GD_WinNumber, PLACETEXT_LEFT, NULL, NULL,
	332, 92, 43, 13, (UBYTE *)"GTList Number", NULL, GD_GTListNumber, PLACETEXT_LEFT, NULL, NULL,
	339, 160, 47, 13, (UBYTE *)"Menu", NULL, GD_MenuMax, PLACETEXT_LEFT, NULL, NULL,
	197, 160, 47, 13, (UBYTE *)"Text", NULL, GD_TextMax, PLACETEXT_LEFT, NULL, NULL,
	70, 160, 47, 13, (UBYTE *)"Bevels", NULL, GD_BevelMax, PLACETEXT_LEFT, NULL, NULL
};

ULONG Project0GTags[] = {
	(TAG_DONE),
	(TAG_DONE),
	(TAG_DONE),
	(TAG_DONE),
	(TAG_DONE),
	(TAG_DONE),
	(GTTX_Border), TRUE, (TAG_DONE),
	(TAG_DONE),
	(GTIN_Number), 0, (GTIN_MaxChars), 2, (TAG_DONE),
	(GTIN_Number), 0, (GTIN_MaxChars), 2, (TAG_DONE),
	(GTIN_Number), 50, (GTIN_MaxChars), 4, (TAG_DONE),
	(GTIN_Number), 30, (GTIN_MaxChars), 4, (TAG_DONE),
	(GTIN_Number), 30, (GTIN_MaxChars), 4, (TAG_DONE)
};

int SetupScreen( void )
{
	if ( ! ( Scr = LockPubScreen( PubScreenName )))
		return( 1L );

	if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
		return( 2L );

	return( 0L );
}

void CloseDownScreen( void )
{
	if ( VisualInfo ) {
		FreeVisualInfo( VisualInfo );
		VisualInfo = NULL;
	}

	if ( Scr        ) {
		UnlockPubScreen( NULL, Scr );
		Scr = NULL;
	}
}

void Project0Render( void )
{
	UWORD		offx, offy;

	offx = Project0Wnd->BorderLeft;
	offy = Project0Wnd->BorderTop;


	DrawBevelBox( Project0Wnd->RPort, offx + 19, offy + 8, 139, 14, GT_VisualInfo, VisualInfo, TAG_DONE );
	DrawBevelBox( Project0Wnd->RPort, offx + 19, offy + 89, 139, 20, GT_VisualInfo, VisualInfo, TAG_DONE );
	DrawBevelBox( Project0Wnd->RPort, offx + 23, offy + 91, 131, 16, GT_VisualInfo, VisualInfo, GTBB_Recessed, TRUE, TAG_DONE );
	DrawBevelBox( Project0Wnd->RPort, offx + 177, offy + 8, 207, 14, GT_VisualInfo, VisualInfo, TAG_DONE );
	DrawBevelBox( Project0Wnd->RPort, offx + 19, offy + 23, 139, 45, GT_VisualInfo, VisualInfo, TAG_DONE );
	DrawBevelBox( Project0Wnd->RPort, offx + 8, offy + 117, 386, 20, GT_VisualInfo, VisualInfo, TAG_DONE );
	DrawBevelBox( Project0Wnd->RPort, offx + 12, offy + 119, 378, 16, GT_VisualInfo, VisualInfo, GTBB_Recessed, TRUE, TAG_DONE );
	DrawBevelBox( Project0Wnd->RPort, offx + 0, offy + 140, 402, 37, GT_VisualInfo, VisualInfo, TAG_DONE );
	DrawBevelBox( Project0Wnd->RPort, offx + 4, offy + 142, 394, 33, GT_VisualInfo, VisualInfo, GTBB_Recessed, TRUE, TAG_DONE );
	DrawBevelBox( Project0Wnd->RPort, offx + 11, offy + 4, 156, 109, GT_VisualInfo, VisualInfo, TAG_DONE );
	DrawBevelBox( Project0Wnd->RPort, offx + 15, offy + 6, 148, 105, GT_VisualInfo, VisualInfo, GTBB_Recessed, TRUE, TAG_DONE );
	DrawBevelBox( Project0Wnd->RPort, offx + 177, offy + 23, 207, 86, GT_VisualInfo, VisualInfo, TAG_DONE );
	DrawBevelBox( Project0Wnd->RPort, offx + 169, offy + 4, 222, 109, GT_VisualInfo, VisualInfo, TAG_DONE );
	DrawBevelBox( Project0Wnd->RPort, offx + 173, offy + 6, 214, 105, GT_VisualInfo, VisualInfo, GTBB_Recessed, TRUE, TAG_DONE );
	DrawBevelBox( Project0Wnd->RPort, offx + 6, offy + 2, 389, 114, GT_VisualInfo, VisualInfo, TAG_DONE );
	DrawBevelBox( Project0Wnd->RPort, offx + 1, offy + 0, 401, 140, GT_VisualInfo, VisualInfo, TAG_DONE );
	PrintIText( Project0Wnd->RPort, Project0IText, offx, offy );
}

int OpenProject0Window( void )
{
	struct NewGadget	ng;
	struct Gadget	*g;
	UWORD		lc, tc;
	UWORD		offx = Scr->WBorLeft, offy = Scr->WBorTop + Scr->RastPort.TxHeight + 1;

	if ( ! ( g = CreateContext( &Project0GList )))
		return( 1L );

	for( lc = 0, tc = 0; lc < Project0_CNT; lc++ ) {

		CopyMem((char * )&Project0NGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));

		ng.ng_VisualInfo = VisualInfo;
		ng.ng_TextAttr   = &topaz8;
		ng.ng_LeftEdge  += offx;
		ng.ng_TopEdge   += offy;

		Project0Gadgets[ lc ] = g = CreateGadgetA((ULONG)Project0GTypes[ lc ], g, &ng, ( struct TagItem * )&Project0GTags[ tc ] );

		while( Project0GTags[ tc ] ) tc += 2;
		tc++;

		if ( NOT g )
			return( 2L );
	}

	if ( ! ( Project0Wnd = OpenWindowTags( NULL,
				WA_Left,	Project0Left,
				WA_Top,		Project0Top,
				WA_Width,	Project0Width,
				WA_Height,	Project0Height + offy,
				WA_IDCMP,	BUTTONIDCMP|CHECKBOXIDCMP|TEXTIDCMP|INTEGERIDCMP|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
				WA_Flags,	WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
				WA_Gadgets,	Project0GList,
				WA_Title,	Project0Wdt,
				WA_ScreenTitle,	"GadToolsBox V2.0b © 1991-1993",
				WA_PubScreen,	Scr,
				TAG_DONE )))
	return( 4L );

	GT_RefreshWindow( Project0Wnd, NULL );

	Project0Render();

	return( 0L );
}

void CloseProject0Window( void )
{
	if ( Project0Wnd        ) {
		CloseWindow( Project0Wnd );
		Project0Wnd = NULL;
	}

	if ( Project0GList      ) {
		FreeGadgets( Project0GList );
		Project0GList = NULL;
	}
}

