/*********************************************/
/*                                           */
/*       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 "NodeGUI.h"

#include "/common/types.h"
#include "/common/defines.h"
#include "/common/structures.h"

extern struct BBSGlobalData *BBSGlobal;
extern struct NodeData *N_ND;

ULONG BevelTags[] =
	{
	(GTBB_Recessed), TRUE,
	(GT_VisualInfo), 0,
	(TAG_DONE)
	};

struct IntuiText NodeWndTexts[] =
	{
	1, 3, JAM1, 5, 3, &HBBS8066, (UBYTE *)"Name", &NodeWndTexts[1],
	1, 3, JAM1, 165, 3, &HBBS8066, (UBYTE *)"Group", &NodeWndTexts[2],
	1, 3, JAM1, 325, 3, &HBBS8066, (UBYTE *)"Action", &NodeWndTexts[3],
	1, 3, JAM1, 557, 3, &HBBS8066, (UBYTE *)"CPS/BAUD", NULL
	};

struct Window *NodeWnd = NULL;
APTR NodeWndVisualInfo;
struct DrawInfo *NodeWndDrawInfo;
struct Gadget *NodeWndGList;
struct Gadget *NodeWndGadgets[8];
UBYTE NodeWndFirstRun = 0;

STRPTR NodeWnd_ChatFlagLabels[] =
{
	(STRPTR)"Chat ON",
	(STRPTR)"Chat OFF",
	NULL
};

STRPTR NodeWnd_OffHookLabels[] =
{
	(STRPTR)"OnHook",
	(STRPTR)"OffHook",
	NULL
};

STRPTR NodeWnd_ReserveLabels[] =
{
	(STRPTR)"UnReserved",
	(STRPTR)"Reserved",
	NULL
};

ULONG NodeWndGadgetTags[] =
	{
	(GTCY_Labels), (ULONG)&NodeWnd_ChatFlagLabels[0],
	(TAG_END),
	(GTCY_Labels), (ULONG)&NodeWnd_OffHookLabels[0],
	(TAG_END),
	(GTCY_Labels), (ULONG)&NodeWnd_ReserveLabels[0],
	(TAG_END),
	};

UWORD NodeWndGadgetTypes[] =
	{
	BUTTON_KIND,
	BUTTON_KIND,
	BUTTON_KIND,
	BUTTON_KIND,
	BUTTON_KIND,
	CYCLE_KIND,
	CYCLE_KIND,
	CYCLE_KIND,
	};

struct NewGadget NodeWndNewGad[] =
	{
	311, 27, 87, 12, (UBYTE *)"Init Modem", &HBBS8066, NodeWnd_InitModem, 16, NULL,  NULL,
	463, 27, 52, 12, (UBYTE *)"Chat", &HBBS8066, NodeWnd_ChatNow, 16, NULL,  NULL,
	516, 27, 71, 12, (UBYTE *)"Settings", &HBBS8066, NodeWnd_Settings, 16, NULL,  NULL,
	588, 27, 42, 12, (UBYTE *)"Info", &HBBS8066, NodeWnd_Information, 16, NULL,  NULL,
	399, 27, 63, 12, (UBYTE *)"Watch", &HBBS8066, NodeWnd_Screen, 16, NULL,  NULL,
	2, 27, 98, 12, NULL, &HBBS8066, NodeWnd_ChatFlag, 1, NULL,  (APTR)&NodeWndGadgetTags[0],
	101, 27, 93, 12, NULL, &HBBS8066, NodeWnd_OffHook, 1, NULL,  (APTR)&NodeWndGadgetTags[3],
	195, 27, 115, 12, NULL, &HBBS8066, NodeWnd_Reserve, 1, NULL,  (APTR)&NodeWndGadgetTags[6],
	};
UWORD NodeWndZoomInfo[4] = { 0, 11, 150, 11 };

struct Window *InfoWin = NULL;
APTR InfoWinVisualInfo;
struct DrawInfo *InfoWinDrawInfo;
struct Gadget *InfoWinGList;
struct Gadget *InfoWinGadgets[5];
UBYTE InfoWinFirstRun = 0;

STRPTR InfoWin_LV1_Cycle1Labels[] =
{
	(STRPTR)"Callers",
	(STRPTR)"Uploads",
	(STRPTR)"Downloads",
	(STRPTR)"Pagers",
	(STRPTR)"PWFails",
	(STRPTR)"Carrier Losses",
	NULL
};

ULONG InfoWinGadgetTags[] =
	{
	(GTCY_Labels), (ULONG)&InfoWin_LV1_Cycle1Labels[0],
	(TAG_END),
	(GTLV_Selected), 0,
	(TAG_END),
	(GTNM_Border), TRUE,
	(TAG_END),
	(GTNM_Border), TRUE,
	(TAG_END),
	(GTNM_Border), TRUE,
	(TAG_END),
	};

UWORD InfoWinGadgetTypes[] =
	{
	CYCLE_KIND,
	LISTVIEW_KIND,
	NUMBER_KIND,
	NUMBER_KIND,
	NUMBER_KIND,
	};

struct NewGadget InfoWinNewGad[] =
	{
	2, 28, 252, 14, NULL, &HBBS8066, InfoWin_LV1_Cycle1, 1, NULL,  (APTR)&InfoWinGadgetTags[0],
	2, 43, 252, 109, NULL, &HBBS8066, InfoWin_LV1, 1, NULL,  (APTR)&InfoWinGadgetTags[3],
	63, 8, 45, 12, (UBYTE *)"Calls", &HBBS8066, InfoWin_Calls, 1, NULL,  (APTR)&InfoWinGadgetTags[6],
	139, 8, 34, 12, (UBYTE *)"UL", &HBBS8066, InfoWin_Uploads, 1, NULL,  (APTR)&InfoWinGadgetTags[9],
	208, 8, 34, 12, (UBYTE *)"DL", &HBBS8066, InfoWin_Downloads, 1, NULL,  (APTR)&InfoWinGadgetTags[12],
	};
UWORD InfoWinZoomInfo[4] = { 0, 11, 150, 11 };

struct IntuiText SettingsWinTexts[] =
	{
	2, 0, JAM2, 13, 4, &topa81281, (UBYTE *)"Screen/Window Settings", &SettingsWinTexts[1],
	2, 0, JAM2, 13, 55, &topa81281, (UBYTE *)"Modem Settings", &SettingsWinTexts[2],
	2, 0, JAM2, 13, 111, &HBBS8066, (UBYTE *)"Misc Settings", NULL
	};

struct Window *SettingsWin = NULL;
APTR SettingsWinVisualInfo;
struct DrawInfo *SettingsWinDrawInfo;
struct Gadget *SettingsWinGList;
struct Gadget *SettingsWinGadgets[11];
UBYTE SettingsWinFirstRun = 0;

STRPTR SettingsWin_WinOrScreenLabels[] =
{
	(STRPTR)"Use Screen",
	(STRPTR)"Use Window",
	NULL
};

ULONG SettingsWinGadgetTags[] =
	{
	(GTCY_Labels), (ULONG)&SettingsWin_WinOrScreenLabels[0],
	(TAG_END),
	(GTCB_Checked), TRUE,
	(TAG_END),
	};

UWORD SettingsWinGadgetTypes[] =
	{
	BUTTON_KIND,
	CYCLE_KIND,
	CHECKBOX_KIND,
	CHECKBOX_KIND,
	CHECKBOX_KIND,
	BUTTON_KIND,
	BUTTON_KIND,
	BUTTON_KIND,
	BUTTON_KIND,
	BUTTON_KIND,
	CHECKBOX_KIND,
	};

struct NewGadget SettingsWinNewGad[] =
	{
	12, 15, 129, 12, (UBYTE *)"Screen Mode", &HBBS8066, SettingsWin_ScreenMode, 16, NULL,  NULL,
	12, 30, 129, 12, NULL, &HBBS8066, SettingsWin_WinOrScreen, 2, NULL,  (APTR)&SettingsWinGadgetTags[0],
	12, 65, 26, 11, (UBYTE *)"Modem Debug", &HBBS8066, SettingsWin_ModemDebug, 2, NULL,  NULL,
	12, 77, 26, 11, (UBYTE *)"Modem Log", &HBBS8066, SettingsWin_ModemLog, 2, NULL,  NULL,
	13, 122, 26, 11, (UBYTE *)"Allow Logins", &HBBS8066, SettingsWin_AllowLogins, 2, NULL,  (APTR)&SettingsWinGadgetTags[3],
	143, 15, 129, 12, (UBYTE *)"Save Windows", &HBBS8066, SettingsWin_SaveWin, 16, NULL,  NULL,
	143, 65, 129, 12, (UBYTE *)"Device Config", &HBBS8066, SettingsWin_DeviceConfig, 16, NULL,  NULL,
	143, 154, 129, 12, (UBYTE *)"Node Config", &HBBS8066, SettingsWin_NodeConfig, 16, NULL,  NULL,
	143, 124, 129, 12, (UBYTE *)"Callers Log", &HBBS8066, SettingsWin_CallersLog, 16, NULL,  NULL,
	143, 139, 129, 12, (UBYTE *)"Door Log", &HBBS8066, SettingsWin_DoorLog, 16, NULL,  NULL,
	12, 90, 26, 11, (UBYTE *)"Dump Modem", &HBBS8066, SettingsWin_DumpModem, 2, NULL,  NULL,
	};
UWORD SettingsWinZoomInfo[4] = { 0, 11, 150, 11 };

struct Library *DiskfontBase = NULL;
struct Library *GadToolsBase = NULL;
struct GfxBase *GfxBase = NULL;
struct IntuitionBase *IntuitionBase = NULL;
struct LocaleBase *LocaleBase = NULL;

APTR WaitPointer = NULL;
UWORD WaitPointerData[] =
    {
    0x0000,0x0000,0x0400,0x07c0,
    0x0000,0x07c0,0x0100,0x0380,
    0x0000,0x07e0,0x07c0,0x1ff8,
    0x1ff0,0x3fec,0x3ff8,0x7fde,
    0x3ff8,0x7fbe,0x7ffc,0xff7f,
    0x7ffc,0xffff,0x7ffc,0xffff,
    0x3ff8,0x7ffe,0x3ff8,0x7ffe,
    0x1ff0,0x3ffc,0x07c0,0x1ff8,
    0x0000,0x07e0,0x0000,0x0000
    };

struct TextAttr HBBS8066 = { (STRPTR)"HBBS.font", 8, 0, 66 };
struct TextAttr topa81281 = { (STRPTR)"topaz", 8, 128, 1 };

void RendWindowNodeWnd( struct Window *Win, void *vi )
{
int loop;
UWORD offx = Win->BorderLeft;
UWORD offy = Win->BorderTop;
if (Win != NULL)
	{
	BevelTags[3] = (ULONG)vi;
	DrawBevelBoxA( Win->RPort, 1+offx,1+offy,629,12, (struct TagItem *)(&BevelTags[2]));
	DrawBevelBoxA( Win->RPort, 1+offx,14+offy,629,12, (struct TagItem *)(&BevelTags[2]));
	for( loop=0; loop<4; loop++)
	{
		NodeWndTexts[loop].FrontPen = NodeWndDrawInfo->dri_Pens[TEXTPEN];
		NodeWndTexts[loop].BackPen = NodeWndDrawInfo->dri_Pens[BACKGROUNDPEN];
		if (NodeWndTexts[loop].ITextFont==NULL)
			NodeWndTexts[loop].ITextFont=Win->WScreen->Font;
	}
	PrintIText( Win->RPort, NodeWndTexts, offx, offy);
	}
}

int OpenNodeWndWindow( struct Screen *Scr)
{
UWORD offx, offy;
UWORD loop;
struct NewGadget newgad;
struct Gadget *Gad;
struct Gadget *Gad2;
APTR Cla;
if (NodeWndFirstRun == 0)
	{
	NodeWndFirstRun = 1;
	}
if (NodeWnd == NULL)
	{
	offx = Scr->WBorLeft;
	offy = Scr->WBorTop + Scr->Font->ta_YSize+1;
	if (NULL != ( NodeWndVisualInfo = GetVisualInfoA( Scr, NULL)))
		{
		if (NULL != ( NodeWndDrawInfo = GetScreenDrawInfo( Scr)))
			{
			NodeWndGList = NULL;
			Gad = CreateContext( &NodeWndGList);
			for ( loop=0 ; loop<8 ; loop++ )
				if (NodeWndGadgetTypes[loop] != 198)
					{
					CopyMem((char * )&NodeWndNewGad[loop], ( char * )&newgad, (long)sizeof( struct NewGadget ));
					newgad.ng_VisualInfo = NodeWndVisualInfo;
					newgad.ng_LeftEdge += offx;
					newgad.ng_TopEdge += offy;
					NodeWndGadgets[ loop ] = NULL;
					NodeWndGadgets[ newgad.ng_GadgetID - NodeWndFirstID ] = Gad = CreateGadgetA( NodeWndGadgetTypes[loop], Gad, &newgad, newgad.ng_UserData );
					}
			for ( loop=0 ; loop<8 ; loop++ )
				if (NodeWndGadgetTypes[loop] == 198)
					{
					NodeWndGadgets[ loop ] = NULL;
					Cla = NULL;
					if (Gad)
						NodeWndGadgets[ loop ] = Gad2 = (struct Gadget *) NewObjectA( (struct IClass *)Cla, NodeWndNewGad[ loop ].ng_GadgetText, NodeWndNewGad[ loop ].ng_UserData );
					}
			if (Gad != NULL)
				{
				if (NULL != (NodeWnd = OpenWindowTags( NULL,
                (WA_Left), N_ND->NodeX,
                (WA_Top), N_ND->NodeY,
								(WA_Width), 636+offx,
								(WA_Height), 42+offy,
								(WA_Title), "",
								(WA_MinWidth), 200,
								(WA_MinHeight), 11,
								(WA_MaxWidth), 65534,
								(WA_MaxHeight), 65534,
								(WA_DragBar), TRUE,
								(WA_DepthGadget), TRUE,
								(WA_CloseGadget), TRUE,
								(WA_Activate), TRUE,
								(WA_Dummy+0x30), TRUE,
								(WA_SmartRefresh), TRUE,
								(WA_Gadgets), NodeWndGList,
								(WA_Zoom), NodeWndZoomInfo,
								(WA_PubScreen) , (LONG)Scr,
								(WA_IDCMP),2097732,
//								NodeWndDrawInfo->dri_Depth >=4 ? (WA_BackFill) : (TAG_IGNORE), &BBSGlobal->backfillhook, // *!* Added
                BBSGlobal->ScreenInfo->UsingBackfill ? (WA_BackFill) : (TAG_IGNORE), &BBSGlobal->backfillhook, // *!* Added
								(TAG_END))))
					{
					RendWindowNodeWnd(NodeWnd, NodeWndVisualInfo );
					GT_RefreshWindow( NodeWnd, NULL);
					RefreshGList( NodeWndGList, NodeWnd, NULL, ~0);
					return( 0L );
					}
				}
			FreeGadgets( NodeWndGList);
			FreeScreenDrawInfo( Scr, NodeWndDrawInfo );
			}
		FreeVisualInfo( NodeWndVisualInfo );
		}
	}
else
	{
	WindowToFront(NodeWnd);
	ActivateWindow(NodeWnd);
	return( 1L );
	}
return( 1L );
}

void CloseNodeWndWindow( void )
{
if (NodeWnd != NULL)
	{
	FreeScreenDrawInfo( NodeWnd->WScreen, NodeWndDrawInfo );
	NodeWndDrawInfo = NULL;
	CloseWindow( NodeWnd);
	NodeWnd = NULL;
	FreeVisualInfo( NodeWndVisualInfo);
	FreeGadgets( NodeWndGList);
	}
}

void RendWindowInfoWin( struct Window *Win, void *vi )
{
UWORD offx = Win->BorderLeft;
UWORD offy = Win->BorderTop;
if (Win != NULL)
	{
	BevelTags[3] = (ULONG)vi;
	DrawBevelBoxA( Win->RPort, 2+offx,1+offy,252,26, (struct TagItem *)(&BevelTags[2]));
	}
}

int OpenInfoWinWindow( struct Screen *Scr)
{
UWORD offx, offy;
UWORD loop;
struct NewGadget newgad;
struct Gadget *Gad;
struct Gadget *Gad2;
APTR Cla;
if (InfoWinFirstRun == 0)
	{
	InfoWinFirstRun = 1;
	}
if (InfoWin == NULL)
	{
	offx = Scr->WBorLeft;
	offy = Scr->WBorTop + Scr->Font->ta_YSize+1;
	if (NULL != ( InfoWinVisualInfo = GetVisualInfoA( Scr, NULL)))
		{
		if (NULL != ( InfoWinDrawInfo = GetScreenDrawInfo( Scr)))
			{
			InfoWinGList = NULL;
			Gad = CreateContext( &InfoWinGList);
			for ( loop=0 ; loop<5 ; loop++ )
				if (InfoWinGadgetTypes[loop] != 198)
					{
					CopyMem((char * )&InfoWinNewGad[loop], ( char * )&newgad, (long)sizeof( struct NewGadget ));
					newgad.ng_VisualInfo = InfoWinVisualInfo;
					newgad.ng_LeftEdge += offx;
					newgad.ng_TopEdge += offy;
					InfoWinGadgets[ loop ] = NULL;
					InfoWinGadgets[ newgad.ng_GadgetID - InfoWinFirstID ] = Gad = CreateGadgetA( InfoWinGadgetTypes[loop], Gad, &newgad, newgad.ng_UserData );
					}
			for ( loop=0 ; loop<5 ; loop++ )
				if (InfoWinGadgetTypes[loop] == 198)
					{
					InfoWinGadgets[ loop ] = NULL;
					Cla = NULL;
					if (Gad)
						InfoWinGadgets[ loop ] = Gad2 = (struct Gadget *) NewObjectA( (struct IClass *)Cla, InfoWinNewGad[ loop ].ng_GadgetText, InfoWinNewGad[ loop ].ng_UserData );
					}
			if (Gad != NULL)
				{
				if (NULL != (InfoWin = OpenWindowTags( NULL, (WA_Left), 234,
								(WA_Top), 68,
								(WA_Width), 260+offx,
								(WA_Height), 154+offy,
								(WA_Title), "",
								(WA_MinWidth), 150,
								(WA_MinHeight), 25,
								(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_Gadgets), InfoWinGList,
								(WA_Zoom), InfoWinZoomInfo,
								(WA_PubScreen) , (LONG)Scr,
								(WA_IDCMP),4194940,
//								InfoWinDrawInfo->dri_Depth >=4 ? (WA_BackFill) : (TAG_IGNORE), &BBSGlobal->backfillhook, // *!* Added
                 BBSGlobal->ScreenInfo->UsingBackfill ? (WA_BackFill) : (TAG_IGNORE), &BBSGlobal->backfillhook, // *!* Added
								(TAG_END))))
					{
					RendWindowInfoWin(InfoWin, InfoWinVisualInfo );
					GT_RefreshWindow( InfoWin, NULL);
					RefreshGList( InfoWinGList, InfoWin, NULL, ~0);
					return( 0L );
					}
				}
			FreeGadgets( InfoWinGList);
			FreeScreenDrawInfo( Scr, InfoWinDrawInfo );
			}
		FreeVisualInfo( InfoWinVisualInfo );
		}
	}
else
	{
	WindowToFront(InfoWin);
	ActivateWindow(InfoWin);
	return( 0L );
	}
return( 1L );
}

void CloseInfoWinWindow( void )
{
if (InfoWin != NULL)
	{
	FreeScreenDrawInfo( InfoWin->WScreen, InfoWinDrawInfo );
	InfoWinDrawInfo = NULL;
	CloseWindow( InfoWin);
	InfoWin = NULL;
	FreeVisualInfo( InfoWinVisualInfo);
	FreeGadgets( InfoWinGList);
	}
}

void RendWindowSettingsWin( struct Window *Win, void *vi )
{
int loop;
UWORD offx = Win->BorderLeft;
UWORD offy = Win->BorderTop;
if (Win != NULL)
	{
	BevelTags[3] = (ULONG)vi;
	DrawBevelBoxA( Win->RPort, 2+offx,6+offy,280,44, (struct TagItem *)(&BevelTags[0]));
	DrawBevelBoxA( Win->RPort,2+4+offx,6+2+offy,280-8,44-4, (struct TagItem *)(&BevelTags[2]));
	DrawBevelBoxA( Win->RPort, 2+offx,57+offy,280,50, (struct TagItem *)(&BevelTags[0]));
	DrawBevelBoxA( Win->RPort,2+4+offx,57+2+offy,280-8,50-4, (struct TagItem *)(&BevelTags[2]));
	DrawBevelBoxA( Win->RPort, 2+offx,114+offy,280,59, (struct TagItem *)(&BevelTags[0]));
	DrawBevelBoxA( Win->RPort,2+4+offx,114+2+offy,280-8,59-4, (struct TagItem *)(&BevelTags[2]));
	for( loop=0; loop<3; loop++)
	{
		SettingsWinTexts[loop].FrontPen = SettingsWinDrawInfo->dri_Pens[TEXTPEN];
		SettingsWinTexts[loop].BackPen = SettingsWinDrawInfo->dri_Pens[BACKGROUNDPEN];

		if (SettingsWinTexts[loop].ITextFont==NULL)
			SettingsWinTexts[loop].ITextFont=Win->WScreen->Font;
	}
	PrintIText( Win->RPort, SettingsWinTexts, offx, offy);
	}
}

int OpenSettingsWinWindow( struct Screen *Scr)
{
UWORD offx, offy;
UWORD loop;
struct NewGadget newgad;
struct Gadget *Gad;
struct Gadget *Gad2;
APTR Cla;
if (SettingsWinFirstRun == 0)
	{
	SettingsWinFirstRun = 1;
	}
if (SettingsWin == NULL)
	{
	offx = Scr->WBorLeft;
	offy = Scr->WBorTop + Scr->Font->ta_YSize+1;
	if (NULL != ( SettingsWinVisualInfo = GetVisualInfoA( Scr, NULL)))
		{
		if (NULL != ( SettingsWinDrawInfo = GetScreenDrawInfo( Scr)))
			{
			SettingsWinGList = NULL;
			Gad = CreateContext( &SettingsWinGList);
			for ( loop=0 ; loop<11 ; loop++ )
				if (SettingsWinGadgetTypes[loop] != 198)
					{
					CopyMem((char * )&SettingsWinNewGad[loop], ( char * )&newgad, (long)sizeof( struct NewGadget ));
					newgad.ng_VisualInfo = SettingsWinVisualInfo;
					newgad.ng_LeftEdge += offx;
					newgad.ng_TopEdge += offy;
					SettingsWinGadgets[ loop ] = NULL;
					SettingsWinGadgets[ newgad.ng_GadgetID - SettingsWinFirstID ] = Gad = CreateGadgetA( SettingsWinGadgetTypes[loop], Gad, &newgad, newgad.ng_UserData );
					}
			for ( loop=0 ; loop<11 ; loop++ )
				if (SettingsWinGadgetTypes[loop] == 198)
					{
					SettingsWinGadgets[ loop ] = NULL;
					Cla = NULL;
					if (Gad)
						SettingsWinGadgets[ loop ] = Gad2 = (struct Gadget *) NewObjectA( (struct IClass *)Cla, SettingsWinNewGad[ loop ].ng_GadgetText, SettingsWinNewGad[ loop ].ng_UserData );
					}
			if (Gad != NULL)
				{
				if (NULL != (SettingsWin = OpenWindowTags( NULL, (WA_Left), 288,
								(WA_Top), 53,
								(WA_Width), 290+offx,
								(WA_Height), 179+offy,
								(WA_Title), "",
								(WA_MinWidth), 100,
								(WA_MinHeight), 25,
								(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), SettingsWinGList,
								(WA_Zoom), SettingsWinZoomInfo,
								(WA_PubScreen) , (LONG)Scr,
								(WA_IDCMP),580,
//								SettingsWinDrawInfo->dri_Depth >=4 ? (WA_BackFill) : (TAG_IGNORE), &BBSGlobal->backfillhook, // *!* Added
                BBSGlobal->ScreenInfo->UsingBackfill ? (WA_BackFill) : (TAG_IGNORE), &BBSGlobal->backfillhook, // *!* Added
							(TAG_END))))
					{
					RendWindowSettingsWin(SettingsWin, SettingsWinVisualInfo );
					GT_RefreshWindow( SettingsWin, NULL);
					RefreshGList( SettingsWinGList, SettingsWin, NULL, ~0);
					return( 0L );
					}
				}
			FreeGadgets( SettingsWinGList);
			FreeScreenDrawInfo( Scr, SettingsWinDrawInfo );
			}
		FreeVisualInfo( SettingsWinVisualInfo );
		}
	}
else
	{
	WindowToFront(SettingsWin);
	ActivateWindow(SettingsWin);
	return( 0L );
	}
return( 1L );
}

void CloseSettingsWinWindow( void )
{
if (SettingsWin != NULL)
	{
	FreeScreenDrawInfo( SettingsWin->WScreen, SettingsWinDrawInfo );
	SettingsWinDrawInfo = NULL;
	CloseWindow( SettingsWin);
	SettingsWin = NULL;
	FreeVisualInfo( SettingsWinVisualInfo);
	FreeGadgets( SettingsWinGList);
	}
}

int OpenLibs( void )
{
LocaleBase = (struct LocaleBase * )OpenLibrary((UBYTE *)"locale.library", 38);
if ( NULL != (DiskfontBase = OpenLibrary((UBYTE *)"diskfont.library" , 36)))
	if ( NULL != (GadToolsBase = OpenLibrary((UBYTE *)"gadtools.library" , 37)))
		if ( NULL != (GfxBase = (struct GfxBase * )OpenLibrary((UBYTE *)"graphics.library" , 37)))
			if ( NULL != (IntuitionBase = (struct IntuitionBase * )OpenLibrary((UBYTE *)"intuition.library" , 37)))
				return( 0L );
CloseLibs();
return( 1L );
}

void CloseLibs( void )
{
if (NULL != DiskfontBase )
	CloseLibrary( DiskfontBase );
if (NULL != GadToolsBase )
	CloseLibrary( GadToolsBase );
if (NULL != GfxBase )
	CloseLibrary( ( struct Library * )GfxBase );
if (NULL != IntuitionBase )
	CloseLibrary( ( struct Library * )IntuitionBase );
if (NULL != LocaleBase )
	CloseLibrary( ( struct Library * )LocaleBase );
}

int OpenDiskFonts( void )
{
	int OKSoFar = 0;
if (NULL == OpenDiskFont( &HBBS8066 ) )
	OKSoFar = 1;
if (NULL == OpenDiskFont( &topa81281 ) )
	OKSoFar = 1;
return ( OKSoFar );
}

int MakeImages( void )
{
UWORD failed = 0;
if (NULL != (WaitPointer=AllocMem( 72, MEMF_CHIP)))
	CopyMem( WaitPointerData, WaitPointer, 72);
else
	failed = 1;
if (failed==0)
	return( 0L );
else
	{
	FreeImages();
	return( 1L );
	}
}

void FreeImages( void )
{
if (WaitPointer != NULL)
	FreeMem( WaitPointer, 72);
WaitPointer = NULL;
}

