//------------------------------------------------------------------------------------
// irr::IEventReceiver wrappers
//------------------------------------------------------------------------------------

class BMXEventReceiver : public IEventReceiver
{
public:

	BMXBinder binder;

	bool (*BMXEventReceiver_OnEvent)(s32 binding,SEvent* event);

	BMXEventReceiver() : IEventReceiver()
	{
		BMXEventReceiver_OnEvent=0;
	}
	
	void bindOnEvent(bool (*bind_OnEvent)(s32 binding,SEvent* event))
	{
		BMXEventReceiver_OnEvent=bind_OnEvent;
	}

	virtual bool OnEvent(const SEvent& event)
	{
		if (BMXEventReceiver_OnEvent)
			return BMXEventReceiver_OnEvent(binder.binding,(SEvent*)&event);
		else return false;
	}	

	BMXBinder* getBinder()
	{
		return &binder;
	}
};

extern "C" {

BMXEventReceiver* Irr_BMXEventReceiver_new()
{
	return new BMXEventReceiver();
}

BMXBinder* Irr_BMXEventReceiver_getBinder(BMXEventReceiver* rec)
{
	if (rec)
		return rec->getBinder();
	else return 0;
}

void Irr_BMXEventReceiver_bindOnEvent(BMXEventReceiver* rec,bool (*bind_OnEvent)(s32 binding,SEvent* event))
{
	if (rec)
		rec->bindOnEvent(bind_OnEvent);
}

void Irr_BMXEventReceiver_del(BMXEventReceiver* del)
{
	if (del)
		delete del;
		
	del=0;
}

} // extern "C"