Home | History | Annotate | Download | only in platform
      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 #if PLATFORM(ANDROID)
     56     , TouchLongPress
     57     , TouchDoubleTap
     58 #endif
     59 };
     60 
     61 class PlatformTouchEvent {
     62 public:
     63     PlatformTouchEvent()
     64         : m_type(TouchStart)
     65         , m_ctrlKey(false)
     66         , m_altKey(false)
     67         , m_shiftKey(false)
     68         , m_metaKey(false)
     69         , m_timestamp(0)
     70     {}
     71 #if PLATFORM(QT)
     72     PlatformTouchEvent(QTouchEvent*);
     73 #elif PLATFORM(ANDROID)
     74     PlatformTouchEvent(const Vector<int>&, const Vector<IntPoint>&, TouchEventType, const Vector<PlatformTouchPoint::State>&, int metaState);
     75 #elif PLATFORM(BREWMP)
     76     PlatformTouchEvent(AEEEvent, uint16 wParam, uint32 dwParam);
     77 #elif PLATFORM(EFL)
     78     PlatformTouchEvent(Eina_List*, const IntPoint, TouchEventType, int metaState);
     79 #endif
     80 
     81     TouchEventType type() const { return m_type; }
     82     const Vector<PlatformTouchPoint>& touchPoints() const { return m_touchPoints; }
     83 
     84     bool ctrlKey() const { return m_ctrlKey; }
     85     bool altKey() const { return m_altKey; }
     86     bool shiftKey() const { return m_shiftKey; }
     87     bool metaKey() const { return m_metaKey; }
     88 
     89     // Time in seconds.
     90     double timestamp() const { return m_timestamp; }
     91 
     92 protected:
     93     TouchEventType m_type;
     94     Vector<PlatformTouchPoint> m_touchPoints;
     95     bool m_ctrlKey;
     96     bool m_altKey;
     97     bool m_shiftKey;
     98     bool m_metaKey;
     99     double m_timestamp;
    100 };
    101 
    102 }
    103 
    104 #endif // ENABLE(TOUCH_EVENTS)
    105 
    106 #endif // PlatformTouchEvent_h
    107