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

#include <exec/types.h>
#include <exec/memory.h>
#include <dos/dosextens.h>
#include <intuition/screens.h>
#include <intuition/intuition.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <diskfont/diskfont.h>
#include <utility/utility.h>
#include <graphics/gfxbase.h>
#include <workbench/workbench.h>
#include <graphics/scale.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 <clib/diskfont_protos.h>

#include "SysopListView.h"


struct Window *SLV = NULL;
APTR SLVVisualInfo;
APTR SLVDrawInfo;
struct Gadget *SLVGList;
struct Gadget *SLVGadgets[2];
UBYTE SLVFirstRun = 0;

struct Node LV1ListItems[] =
	{
	&LV1ListItems[1], (struct Node *)&LV1List.mlh_Head, 0, 0, (STRPTR)"Nodes",
	&LV1ListItems[2], &LV1ListItems[0], 0, 0, (STRPTR)"Conferences",
	&LV1ListItems[3], &LV1ListItems[1], 0, 0, (STRPTR)"Access Levels",
	&LV1ListItems[4], &LV1ListItems[2], 0, 0, (STRPTR)"Access Names",
	&LV1ListItems[5], &LV1ListItems[3], 0, 0, (STRPTR)"Language Name",
	&LV1ListItems[6], &LV1ListItems[4], 0, 0, (STRPTR)"Language Extn",
	&LV1ListItems[7], &LV1ListItems[5], 0, 0, (STRPTR)"Drives",
	( struct Node *)&LV1List.mlh_Tail, &LV1ListItems[6], 0, 0, (STRPTR)"Protocols"
	};

struct MinList LV1List =
	{
	( struct MinNode * )&LV1ListItems[0], ( struct MinNode * )NULL , ( struct MinNode * )&LV1ListItems[7]
	};

ULONG SLVGadgetTags[] =
	{
	(GTLV_ShowSelected), 0,
	(GTLV_Selected), 0,
	(GTLV_Labels), (ULONG)&LV1List,
	(TAG_END),
	(GTLV_Selected), 0,
	(TAG_END),
	};

UWORD SLVGadgetTypes[] =
	{
	LISTVIEW_KIND,
	LISTVIEW_KIND,
	};

struct NewGadget SLVNewGadgets[] =
	{
	2, 5, 134, 132, NULL, &topaz800, LV1, 1, NULL,  (APTR)&SLVGadgetTags[0],
	139, 5, 491, 132, NULL, &topaz800, LV2, 1, NULL,  (APTR)&SLVGadgetTags[7],
	};
UWORD SLVZoomInfo[4] = { 0, 0, 200, 11 };

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

void RendWindowSLV( struct Window *Win, void *vi )
{
UWORD offx = Win->BorderLeft;
UWORD offy = Win->BorderTop;
if (Win != NULL) 
	{
	}
}

int OpenWindowSLV( void )
{
struct Screen *Scr;
UWORD offx, offy;
UWORD loop;
struct NewGadget newgad;
struct Gadget *Gad;
struct Gadget *Gad2;
APTR Cla;
if (SLVFirstRun == 0)
	{
	SLVFirstRun = 1;
	}
if (SLV == NULL)
	{
	Scr = LockPubScreen((UBYTE *)"CtrlScrn");
	if (NULL != Scr)
		{
		offx = Scr->WBorLeft;
		offy = Scr->WBorTop + Scr->Font->ta_YSize+1;
		if (NULL != ( SLVVisualInfo = GetVisualInfoA( Scr, NULL)))
			{
			if (NULL != ( SLVDrawInfo = GetScreenDrawInfo( Scr)))
				{
				SLVGList = NULL;
				Gad = CreateContext( &SLVGList);
				for ( loop=0 ; loop<2 ; loop++ )
					if (SLVGadgetTypes[loop] != 198)
						{
						CopyMem((char * )&SLVNewGadgets[loop], ( char * )&newgad, (long)sizeof( struct NewGadget ));
						newgad.ng_VisualInfo = SLVVisualInfo;
						newgad.ng_LeftEdge += offx;
						newgad.ng_TopEdge += offy;
						SLVGadgets[ loop ] = NULL;
						SLVGadgets[ newgad.ng_GadgetID - SLVFirstID ] = Gad = CreateGadgetA( SLVGadgetTypes[loop], Gad, &newgad, newgad.ng_UserData );
						}
				for ( loop=0 ; loop<2 ; loop++ )
					if (SLVGadgetTypes[loop] == 198)
						{
						SLVGadgets[ loop ] = NULL;
						Cla = NULL;
						if (Gad)
							SLVGadgets[ loop ] = Gad2 = (struct Gadget *) NewObjectA( (struct IClass *)Cla, SLVNewGadgets[ loop ].ng_GadgetText, SLVNewGadgets[ loop ].ng_UserData );
						}
				if (Gad != NULL)
					{
					if (NULL != (SLV = OpenWindowTags( NULL, (WA_Left), 0,
									(WA_Top), 11,
									(WA_Width), 636+offx,
									(WA_Height), 144+offy,
									(WA_Title), "Sysop List Viewer",
									(WA_MinWidth), 200,
									(WA_MinHeight), 11,
									(WA_MaxWidth), 1200,
									(WA_MaxHeight), 1200,
									(WA_DragBar), TRUE,
									(WA_DepthGadget), TRUE,
									(WA_CloseGadget), TRUE,
									(WA_Activate), TRUE,
									(WA_Dummy+0x30), TRUE,
									(WA_SmartRefresh), TRUE,
									(WA_AutoAdjust), TRUE,
									(WA_Gadgets), SLVGList,
									(WA_Zoom), SLVZoomInfo,
									(WA_PubScreen) , (LONG)Scr,
									(WA_IDCMP),4194940,
									(TAG_END))))
						{
						RendWindowSLV(SLV, SLVVisualInfo );
						GT_RefreshWindow( SLV, NULL);
						RefreshGList( SLVGList, SLV, NULL, ~0);
						UnlockPubScreen( NULL, Scr);
						return( 0L );
						}
					}
				FreeGadgets( SLVGList);
				FreeScreenDrawInfo( Scr, SLVDrawInfo );
				}
			FreeVisualInfo( SLVVisualInfo );
			}
		UnlockPubScreen( NULL, Scr);
		}
	}
else
	{
	WindowToFront(SLV);
	ActivateWindow(SLV);
	return( 0L );
	}
return( 1L );
}

void CloseWindowSLV( void )
{
if (SLV != NULL)
	{
	FreeScreenDrawInfo( SLV->WScreen, SLVDrawInfo );
	SLVDrawInfo = NULL;
	CloseWindow( SLV);
	SLV = NULL;
	FreeVisualInfo( SLVVisualInfo);
	FreeGadgets( SLVGList);
	}
}

