#ifndef PlatformWheelEvent_h
#define PlatformWheelEvent_h
#include "platform/PlatformEvent.h"
#include "platform/geometry/IntPoint.h"
namespace WebCore {
class FloatPoint;
class FloatSize;
enum PlatformWheelEventGranularity {
    ScrollByPageWheelEvent,
    ScrollByPixelWheelEvent,
};
#if OS(MACOSX)
enum PlatformWheelEventPhase {
    PlatformWheelEventPhaseNone        = 0,
    PlatformWheelEventPhaseBegan       = 1 << 0,
    PlatformWheelEventPhaseStationary  = 1 << 1,
    PlatformWheelEventPhaseChanged     = 1 << 2,
    PlatformWheelEventPhaseEnded       = 1 << 3,
    PlatformWheelEventPhaseCancelled   = 1 << 4,
    PlatformWheelEventPhaseMayBegin    = 1 << 5,
};
#endif
class PlatformWheelEvent : public PlatformEvent {
public:
    PlatformWheelEvent()
        : PlatformEvent(PlatformEvent::Wheel)
        , m_deltaX(0)
        , m_deltaY(0)
        , m_wheelTicksX(0)
        , m_wheelTicksY(0)
        , m_granularity(ScrollByPixelWheelEvent)
        , m_directionInvertedFromDevice(false)
        , m_hasPreciseScrollingDeltas(false)
#if OS(MACOSX)
        , m_phase(PlatformWheelEventPhaseNone)
        , m_momentumPhase(PlatformWheelEventPhaseNone)
        , m_scrollCount(0)
        , m_unacceleratedScrollingDeltaX(0)
        , m_unacceleratedScrollingDeltaY(0)
        , m_canRubberbandLeft(true)
        , m_canRubberbandRight(true)
#endif
    {
    }
    PlatformWheelEvent(IntPoint position, IntPoint globalPosition, float deltaX, float deltaY, float wheelTicksX, float wheelTicksY, PlatformWheelEventGranularity granularity, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey)
        : PlatformEvent(PlatformEvent::Wheel, shiftKey, ctrlKey, altKey, metaKey, 0)
        , m_position(position)
        , m_globalPosition(globalPosition)
        , m_deltaX(deltaX)
        , m_deltaY(deltaY)
        , m_wheelTicksX(wheelTicksX)
        , m_wheelTicksY(wheelTicksY)
        , m_granularity(granularity)
        , m_directionInvertedFromDevice(false)
        , m_hasPreciseScrollingDeltas(false)
#if OS(MACOSX)
        , m_phase(PlatformWheelEventPhaseNone)
        , m_momentumPhase(PlatformWheelEventPhaseNone)
        , m_scrollCount(0)
        , m_unacceleratedScrollingDeltaX(0)
        , m_unacceleratedScrollingDeltaY(0)
        , m_canRubberbandLeft(true)
        , m_canRubberbandRight(true)
#endif
    {
    }
    PlatformWheelEvent copyTurningVerticalTicksIntoHorizontalTicks() const
    {
        PlatformWheelEvent copy = *this;
        copy.m_deltaX = copy.m_deltaY;
        copy.m_deltaY = 0;
        copy.m_wheelTicksX = copy.m_wheelTicksY;
        copy.m_wheelTicksY = 0;
        return copy;
    }
    const IntPoint& position() const { return m_position; } 
    const IntPoint& globalPosition() const { return m_globalPosition; } 
    float deltaX() const { return m_deltaX; }
    float deltaY() const { return m_deltaY; }
    float wheelTicksX() const { return m_wheelTicksX; }
    float wheelTicksY() const { return m_wheelTicksY; }
    PlatformWheelEventGranularity granularity() const { return m_granularity; }
    bool directionInvertedFromDevice() const { return m_directionInvertedFromDevice; }
    bool hasPreciseScrollingDeltas() const { return m_hasPreciseScrollingDeltas; }
    void setHasPreciseScrollingDeltas(bool b) { m_hasPreciseScrollingDeltas = b; }
#if OS(MACOSX)
    PlatformWheelEventPhase phase() const { return m_phase; }
    PlatformWheelEventPhase momentumPhase() const { return m_momentumPhase; }
    unsigned scrollCount() const { return m_scrollCount; }
    float unacceleratedScrollingDeltaX() const { return m_unacceleratedScrollingDeltaX; }
    float unacceleratedScrollingDeltaY() const { return m_unacceleratedScrollingDeltaY; }
    bool useLatchedEventNode() const { return m_momentumPhase == PlatformWheelEventPhaseBegan || m_momentumPhase == PlatformWheelEventPhaseChanged; }
    bool canRubberbandLeft() const { return m_canRubberbandLeft; }
    bool canRubberbandRight() const { return m_canRubberbandRight; }
#else
    bool useLatchedEventNode() const { return false; }
#endif
protected:
    IntPoint m_position;
    IntPoint m_globalPosition;
    float m_deltaX;
    float m_deltaY;
    float m_wheelTicksX;
    float m_wheelTicksY;
    PlatformWheelEventGranularity m_granularity;
    bool m_directionInvertedFromDevice;
    bool m_hasPreciseScrollingDeltas;
#if OS(MACOSX)
    PlatformWheelEventPhase m_phase;
    PlatformWheelEventPhase m_momentumPhase;
    unsigned m_scrollCount;
    float m_unacceleratedScrollingDeltaX;
    float m_unacceleratedScrollingDeltaY;
    bool m_canRubberbandLeft;
    bool m_canRubberbandRight;
#endif
};
} 
#endif