#ifndef PlatformEvent_h
#define PlatformEvent_h
namespace WebCore {
class PlatformEvent {
public:
enum Type {
NoType = 0,
KeyDown,
KeyUp,
RawKeyDown,
Char,
MouseMoved,
MousePressed,
MouseReleased,
MouseScroll,
Wheel,
GestureScrollBegin,
GestureScrollEnd,
GestureScrollUpdate,
GestureScrollUpdateWithoutPropagation,
GestureTap,
GestureTapUnconfirmed,
GestureTapDown,
GestureShowPress,
GestureTapDownCancel,
GestureTwoFingerTap,
GestureLongPress,
GestureLongTap,
GesturePinchBegin,
GesturePinchEnd,
GesturePinchUpdate,
GestureFlingStart,
TouchStart,
TouchMove,
TouchEnd,
TouchCancel,
};
enum Modifiers {
AltKey = 1 << 0,
CtrlKey = 1 << 1,
MetaKey = 1 << 2,
ShiftKey = 1 << 3,
};
Type type() const { return static_cast<Type>(m_type); }
bool shiftKey() const { return m_modifiers & ShiftKey; }
bool ctrlKey() const { return m_modifiers & CtrlKey; }
bool altKey() const { return m_modifiers & AltKey; }
bool metaKey() const { return m_modifiers & MetaKey; }
unsigned modifiers() const { return m_modifiers; }
double timestamp() const { return m_timestamp; }
protected:
PlatformEvent()
: m_type(NoType)
, m_modifiers(0)
, m_timestamp(0)
{
}
explicit PlatformEvent(Type type)
: m_type(type)
, m_modifiers(0)
, m_timestamp(0)
{
}
PlatformEvent(Type type, Modifiers modifiers, double timestamp)
: m_type(type)
, m_modifiers(modifiers)
, m_timestamp(timestamp)
{
}
PlatformEvent(Type type, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey, double timestamp)
: m_type(type)
, m_modifiers(0)
, m_timestamp(timestamp)
{
if (shiftKey)
m_modifiers |= ShiftKey;
if (ctrlKey)
m_modifiers |= CtrlKey;
if (altKey)
m_modifiers |= AltKey;
if (metaKey)
m_modifiers |= MetaKey;
}
~PlatformEvent()
{
}
unsigned m_type;
unsigned m_modifiers;
double m_timestamp;
};
}
#endif