#ifndef JEZUK_EVENTS_EVENTTARGET_H #define JEZUK_EVENTS_EVENTTARGET_H //////////////////////////// // C++ DOM definition // // $Id$ //////////////////////////// #include namespace Arabica { namespace DOM { namespace Events { template class Event; template class EventListener; template class EventTarget_impl; template class EventTarget : protected DOM::Proxy { public: EventTarget() : Proxy(0) { } EventTarget(EventTarget_impl* const impl) : Proxy(impl) { } EventTarget(const EventTarget& rhs) : Proxy(rhs) { } explicit EventTarget(const DOM::Node& rhs) : Proxy(rhs.nImpl()) { if(dynamic_cast*>(rhs.nImpl()) == 0) throw DOM::DOMException(DOM::DOMException::NOT_SUPPORTED_ERR); } // DocumentTraversal virtual ~EventTarget() { } bool operator==(const EventTarget& rhs) const { return Proxy::operator==(rhs); } bool operator!=(const EventTarget& rhs) const { return Proxy::operator!=(rhs); } bool operator==(int dummy) const { return Proxy::operator==(dummy); } bool operator!=(int dummy) const { return Proxy::operator!=(dummy); } EventTarget& operator=(const EventTarget& rhs) { Proxy::operator=(rhs); return *this; } // operator= /////////////////////////////////////////////////////////////// // EventTarget methods void addEventListener(const stringT type, EventListener& listener, bool useCapture) { Impl()->addEventListener(type, listener, useCapture) } // addEventListener void removeEventListener(const stringT type, EventListener& listener, bool useCapture) { Impl()->removeEventListener(type, listener, useCapture); } // removeEventListener bool dispatchEvent(Event& event) { Impl()->dispatchEvent(event); } // dispatchEvent private: EventTarget_impl* Impl() const { return dynamic_cast*>(impl()); } }; // class EventTarget ////////////////////////////////////////////////////////////////////// // Event_impl template class EventTarget_impl : virtual public Impl { /////////////////////////////////////////////////////////////// // EventTarget methods virtual void addEventListener(const stringT type, EventListener& listener, bool useCapture) = 0; virtual void removeEventListener(const stringT type, EventListener& listener, bool useCapture) = 0; virtual bool dispatchEvent(Event& event) = 0; }; // class EventTarget_impl } // namespace Events } // namespace DOM } // namespace Arabica #endif