#include <stream.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#include "GUICINCLUDE:GUIC_Text.hpp"
#include "GUICINCLUDE:GUIC_Fillbar.hpp"
#include "GUICINCLUDE:GUIC_Screen.hpp"
#include "GUICINCLUDE:GUIC_Application.hpp"

#include "StatusWindow.hpp"

/*********************************************************************************************************/

StatusWindowC::StatusWindowC			(GUIC_ApplicationC &app, GUIC_ScreenC &screen) : GUIC_WindowC(-1,-1, 50,9)
{
	this->app 		= &app;
	this->screen	= &screen;
	
	message 		= new GUIC_TextC 	(1,1,48,2,"");
	percent 			= new GUIC_FillbarC	(1,4,48,4,0);
	
	message->setJustification (GUIC_Center);
	
	add ( message );
	add ( percent );
	
	setTitle ("Gallery Status Window");
	
	app.addPrefs("StatusWindow", this);
}
StatusWindowC::~StatusWindowC			(VOID)
{
	cleanUp();
}

/*********************************************************************************************************/

STRPTR	StatusWindowC::getMessage	(VOID)
{
	return	message->get();
}
VOID 		StatusWindowC::setMessage	(STRPTR t)
{
	message->set(t);
}
VOID		StatusWindowC::setPercent	(ULONG i)
{
	percent->set(i);
}
BOOL		StatusWindowC::action			(GUIC_EventC &e)
{
	switch (e.id)
		{
		case GUIC_GadgetEvent:
			return TRUE;
			break;
		case GUIC_OpenWindow:
			percent->set(0);
			message->set("");
			return TRUE;
			break;
		case GUIC_CloseWindow: 
			return TRUE;
			break;
		default:
			cerr << "Got an event: " << e.id << endl;
		}
	
	return FALSE;
}

STRPTR	StatusWindowC::getClass		(VOID)
{
	return "StatusWindowC";
}

/*********************************************************************************************************/

VOID		StatusWindowC::cleanUp		(VOID)
{
	delete message;
	delete percent;
}

