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

#include <qmacgesturerecognizer_mac_p.h>

Inheritance diagram for QMacPinchGestureRecognizer:
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...
 
 QMacPinchGestureRecognizer ()
 
QGestureRecognizer::Result recognize (QGesture *gesture, 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 *gesture)
 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 74 of file qmacgesturerecognizer_mac_p.h.

Constructors and Destructors

◆ QMacPinchGestureRecognizer()

QMacPinchGestureRecognizer::QMacPinchGestureRecognizer ( )

Definition at line 92 of file qmacgesturerecognizer_mac.mm.

93 {
94 }

Functions

◆ create()

QGesture * QMacPinchGestureRecognizer::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 96 of file qmacgesturerecognizer_mac.mm.

97 {
98  return new QPinchGesture;
99 }
The QPinchGesture class describes a pinch gesture made by the user.
Definition: qgesture.h:136

◆ recognize()

QGestureRecognizer::Result QMacPinchGestureRecognizer::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 102 of file qmacgesturerecognizer_mac.mm.

103 {
104  if (event->type() == QEvent::NativeGesture && obj->isWidgetType()) {
105  QPinchGesture *g = static_cast<QPinchGesture *>(gesture);
106  QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event);
107  switch(ev->gestureType) {
109  reset(gesture);
110  g->setStartCenterPoint(static_cast<QWidget*>(obj)->mapFromGlobal(ev->position));
114  g->setHotSpot(ev->position);
122  g->setHotSpot(ev->position);
124  }
128  g->setScaleFactor(g->scaleFactor() * (1 + ev->percentage));
131  g->setHotSpot(ev->position);
135  default:
136  break;
137  }
138  }
139 
141 }
qreal rotationAngle
the angle covered by the gesture motion
Definition: qgesture.h:159
void setCenterPoint(const QPointF &value)
Definition: qgesture.cpp:611
EventRef event
void setLastScaleFactor(qreal value)
Definition: qgesture.cpp:637
void setChangeFlags(ChangeFlags value)
Definition: qgesture.cpp:581
qreal scaleFactor
the current scale factor
Definition: qgesture.h:155
void setLastRotationAngle(qreal value)
Definition: qgesture.cpp:668
The QPinchGesture class describes a pinch gesture made by the user.
Definition: qgesture.h:136
void setScaleFactor(qreal value)
Definition: qgesture.cpp:642
QPointF startCenterPoint
the starting position of the center point
Definition: qgesture.h:161
ChangeFlags totalChangeFlags
the property of the gesture that has change
Definition: qgesture.h:150
void setHotSpot(const QPointF &value)
Definition: qgesture.cpp:180
ChangeFlags changeFlags
the property of the gesture that has changed in the current step
Definition: qgesture.h:151
void reset(QGesture *gesture)
This function is called by the framework to reset a given gesture.
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
void setStartCenterPoint(const QPointF &value)
Definition: qgesture.cpp:601
void setTotalChangeFlags(ChangeFlags value)
Definition: qgesture.cpp:571
void setRotationAngle(qreal value)
Definition: qgesture.cpp:673

◆ reset()

void QMacPinchGestureRecognizer::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 143 of file qmacgesturerecognizer_mac.mm.

144 {
145  QPinchGesture *g = static_cast<QPinchGesture *>(gesture);
146  g->setChangeFlags(0);
147  g->setTotalChangeFlags(0);
148  g->setScaleFactor(1.0f);
149  g->setTotalScaleFactor(1.0f);
150  g->setLastScaleFactor(1.0f);
151  g->setRotationAngle(0.0f);
152  g->setTotalRotationAngle(0.0f);
153  g->setLastRotationAngle(0.0f);
154  g->setCenterPoint(QPointF());
157  QGestureRecognizer::reset(gesture);
158 }
void setCenterPoint(const QPointF &value)
Definition: qgesture.cpp:611
void setLastScaleFactor(qreal value)
Definition: qgesture.cpp:637
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
void setChangeFlags(ChangeFlags value)
Definition: qgesture.cpp:581
void setTotalScaleFactor(qreal value)
Definition: qgesture.cpp:632
virtual void reset(QGesture *state)
This function is called by the framework to reset a given gesture.
void setLastRotationAngle(qreal value)
Definition: qgesture.cpp:668
The QPinchGesture class describes a pinch gesture made by the user.
Definition: qgesture.h:136
void setScaleFactor(qreal value)
Definition: qgesture.cpp:642
void setTotalRotationAngle(qreal value)
Definition: qgesture.cpp:663
void setLastCenterPoint(const QPointF &value)
Definition: qgesture.cpp:606
void setStartCenterPoint(const QPointF &value)
Definition: qgesture.cpp:601
void setTotalChangeFlags(ChangeFlags value)
Definition: qgesture.cpp:571
void setRotationAngle(qreal value)
Definition: qgesture.cpp:673

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