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