arabica/include/DOM/Events/Event.hpp

114 lines
3.3 KiB
C++
Raw Permalink Normal View History

2002-06-21 13:16:28 +02:00
#ifndef JEZUK_EVENTS_EVENT_H
#define JEZUK_EVENTS_EVENT_H
2007-09-05 13:47:13 +02:00
namespace Arabica
{
2002-06-21 13:16:28 +02:00
namespace DOM
{
namespace Events
{
2012-12-30 01:10:31 +01:00
template<class stringT, class string_adaptorT> class Event_impl;
2002-06-21 13:16:28 +02:00
2012-12-30 01:10:31 +01:00
template<class stringT, class string_adaptorT = Arabica::default_string_adaptor<stringT> >
class Event : public Arabica::DOM::Proxy<Event_impl<stringT, string_adaptorT> >
2002-06-21 13:16:28 +02:00
{
public:
2012-12-30 01:10:31 +01:00
typedef Event_impl<stringT, string_adaptorT> Event_implT;
typedef DOM::Proxy<Event_implT> proxy_t;
Event() : proxy_t(0) { }
Event(Event_impl<stringT, string_adaptorT>* const impl) : proxy_t(impl) { }
Event(const Event& rhs) : proxy_t(rhs) { }
2002-06-21 13:16:28 +02:00
virtual ~Event() { }
2012-12-30 01:10:31 +01:00
bool operator==(const Event& rhs) const { return proxy_t::operator==(rhs); }
bool operator!=(const Event& rhs) const { return proxy_t::operator!=(rhs); }
bool operator==(int dummy) const { return proxy_t::operator==(dummy); }
bool operator!=(int dummy) const { return proxy_t::operator!=(dummy); }
2002-06-21 13:16:28 +02:00
Event& operator=(const Event& rhs)
{
2012-12-30 01:10:31 +01:00
proxy_t::operator=(rhs);
2002-06-21 13:16:28 +02:00
return *this;
} // operator=
/////////////////////////////////////////////
// Event methods
enum Phase
{
CAPTURING_PHASE = 1,
AT_TARGET = 2,
BUBBLING_PHASE = 3
}; // enum Phase
stringT getType() const { return Impl()->getType(); }
2012-12-30 01:10:31 +01:00
EventTarget<stringT, string_adaptorT> getTarget() const { return Impl()->getTarget(); }
2002-06-21 13:16:28 +02:00
2012-12-30 01:10:31 +01:00
EventTarget<stringT, string_adaptorT> getCurrentTarget() const { return Impl()->getCurrentTarget(); }
2002-06-21 13:16:28 +02:00
Phase getEventPhase() const { return Impl()->getEventPhase(); }
bool getBubbles() const { return Impl()->getBubbles(); }
bool getCancelable() const { return Impl()->getCancelable(); }
long getTimeStamp() const { return Impl()->getTimeStamp(); }
void stopPropagation() { return Impl()->stopPropagation(); }
void preventDefault() { return Impl()->preventDefault(); }
void initEvent(const stringT& eventTypeArg, bool canBubble, bool cancelable)
{
return Impl()->initEvent(eventTypeArg, canBubble, cancelable);
} // initEvent
protected:
2012-12-30 01:10:31 +01:00
Event_impl<stringT, string_adaptorT>* Impl() const { return dynamic_cast<Event_impl<stringT, string_adaptorT>*>(proxy_t::operator*()); }
2002-06-21 13:16:28 +02:00
}; // class Event
///////////////////////////////////////////////////////////
// Event_impl
2012-12-30 01:10:31 +01:00
template<class stringT, class string_adaptorT>
class Event_impl
2002-06-21 13:16:28 +02:00
{
public:
//////////////////////////////////////////////////
// Event methods
virtual stringT getType() const = 0;
2012-12-30 01:10:31 +01:00
virtual EventTarget<stringT, string_adaptorT> getTarget() const = 0;
2002-06-21 13:16:28 +02:00
2012-12-30 01:10:31 +01:00
virtual EventTarget<stringT, string_adaptorT> getCurrentTarget() const = 0;
2002-06-21 13:16:28 +02:00
2012-12-30 01:10:31 +01:00
virtual typename Event<stringT, string_adaptorT>::Phase getEventPhase() const = 0;
2002-06-21 13:16:28 +02:00
virtual bool getBubbles() const = 0;
virtual bool getCancelable() const = 0;
virtual unsigned long long getTimeStamp() const = 0;
2002-06-21 13:16:28 +02:00
virtual void stopPropagation() = 0;
virtual void preventDefault() = 0;
virtual void initEvent(const stringT& eventTypeArg, bool canBubble, bool cancelable) = 0;
2012-12-30 01:10:31 +01:00
///////////////////////////////////////////////////////
// Ref counting
virtual void addRef() = 0;
virtual void releaseRef() = 0;
2002-06-21 13:16:28 +02:00
}; // class Event_impl
} // namespace Events
} // namespace DOM
2007-09-05 13:47:13 +02:00
} // namespace Arabica
2002-06-21 13:16:28 +02:00
#endif
2007-09-05 13:47:13 +02:00
// end of file