]> git.saurik.com Git - iphone-api.git/blob - WebCore/PlatformMouseEvent.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / PlatformMouseEvent.h
1 /*
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
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.
12 *
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.
24 */
25
26 #ifndef PlatformMouseEvent_h
27 #define PlatformMouseEvent_h
28
29 #include <GraphicsServices/GSEvent.h>
30
31 #include "IntPoint.h"
32 #include <wtf/Platform.h>
33
34 #if PLATFORM(MAC)
35 #ifdef __OBJC__
36 @class NSEvent;
37 @class NSScreen;
38 @class NSWindow;
39 #else
40 class NSEvent;
41 class NSScreen;
42 class NSWindow;
43 #endif
44 #endif
45
46 #if PLATFORM(WIN)
47 typedef struct HWND__* HWND;
48 typedef unsigned UINT;
49 typedef unsigned WPARAM;
50 typedef long LPARAM;
51 #endif
52
53 #if PLATFORM(GTK)
54 typedef struct _GdkEventButton GdkEventButton;
55 typedef struct _GdkEventMotion GdkEventMotion;
56 #endif
57
58 #if PLATFORM(QT)
59 QT_BEGIN_NAMESPACE
60 class QInputEvent;
61 QT_END_NAMESPACE
62 #endif
63
64 #if PLATFORM(WX)
65 class wxMouseEvent;
66 #endif
67
68 namespace WebCore {
69
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 };
73
74 class PlatformMouseEvent {
75 public:
76 PlatformMouseEvent()
77 : m_button(NoButton)
78 , m_eventType(MouseEventMoved)
79 , m_clickCount(0)
80 , m_shiftKey(false)
81 , m_ctrlKey(false)
82 , m_altKey(false)
83 , m_metaKey(false)
84 , m_timestamp(0)
85 , m_modifierFlags(0)
86 {
87 }
88
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)
94 , m_shiftKey(shift)
95 , m_ctrlKey(ctrl)
96 , m_altKey(alt)
97 , m_metaKey(meta)
98 , m_timestamp(timestamp)
99 , m_modifierFlags(0)
100 {
101 }
102
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; }
116
117 //time in seconds
118 double timestamp() const { return m_timestamp; }
119
120 #if PLATFORM(MAC)
121 PlatformMouseEvent(GSEventRef);
122 #endif
123 #if PLATFORM(WIN)
124 PlatformMouseEvent(HWND, UINT, WPARAM, LPARAM, bool activatedWebView = false);
125 void setClickCount(int count) { m_clickCount = count; }
126 bool activatedWebView() const { return m_activatedWebView; }
127 #endif
128 #if PLATFORM(GTK)
129 PlatformMouseEvent(GdkEventButton*);
130 PlatformMouseEvent(GdkEventMotion*);
131 #endif
132 #if PLATFORM(QT)
133 PlatformMouseEvent(QInputEvent*, int clickCount);
134 #endif
135
136 #if PLATFORM(WX)
137 PlatformMouseEvent(const wxMouseEvent&, const wxPoint& globalPoint);
138 #endif
139
140
141 protected:
142 IntPoint m_position;
143 IntPoint m_globalPosition;
144 MouseButton m_button;
145 MouseEventType m_eventType;
146 int m_clickCount;
147 bool m_shiftKey;
148 bool m_ctrlKey;
149 bool m_altKey;
150 bool m_metaKey;
151 double m_timestamp; // unit: seconds
152 unsigned m_modifierFlags;
153 #if PLATFORM(WIN)
154 bool m_activatedWebView;
155 #endif
156 };
157
158 #if PLATFORM(MAC)
159 IntPoint pointForEvent(GSEventRef event);
160 IntPoint globalPointForEvent(GSEventRef event);
161 #endif
162
163 } // namespace WebCore
164
165 #endif // PlatformMouseEvent_h