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