1 /*
2     Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
3 
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Library General Public
6     License as published by the Free Software Foundation; either
7     version 2 of the License, or (at your option) any later version.
8 
9     This library is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12     Library General Public License for more details.
13 
14     You should have received a copy of the GNU Library General Public License
15     along with this library; see the file COPYING.LIB.  If not, write to
16     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17     Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef PlatformTouchEvent_h
21 #define PlatformTouchEvent_h
22 
23 #include "PlatformTouchPoint.h"
24 #include <wtf/Vector.h>
25 
26 #if ENABLE(TOUCH_EVENTS)
27 
28 #if PLATFORM(QT)
29 QT_BEGIN_NAMESPACE
30 class QTouchEvent;
31 QT_END_NAMESPACE
32 #endif
33 
34 #if PLATFORM(ANDROID)
35 #include "IntPoint.h"
36 #endif
37 
38 #if PLATFORM(BREWMP)
39 typedef unsigned short    uint16;
40 typedef unsigned long int uint32;
41 #define AEEEvent uint16
42 #endif
43 
44 #if PLATFORM(EFL)
45 typedef struct _Eina_List Eina_List;
46 #endif
47 
48 namespace WebCore {
49 
50 enum TouchEventType {
51     TouchStart
52     , TouchMove
53     , TouchEnd
54     , TouchCancel
55 };
56 
57 class PlatformTouchEvent {
58 public:
PlatformTouchEvent()59     PlatformTouchEvent()
60         : m_type(TouchStart)
61         , m_ctrlKey(false)
62         , m_altKey(false)
63         , m_shiftKey(false)
64         , m_metaKey(false)
65         , m_timestamp(0)
66     {}
67 #if PLATFORM(QT)
68     PlatformTouchEvent(QTouchEvent*);
69 #elif PLATFORM(ANDROID)
70     PlatformTouchEvent(const Vector<int>&, const Vector<IntPoint>&, TouchEventType, const Vector<PlatformTouchPoint::State>&, int metaState);
71 #elif PLATFORM(BREWMP)
72     PlatformTouchEvent(AEEEvent, uint16 wParam, uint32 dwParam);
73 #elif PLATFORM(EFL)
74     PlatformTouchEvent(Eina_List*, const IntPoint, TouchEventType, int metaState);
75 #endif
76 
type()77     TouchEventType type() const { return m_type; }
touchPoints()78     const Vector<PlatformTouchPoint>& touchPoints() const { return m_touchPoints; }
79 
ctrlKey()80     bool ctrlKey() const { return m_ctrlKey; }
altKey()81     bool altKey() const { return m_altKey; }
shiftKey()82     bool shiftKey() const { return m_shiftKey; }
metaKey()83     bool metaKey() const { return m_metaKey; }
84 
85     // Time in seconds.
timestamp()86     double timestamp() const { return m_timestamp; }
87 
88 protected:
89     TouchEventType m_type;
90     Vector<PlatformTouchPoint> m_touchPoints;
91     bool m_ctrlKey;
92     bool m_altKey;
93     bool m_shiftKey;
94     bool m_metaKey;
95     double m_timestamp;
96 };
97 
98 }
99 
100 #endif // ENABLE(TOUCH_EVENTS)
101 
102 #endif // PlatformTouchEvent_h
103