ginebra2/WebGestureHelper.h
branchGCC_SURGE
changeset 8 2e16851ffecd
parent 5 0f2326c2a325
child 16 3c88a81ff781
equal deleted inserted replaced
2:bf4420e9fa4d 8:2e16851ffecd
     1 /*
     1 /*
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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 *
     4 *
     9 * Initial Contributors:
     5 * This program is free software: you can redistribute it and/or modify
    10 * Nokia Corporation - initial contribution.
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
    11 *
     8 *
    12 * Contributors:
     9 * This program 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
       
    12 * GNU Lesser General Public License for more details.
    13 *
    13 *
    14 * Description: 
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not,
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
    15 *
    19 *
    16 */
    20 */
    17 
       
    18 
    21 
    19 #ifndef WEBGESTUREHELPER_H_
    22 #ifndef WEBGESTUREHELPER_H_
    20 #define WEBGESTUREHELPER_H_
    23 #define WEBGESTUREHELPER_H_
    21 #include "qstmgestureapi.h"
    24 #include "qstmgestureapi.h"
    22 #include "qstmgestureevent.h"
    25 #include "qstmgestureevent.h"
    30 
    33 
    31 class QStm_QtDummyGestureRecognizer;
    34 class QStm_QtDummyGestureRecognizer;
    32 
    35 
    33 class WebGestureHelper
    36 class WebGestureHelper
    34 {
    37 {
    35 public:	
    38 public:
    36 	WebGestureHelper(QWidget* ctrl);
    39     WebGestureHelper(QWidget* ctrl);
    37 		
    40 
    38 	virtual ~WebGestureHelper();	
    41     virtual ~WebGestureHelper();
    39 	    
    42 
    40 	QStm_GestureEngineApi* gestureEngine() { return m_gestureEngine; }
    43     QStm_GestureEngineApi* gestureEngine() { return m_gestureEngine; }
    41 	QStm_GestureContext*   gestureContext(){ return m_gestures; }
    44     QStm_GestureContext*   gestureContext(){ return m_gestures; }
    42 	bool symbianEventFilter(const QSymbianEvent *event);
    45     bool symbianEventFilter(const QSymbianEvent *event);
    43 	bool x11EventFilter (XEvent* event);
    46     bool x11EventFilter (XEvent* event);
    44 	void setupGestureEngine(QWidget* ctrl);
    47     void setupGestureEngine(QWidget* ctrl);
    45 	
    48 
    46 private:
    49 private:
    47     QStm_GestureEngineApi* m_gestureEngine;    
    50     QStm_GestureEngineApi* m_gestureEngine;
    48     QStm_GestureContext* m_gestures;
    51     QStm_GestureContext* m_gestures;
    49     QStm_GestureParameters* m_parameters;    
    52     QStm_GestureParameters* m_parameters;
    50     QWidget* m_ctrl;
    53     QWidget* m_ctrl;
    51     QStm_QtDummyGestureRecognizer* m_dummyRecognizer;
    54     QStm_QtDummyGestureRecognizer* m_dummyRecognizer;
    52     Qt::GestureType m_qstmGestureType;
    55     Qt::GestureType m_qstmGestureType;
    53 
    56 
    54 };
    57 };
    58 
    61 
    59 #define browserApp   (static_cast<BrowserApp*>(QApplication::instance()))
    62 #define browserApp   (static_cast<BrowserApp*>(QApplication::instance()))
    60 
    63 
    61 class BrowserApp : public QApplication
    64 class BrowserApp : public QApplication
    62 {
    65 {
    63 	Q_OBJECT
    66     Q_OBJECT
    64 public:
    67 public:
    65 	BrowserApp(int argc, char** argv);
    68     BrowserApp(int argc, char** argv);
    66 	virtual bool symbianEventFilter(const QSymbianEvent *event);
    69     virtual bool symbianEventFilter(const QSymbianEvent *event);
    67     virtual bool x11EventFilter (XEvent* event);
    70     virtual bool x11EventFilter (XEvent* event);
    68 	void  setGestureHelper(WebGestureHelper* gh);
    71     void  setGestureHelper(WebGestureHelper* gh);
    69 	WebGestureHelper* gestureHelper() { return m_gestureHelper; }
    72     WebGestureHelper* gestureHelper() { return m_gestureHelper; }
    70 
    73 
    71 	void setMainWindow(QWidget* mw) { m_mainWindow = mw; }
    74     void setMainWindow(QWidget* mw) { m_mainWindow = mw; }
    72 	QWidget* mainWindow() { return m_mainWindow; }
    75     QWidget* mainWindow() { return m_mainWindow; }
    73 	QStm_GestureEngineApi* gestureEngine() { return m_gestureEngine; }
    76     QStm_GestureEngineApi* gestureEngine() { return m_gestureEngine; }
    74 	
    77 
    75 private:
    78 private:
    76 	WebGestureHelper*        m_gestureHelper;
    79     WebGestureHelper*        m_gestureHelper;
    77 	QWidget*                 m_mainWindow;
    80     QWidget*                 m_mainWindow;
    78 	QStm_GestureEngineApi*   m_gestureEngine;    
    81     QStm_GestureEngineApi*   m_gestureEngine;
    79 };
    82 };
    80 
    83 
    81 
    84 
    82 
    85 
    83 class WebGestureHelperEventFilter : public QObject
    86 class WebGestureHelperEventFilter : public QObject
    84 {
    87 {
    85 public:
    88 public:
    86 	WebGestureHelperEventFilter() {}
    89     WebGestureHelperEventFilter() {}
    87 	virtual ~WebGestureHelperEventFilter() {}
    90     virtual ~WebGestureHelperEventFilter() {}
    88     static 	WebGestureHelperEventFilter* instance();
    91     static  WebGestureHelperEventFilter* instance();
    89     bool eventFilter(QObject* receiver, QEvent* event);
    92     bool eventFilter(QObject* receiver, QEvent* event);
    90     
    93 
    91 private:
    94 private:
    92     static WebGestureHelperEventFilter* m_instance;
    95     static WebGestureHelperEventFilter* m_instance;
    93 };
    96 };
    94 
    97 
    95 
    98 
    96 class QStm_QtDummyGestureRecognizer : public QGestureRecognizer,
    99 class QStm_QtDummyGestureRecognizer : public QGestureRecognizer,
    97                                       public QStm_GestureListenerApiIf
   100                                       public QStm_GestureListenerApiIf
    98 {
   101 {
    99 public:
   102 public:
   100 	QStm_QtDummyGestureRecognizer(QStm_GestureContext* ctx);
   103     QStm_QtDummyGestureRecognizer(QStm_GestureContext* ctx);
   101 	~QStm_QtDummyGestureRecognizer();
   104     ~QStm_QtDummyGestureRecognizer();
   102 	QGesture* create(QObject* target);
   105     QGesture* create(QObject* target);
   103 	QGestureRecognizer::Result recognize(QGesture *state, 
   106     QGestureRecognizer::Result recognize(QGesture *state,
   104 			                             QObject *watched, 
   107                                          QObject *watched,
   105 			                             QEvent *event);
   108                                          QEvent *event);
   106 	void reset(QGesture *state);
   109     void reset(QGesture *state);
   107 	
   110 
   108 	//from QStm_GestureListenerApiIf
   111     //from QStm_GestureListenerApiIf
   109 	QStm_ProcessingResult handleGestureEvent(qstmGesture::QStm_GestureUid uid, qstmGesture::QStm_GestureIf* gesture);
   112     QStm_ProcessingResult handleGestureEvent(qstmGesture::QStm_GestureUid uid, qstmGesture::QStm_GestureIf* gesture);
   110 	
   113 
   111 private:	
   114 private:
   112 	QStm_GestureContext* m_context;
   115     QStm_GestureContext* m_context;
   113 	QStm_Gesture* m_currentGesture;
   116     QStm_Gesture* m_currentGesture;
   114 };
   117 };
   115 
   118 
   116 #endif /* GESTUREHELPER_H_ */
   119 #endif /* GESTUREHELPER_H_ */