#ifndef PlatformMouseEvent_h
#define PlatformMouseEvent_h
#include "platform/PlatformEvent.h"
#include "platform/geometry/IntPoint.h"
namespace WebCore {
enum MouseButton { NoButton = -1, LeftButton, MiddleButton, RightButton };
class PlatformMouseEvent : public PlatformEvent {
public:
enum SyntheticEventType {
NotFromTouch,
FromTouch,
};
PlatformMouseEvent()
: PlatformEvent(PlatformEvent::MouseMoved)
, m_button(NoButton)
, m_clickCount(0)
, m_synthesized(NotFromTouch)
, m_modifierFlags(0)
{
}
PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, PlatformEvent::Type type, int clickCount, Modifiers modifiers, double timestamp)
: PlatformEvent(type, modifiers, timestamp)
, m_position(position)
, m_globalPosition(globalPosition)
, m_button(button)
, m_clickCount(clickCount)
, m_synthesized(NotFromTouch)
, m_modifierFlags(0)
{
}
PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, PlatformEvent::Type type, int clickCount, Modifiers modifiers, SyntheticEventType synthesized, double timestamp)
: PlatformEvent(type, modifiers, timestamp)
, m_position(position)
, m_globalPosition(globalPosition)
, m_button(button)
, m_clickCount(clickCount)
, m_synthesized(synthesized)
, m_modifierFlags(0)
{
}
PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, PlatformEvent::Type type, int clickCount, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey, double timestamp)
: PlatformEvent(type, shiftKey, ctrlKey, altKey, metaKey, timestamp)
, m_position(position)
, m_globalPosition(globalPosition)
, m_button(button)
, m_clickCount(clickCount)
, m_synthesized(NotFromTouch)
, m_modifierFlags(0)
{
}
const IntPoint& position() const { return m_position; }
const IntPoint& globalPosition() const { return m_globalPosition; }
const IntPoint& movementDelta() const { return m_movementDelta; }
MouseButton button() const { return m_button; }
int clickCount() const { return m_clickCount; }
unsigned modifierFlags() const { return m_modifierFlags; }
bool fromTouch() const { return m_synthesized == FromTouch; }
protected:
IntPoint m_position;
IntPoint m_globalPosition;
IntPoint m_movementDelta;
MouseButton m_button;
int m_clickCount;
SyntheticEventType m_synthesized;
unsigned m_modifierFlags;
};
}
#endif