summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qapplication_p.h
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-06-15 14:00:46 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-07-02 15:16:07 (GMT)
commit60e965fd35037f4a27816d2aeccafdff0d6ae9d6 (patch)
tree8a968022a03057cc29aa3f7cc246ee708d869b8a /src/gui/kernel/qapplication_p.h
parent099a32d121cbc80a1a234c3146f4be9b5237e7e8 (diff)
downloadQt-60e965fd35037f4a27816d2aeccafdff0d6ae9d6.zip
Qt-60e965fd35037f4a27816d2aeccafdff0d6ae9d6.tar.gz
Qt-60e965fd35037f4a27816d2aeccafdff0d6ae9d6.tar.bz2
Refactored gesture api
Rewritten the api almost from scratch, making it simplier and more flexible at the same time. The current implementation will not have complex gseturemanager class inside Qt, but the QGesture base class, which represents both a gesture recognizer and a gesture itself with a set of properties. A set of common gestures that can use used in third-party applications (and in Qt itself internally) is supposed to be found in qstandardgestures.h, and a base class for user-defined gestures is in qgesture.h Gesture implementation for Pan on Windows7 has also been added as a reference implementation for platform gestures.
Diffstat (limited to 'src/gui/kernel/qapplication_p.h')
-rw-r--r--src/gui/kernel/qapplication_p.h121
1 files changed, 116 insertions, 5 deletions
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 4b2bf15..db77b07 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -193,7 +193,109 @@ extern "C" {
typedef BOOL (WINAPI *qt_RegisterTouchWindowPtr)(HWND, ULONG);
typedef BOOL (WINAPI *qt_GetTouchInputInfoPtr)(HANDLE, UINT, PVOID, int);
typedef BOOL (WINAPI *qt_CloseTouchInputHandlePtr)(HANDLE);
-#endif
+
+#ifndef WM_GESTURE
+
+#define WM_GESTURE 0x0119
+#define WM_GESTURE_NOTIFY 0x011A
+
+DECLARE_HANDLE(HGESTUREINFO);
+
+#define GF_BEGIN 0x00000001
+#define GF_INERTIA 0x00000002
+#define GF_END 0x00000004
+
+/*
+ * Gesture IDs
+ */
+#define GID_BEGIN 1
+#define GID_END 2
+#define GID_ZOOM 3
+#define GID_PAN 4
+#define GID_ROTATE 5
+#define GID_TWOFINGERTAP 6
+#define GID_ROLLOVER 7
+
+typedef struct tagGESTUREINFO {
+ UINT cbSize; // size, in bytes, of this structure (including variable length Args field)
+ DWORD dwFlags; // see GF_* flags
+ DWORD dwID; // gesture ID, see GID_* defines
+ HWND hwndTarget; // handle to window targeted by this gesture
+ POINTS ptsLocation; // current location of this gesture
+ DWORD dwInstanceID; // internally used
+ DWORD dwSequenceID; // internally used
+ ULONGLONG ullArguments; // arguments for gestures whose arguments fit in 8 BYTES
+ UINT cbExtraArgs; // size, in bytes, of extra arguments, if any, that accompany this gesture
+} GESTUREINFO, *PGESTUREINFO;
+typedef GESTUREINFO const * PCGESTUREINFO;
+
+typedef struct tagGESTURENOTIFYSTRUCT {
+ UINT cbSize; // size, in bytes, of this structure
+ DWORD dwFlags; // unused
+ HWND hwndTarget; // handle to window targeted by the gesture
+ POINTS ptsLocation; // starting location
+ DWORD dwInstanceID; // internally used
+} GESTURENOTIFYSTRUCT, *PGESTURENOTIFYSTRUCT;
+
+/*
+ * Gesture argument helpers
+ * - Angle should be a double in the range of -2pi to +2pi
+ * - Argument should be an unsigned 16-bit value
+ */
+#define GID_ROTATE_ANGLE_TO_ARGUMENT(_arg_) ((USHORT)((((_arg_) + 2.0 * 3.14159265) / (4.0 * 3.14159265)) * 65535.0))
+#define GID_ROTATE_ANGLE_FROM_ARGUMENT(_arg_) ((((double)(_arg_) / 65535.0) * 4.0 * 3.14159265) - 2.0 * 3.14159265)
+
+typedef struct tagGESTURECONFIG {
+ DWORD dwID; // gesture ID
+ DWORD dwWant; // settings related to gesture ID that are to be turned on
+ DWORD dwBlock; // settings related to gesture ID that are to be turned off
+} GESTURECONFIG, *PGESTURECONFIG;
+
+#define GC_ALLGESTURES 0x00000001
+#define GC_ZOOM 0x00000001
+#define GC_PAN 0x00000001
+#define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002
+#define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
+#define GC_PAN_WITH_GUTTER 0x00000008
+#define GC_PAN_WITH_INERTIA 0x00000010
+#define GC_ROTATE 0x00000001
+#define GC_TWOFINGERTAP 0x00000001
+#define GC_ROLLOVER 0x00000001
+#define GESTURECONFIGMAXCOUNT 256 // Maximum number of gestures that can be included
+ // in a single call to SetGestureConfig / GetGestureConfig
+
+
+
+#define GCF_INCLUDE_ANCESTORS 0x00000001 // If specified, GetGestureConfig returns consolidated configuration
+ // for the specified window and it's parent window chain
+
+typedef BOOL (*PtrGetGestureInfo)(HGESTUREINFO hGestureInfo, PGESTUREINFO pGestureInfo);
+typedef BOOL (*PtrGetGestureExtraArgs)(HGESTUREINFO hGestureInfo, UINT cbExtraArgs, PBYTE pExtraArgs);
+typedef BOOL (*PtrCloseGestureInfoHandle)(HGESTUREINFO hGestureInfo);
+typedef BOOL (*PtrSetGestureConfig)(HWND hwnd, DWORD dwReserved, UINT cIDs,
+ PGESTURECONFIG pGestureConfig,
+ UINT cbSize);
+typedef BOOL (*PtrGetGestureConfig)(HWND hwnd, DWORD dwReserved,
+ DWORD dwFlags, PUINT pcIDs,
+ PGESTURECONFIG pGestureConfig,
+ UINT cbSize);
+
+typedef BOOL (*PtrBeginPanningFeedback)(HWND hwnd);
+typedef BOOL (*PtrUpdatePanningFeedback)(HWND hwnd, LONG, LONG, BOOL);
+typedef BOOL (*PtrEndPanningFeedback)(HWND hwnd, BOOL);
+
+#endif // WM_GESTURE
+#endif // Q_WS_WIN
+
+class QPanGesture;
+class QPinchGesture;
+struct StandardGestures
+{
+ QPanGesture *pan;
+ QPinchGesture *pinch;
+ StandardGestures() : pan(0), pinch(0) { }
+};
+
class QScopedLoopLevelCounter
{
@@ -439,10 +541,6 @@ public:
void sendSyntheticEnterLeave(QWidget *widget);
#endif
- QGestureManager *gestureManager;
- // map<gesture name -> number of widget subscribed to it>
- QMap<QString, int> grabbedGestures;
-
QMap<int, QWidget *> widgetForTouchPointId;
QMap<int, QTouchEvent::TouchPoint> appCurrentTouchPoints;
static void updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent);
@@ -465,6 +563,19 @@ public:
QHash<DWORD, int> touchInputIDToTouchPointID;
QList<QTouchEvent::TouchPoint> appAllTouchPoints;
bool translateTouchEvent(const MSG &msg);
+
+ typedef QMap<QWidget*, StandardGestures> WidgetStandardGesturesMap;
+ WidgetStandardGesturesMap widgetGestures;
+ ulong lastGestureId;
+
+ PtrGetGestureInfo GetGestureInfo;
+ PtrGetGestureExtraArgs GetGestureExtraArgs;
+ PtrCloseGestureInfoHandle CloseGestureInfoHandle;
+ PtrSetGestureConfig SetGestureConfig;
+ PtrGetGestureConfig GetGestureConfig;
+ PtrBeginPanningFeedback BeginPanningFeedback;
+ PtrUpdatePanningFeedback UpdatePanningFeedback;
+ PtrEndPanningFeedback EndPanningFeedback;
#endif
#ifdef QT_RX71_MULTITOUCH