// ------------------------------------------------------------------------
/*
	author: Jaap Suter
   
	Copyright (C) Electronic Arts Canada Inc. 2002.  All rights reserved.	
*/
// ------------------------------------------------------------------------

/*! \file */

#ifndef REVEAL_CONTEXT_H
#define REVEAL_CONTEXT_H

#include <stddef.h>

#include "reveal/impl/tree.h"
#include "reveal/input_state.h"

namespace Reveal {

	class Renderer;

	namespace Context {

// ------------------------------------------------------------------------------
/*!
	\brief This is the base class for a context specific menu tree;
		   The actual used class is the BoundContext type, which is parametrized
		   over the type the context is bound to;
*/
// ------------------------------------------------------------------------------
class Context : public Impl::Tree
{
public:
	Context( const char* rootName ) : Impl::Tree( rootName ), mRefCount( 1 ) {}

	void AddRef() { ++mRefCount; }
	void DecRef() { --mRefCount; }

	void Render( const Renderer& renderer )
	{
		Root().Render( renderer, GetGuiColors() );
	}

	void Show( int x, int y )
	{
        ShowRoot( x, y );
	}

	bool Handle( const InputState& inputState )
	{
		return 0 == Root().Handle( inputState );
	}

private:

	size_t mRefCount;
};

	} // Namespace Context;
} // Namespace Reveal;

#endif
