Merge remote-tracking branch 'gerrit/master' into containers
[profile/ivi/qtbase.git] / src / gui / kernel / qevent.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QEVENT_H
43 #define QEVENT_H
44
45 #include <QtGui/qwindowdefs.h>
46 #include <QtCore/qobject.h>
47 #include <QtGui/qregion.h>
48 #include <QtCore/qnamespace.h>
49 #include <QtCore/qstring.h>
50 #include <QtGui/qkeysequence.h>
51 #include <QtCore/qcoreevent.h>
52 #include <QtCore/qvariant.h>
53 #include <QtCore/qmap.h>
54 #include <QtCore/qvector.h>
55 #include <QtCore/qset.h>
56 #include <QtCore/qfile.h>
57 #include <QtGui/qvector2d.h>
58 #include <QtGui/qtouchdevice.h>
59
60 QT_BEGIN_HEADER
61
62 QT_BEGIN_NAMESPACE
63
64
65 class QAction;
66 #ifndef QT_NO_GESTURES
67 class QGesture;
68 #endif
69 class QScreen;
70
71 class Q_GUI_EXPORT QInputEvent : public QEvent
72 {
73 public:
74     QInputEvent(Type type, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
75     ~QInputEvent();
76     inline Qt::KeyboardModifiers modifiers() const { return modState; }
77     inline void setModifiers(Qt::KeyboardModifiers amodifiers) { modState = amodifiers; }
78     inline ulong timestamp() const { return ts; }
79     inline void setTimestamp(ulong atimestamp) { ts = atimestamp; }
80 protected:
81     Qt::KeyboardModifiers modState;
82     ulong ts;
83 };
84
85 class Q_GUI_EXPORT QMouseEvent : public QInputEvent
86 {
87 public:
88     QMouseEvent(Type type, const QPointF &pos, Qt::MouseButton button,
89                 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
90     QMouseEvent(Type type, const QPointF &pos, const QPointF &globalPos,
91                 Qt::MouseButton button, Qt::MouseButtons buttons,
92                 Qt::KeyboardModifiers modifiers);
93     QMouseEvent(Type type, const QPointF &pos, const QPointF &windowPos, const QPointF &globalPos,
94                 Qt::MouseButton button, Qt::MouseButtons buttons,
95                 Qt::KeyboardModifiers modifiers);
96     ~QMouseEvent();
97
98 #ifndef QT_NO_INTEGER_EVENT_COORDINATES
99     inline QPoint pos() const { return l.toPoint(); }
100     inline QPoint globalPos() const { return s.toPoint(); }
101     inline int x() const { return qRound(l.x()); }
102     inline int y() const { return qRound(l.y()); }
103     inline int globalX() const { return qRound(s.x()); }
104     inline int globalY() const { return qRound(s.y()); }
105 #endif
106     const QPointF &localPos() const { return l; }
107     const QPointF &windowPos() const { return w; }
108     const QPointF &screenPos() const { return s; }
109
110     inline Qt::MouseButton button() const { return b; }
111     inline Qt::MouseButtons buttons() const { return mouseState; }
112
113 #if QT_DEPRECATED_SINCE(5, 0)
114     QT_DEPRECATED inline QPointF posF() const { return l; }
115 #endif
116
117 protected:
118     QPointF l, w, s;
119     Qt::MouseButton b;
120     Qt::MouseButtons mouseState;
121 };
122
123 class Q_GUI_EXPORT QHoverEvent : public QInputEvent
124 {
125 public:
126     QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
127     ~QHoverEvent();
128
129 #ifndef QT_NO_INTEGER_EVENT_COORDINATES
130     inline QPoint pos() const { return p.toPoint(); }
131     inline QPoint oldPos() const { return op.toPoint(); }
132 #endif
133
134     inline const QPointF &posF() const { return p; }
135     inline const QPointF &oldPosF() const { return op; }
136
137 protected:
138     QPointF p, op;
139 };
140
141 #ifndef QT_NO_WHEELEVENT
142 class Q_GUI_EXPORT QWheelEvent : public QInputEvent
143 {
144 public:
145     QWheelEvent(const QPointF &pos, int delta,
146                 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
147                 Qt::Orientation orient = Qt::Vertical);
148     QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
149                 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
150                 Qt::Orientation orient = Qt::Vertical);
151     ~QWheelEvent();
152
153     inline int delta() const { return d; }
154 #ifndef QT_NO_INTEGER_EVENT_COORDINATES
155     inline QPoint pos() const { return p.toPoint(); }
156     inline QPoint globalPos()   const { return g.toPoint(); }
157     inline int x() const { return p.x(); }
158     inline int y() const { return p.y(); }
159     inline int globalX() const { return g.x(); }
160     inline int globalY() const { return g.y(); }
161 #endif
162     inline const QPointF &posF() const { return p; }
163     inline const QPointF &globalPosF()   const { return g; }
164
165     inline Qt::MouseButtons buttons() const { return mouseState; }
166     Qt::Orientation orientation() const { return o; }
167
168
169 protected:
170     QPointF p;
171     QPointF g;
172     int d;
173     Qt::MouseButtons mouseState;
174     Qt::Orientation o;
175 };
176 #endif
177
178 #ifndef QT_NO_TABLETEVENT
179 class Q_GUI_EXPORT QTabletEvent : public QInputEvent
180 {
181 public:
182     enum TabletDevice { NoDevice, Puck, Stylus, Airbrush, FourDMouse,
183                         XFreeEraser /*internal*/, RotationStylus };
184     enum PointerType { UnknownPointer, Pen, Cursor, Eraser };
185     QTabletEvent(Type t, const QPointF &pos, const QPointF &globalPos,
186                  int device, int pointerType, qreal pressure, int xTilt, int yTilt,
187                  qreal tangentialPressure, qreal rotation, int z,
188                  Qt::KeyboardModifiers keyState, qint64 uniqueID);
189     ~QTabletEvent();
190
191     inline const QPoint pos() const { return mPos.toPoint(); }
192     inline const QPoint globalPos() const { return mGPos.toPoint(); }
193 #if QT_DEPRECATED_SINCE(5,0)
194     QT_DEPRECATED inline const QPointF &hiResGlobalPos() const { return mPos; }
195 #endif
196
197     inline const QPointF &posF() const { return mPos; }
198     inline const QPointF &globalPosF() const { return mGPos; }
199
200     inline int x() const { return qRound(mPos.x()); }
201     inline int y() const { return qRound(mPos.y()); }
202     inline int globalX() const { return qRound(mGPos.x()); }
203     inline int globalY() const { return qRound(mGPos.y()); }
204     inline qreal hiResGlobalX() const { return mGPos.x(); }
205     inline qreal hiResGlobalY() const { return mGPos.y(); }
206     inline TabletDevice device() const { return TabletDevice(mDev); }
207     inline PointerType pointerType() const { return PointerType(mPointerType); }
208     inline qint64 uniqueId() const { return mUnique; }
209     inline qreal pressure() const { return mPress; }
210     inline int z() const { return mZ; }
211     inline qreal tangentialPressure() const { return mTangential; }
212     inline qreal rotation() const { return mRot; }
213     inline int xTilt() const { return mXT; }
214     inline int yTilt() const { return mYT; }
215
216 protected:
217     QPointF mPos, mGPos;
218     int mDev, mPointerType, mXT, mYT, mZ;
219     qreal mPress, mTangential, mRot;
220     qint64 mUnique;
221
222     // I don't know what the future holds for tablets but there could be some
223     // new devices coming along, and there seem to be "holes" in the
224     // OS-specific events for this.
225     void *mExtra;
226 };
227 #endif // QT_NO_TABLETEVENT
228
229 class Q_GUI_EXPORT QKeyEvent : public QInputEvent
230 {
231 public:
232     QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text = QString(),
233               bool autorep = false, ushort count = 1);
234     ~QKeyEvent();
235
236     int key() const { return k; }
237 #ifndef QT_NO_SHORTCUT
238     bool matches(QKeySequence::StandardKey key) const;
239 #endif
240     Qt::KeyboardModifiers modifiers() const;
241     inline QString text() const { return txt; }
242     inline bool isAutoRepeat() const { return autor; }
243     inline int count() const { return int(c); }
244
245     // Functions for the extended key event information
246     static QKeyEvent *createExtendedKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
247                                              quint32 nativeScanCode, quint32 nativeVirtualKey,
248                                              quint32 nativeModifiers,
249                                              const QString& text = QString(), bool autorep = false,
250                                              ushort count = 1);
251     inline bool hasExtendedInfo() const { return reinterpret_cast<const QKeyEvent*>(d) == this; }
252     quint32 nativeScanCode() const;
253     quint32 nativeVirtualKey() const;
254     quint32 nativeModifiers() const;
255
256 protected:
257     QString txt;
258     int k;
259     ushort c;
260     uint autor:1;
261 };
262
263
264 class Q_GUI_EXPORT QFocusEvent : public QEvent
265 {
266 public:
267     QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason);
268     ~QFocusEvent();
269
270     inline bool gotFocus() const { return type() == FocusIn; }
271     inline bool lostFocus() const { return type() == FocusOut; }
272
273     Qt::FocusReason reason() const;
274
275 private:
276     Qt::FocusReason m_reason;
277 };
278
279
280 class Q_GUI_EXPORT QPaintEvent : public QEvent
281 {
282 public:
283     QPaintEvent(const QRegion& paintRegion);
284     QPaintEvent(const QRect &paintRect);
285     ~QPaintEvent();
286
287     inline const QRect &rect() const { return m_rect; }
288     inline const QRegion &region() const { return m_region; }
289
290 protected:
291     friend class QApplication;
292     friend class QCoreApplication;
293     QRect m_rect;
294     QRegion m_region;
295     bool m_erased;
296 };
297
298 // ### Qt5: make internal
299 class Q_GUI_EXPORT QUpdateLaterEvent : public QEvent
300 {
301 public:
302     QUpdateLaterEvent(const QRegion& paintRegion);
303     ~QUpdateLaterEvent();
304
305     inline const QRegion &region() const { return m_region; }
306
307 protected:
308     QRegion m_region;
309 };
310
311 class Q_GUI_EXPORT QMoveEvent : public QEvent
312 {
313 public:
314     QMoveEvent(const QPoint &pos, const QPoint &oldPos);
315     ~QMoveEvent();
316
317     inline const QPoint &pos() const { return p; }
318     inline const QPoint &oldPos() const { return oldp;}
319 protected:
320     QPoint p, oldp;
321     friend class QApplication;
322     friend class QCoreApplication;
323 };
324
325 class Q_GUI_EXPORT QExposeEvent : public QEvent
326 {
327 public:
328     QExposeEvent(const QRegion &rgn);
329     ~QExposeEvent();
330
331     inline const QRegion &region() const { return rgn; }
332
333 protected:
334     QRegion rgn;
335 };
336
337 class Q_GUI_EXPORT QResizeEvent : public QEvent
338 {
339 public:
340     QResizeEvent(const QSize &size, const QSize &oldSize);
341     ~QResizeEvent();
342
343     inline const QSize &size() const { return s; }
344     inline const QSize &oldSize()const { return olds;}
345 protected:
346     QSize s, olds;
347     friend class QApplication;
348     friend class QCoreApplication;
349 };
350
351
352 class Q_GUI_EXPORT QCloseEvent : public QEvent
353 {
354 public:
355     QCloseEvent();
356     ~QCloseEvent();
357 };
358
359
360 class Q_GUI_EXPORT QIconDragEvent : public QEvent
361 {
362 public:
363     QIconDragEvent();
364     ~QIconDragEvent();
365 };
366
367
368 class Q_GUI_EXPORT QShowEvent : public QEvent
369 {
370 public:
371     QShowEvent();
372     ~QShowEvent();
373 };
374
375
376 class Q_GUI_EXPORT QHideEvent : public QEvent
377 {
378 public:
379     QHideEvent();
380     ~QHideEvent();
381 };
382
383 #ifndef QT_NO_CONTEXTMENU
384 class Q_GUI_EXPORT QContextMenuEvent : public QInputEvent
385 {
386 public:
387     enum Reason { Mouse, Keyboard, Other };
388
389     QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
390                       Qt::KeyboardModifiers modifiers);
391     QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos);
392     QContextMenuEvent(Reason reason, const QPoint &pos);
393     ~QContextMenuEvent();
394
395     inline int x() const { return p.x(); }
396     inline int y() const { return p.y(); }
397     inline int globalX() const { return gp.x(); }
398     inline int globalY() const { return gp.y(); }
399
400     inline const QPoint& pos() const { return p; }
401     inline const QPoint& globalPos() const { return gp; }
402
403     inline Reason reason() const { return Reason(reas); }
404
405 protected:
406     QPoint p;
407     QPoint gp;
408     uint reas : 8;
409 };
410 #endif // QT_NO_CONTEXTMENU
411
412 #ifndef QT_NO_INPUTMETHOD
413 class Q_GUI_EXPORT QInputMethodEvent : public QEvent
414 {
415 public:
416     enum AttributeType {
417        TextFormat,
418        Cursor,
419        Language,
420        Ruby,
421        Selection
422     };
423     class Attribute {
424     public:
425         Attribute(AttributeType t, int s, int l, QVariant val) : type(t), start(s), length(l), value(val) {}
426         AttributeType type;
427
428         int start;
429         int length;
430         QVariant value;
431     };
432     QInputMethodEvent();
433     QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes);
434     void setCommitString(const QString &commitString, int replaceFrom = 0, int replaceLength = 0);
435     void setTentativeCommitString(const QString &tentativeCommitString);
436
437     inline const QList<Attribute> &attributes() const { return attrs; }
438     inline const QString &preeditString() const { return preedit; }
439
440     inline const QString &commitString() const { return commit; }
441     inline int replacementStart() const { return replace_from; }
442     inline int replacementLength() const { return replace_length; }
443     inline const QString &tentativeCommitString() const { return tentativeCommit; }
444
445     QInputMethodEvent(const QInputMethodEvent &other);
446
447 private:
448     QString preedit;
449     QList<Attribute> attrs;
450     QString commit;
451     int replace_from;
452     int replace_length;
453     QString tentativeCommit;
454 };
455
456 class Q_GUI_EXPORT QInputMethodQueryEvent : public QEvent
457 {
458 public:
459     QInputMethodQueryEvent(Qt::InputMethodQueries queries);
460     ~QInputMethodQueryEvent();
461
462     Qt::InputMethodQueries queries() const { return m_queries; }
463
464     void setValue(Qt::InputMethodQuery query, const QVariant &value);
465     QVariant value(Qt::InputMethodQuery query) const;
466 private:
467     Qt::InputMethodQueries m_queries;
468     struct QueryPair {
469         Qt::InputMethodQuery query;
470         QVariant value;
471     };
472     QVector<QueryPair> m_values;
473 };
474
475 #endif // QT_NO_INPUTMETHOD
476
477 #ifndef QT_NO_DRAGANDDROP
478
479 class QMimeData;
480
481 class Q_GUI_EXPORT QDropEvent : public QEvent
482 {
483 public:
484     QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data,
485                Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop);
486     ~QDropEvent();
487
488     inline const QPoint pos() const { return p.toPoint(); }
489     inline const QPointF &posF() const { return p; }
490     inline Qt::MouseButtons mouseButtons() const { return mouseState; }
491     inline Qt::KeyboardModifiers keyboardModifiers() const { return modState; }
492
493     inline Qt::DropActions possibleActions() const { return act; }
494     inline Qt::DropAction proposedAction() const { return default_action; }
495     inline void acceptProposedAction() { drop_action = default_action; accept(); }
496
497     inline Qt::DropAction dropAction() const { return drop_action; }
498     void setDropAction(Qt::DropAction action);
499
500     QObject* source() const;
501     inline const QMimeData *mimeData() const { return mdata; }
502
503 protected:
504     friend class QApplication;
505     QPointF p;
506     Qt::MouseButtons mouseState;
507     Qt::KeyboardModifiers modState;
508     Qt::DropActions act;
509     Qt::DropAction drop_action;
510     Qt::DropAction default_action;
511     const QMimeData *mdata;
512 };
513
514
515 class Q_GUI_EXPORT QDragMoveEvent : public QDropEvent
516 {
517 public:
518     QDragMoveEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
519                    Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = DragMove);
520     ~QDragMoveEvent();
521
522     inline QRect answerRect() const { return rect; }
523
524     inline void accept() { QDropEvent::accept(); }
525     inline void ignore() { QDropEvent::ignore(); }
526
527     inline void accept(const QRect & r) { accept(); rect = r; }
528     inline void ignore(const QRect & r) { ignore(); rect = r; }
529
530 protected:
531     friend class QApplication;
532     QRect rect;
533 };
534
535
536 class Q_GUI_EXPORT QDragEnterEvent : public QDragMoveEvent
537 {
538 public:
539     QDragEnterEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
540                     Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
541     ~QDragEnterEvent();
542 };
543
544
545 class Q_GUI_EXPORT QDragLeaveEvent : public QEvent
546 {
547 public:
548     QDragLeaveEvent();
549     ~QDragLeaveEvent();
550 };
551 #endif // QT_NO_DRAGANDDROP
552
553
554 class Q_GUI_EXPORT QHelpEvent : public QEvent
555 {
556 public:
557     QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos);
558     ~QHelpEvent();
559
560     inline int x() const { return p.x(); }
561     inline int y() const { return p.y(); }
562     inline int globalX() const { return gp.x(); }
563     inline int globalY() const { return gp.y(); }
564
565     inline const QPoint& pos()  const { return p; }
566     inline const QPoint& globalPos() const { return gp; }
567
568 private:
569     QPoint p;
570     QPoint gp;
571 };
572
573 #ifndef QT_NO_STATUSTIP
574 class Q_GUI_EXPORT QStatusTipEvent : public QEvent
575 {
576 public:
577     QStatusTipEvent(const QString &tip);
578     ~QStatusTipEvent();
579
580     inline QString tip() const { return s; }
581 private:
582     QString s;
583 };
584 #endif
585
586 #ifndef QT_NO_WHATSTHIS
587 class Q_GUI_EXPORT QWhatsThisClickedEvent : public QEvent
588 {
589 public:
590     QWhatsThisClickedEvent(const QString &href);
591     ~QWhatsThisClickedEvent();
592
593     inline QString href() const { return s; }
594 private:
595     QString s;
596 };
597 #endif
598
599 #ifndef QT_NO_ACTION
600 class Q_GUI_EXPORT QActionEvent : public QEvent
601 {
602     QAction *act, *bef;
603 public:
604     QActionEvent(int type, QAction *action, QAction *before = 0);
605     ~QActionEvent();
606
607     inline QAction *action() const { return act; }
608     inline QAction *before() const { return bef; }
609 };
610 #endif
611
612 class Q_GUI_EXPORT QFileOpenEvent : public QEvent
613 {
614 public:
615     QFileOpenEvent(const QString &file);
616     QFileOpenEvent(const QUrl &url);
617     ~QFileOpenEvent();
618
619     inline QString file() const { return f; }
620     QUrl url() const;
621     bool openFile(QFile &file, QIODevice::OpenMode flags) const;
622 private:
623     QString f;
624 };
625
626 #ifndef QT_NO_TOOLBAR
627 class Q_GUI_EXPORT QToolBarChangeEvent : public QEvent
628 {
629 public:
630     QToolBarChangeEvent(bool t);
631     ~QToolBarChangeEvent();
632
633     inline bool toggle() const { return tog; }
634 private:
635     uint tog : 1;
636 };
637 #endif
638
639 #ifndef QT_NO_SHORTCUT
640 class Q_GUI_EXPORT QShortcutEvent : public QEvent
641 {
642 public:
643     QShortcutEvent(const QKeySequence &key, int id, bool ambiguous = false);
644     ~QShortcutEvent();
645
646     inline const QKeySequence &key() const { return sequence; }
647     inline int shortcutId() const { return sid; }
648     inline bool isAmbiguous() const { return ambig; }
649 protected:
650     QKeySequence sequence;
651     bool ambig;
652     int  sid;
653 };
654 #endif
655
656 #ifndef QT_NO_CLIPBOARD
657 class Q_GUI_EXPORT QClipboardEvent : public QEvent
658 {
659 public:
660     QClipboardEvent(QEventPrivate *data);
661     ~QClipboardEvent();
662
663     QEventPrivate *data() { return d; }
664 };
665 #endif
666
667 class Q_GUI_EXPORT QWindowStateChangeEvent: public QEvent
668 {
669 public:
670     QWindowStateChangeEvent(Qt::WindowStates aOldState);
671     QWindowStateChangeEvent(Qt::WindowStates aOldState, bool isOverride);
672     ~QWindowStateChangeEvent();
673
674     inline Qt::WindowStates oldState() const { return ostate; }
675     bool isOverride() const;
676
677 private:
678     Qt::WindowStates ostate;
679 };
680
681 #ifndef QT_NO_DEBUG_STREAM
682 Q_GUI_EXPORT QDebug operator<<(QDebug, const QEvent *);
683 #endif
684
685 #ifndef QT_NO_SHORTCUT
686 inline bool operator==(QKeyEvent *e, QKeySequence::StandardKey key){return (e ? e->matches(key) : false);}
687 inline bool operator==(QKeySequence::StandardKey key, QKeyEvent *e){return (e ? e->matches(key) : false);}
688 #endif // QT_NO_SHORTCUT
689
690 class QTouchEventTouchPointPrivate;
691 class Q_GUI_EXPORT QTouchEvent : public QInputEvent
692 {
693 public:
694     class Q_GUI_EXPORT TouchPoint
695     {
696     public:
697         enum InfoFlag {
698             Pen  = 0x0001
699         };
700         Q_DECLARE_FLAGS(InfoFlags, InfoFlag)
701
702         TouchPoint(int id = -1);
703         TouchPoint(const QTouchEvent::TouchPoint &other);
704         ~TouchPoint();
705
706         int id() const;
707
708         Qt::TouchPointState state() const;
709
710         QPointF pos() const;
711         QPointF startPos() const;
712         QPointF lastPos() const;
713
714         QPointF scenePos() const;
715         QPointF startScenePos() const;
716         QPointF lastScenePos() const;
717
718         QPointF screenPos() const;
719         QPointF startScreenPos() const;
720         QPointF lastScreenPos() const;
721
722         QPointF normalizedPos() const;
723         QPointF startNormalizedPos() const;
724         QPointF lastNormalizedPos() const;
725
726         QRectF rect() const;
727         QRectF sceneRect() const;
728         QRectF screenRect() const;
729
730         qreal pressure() const;
731         QVector2D velocity() const;
732         InfoFlags flags() const;
733         QList<QPointF> rawScreenPositions() const;
734
735         // internal
736         void setId(int id);
737         void setState(Qt::TouchPointStates state);
738         void setPos(const QPointF &pos);
739         void setScenePos(const QPointF &scenePos);
740         void setScreenPos(const QPointF &screenPos);
741         void setNormalizedPos(const QPointF &normalizedPos);
742         void setStartPos(const QPointF &startPos);
743         void setStartScenePos(const QPointF &startScenePos);
744         void setStartScreenPos(const QPointF &startScreenPos);
745         void setStartNormalizedPos(const QPointF &startNormalizedPos);
746         void setLastPos(const QPointF &lastPos);
747         void setLastScenePos(const QPointF &lastScenePos);
748         void setLastScreenPos(const QPointF &lastScreenPos);
749         void setLastNormalizedPos(const QPointF &lastNormalizedPos);
750         void setRect(const QRectF &rect);
751         void setSceneRect(const QRectF &sceneRect);
752         void setScreenRect(const QRectF &screenRect);
753         void setPressure(qreal pressure);
754         void setVelocity(const QVector2D &v);
755         void setFlags(InfoFlags flags);
756         void setRawScreenPositions(const QList<QPointF> &positions);
757         QTouchEvent::TouchPoint &operator=(const QTouchEvent::TouchPoint &other);
758
759     private:
760         QTouchEventTouchPointPrivate *d;
761         friend class QGuiApplication;
762         friend class QGuiApplicationPrivate;
763         friend class QApplication;
764         friend class QApplicationPrivate;
765     };
766
767 #if QT_DEPRECATED_SINCE(5, 0)
768     QT_DEPRECATED enum DeviceType {
769         TouchScreen,
770         TouchPad
771     };
772 #endif
773
774     QTouchEvent(QEvent::Type eventType,
775                 QTouchDevice *device = 0,
776                 Qt::KeyboardModifiers modifiers = Qt::NoModifier,
777                 Qt::TouchPointStates touchPointStates = 0,
778                 const QList<QTouchEvent::TouchPoint> &touchPoints = QList<QTouchEvent::TouchPoint>());
779     ~QTouchEvent();
780
781     inline QWindow *window() const { return _window; }
782     inline QObject *target() const { return _target; }
783 #if QT_DEPRECATED_SINCE(5, 0)
784     QT_DEPRECATED inline QTouchEvent::DeviceType deviceType() const { return static_cast<DeviceType>(int(_device->type())); }
785 #endif
786     inline Qt::TouchPointStates touchPointStates() const { return _touchPointStates; }
787     inline const QList<QTouchEvent::TouchPoint> &touchPoints() const { return _touchPoints; }
788     inline QTouchDevice *device() const { return _device; }
789
790     // internal
791     inline void setWindow(QWindow *awindow) { _window = awindow; }
792     inline void setTarget(QObject *atarget) { _target = atarget; }
793     inline void setTouchPointStates(Qt::TouchPointStates aTouchPointStates) { _touchPointStates = aTouchPointStates; }
794     inline void setTouchPoints(const QList<QTouchEvent::TouchPoint> &atouchPoints) { _touchPoints = atouchPoints; }
795     inline void setDevice(QTouchDevice *adevice) { _device = adevice; }
796
797 protected:
798     QWindow *_window;
799     QObject *_target;
800     QTouchDevice *_device;
801     Qt::TouchPointStates _touchPointStates;
802     QList<QTouchEvent::TouchPoint> _touchPoints;
803
804     friend class QGuiApplication;
805     friend class QGuiApplicationPrivate;
806     friend class QApplication;
807     friend class QApplicationPrivate;
808 };
809
810 Q_DECLARE_OPERATORS_FOR_FLAGS(QTouchEvent::TouchPoint::InfoFlags)
811
812 class QScrollPrepareEventPrivate;
813 class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent
814 {
815 public:
816     QScrollPrepareEvent(const QPointF &startPos);
817     ~QScrollPrepareEvent();
818
819     QPointF startPos() const;
820
821     QSizeF viewportSize() const;
822     QRectF contentPosRange() const;
823     QPointF contentPos() const;
824
825     void setViewportSize(const QSizeF &size);
826     void setContentPosRange(const QRectF &rect);
827     void setContentPos(const QPointF &pos);
828
829 private:
830     QScrollPrepareEventPrivate *d_func();
831     const QScrollPrepareEventPrivate *d_func() const;
832 };
833
834
835 class QScrollEventPrivate;
836 class Q_GUI_EXPORT QScrollEvent : public QEvent
837 {
838 public:
839     enum ScrollState
840     {
841         ScrollStarted,
842         ScrollUpdated,
843         ScrollFinished
844     };
845
846     QScrollEvent(const QPointF &contentPos, const QPointF &overshoot, ScrollState scrollState);
847     ~QScrollEvent();
848
849     QPointF contentPos() const;
850     QPointF overshootDistance() const;
851     ScrollState scrollState() const;
852
853 private:
854     QScrollEventPrivate *d_func();
855     const QScrollEventPrivate *d_func() const;
856 };
857
858 class QScreenOrientationChangeEventPrivate;
859 class Q_GUI_EXPORT QScreenOrientationChangeEvent : public QEvent
860 {
861 public:
862     QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation orientation);
863     ~QScreenOrientationChangeEvent();
864
865     QScreen *screen() const;
866     Qt::ScreenOrientation orientation() const;
867
868 private:
869     QScreenOrientationChangeEventPrivate *d_func();
870     const QScreenOrientationChangeEventPrivate *d_func() const;
871 };
872
873 QT_END_NAMESPACE
874
875 QT_END_HEADER
876
877 #endif // QEVENT_H