Qt 4.8
Public Functions | List of all members
QWinNativePanGestureRecognizer Class Reference

#include <qwinnativepangesturerecognizer_win_p.h>

Inheritance diagram for QWinNativePanGestureRecognizer:
QGestureRecognizer

Public Functions

QGesturecreate (QObject *target)
 This function is called by Qt to create a new QGesture object for the given target (QWidget or QGraphicsObject). More...
 
 QWinNativePanGestureRecognizer ()
 
QGestureRecognizer::Result recognize (QGesture *state, QObject *watched, QEvent *event)
 Handles the given event for the watched object, updating the state of the gesture object as required, and returns a suitable result for the current recognition step. More...
 
void reset (QGesture *state)
 This function is called by the framework to reset a given gesture. More...
 
- Public Functions inherited from QGestureRecognizer
 QGestureRecognizer ()
 Constructs a new gesture recognizer object. More...
 
virtual ~QGestureRecognizer ()
 Destroys the gesture recognizer. More...
 

Additional Inherited Members

- Public Types inherited from QGestureRecognizer
enum  ResultFlag {
  Ignore = 0x0001, MayBeGesture = 0x0002, TriggerGesture = 0x0004, FinishGesture = 0x0008,
  CancelGesture = 0x0010, ResultState_Mask = 0x00ff, ConsumeEventHint = 0x0100, ResultHint_Mask = 0xff00
}
 This enum describes the result of the current event filtering step in a gesture recognizer state machine. More...
 
- Static Public Functions inherited from QGestureRecognizer
static Qt::GestureType registerRecognizer (QGestureRecognizer *recognizer)
 Registers the given recognizer in the gesture framework and returns a gesture ID for it. More...
 
static void unregisterRecognizer (Qt::GestureType type)
 Unregisters all gesture recognizers of the specified type. More...
 

Detailed Description

Definition at line 64 of file qwinnativepangesturerecognizer_win_p.h.

Constructors and Destructors

◆ QWinNativePanGestureRecognizer()

QWinNativePanGestureRecognizer::QWinNativePanGestureRecognizer ( )

Definition at line 59 of file qwinnativepangesturerecognizer_win.cpp.

60 {
61 }

Functions

◆ create()

QGesture * QWinNativePanGestureRecognizer::create ( QObject target)
virtual

This function is called by Qt to create a new QGesture object for the given target (QWidget or QGraphicsObject).

Reimplement this function to create a custom QGesture-derived gesture object if necessary.

The application takes ownership of the created gesture object.

Reimplemented from QGestureRecognizer.

Definition at line 63 of file qwinnativepangesturerecognizer_win.cpp.

64 {
65  if (!target)
66  return new QPanGesture; // a special case
67  if (!target->isWidgetType())
68  return 0;
69  if (qobject_cast<QGraphicsObject *>(target))
70  return 0;
71 
72  QWidget *q = static_cast<QWidget *>(target);
73  QWidgetPrivate *d = q->d_func();
74  d->nativeGesturePanEnabled = true;
75  d->winSetupGestures();
76 
77  return new QPanGesture;
78 }
double d
Definition: qnumeric_p.h:62
The QPanGesture class describes a panning gesture made by the user.
Definition: qgesture.h:107
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146

◆ recognize()

QGestureRecognizer::Result QWinNativePanGestureRecognizer::recognize ( QGesture gesture,
QObject watched,
QEvent event 
)
virtual

Handles the given event for the watched object, updating the state of the gesture object as required, and returns a suitable result for the current recognition step.

This function is called by the framework to allow the recognizer to filter input events dispatched to QWidget or QGraphicsObject instances that it is monitoring.

The result reflects how much of the gesture has been recognized. The state of the gesture object is set depending on the result.

See also
QGestureRecognizer::Result

Implements QGestureRecognizer.

Definition at line 80 of file qwinnativepangesturerecognizer_win.cpp.

83 {
84  QPanGesture *q = static_cast<QPanGesture*>(state);
85  QPanGesturePrivate *d = q->d_func();
86 
87  QGestureRecognizer::Result result = QGestureRecognizer::Ignore;
88  if (event->type() == QEvent::NativeGesture) {
89  QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event);
90  switch(ev->gestureType) {
92  break;
95  event->accept();
96  break;
98  if (q->state() == Qt::NoGesture)
99  return QGestureRecognizer::Ignore; // some other gesture has ended
101  break;
102  default:
104  }
105  if (q->state() == Qt::NoGesture) {
106  d->lastOffset = d->offset = QPointF();
107  d->startPosition = ev->position;
108  } else {
109  d->lastOffset = d->offset;
110  d->offset = QPointF(ev->position.x() - d->startPosition.x(),
111  ev->position.y() - d->startPosition.y());
112  }
113  }
114  return result;
115 }
double d
Definition: qnumeric_p.h:62
The QPanGesture class describes a panning gesture made by the user.
Definition: qgesture.h:107
EventRef event
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
Qt::GestureState state() const
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ reset()

void QWinNativePanGestureRecognizer::reset ( QGesture gesture)
virtual

This function is called by the framework to reset a given gesture.

Reimplement this function to implement additional requirements for custom QGesture objects. This may be necessary if you implement a custom QGesture whose properties need special handling when the gesture is reset.

Reimplemented from QGestureRecognizer.

Definition at line 117 of file qwinnativepangesturerecognizer_win.cpp.

118 {
119  QPanGesture *pan = static_cast<QPanGesture*>(state);
120  QPanGesturePrivate *d = pan->d_func();
121 
122  d->lastOffset = d->offset = QPointF();
123  d->startPosition = QPoint();
124  d->acceleration = 0;
125 
127 }
double d
Definition: qnumeric_p.h:62
The QPanGesture class describes a panning gesture made by the user.
Definition: qgesture.h:107
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
virtual void reset(QGesture *state)
This function is called by the framework to reset a given gesture.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53

The documentation for this class was generated from the following files: