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

/*! \file */

#ifndef REVEAL_BOUND_OBJECT_H
#define REVEAL_BOUND_OBJECT_H

#include "reveal/context/object.h"

namespace Reveal {
	namespace Context {

		template < class T > class BoundContext;

// ------------------------------------------------------------------------------
/*!
	\brief Todo;
*/
// ------------------------------------------------------------------------------
template < class T >
class BoundObject : public Object
{
public:

	BoundObject( T& object, float sphereRadius, 
				 const ClickAndHoldCallback& clickAndHoldCallback, 
				 const GetPositionCallback& getPosCallback, 
				 BoundContext< T >& boundContext )
		: Object( sphereRadius, clickAndHoldCallback, getPosCallback ),
		  mObject( &object ),
		  mBoundContext( boundContext )
		{
			mBoundContext.AddRef();
		}

	~BoundObject()
	{
		mBoundContext.DecRef();
	}

	virtual void EnableAndShowContext( int x, int y )
	{
		assert( mObject );
		mBoundContext.Show( x, y );
		mBoundContext.SetObject( *mObject );
	}

	virtual bool HandleMenu( const InputState& inputState )
	{
		return mBoundContext.Handle( inputState );
	}
	virtual void RenderMenu( const Renderer& renderer )
	{
		mBoundContext.Render( renderer );
	}

private:

	T*				   mObject;
	BoundContext< T >& mBoundContext;
};

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

#endif
