{QTouchEvent,QWindowSystemInterface}::TouchPoint: replace QList<QPointF> with QVector
[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     explicit 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(const QPointF &pos, const QPointF& globalPos,
152                 QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
153                 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
154
155     ~QWheelEvent();
156
157
158     inline QPoint pixelDelta() const { return pixelD; }
159     inline QPoint angleDelta() const { return angleD; }
160
161 #if QT_DEPRECATED_SINCE(5, 0)
162     inline QT_DEPRECATED int delta() const  { return qt4D; }
163     inline QT_DEPRECATED Qt::Orientation orientation() const { return qt4O; }
164 #endif
165
166 #ifndef QT_NO_INTEGER_EVENT_COORDINATES
167     inline QPoint pos() const { return p.toPoint(); }
168     inline QPoint globalPos()   const { return g.toPoint(); }
169     inline int x() const { return p.x(); }
170     inline int y() const { return p.y(); }
171     inline int globalX() const { return g.x(); }
172     inline int globalY() const { return g.y(); }
173 #endif
174     inline const QPointF &posF() const { return p; }
175     inline const QPointF &globalPosF()   const { return g; }
176
177     inline Qt::MouseButtons buttons() const { return mouseState; }
178 protected:
179     QPointF p;
180     QPointF g;
181     QPoint pixelD;
182     QPoint angleD;
183     int qt4D;
184     Qt::Orientation qt4O;
185     Qt::MouseButtons mouseState;
186     int reserved;
187 };
188 #endif
189
190 #ifndef QT_NO_TABLETEVENT
191 class Q_GUI_EXPORT QTabletEvent : public QInputEvent
192 {
193 public:
194     enum TabletDevice { NoDevice, Puck, Stylus, Airbrush, FourDMouse,
195                         XFreeEraser /*internal*/, RotationStylus };
196     enum PointerType { UnknownPointer, Pen, Cursor, Eraser };
197     QTabletEvent(Type t, const QPointF &pos, const QPointF &globalPos,
198                  int device, int pointerType, qreal pressure, int xTilt, int yTilt,
199                  qreal tangentialPressure, qreal rotation, int z,
200                  Qt::KeyboardModifiers keyState, qint64 uniqueID);
201     ~QTabletEvent();
202
203     inline const QPoint pos() const { return mPos.toPoint(); }
204     inline const QPoint globalPos() const { return mGPos.toPoint(); }
205 #if QT_DEPRECATED_SINCE(5,0)
206     QT_DEPRECATED inline const QPointF &hiResGlobalPos() const { return mPos; }
207 #endif
208
209     inline const QPointF &posF() const { return mPos; }
210     inline const QPointF &globalPosF() const { return mGPos; }
211
212     inline int x() const { return qRound(mPos.x()); }
213     inline int y() const { return qRound(mPos.y()); }
214     inline int globalX() const { return qRound(mGPos.x()); }
215     inline int globalY() const { return qRound(mGPos.y()); }
216     inline qreal hiResGlobalX() const { return mGPos.x(); }
217     inline qreal hiResGlobalY() const { return mGPos.y(); }
218     inline TabletDevice device() const { return TabletDevice(mDev); }
219     inline PointerType pointerType() const { return PointerType(mPointerType); }
220     inline qint64 uniqueId() const { return mUnique; }
221     inline qreal pressure() const { return mPress; }
222     inline int z() const { return mZ; }
223     inline qreal tangentialPressure() const { return mTangential; }
224     inline qreal rotation() const { return mRot; }
225     inline int xTilt() const { return mXT; }
226     inline int yTilt() const { return mYT; }
227
228 protected:
229     QPointF mPos, mGPos;
230     int mDev, mPointerType, mXT, mYT, mZ;
231     qreal mPress, mTangential, mRot;
232     qint64 mUnique;
233
234     // I don't know what the future holds for tablets but there could be some
235     // new devices coming along, and there seem to be "holes" in the
236     // OS-specific events for this.
237     void *mExtra;
238 };
239 #endif // QT_NO_TABLETEVENT
240
241 class Q_GUI_EXPORT QKeyEvent : public QInputEvent
242 {
243 public:
244     QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text = QString(),
245               bool autorep = false, ushort count = 1);
246     ~QKeyEvent();
247
248     int key() const { return k; }
249 #ifndef QT_NO_SHORTCUT
250     bool matches(QKeySequence::StandardKey key) const;
251 #endif
252     Qt::KeyboardModifiers modifiers() const;
253     inline QString text() const { return txt; }
254     inline bool isAutoRepeat() const { return autor; }
255     inline int count() const { return int(c); }
256
257     // Functions for the extended key event information
258     static QKeyEvent *createExtendedKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
259                                              quint32 nativeScanCode, quint32 nativeVirtualKey,
260                                              quint32 nativeModifiers,
261                                              const QString& text = QString(), bool autorep = false,
262                                              ushort count = 1);
263     inline bool hasExtendedInfo() const { return reinterpret_cast<const QKeyEvent*>(d) == this; }
264     quint32 nativeScanCode() const;
265     quint32 nativeVirtualKey() const;
266     quint32 nativeModifiers() const;
267
268 protected:
269     QString txt;
270     int k;
271     ushort c;
272     uint autor:1;
273 };
274
275
276 class Q_GUI_EXPORT QFocusEvent : public QEvent
277 {
278 public:
279     explicit QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason);
280     ~QFocusEvent();
281
282     inline bool gotFocus() const { return type() == FocusIn; }
283     inline bool lostFocus() const { return type() == FocusOut; }
284
285     Qt::FocusReason reason() const;
286
287 private:
288     Qt::FocusReason m_reason;
289 };
290
291
292 class Q_GUI_EXPORT QPaintEvent : public QEvent
293 {
294 public:
295     explicit QPaintEvent(const QRegion& paintRegion);
296     explicit QPaintEvent(const QRect &paintRect);
297     ~QPaintEvent();
298
299     inline const QRect &rect() const { return m_rect; }
300     inline const QRegion &region() const { return m_region; }
301
302 protected:
303     friend class QApplication;
304     friend class QCoreApplication;
305     QRect m_rect;
306     QRegion m_region;
307     bool m_erased;
308 };
309
310 // ### Qt5: make internal
311 class Q_GUI_EXPORT QUpdateLaterEvent : public QEvent
312 {
313 public:
314     explicit QUpdateLaterEvent(const QRegion& paintRegion);
315     ~QUpdateLaterEvent();
316
317     inline const QRegion &region() const { return m_region; }
318
319 protected:
320     QRegion m_region;
321 };
322
323 class Q_GUI_EXPORT QMoveEvent : public QEvent
324 {
325 public:
326     QMoveEvent(const QPoint &pos, const QPoint &oldPos);
327     ~QMoveEvent();
328
329     inline const QPoint &pos() const { return p; }
330     inline const QPoint &oldPos() const { return oldp;}
331 protected:
332     QPoint p, oldp;
333     friend class QApplication;
334     friend class QCoreApplication;
335 };
336
337 class Q_GUI_EXPORT QExposeEvent : public QEvent
338 {
339 public:
340     explicit QExposeEvent(const QRegion &rgn);
341     ~QExposeEvent();
342
343     inline const QRegion &region() const { return rgn; }
344
345 protected:
346     QRegion rgn;
347 };
348
349 class Q_GUI_EXPORT QResizeEvent : public QEvent
350 {
351 public:
352     QResizeEvent(const QSize &size, const QSize &oldSize);
353     ~QResizeEvent();
354
355     inline const QSize &size() const { return s; }
356     inline const QSize &oldSize()const { return olds;}
357 protected:
358     QSize s, olds;
359     friend class QApplication;
360     friend class QCoreApplication;
361 };
362
363
364 class Q_GUI_EXPORT QCloseEvent : public QEvent
365 {
366 public:
367     QCloseEvent();
368     ~QCloseEvent();
369 };
370
371
372 class Q_GUI_EXPORT QIconDragEvent : public QEvent
373 {
374 public:
375     QIconDragEvent();
376     ~QIconDragEvent();
377 };
378
379
380 class Q_GUI_EXPORT QShowEvent : public QEvent
381 {
382 public:
383     QShowEvent();
384     ~QShowEvent();
385 };
386
387
388 class Q_GUI_EXPORT QHideEvent : public QEvent
389 {
390 public:
391     QHideEvent();
392     ~QHideEvent();
393 };
394
395 #ifndef QT_NO_CONTEXTMENU
396 class Q_GUI_EXPORT QContextMenuEvent : public QInputEvent
397 {
398 public:
399     enum Reason { Mouse, Keyboard, Other };
400
401     QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
402                       Qt::KeyboardModifiers modifiers);
403     QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos);
404     QContextMenuEvent(Reason reason, const QPoint &pos);
405     ~QContextMenuEvent();
406
407     inline int x() const { return p.x(); }
408     inline int y() const { return p.y(); }
409     inline int globalX() const { return gp.x(); }
410     inline int globalY() const { return gp.y(); }
411
412     inline const QPoint& pos() const { return p; }
413     inline const QPoint& globalPos() const { return gp; }
414
415     inline Reason reason() const { return Reason(reas); }
416
417 protected:
418     QPoint p;
419     QPoint gp;
420     uint reas : 8;
421 };
422 #endif // QT_NO_CONTEXTMENU
423
424 #ifndef QT_NO_INPUTMETHOD
425 class Q_GUI_EXPORT QInputMethodEvent : public QEvent
426 {
427 public:
428     enum AttributeType {
429        TextFormat,
430        Cursor,
431        Language,
432        Ruby,
433        Selection
434     };
435     class Attribute {
436     public:
437         Attribute(AttributeType t, int s, int l, QVariant val) : type(t), start(s), length(l), value(val) {}
438         AttributeType type;
439
440         int start;
441         int length;
442         QVariant value;
443     };
444     QInputMethodEvent();
445     QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes);
446     void setCommitString(const QString &commitString, int replaceFrom = 0, int replaceLength = 0);
447     void setTentativeCommitString(const QString &tentativeCommitString);
448
449     inline const QList<Attribute> &attributes() const { return attrs; }
450     inline const QString &preeditString() const { return preedit; }
451
452     inline const QString &commitString() const { return commit; }
453     inline int replacementStart() const { return replace_from; }
454     inline int replacementLength() const { return replace_length; }
455     inline const QString &tentativeCommitString() const { return tentativeCommit; }
456
457     QInputMethodEvent(const QInputMethodEvent &other);
458
459 private:
460     QString preedit;
461     QList<Attribute> attrs;
462     QString commit;
463     int replace_from;
464     int replace_length;
465     QString tentativeCommit;
466 };
467 Q_DECLARE_TYPEINFO(QInputMethodEvent::Attribute, Q_MOVABLE_TYPE);
468
469 class Q_GUI_EXPORT QInputMethodQueryEvent : public QEvent
470 {
471 public:
472     explicit QInputMethodQueryEvent(Qt::InputMethodQueries queries);
473     ~QInputMethodQueryEvent();
474
475     Qt::InputMethodQueries queries() const { return m_queries; }
476
477     void setValue(Qt::InputMethodQuery query, const QVariant &value);
478     QVariant value(Qt::InputMethodQuery query) const;
479 private:
480     Qt::InputMethodQueries m_queries;
481     struct QueryPair {
482         Qt::InputMethodQuery query;
483         QVariant value;
484     };
485     QVector<QueryPair> m_values;
486 };
487
488 #endif // QT_NO_INPUTMETHOD
489
490 #ifndef QT_NO_DRAGANDDROP
491
492 class QMimeData;
493
494 class Q_GUI_EXPORT QDropEvent : public QEvent
495 {
496 public:
497     QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data,
498                Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop);
499     ~QDropEvent();
500
501     inline const QPoint pos() const { return p.toPoint(); }
502     inline const QPointF &posF() const { return p; }
503     inline Qt::MouseButtons mouseButtons() const { return mouseState; }
504     inline Qt::KeyboardModifiers keyboardModifiers() const { return modState; }
505
506     inline Qt::DropActions possibleActions() const { return act; }
507     inline Qt::DropAction proposedAction() const { return default_action; }
508     inline void acceptProposedAction() { drop_action = default_action; accept(); }
509
510     inline Qt::DropAction dropAction() const { return drop_action; }
511     void setDropAction(Qt::DropAction action);
512
513     QObject* source() const;
514     inline const QMimeData *mimeData() const { return mdata; }
515
516 protected:
517     friend class QApplication;
518     QPointF p;
519     Qt::MouseButtons mouseState;
520     Qt::KeyboardModifiers modState;
521     Qt::DropActions act;
522     Qt::DropAction drop_action;
523     Qt::DropAction default_action;
524     const QMimeData *mdata;
525 };
526
527
528 class Q_GUI_EXPORT QDragMoveEvent : public QDropEvent
529 {
530 public:
531     QDragMoveEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
532                    Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = DragMove);
533     ~QDragMoveEvent();
534
535     inline QRect answerRect() const { return rect; }
536
537     inline void accept() { QDropEvent::accept(); }
538     inline void ignore() { QDropEvent::ignore(); }
539
540     inline void accept(const QRect & r) { accept(); rect = r; }
541     inline void ignore(const QRect & r) { ignore(); rect = r; }
542
543 protected:
544     friend class QApplication;
545     QRect rect;
546 };
547
548
549 class Q_GUI_EXPORT QDragEnterEvent : public QDragMoveEvent
550 {
551 public:
552     QDragEnterEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
553                     Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
554     ~QDragEnterEvent();
555 };
556
557
558 class Q_GUI_EXPORT QDragLeaveEvent : public QEvent
559 {
560 public:
561     QDragLeaveEvent();
562     ~QDragLeaveEvent();
563 };
564 #endif // QT_NO_DRAGANDDROP
565
566
567 class Q_GUI_EXPORT QHelpEvent : public QEvent
568 {
569 public:
570     QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos);
571     ~QHelpEvent();
572
573     inline int x() const { return p.x(); }
574     inline int y() const { return p.y(); }
575     inline int globalX() const { return gp.x(); }
576     inline int globalY() const { return gp.y(); }
577
578     inline const QPoint& pos()  const { return p; }
579     inline const QPoint& globalPos() const { return gp; }
580
581 private:
582     QPoint p;
583     QPoint gp;
584 };
585
586 #ifndef QT_NO_STATUSTIP
587 class Q_GUI_EXPORT QStatusTipEvent : public QEvent
588 {
589 public:
590     explicit QStatusTipEvent(const QString &tip);
591     ~QStatusTipEvent();
592
593     inline QString tip() const { return s; }
594 private:
595     QString s;
596 };
597 #endif
598
599 #ifndef QT_NO_WHATSTHIS
600 class Q_GUI_EXPORT QWhatsThisClickedEvent : public QEvent
601 {
602 public:
603     explicit QWhatsThisClickedEvent(const QString &href);
604     ~QWhatsThisClickedEvent();
605
606     inline QString href() const { return s; }
607 private:
608     QString s;
609 };
610 #endif
611
612 #ifndef QT_NO_ACTION
613 class Q_GUI_EXPORT QActionEvent : public QEvent
614 {
615     QAction *act, *bef;
616 public:
617     QActionEvent(int type, QAction *action, QAction *before = 0);
618     ~QActionEvent();
619
620     inline QAction *action() const { return act; }
621     inline QAction *before() const { return bef; }
622 };
623 #endif
624
625 class Q_GUI_EXPORT QFileOpenEvent : public QEvent
626 {
627 public:
628     explicit QFileOpenEvent(const QString &file);
629     explicit QFileOpenEvent(const QUrl &url);
630     ~QFileOpenEvent();
631
632     inline QString file() const { return f; }
633     QUrl url() const;
634     bool openFile(QFile &file, QIODevice::OpenMode flags) const;
635 private:
636     QString f;
637 };
638
639 #ifndef QT_NO_TOOLBAR
640 class Q_GUI_EXPORT QToolBarChangeEvent : public QEvent
641 {
642 public:
643     explicit QToolBarChangeEvent(bool t);
644     ~QToolBarChangeEvent();
645
646     inline bool toggle() const { return tog; }
647 private:
648     uint tog : 1;
649 };
650 #endif
651
652 #ifndef QT_NO_SHORTCUT
653 class Q_GUI_EXPORT QShortcutEvent : public QEvent
654 {
655 public:
656     QShortcutEvent(const QKeySequence &key, int id, bool ambiguous = false);
657     ~QShortcutEvent();
658
659     inline const QKeySequence &key() const { return sequence; }
660     inline int shortcutId() const { return sid; }
661     inline bool isAmbiguous() const { return ambig; }
662 protected:
663     QKeySequence sequence;
664     bool ambig;
665     int  sid;
666 };
667 #endif
668
669 #ifndef QT_NO_CLIPBOARD
670 class Q_GUI_EXPORT QClipboardEvent : public QEvent
671 {
672 public:
673     explicit QClipboardEvent(QEventPrivate *data);
674     ~QClipboardEvent();
675
676     QEventPrivate *data() { return d; }
677 };
678 #endif
679
680 class Q_GUI_EXPORT QWindowStateChangeEvent: public QEvent
681 {
682 public:
683     explicit QWindowStateChangeEvent(Qt::WindowStates aOldState);
684     QWindowStateChangeEvent(Qt::WindowStates aOldState, bool isOverride);
685     ~QWindowStateChangeEvent();
686
687     inline Qt::WindowStates oldState() const { return ostate; }
688     bool isOverride() const;
689
690 private:
691     Qt::WindowStates ostate;
692 };
693
694 #ifndef QT_NO_DEBUG_STREAM
695 Q_GUI_EXPORT QDebug operator<<(QDebug, const QEvent *);
696 #endif
697
698 #ifndef QT_NO_SHORTCUT
699 inline bool operator==(QKeyEvent *e, QKeySequence::StandardKey key){return (e ? e->matches(key) : false);}
700 inline bool operator==(QKeySequence::StandardKey key, QKeyEvent *e){return (e ? e->matches(key) : false);}
701 #endif // QT_NO_SHORTCUT
702
703 class QTouchEventTouchPointPrivate;
704 class Q_GUI_EXPORT QTouchEvent : public QInputEvent
705 {
706 public:
707     class Q_GUI_EXPORT TouchPoint
708     {
709     public:
710         enum InfoFlag {
711             Pen  = 0x0001
712         };
713         Q_DECLARE_FLAGS(InfoFlags, InfoFlag)
714
715         explicit TouchPoint(int id = -1);
716         TouchPoint(const TouchPoint &other);
717 #ifdef Q_COMPILER_RVALUE_REFS
718         TouchPoint(TouchPoint &&other) : d(other.d) { other.d = 0; }
719         TouchPoint &operator=(TouchPoint &&other)
720         { qSwap(d, other.d); return *this; }
721 #endif
722         ~TouchPoint();
723
724         TouchPoint &operator=(const TouchPoint &other)
725         { if ( d != other.d ) { TouchPoint copy(other); swap(copy); } return *this; }
726
727         void swap(TouchPoint &other) { qSwap(d, other.d); }
728
729         int id() const;
730
731         Qt::TouchPointState state() const;
732
733         QPointF pos() const;
734         QPointF startPos() const;
735         QPointF lastPos() const;
736
737         QPointF scenePos() const;
738         QPointF startScenePos() const;
739         QPointF lastScenePos() const;
740
741         QPointF screenPos() const;
742         QPointF startScreenPos() const;
743         QPointF lastScreenPos() const;
744
745         QPointF normalizedPos() const;
746         QPointF startNormalizedPos() const;
747         QPointF lastNormalizedPos() const;
748
749         QRectF rect() const;
750         QRectF sceneRect() const;
751         QRectF screenRect() const;
752
753         qreal pressure() const;
754         QVector2D velocity() const;
755         InfoFlags flags() const;
756         QVector<QPointF> rawScreenPositions() const;
757
758         // internal
759         void setId(int id);
760         void setState(Qt::TouchPointStates state);
761         void setPos(const QPointF &pos);
762         void setScenePos(const QPointF &scenePos);
763         void setScreenPos(const QPointF &screenPos);
764         void setNormalizedPos(const QPointF &normalizedPos);
765         void setStartPos(const QPointF &startPos);
766         void setStartScenePos(const QPointF &startScenePos);
767         void setStartScreenPos(const QPointF &startScreenPos);
768         void setStartNormalizedPos(const QPointF &startNormalizedPos);
769         void setLastPos(const QPointF &lastPos);
770         void setLastScenePos(const QPointF &lastScenePos);
771         void setLastScreenPos(const QPointF &lastScreenPos);
772         void setLastNormalizedPos(const QPointF &lastNormalizedPos);
773         void setRect(const QRectF &rect);
774         void setSceneRect(const QRectF &sceneRect);
775         void setScreenRect(const QRectF &screenRect);
776         void setPressure(qreal pressure);
777         void setVelocity(const QVector2D &v);
778         void setFlags(InfoFlags flags);
779         void setRawScreenPositions(const QVector<QPointF> &positions);
780
781     private:
782         QTouchEventTouchPointPrivate *d;
783         friend class QGuiApplication;
784         friend class QGuiApplicationPrivate;
785         friend class QApplication;
786         friend class QApplicationPrivate;
787     };
788
789 #if QT_DEPRECATED_SINCE(5, 0)
790     QT_DEPRECATED enum DeviceType {
791         TouchScreen,
792         TouchPad
793     };
794 #endif
795
796     explicit QTouchEvent(QEvent::Type eventType,
797                          QTouchDevice *device = 0,
798                          Qt::KeyboardModifiers modifiers = Qt::NoModifier,
799                          Qt::TouchPointStates touchPointStates = 0,
800                          const QList<QTouchEvent::TouchPoint> &touchPoints = QList<QTouchEvent::TouchPoint>());
801     ~QTouchEvent();
802
803     inline QWindow *window() const { return _window; }
804     inline QObject *target() const { return _target; }
805 #if QT_DEPRECATED_SINCE(5, 0)
806     QT_DEPRECATED inline QTouchEvent::DeviceType deviceType() const { return static_cast<DeviceType>(int(_device->type())); }
807 #endif
808     inline Qt::TouchPointStates touchPointStates() const { return _touchPointStates; }
809     inline const QList<QTouchEvent::TouchPoint> &touchPoints() const { return _touchPoints; }
810     inline QTouchDevice *device() const { return _device; }
811
812     // internal
813     inline void setWindow(QWindow *awindow) { _window = awindow; }
814     inline void setTarget(QObject *atarget) { _target = atarget; }
815     inline void setTouchPointStates(Qt::TouchPointStates aTouchPointStates) { _touchPointStates = aTouchPointStates; }
816     inline void setTouchPoints(const QList<QTouchEvent::TouchPoint> &atouchPoints) { _touchPoints = atouchPoints; }
817     inline void setDevice(QTouchDevice *adevice) { _device = adevice; }
818
819 protected:
820     QWindow *_window;
821     QObject *_target;
822     QTouchDevice *_device;
823     Qt::TouchPointStates _touchPointStates;
824     QList<QTouchEvent::TouchPoint> _touchPoints;
825
826     friend class QGuiApplication;
827     friend class QGuiApplicationPrivate;
828     friend class QApplication;
829     friend class QApplicationPrivate;
830 };
831 Q_DECLARE_TYPEINFO(QTouchEvent::TouchPoint, Q_MOVABLE_TYPE);
832 Q_DECLARE_OPERATORS_FOR_FLAGS(QTouchEvent::TouchPoint::InfoFlags)
833
834 class QScrollPrepareEventPrivate;
835 class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent
836 {
837 public:
838     explicit QScrollPrepareEvent(const QPointF &startPos);
839     ~QScrollPrepareEvent();
840
841     QPointF startPos() const;
842
843     QSizeF viewportSize() const;
844     QRectF contentPosRange() const;
845     QPointF contentPos() const;
846
847     void setViewportSize(const QSizeF &size);
848     void setContentPosRange(const QRectF &rect);
849     void setContentPos(const QPointF &pos);
850
851 private:
852     QScrollPrepareEventPrivate *d_func();
853     const QScrollPrepareEventPrivate *d_func() const;
854 };
855
856
857 class QScrollEventPrivate;
858 class Q_GUI_EXPORT QScrollEvent : public QEvent
859 {
860 public:
861     enum ScrollState
862     {
863         ScrollStarted,
864         ScrollUpdated,
865         ScrollFinished
866     };
867
868     QScrollEvent(const QPointF &contentPos, const QPointF &overshoot, ScrollState scrollState);
869     ~QScrollEvent();
870
871     QPointF contentPos() const;
872     QPointF overshootDistance() const;
873     ScrollState scrollState() const;
874
875 private:
876     QScrollEventPrivate *d_func();
877     const QScrollEventPrivate *d_func() const;
878 };
879
880 class QScreenOrientationChangeEventPrivate;
881 class Q_GUI_EXPORT QScreenOrientationChangeEvent : public QEvent
882 {
883 public:
884     QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation orientation);
885     ~QScreenOrientationChangeEvent();
886
887     QScreen *screen() const;
888     Qt::ScreenOrientation orientation() const;
889
890 private:
891     QScreenOrientationChangeEventPrivate *d_func();
892     const QScreenOrientationChangeEventPrivate *d_func() const;
893 };
894
895 QT_END_NAMESPACE
896
897 QT_END_HEADER
898
899 #endif // QEVENT_H