2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef PlatformMouseEvent_h
27 #define PlatformMouseEvent_h
29 #include <GraphicsServices/GSEvent.h>
32 #include <wtf/Platform.h>
47 typedef struct HWND__
* HWND
;
48 typedef unsigned UINT
;
49 typedef unsigned WPARAM
;
54 typedef struct _GdkEventButton GdkEventButton
;
55 typedef struct _GdkEventMotion GdkEventMotion
;
70 // These button numbers match the ones used in the DOM API, 0 through 2, except for NoButton which isn't specified.
71 enum MouseButton
{ NoButton
= -1, LeftButton
, MiddleButton
, RightButton
};
72 enum MouseEventType
{ MouseEventMoved
, MouseEventPressed
, MouseEventReleased
, MouseEventScroll
};
74 class PlatformMouseEvent
{
78 , m_eventType(MouseEventMoved
)
89 PlatformMouseEvent(const IntPoint
& pos
, const IntPoint
& globalPos
, MouseButton button
, MouseEventType eventType
,
90 int clickCount
, bool shift
, bool ctrl
, bool alt
, bool meta
, double timestamp
)
91 : m_position(pos
), m_globalPosition(globalPos
), m_button(button
)
92 , m_eventType(eventType
)
93 , m_clickCount(clickCount
)
98 , m_timestamp(timestamp
)
103 const IntPoint
& pos() const { return m_position
; }
104 int x() const { return m_position
.x(); }
105 int y() const { return m_position
.y(); }
106 int globalX() const { return m_globalPosition
.x(); }
107 int globalY() const { return m_globalPosition
.y(); }
108 MouseButton
button() const { return m_button
; }
109 MouseEventType
eventType() const { return m_eventType
; }
110 int clickCount() const { return m_clickCount
; }
111 bool shiftKey() const { return m_shiftKey
; }
112 bool ctrlKey() const { return m_ctrlKey
; }
113 bool altKey() const { return m_altKey
; }
114 bool metaKey() const { return m_metaKey
; }
115 unsigned modifierFlags() const { return m_modifierFlags
; }
118 double timestamp() const { return m_timestamp
; }
121 PlatformMouseEvent(GSEventRef
);
124 PlatformMouseEvent(HWND
, UINT
, WPARAM
, LPARAM
, bool activatedWebView
= false);
125 void setClickCount(int count
) { m_clickCount
= count
; }
126 bool activatedWebView() const { return m_activatedWebView
; }
129 PlatformMouseEvent(GdkEventButton
*);
130 PlatformMouseEvent(GdkEventMotion
*);
133 PlatformMouseEvent(QInputEvent
*, int clickCount
);
137 PlatformMouseEvent(const wxMouseEvent
&, const wxPoint
& globalPoint
);
143 IntPoint m_globalPosition
;
144 MouseButton m_button
;
145 MouseEventType m_eventType
;
151 double m_timestamp
; // unit: seconds
152 unsigned m_modifierFlags
;
154 bool m_activatedWebView
;
159 IntPoint
pointForEvent(GSEventRef event
);
160 IntPoint
globalPointForEvent(GSEventRef event
);
163 } // namespace WebCore
165 #endif // PlatformMouseEvent_h