#include "config.h"
#include "PlatformMouseEvent.h"
#include <wtf/Assertions.h>
#include <wx/defs.h>
#include <wx/event.h>
#include <wtf/CurrentTime.h>
namespace WebCore {
static PlatformEvent::Type typeFromMouseEvent(const wxMouseEvent& event)
{
wxEventType type = event.GetEventType();
if (type == wxEVT_LEFT_DOWN || type == wxEVT_MIDDLE_DOWN || type == wxEVT_RIGHT_DOWN)
return PlatformEvent::MousePressed;
if (type == wxEVT_LEFT_UP || type == wxEVT_MIDDLE_UP || type == wxEVT_RIGHT_UP || type == wxEVT_LEFT_DCLICK || type == wxEVT_MIDDLE_DCLICK || type == wxEVT_RIGHT_DCLICK)
return PlatformEvent::MouseReleased;
if (type == wxEVT_MOTION)
return PlatformEvent::MouseMoved;
return PlatformEvent::MouseMoved;
}
PlatformMouseEvent::PlatformMouseEvent(const wxMouseEvent& event, const wxPoint& globalPoint, int clickCount)
: PlatformEvent(typeFromMouseEvent(event), event.ShiftDown(), event.CmdDown() || event.ControlDown(), event.AltDown(), event.MetaDown(), WTF::currentTime())
, m_position(event.GetPosition())
, m_globalPosition(globalPoint)
{
if (event.LeftIsDown() || event.Button(wxMOUSE_BTN_LEFT))
m_button = LeftButton;
else if (event.RightIsDown() || event.Button(wxMOUSE_BTN_RIGHT))
m_button = RightButton;
else if (event.MiddleIsDown() || event.Button(wxMOUSE_BTN_MIDDLE))
m_button = MiddleButton;
if (m_type == PlatformEvent::MouseMoved)
m_clickCount = 0;
else
m_clickCount = clickCount;
}
}