|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef WEBGESTUREHELPER_H_ |
|
20 #define WEBGESTUREHELPER_H_ |
|
21 #include "qstmgestureapi.h" |
|
22 #include "qstmgestureevent.h" |
|
23 #include <QApplication> |
|
24 //#include "BWFGlobal.h" |
|
25 |
|
26 #if !defined(Q_WS_X11) |
|
27 #define XEvent void |
|
28 #endif |
|
29 |
|
30 |
|
31 class QStm_QtDummyGestureRecognizer; |
|
32 |
|
33 class WebGestureHelper |
|
34 { |
|
35 public: |
|
36 WebGestureHelper(QWidget* ctrl); |
|
37 |
|
38 virtual ~WebGestureHelper(); |
|
39 |
|
40 QStm_GestureEngineApi* gestureEngine() { return m_gestureEngine; } |
|
41 QStm_GestureContext* gestureContext(){ return m_gestures; } |
|
42 bool symbianEventFilter(const QSymbianEvent *event); |
|
43 bool x11EventFilter (XEvent* event); |
|
44 void setupGestureEngine(QWidget* ctrl); |
|
45 |
|
46 private: |
|
47 QStm_GestureEngineApi* m_gestureEngine; |
|
48 QStm_GestureContext* m_gestures; |
|
49 QStm_GestureParameters* m_parameters; |
|
50 QWidget* m_ctrl; |
|
51 QStm_QtDummyGestureRecognizer* m_dummyRecognizer; |
|
52 Qt::GestureType m_qstmGestureType; |
|
53 |
|
54 }; |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 #define browserApp (static_cast<BrowserApp*>(QApplication::instance())) |
|
60 |
|
61 class BrowserApp : public QApplication |
|
62 { |
|
63 Q_OBJECT |
|
64 public: |
|
65 BrowserApp(int argc, char** argv); |
|
66 virtual bool symbianEventFilter(const QSymbianEvent *event); |
|
67 virtual bool x11EventFilter (XEvent* event); |
|
68 void setGestureHelper(WebGestureHelper* gh); |
|
69 WebGestureHelper* gestureHelper() { return m_gestureHelper; } |
|
70 |
|
71 void setMainWindow(QWidget* mw) { m_mainWindow = mw; } |
|
72 QWidget* mainWindow() { return m_mainWindow; } |
|
73 QStm_GestureEngineApi* gestureEngine() { return m_gestureEngine; } |
|
74 |
|
75 private: |
|
76 WebGestureHelper* m_gestureHelper; |
|
77 QWidget* m_mainWindow; |
|
78 QStm_GestureEngineApi* m_gestureEngine; |
|
79 }; |
|
80 |
|
81 |
|
82 |
|
83 class WebGestureHelperEventFilter : public QObject |
|
84 { |
|
85 public: |
|
86 WebGestureHelperEventFilter() {} |
|
87 virtual ~WebGestureHelperEventFilter() {} |
|
88 static WebGestureHelperEventFilter* instance(); |
|
89 bool eventFilter(QObject* receiver, QEvent* event); |
|
90 |
|
91 private: |
|
92 static WebGestureHelperEventFilter* m_instance; |
|
93 }; |
|
94 |
|
95 |
|
96 class QStm_QtDummyGestureRecognizer : public QGestureRecognizer, |
|
97 public QStm_GestureListenerApiIf |
|
98 { |
|
99 public: |
|
100 QStm_QtDummyGestureRecognizer(QStm_GestureContext* ctx); |
|
101 ~QStm_QtDummyGestureRecognizer(); |
|
102 QGesture* create(QObject* target); |
|
103 QGestureRecognizer::Result recognize(QGesture *state, |
|
104 QObject *watched, |
|
105 QEvent *event); |
|
106 void reset(QGesture *state); |
|
107 |
|
108 //from QStm_GestureListenerApiIf |
|
109 QStm_ProcessingResult handleGestureEvent(qstmGesture::QStm_GestureUid uid, qstmGesture::QStm_GestureIf* gesture); |
|
110 |
|
111 private: |
|
112 QStm_GestureContext* m_context; |
|
113 QStm_Gesture* m_currentGesture; |
|
114 }; |
|
115 |
|
116 #endif /* GESTUREHELPER_H_ */ |