• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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);
hitTouchHandler()71     bool hitTouchHandler() { return m_hitTouchHandler; }
setHitTouchHandler()72     void setHitTouchHandler() { m_hitTouchHandler = true; }
73 #elif PLATFORM(BREWMP)
74     PlatformTouchEvent(AEEEvent, uint16 wParam, uint32 dwParam);
75 #elif PLATFORM(EFL)
76     PlatformTouchEvent(Eina_List*, const IntPoint, TouchEventType, int metaState);
77 #endif
78 
type()79     TouchEventType type() const { return m_type; }
touchPoints()80     const Vector<PlatformTouchPoint>& touchPoints() const { return m_touchPoints; }
81 
ctrlKey()82     bool ctrlKey() const { return m_ctrlKey; }
altKey()83     bool altKey() const { return m_altKey; }
shiftKey()84     bool shiftKey() const { return m_shiftKey; }
metaKey()85     bool metaKey() const { return m_metaKey; }
86 
87     // Time in seconds.
timestamp()88     double timestamp() const { return m_timestamp; }
89 
90 protected:
91     TouchEventType m_type;
92     Vector<PlatformTouchPoint> m_touchPoints;
93     bool m_ctrlKey;
94     bool m_altKey;
95     bool m_shiftKey;
96     bool m_metaKey;
97     double m_timestamp;
98 #if PLATFORM(ANDROID)
99     bool m_hitTouchHandler;
100 #endif
101 };
102 
103 }
104 
105 #endif // ENABLE(TOUCH_EVENTS)
106 
107 #endif // PlatformTouchEvent_h
108