Merge remote-tracking branch 'gerrit/master' into newdocs
[profile/ivi/qtbase.git] / src / gui / kernel / qevent.cpp
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 #include "qevent.h"
43 #include "qcursor.h"
44 #include "private/qguiapplication_p.h"
45 #include "qpa/qplatformintegration.h"
46 #include "qpa/qplatformdrag.h"
47 #include "private/qevent_p.h"
48 #include "private/qkeysequence_p.h"
49 #include "qdebug.h"
50 #include "qmimedata.h"
51 #include "private/qdnd_p.h"
52 #include "qevent_p.h"
53 #include "qmath.h"
54
55
56 QT_BEGIN_NAMESPACE
57
58 /*!
59     \class QInputEvent
60     \ingroup events
61     \inmodule QtGui
62
63     \brief The QInputEvent class is the base class for events that
64     describe user input.
65 */
66
67 /*!
68   \internal
69 */
70 QInputEvent::QInputEvent(Type type, Qt::KeyboardModifiers modifiers)
71     : QEvent(type), modState(modifiers), ts(0)
72 {}
73
74 /*!
75   \internal
76 */
77 QInputEvent::~QInputEvent()
78 {
79 }
80
81 /*!
82     \fn Qt::KeyboardModifiers QInputEvent::modifiers() const
83
84     Returns the keyboard modifier flags that existed immediately
85     before the event occurred.
86
87     \sa QApplication::keyboardModifiers()
88 */
89
90 /*! \fn void QInputEvent::setModifiers(Qt::KeyboardModifiers modifiers)
91
92     \internal
93
94     Sets the keyboard modifiers flags for this event.
95 */
96
97 /*!
98     \fn ulong QInputEvent::timestamp() const
99
100     Returns the window system's timestamp for this event.
101 */
102
103 /*! \fn void QInputEvent::setTimestamp(ulong atimestamp)
104
105     \internal
106
107     Sets the timestamp for this event.
108 */
109
110 /*!
111     \class QMouseEvent
112     \ingroup events
113
114     \brief The QMouseEvent class contains parameters that describe a mouse event.
115
116     Mouse events occur when a mouse button is pressed or released
117     inside a widget, or when the mouse cursor is moved.
118
119     Mouse move events will occur only when a mouse button is pressed
120     down, unless mouse tracking has been enabled with
121     QWidget::setMouseTracking().
122
123     Qt automatically grabs the mouse when a mouse button is pressed
124     inside a widget; the widget will continue to receive mouse events
125     until the last mouse button is released.
126
127     A mouse event contains a special accept flag that indicates
128     whether the receiver wants the event. You should call ignore() if
129     the mouse event is not handled by your widget. A mouse event is
130     propagated up the parent widget chain until a widget accepts it
131     with accept(), or an event filter consumes it.
132
133     \note If a mouse event is propagated to a \l{QWidget}{widget} for
134     which Qt::WA_NoMousePropagation has been set, that mouse event
135     will not be propagated further up the parent widget chain.
136
137     The state of the keyboard modifier keys can be found by calling the
138     \l{QInputEvent::modifiers()}{modifiers()} function, inherited from
139     QInputEvent.
140
141     The functions pos(), x(), and y() give the cursor position
142     relative to the widget that receives the mouse event. If you
143     move the widget as a result of the mouse event, use the global
144     position returned by globalPos() to avoid a shaking motion.
145
146     The QWidget::setEnabled() function can be used to enable or
147     disable mouse and keyboard events for a widget.
148
149     Reimplement the QWidget event handlers, QWidget::mousePressEvent(),
150     QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(),
151     and QWidget::mouseMoveEvent() to receive mouse events in your own
152     widgets.
153
154     \sa QWidget::setMouseTracking(), QWidget::grabMouse(),
155     QCursor::pos()
156 */
157
158 /*!
159     Constructs a mouse event object.
160
161     The \a type parameter must be one of QEvent::MouseButtonPress,
162     QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
163     or QEvent::MouseMove.
164
165     The \a localPos is the mouse cursor's position relative to the
166     receiving widget or item. The window position is set to the same value
167     as \a localPos.
168     The \a button that caused the event is given as a value from
169     the Qt::MouseButton enum. If the event \a type is
170     \l MouseMove, the appropriate button for this event is Qt::NoButton.
171     The mouse and keyboard states at the time of the event are specified by
172     \a buttons and \a modifiers.
173
174     The screenPos() is initialized to QCursor::pos(), which may not
175     be appropriate. Use the other constructor to specify the global
176     position explicitly.
177 */
178 QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton button,
179                          Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
180     : QInputEvent(type, modifiers), l(localPos), w(localPos), b(button), mouseState(buttons), caps(0)
181 {
182     s = QCursor::pos();
183 }
184
185
186 /*!
187     Constructs a mouse event object.
188
189     The \a type parameter must be QEvent::MouseButtonPress,
190     QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
191     or QEvent::MouseMove.
192
193     The \a localPos is the mouse cursor's position relative to the
194     receiving widget or item. The cursor's position in screen coordinates is
195     specified by \a screenPos. The window position is set to the same value
196     as \a localPos. The \a button that caused the event is
197     given as a value from the \l Qt::MouseButton enum. If the event \a
198     type is \l MouseMove, the appropriate button for this event is
199     Qt::NoButton. \a buttons is the state of all buttons at the
200     time of the event, \a modifiers the state of all keyboard
201     modifiers.
202
203 */
204 QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &screenPos,
205                          Qt::MouseButton button, Qt::MouseButtons buttons,
206                          Qt::KeyboardModifiers modifiers)
207     : QInputEvent(type, modifiers), l(localPos), w(localPos), s(screenPos), b(button), mouseState(buttons), caps(0)
208 {}
209
210 /*!
211     Constructs a mouse event object.
212
213     The \a type parameter must be QEvent::MouseButtonPress,
214     QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
215     or QEvent::MouseMove.
216
217     The points \a localPos, \a windowPos and \a screenPos specify the
218     mouse cursor's position relative to the receiving widget or item,
219     window, and screen, respectively.
220
221     The \a button that caused the event is
222     given as a value from the \l Qt::MouseButton enum. If the event \a
223     type is \l MouseMove, the appropriate button for this event is
224     Qt::NoButton. \a buttons is the state of all buttons at the
225     time of the event, \a modifiers the state of all keyboard
226     modifiers.
227
228 */
229 QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
230                          Qt::MouseButton button, Qt::MouseButtons buttons,
231                          Qt::KeyboardModifiers modifiers)
232     : QInputEvent(type, modifiers), l(localPos), w(windowPos), s(screenPos), b(button), mouseState(buttons), caps(0)
233 {}
234
235 /*!
236     \internal
237 */
238 QMouseEvent::~QMouseEvent()
239 {
240 }
241
242
243 /*!
244     \fn QPointF QMouseEvent::localPos() const
245
246     \since 5.0
247
248     Returns the position of the mouse cursor as a QPointF, relative to the
249     widget or item that received the event.
250
251     If you move the widget as a result of the mouse event, use the
252     screen position returned by screenPos() to avoid a shaking
253     motion.
254
255     \sa x(), y(), windowPos(), screenPos()
256 */
257
258 /*!
259     \fn QPointF QMouseEvent::windowPos() const
260
261     \since 5.0
262
263     Returns the position of the mouse cursor as a QPointF, relative to the
264     window that received the event.
265
266     If you move the widget as a result of the mouse event, use the
267     global position returned by globalPos() to avoid a shaking
268     motion.
269
270     \sa x(), y(), pos(), localPos(), screenPos()
271 */
272
273 /*!
274     \fn QPointF QMouseEvent::screenPos() const
275
276     \since 5.0
277
278     Returns the position of the mouse cursor as a QPointF, relative to the
279     screen that received the event.
280
281     \sa x(), y(), pos(), localPos(), screenPos()
282 */
283
284 /*!
285     \fn QPoint QMouseEvent::pos() const
286
287     Returns the position of the mouse cursor, relative to the widget
288     that received the event.
289
290     If you move the widget as a result of the mouse event, use the
291     global position returned by globalPos() to avoid a shaking
292     motion.
293
294     \sa x(), y(), globalPos()
295 */
296
297 /*!
298     \fn QPoint QMouseEvent::globalPos() const
299
300     Returns the global position of the mouse cursor \e{at the time
301     of the event}. This is important on asynchronous window systems
302     like X11. Whenever you move your widgets around in response to
303     mouse events, globalPos() may differ a lot from the current
304     pointer position QCursor::pos(), and from
305     QWidget::mapToGlobal(pos()).
306
307     \sa globalX(), globalY()
308 */
309
310 /*!
311     \fn int QMouseEvent::x() const
312
313     Returns the x position of the mouse cursor, relative to the
314     widget that received the event.
315
316     \sa y(), pos()
317 */
318
319 /*!
320     \fn int QMouseEvent::y() const
321
322     Returns the y position of the mouse cursor, relative to the
323     widget that received the event.
324
325     \sa x(), pos()
326 */
327
328 /*!
329     \fn int QMouseEvent::globalX() const
330
331     Returns the global x position of the mouse cursor at the time of
332     the event.
333
334     \sa globalY(), globalPos()
335 */
336
337 /*!
338     \fn int QMouseEvent::globalY() const
339
340     Returns the global y position of the mouse cursor at the time of
341     the event.
342
343     \sa globalX(), globalPos()
344 */
345
346 /*!
347     \fn Qt::MouseButton QMouseEvent::button() const
348
349     Returns the button that caused the event.
350
351     Note that the returned value is always Qt::NoButton for mouse
352     move events.
353
354     \sa buttons(), Qt::MouseButton
355 */
356
357 /*!
358     \fn Qt::MouseButton QMouseEvent::buttons() const
359
360     Returns the button state when the event was generated. The button
361     state is a combination of Qt::LeftButton, Qt::RightButton,
362     Qt::MidButton using the OR operator. For mouse move events,
363     this is all buttons that are pressed down. For mouse press and
364     double click events this includes the button that caused the
365     event. For mouse release events this excludes the button that
366     caused the event.
367
368     \sa button(), Qt::MouseButton
369 */
370
371 /*!
372     \fn QPointF QMouseEvent::posF() const
373     \obsolete
374
375     Use localPos() instead.
376 */
377
378 /*!
379     \class QHoverEvent
380     \ingroup events
381
382     \brief The QHoverEvent class contains parameters that describe a mouse event.
383
384     Mouse events occur when a mouse cursor is moved into, out of, or within a
385     widget, and if the widget has the Qt::WA_Hover attribute.
386
387     The function pos() gives the current cursor position, while oldPos() gives
388     the old mouse position.
389
390     There are a few similarities between the events QEvent::HoverEnter
391     and QEvent::HoverLeave, and the events QEvent::Enter and QEvent::Leave.
392     However, they are slightly different because we do an update() in the event
393     handler of HoverEnter and HoverLeave.
394
395     QEvent::HoverMove is also slightly different from QEvent::MouseMove. Let us
396     consider a top-level window A containing a child B which in turn contains a
397     child C (all with mouse tracking enabled):
398
399     \image hoverevents.png
400
401     Now, if you move the cursor from the top to the bottom in the middle of A,
402     you will get the following QEvent::MouseMove events:
403
404     \list 1
405         \li A::MouseMove
406         \li B::MouseMove
407         \li C::MouseMove
408     \endlist
409
410     You will get the same events for QEvent::HoverMove, except that the event
411     always propagates to the top-level regardless whether the event is accepted
412     or not. It will only stop propagating with the Qt::WA_NoMousePropagation
413     attribute.
414
415     In this case the events will occur in the following way:
416
417     \list 1
418         \li A::HoverMove
419         \li A::HoverMove, B::HoverMove
420         \li A::HoverMove, B::HoverMove, C::HoverMove
421     \endlist
422
423 */
424
425 /*!
426     \fn QPoint QHoverEvent::pos() const
427
428     Returns the position of the mouse cursor, relative to the widget
429     that received the event.
430
431     On QEvent::HoverLeave events, this position will always be
432     QPoint(-1, -1).
433
434     \sa oldPos()
435 */
436
437 /*!
438     \fn QPoint QHoverEvent::oldPos() const
439
440     Returns the previous position of the mouse cursor, relative to the widget
441     that received the event. If there is no previous position, oldPos() will
442     return the same position as pos().
443
444     On QEvent::HoverEnter events, this position will always be
445     QPoint(-1, -1).
446
447     \sa pos()
448 */
449
450 /*!
451     \fn const QPointF &QHoverEvent::posF() const
452
453     Returns the position of the mouse cursor, relative to the widget
454     that received the event.
455
456     On QEvent::HoverLeave events, this position will always be
457     QPointF(-1, -1).
458
459     \sa oldPosF()
460 */
461
462 /*!
463     \fn const QPointF &QHoverEvent::oldPosF() const
464
465     Returns the previous position of the mouse cursor, relative to the widget
466     that received the event. If there is no previous position, oldPosF() will
467     return the same position as posF().
468
469     On QEvent::HoverEnter events, this position will always be
470     QPointF(-1, -1).
471
472     \sa posF()
473 */
474
475 /*!
476     Constructs a hover event object.
477
478     The \a type parameter must be QEvent::HoverEnter,
479     QEvent::HoverLeave, or QEvent::HoverMove.
480
481     The \a pos is the current mouse cursor's position relative to the
482     receiving widget, while \a oldPos is its previous such position.
483     \a modifiers hold the state of all keyboard modifiers at the time
484     of the event.
485 */
486 QHoverEvent::QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers)
487     : QInputEvent(type, modifiers), p(pos), op(oldPos)
488 {
489 }
490
491 /*!
492     \internal
493 */
494 QHoverEvent::~QHoverEvent()
495 {
496 }
497
498
499 /*!
500     \class QWheelEvent
501     \brief The QWheelEvent class contains parameters that describe a wheel event.
502     \inmodule QtGui
503
504     \ingroup events
505
506     Wheel events are sent to the widget under the mouse cursor, but
507     if that widget does not handle the event they are sent to the
508     focus widget. Wheel events are generated for both mouse wheels
509     and trackpad scroll gestures. There are two ways to read the
510     wheel event delta: angleDelta() returns the delta in wheel
511     degrees. This value is always provided. pixelDelta() returns
512     the delta in screen pixels and is available on platforms that
513     have high-resolution trackpads, such as Mac OS X.
514
515     The functions pos() and globalPos() return the mouse cursor's
516     location at the time of the event.
517
518     A wheel event contains a special accept flag that indicates
519     whether the receiver wants the event. You should call ignore() if
520     you do not handle the wheel event; this ensures that it will be
521     sent to the parent widget.
522
523     The QWidget::setEnabled() function can be used to enable or
524     disable mouse and keyboard events for a widget.
525
526     The event handler QWidget::wheelEvent() receives wheel events.
527
528     \sa QMouseEvent, QWidget::grabMouse()
529 */
530
531 /*!
532     \fn Qt::MouseButtons QWheelEvent::buttons() const
533
534     Returns the mouse state when the event occurred.
535 */
536
537 /*!
538     \fn Qt::Orientation QWheelEvent::orientation() const
539     \obsolete
540
541     Returns the wheel's orientation.
542
543     Use angleDelta() instead.
544 */
545
546 /*!
547     \obsolete
548     Constructs a wheel event object.
549
550     Use the constructor taking \e angleDelta and \e pixelDelta QPoints instead.
551
552     The position, \a pos, is the location of the mouse cursor within
553     the widget. The globalPos() is initialized to QCursor::pos()
554     which is usually, but not always, correct.
555     Use the other constructor if you need to specify the global
556     position explicitly.
557
558     The \a buttons describe the state of the mouse buttons at the time
559     of the event, \a delta contains the rotation distance,
560     \a modifiers holds the keyboard modifier flags at the time of the
561     event, and \a orient holds the wheel's orientation.
562
563     \sa pos(), pixelDelta(), angleDelta(), state()
564 */
565 #ifndef QT_NO_WHEELEVENT
566 QWheelEvent::QWheelEvent(const QPointF &pos, int delta,
567                          Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
568                          Qt::Orientation orient)
569     : QInputEvent(Wheel, modifiers), p(pos), qt4D(delta), qt4O(orient), mouseState(buttons)
570 {
571     g = QCursor::pos();
572 }
573
574 /*!
575   \internal
576 */
577 QWheelEvent::~QWheelEvent()
578 {
579 }
580
581 /*!
582     \obsolete
583     Constructs a wheel event object.
584
585     Use the constructor taking \e angleDelta and \e pixelDelta QPoints instead.
586
587     The \a pos provides the location of the mouse cursor
588     within the widget. The position in global coordinates is specified
589     by \a globalPos. \a delta contains the rotation distance, \a modifiers
590     holds the keyboard modifier flags at the time of the event, and
591     \a orient holds the wheel's orientation.
592
593
594     \sa pos(), pixelDelta(), angleDelta(), state()
595 */
596 QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
597                          Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
598                          Qt::Orientation orient)
599     : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), qt4D(delta), qt4O(orient), mouseState(buttons)
600 {}
601
602 /*!
603     Constructs a wheel event object.
604
605     The \a pos provides the location of the mouse cursor
606     within the window. The position in global coordinates is specified
607     by \a globalPos.
608
609     \a pixelDelta contains the scrolling distance in pixels on screen, while
610     \a angleDelta contains the wheel rotation distance. \a pixelDelta is
611     optional and can be null.
612
613     The mouse and keyboard states at the time of the event are specified by
614     \a buttons and \a modifiers.
615
616     For backwards compatibility, the event can also hold monodirectional wheel
617     event data: \a qt4Delta specifies the rotation, and \a qt4Orientation the
618     direction.
619
620     \sa posF(), globalPosF(), angleDelta(), pixelDelta()
621 */
622
623 QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
624             QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
625             Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
626     : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta),
627       angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons)
628 {}
629
630
631 #endif // QT_NO_WHEELEVENT
632
633 /*!
634     \fn QPoint QWheelEvent::pixelDelta() const
635
636     Returns the scrolling distance in pixels on screen. This value is
637     provided on platforms that support high-resolution pixel-based
638     delta values, such as Mac OS X. The value should be used directly
639     to scroll content on screen.
640
641     Example:
642
643     \snippet code/src_gui_kernel_qevent.cpp 0
644 */
645
646 /*!
647     \fn QPoint QWheelEvent::angleDelta() const
648
649     Returns the distance that the wheel is rotated, in eighths of a
650     degree. A positive value indicates that the wheel was rotated
651     forwards away from the user; a negative value indicates that the
652     wheel was rotated backwards toward the user.
653
654     Most mouse types work in steps of 15 degrees, in which case the
655     delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.
656
657     However, some mice have finer-resolution wheels and send delta values
658     that are less than 120 units (less than 15 degrees). To support this
659     possibility, you can either cumulatively add the delta values from events
660     until the value of 120 is reached, then scroll the widget, or you can
661     partially scroll the widget in response to each wheel event.
662
663     Example:
664
665     \snippet code/src_gui_kernel_qevent.cpp 0
666 */
667
668 /*!
669     \fn int QWheelEvent::delta() const
670     \obsolete
671
672     This function has been deprecated, use pixelDelta() or angleDelta() instead.
673 */
674
675 /*!
676     \fn QPoint QWheelEvent::pos() const
677
678     Returns the position of the mouse cursor relative to the widget
679     that received the event.
680
681     If you move your widgets around in response to mouse events,
682     use globalPos() instead of this function.
683
684     \sa x(), y(), globalPos()
685 */
686
687 /*!
688     \fn int QWheelEvent::x() const
689
690     Returns the x position of the mouse cursor, relative to the
691     widget that received the event.
692
693     \sa y(), pos()
694 */
695
696 /*!
697     \fn int QWheelEvent::y() const
698
699     Returns the y position of the mouse cursor, relative to the
700     widget that received the event.
701
702     \sa x(), pos()
703 */
704
705
706 /*!
707     \fn QPoint QWheelEvent::globalPos() const
708
709     Returns the global position of the mouse pointer \e{at the time
710     of the event}. This is important on asynchronous window systems
711     such as X11; whenever you move your widgets around in response to
712     mouse events, globalPos() can differ a lot from the current
713     cursor position returned by QCursor::pos().
714
715     \sa globalX(), globalY()
716 */
717
718 /*!
719     \fn int QWheelEvent::globalX() const
720
721     Returns the global x position of the mouse cursor at the time of
722     the event.
723
724     \sa globalY(), globalPos()
725 */
726
727 /*!
728     \fn int QWheelEvent::globalY() const
729
730     Returns the global y position of the mouse cursor at the time of
731     the event.
732
733     \sa globalX(), globalPos()
734 */
735
736 /*!
737     \fn const QPointF &QWheelEvent::posF() const
738
739     Returns the position of the mouse cursor relative to the widget
740     that received the event.
741
742     If you move your widgets around in response to mouse events,
743     use globalPosF() instead of this function.
744
745     \sa globalPosF()
746 */
747
748 /*!
749     \fn const QPointF &QWheelEvent::globalPosF() const
750
751     Returns the global position of the mouse pointer \e{at the time
752     of the event}. This is important on asynchronous window systems
753     such as X11; whenever you move your widgets around in response to
754     mouse events, globalPosF() can differ a lot from the current
755     cursor position returned by QCursor::pos().
756
757     \sa posF()
758 */
759
760
761 /*!
762     \class QKeyEvent
763     \brief The QKeyEvent class describes a key event.
764
765     \ingroup events
766
767     Key events are sent to the widget with keyboard input focus
768     when keys are pressed or released.
769
770     A key event contains a special accept flag that indicates whether
771     the receiver will handle the key event. You should call ignore()
772     if the key press or release event is not handled by your widget.
773     A key event is propagated up the parent widget chain until a
774     widget accepts it with accept() or an event filter consumes it.
775     Key events for multimedia keys are ignored by default. You should
776     call accept() if your widget handles those events.
777
778     The QWidget::setEnable() function can be used to enable or disable
779     mouse and keyboard events for a widget.
780
781     The event handlers QWidget::keyPressEvent(), QWidget::keyReleaseEvent(),
782     QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent()
783     receive key events.
784
785     \sa QFocusEvent, QWidget::grabKeyboard()
786 */
787
788 /*!
789     Constructs a key event object.
790
791     The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
792     or QEvent::ShortcutOverride.
793
794     Int \a key is the code for the Qt::Key that the event loop should listen
795     for. If \a key is 0, the event is not a result of a known key; for
796     example, it may be the result of a compose sequence or keyboard macro.
797     The \a modifiers holds the keyboard modifiers, and the given \a text
798     is the Unicode text that the key generated. If \a autorep is true,
799     isAutoRepeat() will be true. \a count is the number of keys involved
800     in the event.
801 */
802 QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text,
803                      bool autorep, ushort count)
804     : QInputEvent(type, modifiers), txt(text), k(key),
805       nScanCode(0), nVirtualKey(0), nModifiers(0),
806       c(count), autor(autorep)
807 {
808 }
809
810 /*!
811     Constructs a key event object.
812
813     The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
814     or QEvent::ShortcutOverride.
815
816     Int \a key is the code for the Qt::Key that the event loop should listen
817     for. If \a key is 0, the event is not a result of a known key; for
818     example, it may be the result of a compose sequence or keyboard macro.
819     The \a modifiers holds the keyboard modifiers, and the given \a text
820     is the Unicode text that the key generated. If \a autorep is true,
821     isAutoRepeat() will be true. \a count is the number of keys involved
822     in the event.
823
824     In addition to the normal key event data, also contains \a nativeScanCode,
825     \a nativeVirtualKey and \a nativeModifiers. This extra data is used by the
826     shortcut system, to determine which shortcuts to trigger.
827 */
828 QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
829                      quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
830                      const QString &text, bool autorep, ushort count)
831     : QInputEvent(type, modifiers), txt(text), k(key),
832       nScanCode(nativeScanCode), nVirtualKey(nativeVirtualKey), nModifiers(nativeModifiers),
833       c(count), autor(autorep)
834 {
835 }
836
837
838 /*!
839   \internal
840 */
841 QKeyEvent::~QKeyEvent()
842 {
843 }
844
845 /*!
846     \fn QKeyEvent *QKeyEvent::createExtendedKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString& text, bool autorep, ushort count)
847     \internal
848 */
849
850 /*!
851     \fn bool QKeyEvent::hasExtendedInfo() const
852     \internal
853 */
854
855 /*!
856   \fn quint32 QKeyEvent::nativeScanCode() const
857   \since 4.2
858
859   Returns the native scan code of the key event.  If the key event
860   does not contain this data 0 is returned.
861
862   Note: The native scan code may be 0, even if the key event contains
863   extended information.
864
865   Note: On Mac OS/X, this function is not useful, because there is no
866   way to get the scan code from Carbon or Cocoa. The function always
867   returns 1 (or 0 in the case explained above).
868 */
869
870 /*!
871     \fn quint32 QKeyEvent::nativeVirtualKey() const
872     \since 4.2
873
874     Returns the native virtual key, or key sym of the key event.
875     If the key event does not contain this data 0 is returned.
876
877     Note: The native virtual key may be 0, even if the key event contains extended information.
878 */
879
880 /*!
881     \fn quint32 QKeyEvent::nativeModifiers() const
882     \since 4.2
883
884     Returns the native modifiers of a key event.
885     If the key event does not contain this data 0 is returned.
886
887     Note: The native modifiers may be 0, even if the key event contains extended information.
888 */
889
890 /*!
891     \fn int QKeyEvent::key() const
892
893     Returns the code of the key that was pressed or released.
894
895     See \l Qt::Key for the list of keyboard codes. These codes are
896     independent of the underlying window system. Note that this
897     function does not distinguish between capital and non-capital
898     letters, use the text() function (returning the Unicode text the
899     key generated) for this purpose.
900
901     A value of either 0 or Qt::Key_unknown means that the event is not
902     the result of a known key; for example, it may be the result of
903     a compose sequence, a keyboard macro, or due to key event
904     compression.
905
906     \sa Qt::WA_KeyCompression
907 */
908
909 /*!
910     \fn QString QKeyEvent::text() const
911
912     Returns the Unicode text that this key generated. The text
913     returned can be an empty string in cases
914     where modifier keys, such as Shift, Control, Alt, and Meta,
915     are being pressed or released. In such cases key() will contain
916     a valid value.
917
918     \sa Qt::WA_KeyCompression
919 */
920
921 /*!
922     Returns the keyboard modifier flags that existed immediately
923     after the event occurred.
924
925     \warning This function cannot always be trusted. The user can
926     confuse it by pressing both \uicontrol{Shift} keys simultaneously and
927     releasing one of them, for example.
928
929     \sa QApplication::keyboardModifiers()
930 */
931 //###### We must check with XGetModifierMapping
932 Qt::KeyboardModifiers QKeyEvent::modifiers() const
933 {
934     if (key() == Qt::Key_Shift)
935         return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ShiftModifier);
936     if (key() == Qt::Key_Control)
937         return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ControlModifier);
938     if (key() == Qt::Key_Alt)
939         return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::AltModifier);
940     if (key() == Qt::Key_Meta)
941         return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::MetaModifier);
942     return QInputEvent::modifiers();
943 }
944
945 #ifndef QT_NO_SHORTCUT
946 /*!
947     \fn bool QKeyEvent::matches(QKeySequence::StandardKey key) const
948     \since 4.2
949
950     Returns true if the key event matches the given standard \a key;
951     otherwise returns false.
952 */
953 bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
954 {
955     uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier); //The keypad modifier should not make a difference
956     const uint platform = QKeySequencePrivate::currentKeyPlatforms();
957
958
959     uint N = QKeySequencePrivate::numberOfKeyBindings;
960     int first = 0;
961     int last = N - 1;
962
963     while (first <= last) {
964         int mid = (first + last) / 2;
965         QKeyBinding midVal = QKeySequencePrivate::keyBindings[mid];
966
967         if (searchkey > midVal.shortcut){
968             first = mid + 1;  // Search in top half
969         }
970         else if (searchkey < midVal.shortcut){
971             last = mid - 1; // Search in bottom half
972         }
973         else {
974             //found correct shortcut value, now we must check for platform match
975             if ((midVal.platform & platform) && (midVal.standardKey == matchKey)) {
976                 return true;
977             } else { //We may have several equal values for different platforms, so we must search in both directions
978
979                 //search forward
980                 for ( unsigned int i = mid + 1 ; i < N - 1 ; ++i) {
981                     QKeyBinding current = QKeySequencePrivate::keyBindings[i];
982                     if (current.shortcut != searchkey)
983                         break;
984                     else if (current.platform & platform && current.standardKey == matchKey)
985                         return true;
986                 }
987
988                 //search back
989                 for ( int i = mid - 1 ; i >= 0 ; --i) {
990                     QKeyBinding current = QKeySequencePrivate::keyBindings[i];
991                     if (current.shortcut != searchkey)
992                         break;
993                     else if (current.platform & platform && current.standardKey == matchKey)
994                         return true;
995                 }
996                 return false; //we could not find it among the matching keySequences
997             }
998         }
999     }
1000     return false; //we could not find matching keySequences at all
1001 }
1002 #endif // QT_NO_SHORTCUT
1003
1004
1005 /*!
1006     \fn bool QKeyEvent::isAutoRepeat() const
1007
1008     Returns true if this event comes from an auto-repeating key;
1009     returns false if it comes from an initial key press.
1010
1011     Note that if the event is a multiple-key compressed event that is
1012     partly due to auto-repeat, this function could return either true
1013     or false indeterminately.
1014 */
1015
1016 /*!
1017     \fn int QKeyEvent::count() const
1018
1019     Returns the number of keys involved in this event. If text()
1020     is not empty, this is simply the length of the string.
1021
1022     \sa Qt::WA_KeyCompression
1023 */
1024
1025 /*!
1026     \class QFocusEvent
1027     \brief The QFocusEvent class contains event parameters for widget focus
1028     events.
1029     \inmodule QtGui
1030
1031     \ingroup events
1032
1033     Focus events are sent to widgets when the keyboard input focus
1034     changes. Focus events occur due to mouse actions, key presses
1035     (such as \uicontrol{Tab} or \uicontrol{Backtab}), the window system, popup
1036     menus, keyboard shortcuts, or other application-specific reasons.
1037     The reason for a particular focus event is returned by reason()
1038     in the appropriate event handler.
1039
1040     The event handlers QWidget::focusInEvent(),
1041     QWidget::focusOutEvent(), QGraphicsItem::focusInEvent and
1042     QGraphicsItem::focusOutEvent() receive focus events.
1043
1044     \sa QWidget::setFocus(), QWidget::setFocusPolicy(), {Keyboard Focus}
1045 */
1046
1047 /*!
1048     Constructs a focus event object.
1049
1050     The \a type parameter must be either QEvent::FocusIn or
1051     QEvent::FocusOut. The \a reason describes the cause of the change
1052     in focus.
1053 */
1054 QFocusEvent::QFocusEvent(Type type, Qt::FocusReason reason)
1055     : QEvent(type), m_reason(reason)
1056 {}
1057
1058 /*!
1059     \internal
1060 */
1061 QFocusEvent::~QFocusEvent()
1062 {
1063 }
1064
1065 /*!
1066     Returns the reason for this focus event.
1067  */
1068 Qt::FocusReason QFocusEvent::reason() const
1069 {
1070     return m_reason;
1071 }
1072
1073 /*!
1074     \fn bool QFocusEvent::gotFocus() const
1075
1076     Returns true if type() is QEvent::FocusIn; otherwise returns
1077     false.
1078 */
1079
1080 /*!
1081     \fn bool QFocusEvent::lostFocus() const
1082
1083     Returns true if type() is QEvent::FocusOut; otherwise returns
1084     false.
1085 */
1086
1087
1088 /*!
1089     \class QPaintEvent
1090     \brief The QPaintEvent class contains event parameters for paint events.
1091     \inmodule QtGui
1092
1093     \ingroup events
1094
1095     Paint events are sent to widgets that need to update themselves,
1096     for instance when part of a widget is exposed because a covering
1097     widget was moved.
1098
1099     The event contains a region() that needs to be updated, and a
1100     rect() that is the bounding rectangle of that region. Both are
1101     provided because many widgets can't make much use of region(),
1102     and rect() can be much faster than region().boundingRect().
1103
1104     \section1 Automatic Clipping
1105
1106     Painting is clipped to region() during the processing of a paint
1107     event. This clipping is performed by Qt's paint system and is
1108     independent of any clipping that may be applied to a QPainter used to
1109     draw on the paint device.
1110
1111     As a result, the value returned by QPainter::clipRegion() on
1112     a newly-constructed QPainter will not reflect the clip region that is
1113     used by the paint system.
1114
1115     \sa QPainter, QWidget::update(), QWidget::repaint(),
1116         QWidget::paintEvent()
1117 */
1118
1119 /*!
1120     Constructs a paint event object with the region that needs to
1121     be updated. The region is specified by \a paintRegion.
1122 */
1123 QPaintEvent::QPaintEvent(const QRegion& paintRegion)
1124     : QEvent(Paint), m_rect(paintRegion.boundingRect()), m_region(paintRegion), m_erased(false)
1125 {}
1126
1127 /*!
1128     Constructs a paint event object with the rectangle that needs
1129     to be updated. The region is specified by \a paintRect.
1130 */
1131 QPaintEvent::QPaintEvent(const QRect &paintRect)
1132     : QEvent(Paint), m_rect(paintRect),m_region(paintRect), m_erased(false)
1133 {}
1134
1135
1136 /*!
1137   \internal
1138 */
1139 QPaintEvent::~QPaintEvent()
1140 {
1141 }
1142
1143 /*!
1144     \fn const QRect &QPaintEvent::rect() const
1145
1146     Returns the rectangle that needs to be updated.
1147
1148     \sa region(), QPainter::setClipRect()
1149 */
1150
1151 /*!
1152     \fn const QRegion &QPaintEvent::region() const
1153
1154     Returns the region that needs to be updated.
1155
1156     \sa rect(), QPainter::setClipRegion()
1157 */
1158
1159
1160 /*!
1161     \class QMoveEvent
1162     \brief The QMoveEvent class contains event parameters for move events.
1163     \inmodule QtGui
1164
1165     \ingroup events
1166
1167     Move events are sent to widgets that have been moved to a new
1168     position relative to their parent.
1169
1170     The event handler QWidget::moveEvent() receives move events.
1171
1172     \sa QWidget::move(), QWidget::setGeometry()
1173 */
1174
1175 /*!
1176     Constructs a move event with the new and old widget positions,
1177     \a pos and \a oldPos respectively.
1178 */
1179 QMoveEvent::QMoveEvent(const QPoint &pos, const QPoint &oldPos)
1180     : QEvent(Move), p(pos), oldp(oldPos)
1181 {}
1182
1183 /*!
1184   \internal
1185 */
1186 QMoveEvent::~QMoveEvent()
1187 {
1188 }
1189
1190 /*!
1191     \fn const QPoint &QMoveEvent::pos() const
1192
1193     Returns the new position of the widget. This excludes the window
1194     frame for top level widgets.
1195 */
1196
1197 /*!
1198     \fn const QPoint &QMoveEvent::oldPos() const
1199
1200     Returns the old position of the widget.
1201 */
1202
1203 /*!
1204     \class QExposeEvent
1205     \since 5.0
1206     \brief The QExposeEvent class contains event parameters for expose events.
1207     \inmodule QtGui
1208
1209     \ingroup events
1210
1211     Expose events are sent to windows when an area of the window is invalidated
1212     or window visibility in the windowing system changes.
1213
1214     The event handler QWindow::exposeEvent() receives expose events.
1215 */
1216
1217 /*!
1218     Constructs an expose event for the given \a exposeRegion.
1219 */
1220 QExposeEvent::QExposeEvent(const QRegion &exposeRegion)
1221     : QEvent(Expose)
1222     , rgn(exposeRegion)
1223 {
1224 }
1225
1226 /*!
1227   \internal
1228 */
1229 QExposeEvent::~QExposeEvent()
1230 {
1231 }
1232
1233 /*!
1234     \fn const QRegion &QExposeEvent::region() const
1235
1236     Returns the window area that has been exposed.
1237 */
1238
1239 /*!
1240     \class QResizeEvent
1241     \brief The QResizeEvent class contains event parameters for resize events.
1242     \inmodule QtGui
1243
1244     \ingroup events
1245
1246     Resize events are sent to widgets that have been resized.
1247
1248     The event handler QWidget::resizeEvent() receives resize events.
1249
1250     \sa QWidget::resize(), QWidget::setGeometry()
1251 */
1252
1253 /*!
1254     Constructs a resize event with the new and old widget sizes, \a
1255     size and \a oldSize respectively.
1256 */
1257 QResizeEvent::QResizeEvent(const QSize &size, const QSize &oldSize)
1258     : QEvent(Resize), s(size), olds(oldSize)
1259 {}
1260
1261 /*!
1262   \internal
1263 */
1264 QResizeEvent::~QResizeEvent()
1265 {
1266 }
1267
1268 /*!
1269     \fn const QSize &QResizeEvent::size() const
1270
1271     Returns the new size of the widget. This is the same as
1272     QWidget::size().
1273 */
1274
1275 /*!
1276     \fn const QSize &QResizeEvent::oldSize() const
1277
1278     Returns the old size of the widget.
1279 */
1280
1281
1282 /*!
1283     \class QCloseEvent
1284     \brief The QCloseEvent class contains parameters that describe a close event.
1285
1286     \ingroup events
1287     \inmodule QtGui
1288
1289     Close events are sent to widgets that the user wants to close,
1290     usually by choosing "Close" from the window menu, or by clicking
1291     the \uicontrol{X} title bar button. They are also sent when you call
1292     QWidget::close() to close a widget programmatically.
1293
1294     Close events contain a flag that indicates whether the receiver
1295     wants the widget to be closed or not. When a widget accepts the
1296     close event, it is hidden (and destroyed if it was created with
1297     the Qt::WA_DeleteOnClose flag). If it refuses to accept the close
1298     event nothing happens. (Under X11 it is possible that the window
1299     manager will forcibly close the window; but at the time of writing
1300     we are not aware of any window manager that does this.)
1301
1302     The event handler QWidget::closeEvent() receives close events. The
1303     default implementation of this event handler accepts the close
1304     event. If you do not want your widget to be hidden, or want some
1305     special handing, you should reimplement the event handler and
1306     ignore() the event.
1307
1308     The \l{mainwindows/application#close event handler}{closeEvent() in the
1309     Application example} shows a close event handler that
1310     asks whether to save a document before closing.
1311
1312     If you want the widget to be deleted when it is closed, create it
1313     with the Qt::WA_DeleteOnClose flag. This is very useful for
1314     independent top-level windows in a multi-window application.
1315
1316     \l{QObject}s emits the \l{QObject::destroyed()}{destroyed()}
1317     signal when they are deleted.
1318
1319     If the last top-level window is closed, the
1320     QApplication::lastWindowClosed() signal is emitted.
1321
1322     The isAccepted() function returns true if the event's receiver has
1323     agreed to close the widget; call accept() to agree to close the
1324     widget and call ignore() if the receiver of this event does not
1325     want the widget to be closed.
1326
1327     \sa QWidget::close(), QWidget::hide(), QObject::destroyed(),
1328         QCoreApplication::exec(), QCoreApplication::quit(),
1329         QApplication::lastWindowClosed()
1330 */
1331
1332 /*!
1333     Constructs a close event object.
1334
1335     \sa accept()
1336 */
1337 QCloseEvent::QCloseEvent()
1338     : QEvent(Close)
1339 {}
1340
1341 /*! \internal
1342 */
1343 QCloseEvent::~QCloseEvent()
1344 {
1345 }
1346
1347 /*!
1348    \class QIconDragEvent
1349    \brief The QIconDragEvent class indicates that a main icon drag has begun.
1350     \inmodule QtGui
1351
1352    \ingroup events
1353
1354    Icon drag events are sent to widgets when the main icon of a window
1355    has been dragged away. On Mac OS X, this happens when the proxy
1356    icon of a window is dragged off the title bar.
1357
1358    It is normal to begin using drag and drop in response to this
1359    event.
1360
1361    \sa {Drag and Drop}, QMimeData, QDrag
1362 */
1363
1364 /*!
1365     Constructs an icon drag event object with the accept flag set to
1366     false.
1367
1368     \sa accept()
1369 */
1370 QIconDragEvent::QIconDragEvent()
1371     : QEvent(IconDrag)
1372 { ignore(); }
1373
1374 /*! \internal */
1375 QIconDragEvent::~QIconDragEvent()
1376 {
1377 }
1378
1379 /*!
1380     \class QContextMenuEvent
1381     \brief The QContextMenuEvent class contains parameters that describe a context menu event.
1382     \inmodule QtGui
1383
1384     \ingroup events
1385
1386     Context menu events are sent to widgets when a user performs
1387     an action associated with opening a context menu.
1388     The actions required to open context menus vary between platforms;
1389     for example, on Windows, pressing the menu button or clicking the
1390     right mouse button will cause this event to be sent.
1391
1392     When this event occurs it is customary to show a QMenu with a
1393     context menu, if this is relevant to the context.
1394
1395     Context menu events contain a special accept flag that indicates
1396     whether the receiver accepted the event. If the event handler does
1397     not accept the event then, if possible, whatever triggered the event will be
1398     handled as a regular input event.
1399 */
1400
1401 #ifndef QT_NO_CONTEXTMENU
1402 /*!
1403     Constructs a context menu event object with the accept parameter
1404     flag set to false.
1405
1406     The \a reason parameter must be QContextMenuEvent::Mouse or
1407     QContextMenuEvent::Keyboard.
1408
1409     The \a pos parameter specifies the mouse position relative to the
1410     receiving widget. \a globalPos is the mouse position in absolute
1411     coordinates.
1412 */
1413 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos)
1414     : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason)
1415 {}
1416
1417 /*!
1418     Constructs a context menu event object with the accept parameter
1419     flag set to false.
1420
1421     The \a reason parameter must be QContextMenuEvent::Mouse or
1422     QContextMenuEvent::Keyboard.
1423
1424     The \a pos parameter specifies the mouse position relative to the
1425     receiving widget. \a globalPos is the mouse position in absolute
1426     coordinates. The \a modifiers holds the keyboard modifiers.
1427 */
1428 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
1429                                      Qt::KeyboardModifiers modifiers)
1430     : QInputEvent(ContextMenu, modifiers), p(pos), gp(globalPos), reas(reason)
1431 {}
1432
1433
1434 /*! \internal */
1435 QContextMenuEvent::~QContextMenuEvent()
1436 {
1437 }
1438 /*!
1439     Constructs a context menu event object with the accept parameter
1440     flag set to false.
1441
1442     The \a reason parameter must be QContextMenuEvent::Mouse or
1443     QContextMenuEvent::Keyboard.
1444
1445     The \a pos parameter specifies the mouse position relative to the
1446     receiving widget.
1447
1448     The globalPos() is initialized to QCursor::pos(), which may not be
1449     appropriate. Use the other constructor to specify the global
1450     position explicitly.
1451 */
1452 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
1453     : QInputEvent(ContextMenu), p(pos), reas(reason)
1454 {
1455     gp = QCursor::pos();
1456 }
1457
1458 /*!
1459     \fn const QPoint &QContextMenuEvent::pos() const
1460
1461     Returns the position of the mouse pointer relative to the widget
1462     that received the event.
1463
1464     \sa x(), y(), globalPos()
1465 */
1466
1467 /*!
1468     \fn int QContextMenuEvent::x() const
1469
1470     Returns the x position of the mouse pointer, relative to the
1471     widget that received the event.
1472
1473     \sa y(), pos()
1474 */
1475
1476 /*!
1477     \fn int QContextMenuEvent::y() const
1478
1479     Returns the y position of the mouse pointer, relative to the
1480     widget that received the event.
1481
1482     \sa x(), pos()
1483 */
1484
1485 /*!
1486     \fn const QPoint &QContextMenuEvent::globalPos() const
1487
1488     Returns the global position of the mouse pointer at the time of
1489     the event.
1490
1491     \sa x(), y(), pos()
1492 */
1493
1494 /*!
1495     \fn int QContextMenuEvent::globalX() const
1496
1497     Returns the global x position of the mouse pointer at the time of
1498     the event.
1499
1500     \sa globalY(), globalPos()
1501 */
1502
1503 /*!
1504     \fn int QContextMenuEvent::globalY() const
1505
1506     Returns the global y position of the mouse pointer at the time of
1507     the event.
1508
1509     \sa globalX(), globalPos()
1510 */
1511 #endif // QT_NO_CONTEXTMENU
1512
1513 /*!
1514     \enum QContextMenuEvent::Reason
1515
1516     This enum describes the reason why the event was sent.
1517
1518     \value Mouse The mouse caused the event to be sent. Normally this
1519     means the right mouse button was clicked, but this is platform
1520     dependent.
1521
1522     \value Keyboard The keyboard caused this event to be sent. On
1523     Windows, this means the menu button was pressed.
1524
1525     \value Other The event was sent by some other means (i.e. not by
1526     the mouse or keyboard).
1527 */
1528
1529
1530 /*!
1531     \fn QContextMenuEvent::Reason QContextMenuEvent::reason() const
1532
1533     Returns the reason for this context event.
1534 */
1535
1536
1537 /*!
1538     \class QInputMethodEvent
1539     \brief The QInputMethodEvent class provides parameters for input method events.
1540     \inmodule QtGui
1541
1542     \ingroup events
1543
1544     Input method events are sent to widgets when an input method is
1545     used to enter text into a widget. Input methods are widely used
1546     to enter text for languages with non-Latin alphabets.
1547
1548     Note that when creating custom text editing widgets, the
1549     Qt::WA_InputMethodEnabled window attribute must be set explicitly
1550     (using the QWidget::setAttribute() function) in order to receive
1551     input method events.
1552
1553     The events are of interest to authors of keyboard entry widgets
1554     who want to be able to correctly handle languages with complex
1555     character input. Text input in such languages is usually a three
1556     step process:
1557
1558     \list 1
1559     \li \b{Starting to Compose}
1560
1561        When the user presses the first key on a keyboard, an input
1562        context is created. This input context will contain a string
1563        of the typed characters.
1564
1565     \li \b{Composing}
1566
1567        With every new key pressed, the input method will try to create a
1568        matching string for the text typed so far called preedit
1569        string. While the input context is active, the user can only move
1570        the cursor inside the string belonging to this input context.
1571
1572     \li \b{Completing}
1573
1574        At some point, the user will activate a user interface component
1575        (perhaps using a particular key) where they can choose from a
1576        number of strings matching the text they have typed so far. The
1577        user can either confirm their choice cancel the input; in either
1578        case the input context will be closed.
1579     \endlist
1580
1581     QInputMethodEvent models these three stages, and transfers the
1582     information needed to correctly render the intermediate result. A
1583     QInputMethodEvent has two main parameters: preeditString() and
1584     commitString(). The preeditString() parameter gives the currently
1585     active preedit string. The commitString() parameter gives a text
1586     that should get added to (or replace parts of) the text of the
1587     editor widget. It usually is a result of the input operations and
1588     has to be inserted to the widgets text directly before the preedit
1589     string.
1590
1591     If the commitString() should replace parts of the of the text in
1592     the editor, replacementLength() will contain the number of
1593     characters to be replaced. replacementStart() contains the position
1594     at which characters are to be replaced relative from the start of
1595     the preedit string.
1596
1597     A number of attributes control the visual appearance of the
1598     preedit string (the visual appearance of text outside the preedit
1599     string is controlled by the widget only). The AttributeType enum
1600     describes the different attributes that can be set.
1601
1602     A class implementing QWidget::inputMethodEvent() or
1603     QGraphicsItem::inputMethodEvent() should at least understand and
1604     honor the \l TextFormat and \l Cursor attributes.
1605
1606     Since input methods need to be able to query certain properties
1607     from the widget or graphics item, subclasses must also implement
1608     QWidget::inputMethodQuery() and QGraphicsItem::inputMethodQuery(),
1609     respectively.
1610
1611     When receiving an input method event, the text widget has to performs the
1612     following steps:
1613
1614     \list 1
1615     \li If the widget has selected text, the selected text should get
1616        removed.
1617
1618     \li Remove the text starting at replacementStart() with length
1619        replacementLength() and replace it by the commitString(). If
1620        replacementLength() is 0, replacementStart() gives the insertion
1621        position for the commitString().
1622
1623        When doing replacement the area of the preedit
1624        string is ignored, thus a replacement starting at -1 with a length
1625        of 2 will remove the last character before the preedit string and
1626        the first character afterwards, and insert the commit string
1627        directly before the preedit string.
1628
1629        If the widget implements undo/redo, this operation gets added to
1630        the undo stack.
1631
1632     \li If there is no current preedit string, insert the
1633        preeditString() at the current cursor position; otherwise replace
1634        the previous preeditString with the one received from this event.
1635
1636        If the widget implements undo/redo, the preeditString() should not
1637        influence the undo/redo stack in any way.
1638
1639        The widget should examine the list of attributes to apply to the
1640        preedit string. It has to understand at least the TextFormat and
1641        Cursor attributes and render them as specified.
1642     \endlist
1643
1644     \sa QInputMethod
1645 */
1646
1647 /*!
1648     \enum QInputMethodEvent::AttributeType
1649
1650     \value TextFormat
1651     A QTextCharFormat for the part of the preedit string specified by
1652     start and length. value contains a QVariant of type QTextFormat
1653     specifying rendering of this part of the preedit string. There
1654     should be at most one format for every part of the preedit
1655     string. If several are specified for any character in the string the
1656     behaviour is undefined. A conforming implementation has to at least
1657     honor the backgroundColor, textColor and fontUnderline properties
1658     of the format.
1659
1660     \value Cursor If set, a cursor should be shown inside the preedit
1661     string at position start. The length variable determines whether
1662     the cursor is visible or not. If the length is 0 the cursor is
1663     invisible. If value is a QVariant of type QColor this color will
1664     be used for rendering the cursor, otherwise the color of the
1665     surrounding text will be used. There should be at most one Cursor
1666     attribute per event. If several are specified the behaviour is
1667     undefined.
1668
1669     \value Language
1670     The variant contains a QLocale object specifying the language of a
1671     certain part of the preedit string. There should be at most one
1672     language set for every part of the preedit string. If several are
1673     specified for any character in the string the behavior is undefined.
1674
1675     \value Ruby
1676     The ruby text for a part of the preedit string. There should be at
1677     most one ruby text set for every part of the preedit string. If
1678     several are specified for any character in the string the behaviour
1679     is undefined.
1680
1681     \value Selection
1682     If set, the edit cursor should be moved to the specified position
1683     in the editor text contents. In contrast with \c Cursor, this
1684     attribute does not work on the preedit text, but on the surrounding
1685     text. The cursor will be moved after the commit string has been
1686     committed, and the preedit string will be located at the new edit
1687     position.
1688     The start position specifies the new position and the length
1689     variable can be used to set a selection starting from that point.
1690     The value is unused.
1691
1692     \sa Attribute
1693 */
1694
1695 /*!
1696     \class QInputMethodEvent::Attribute
1697     \brief The QInputMethodEvent::Attribute class stores an input method attribute.
1698 */
1699
1700 /*!
1701     \fn QInputMethodEvent::Attribute::Attribute(AttributeType type, int start, int length, QVariant value)
1702
1703     Constructs an input method attribute. \a type specifies the type
1704     of attribute, \a start and \a length the position of the
1705     attribute, and \a value the value of the attribute.
1706 */
1707
1708 /*!
1709     Constructs an event of type QEvent::InputMethod. The
1710     attributes(), preeditString(), commitString(), replacementStart(),
1711     and replacementLength() are initialized to default values.
1712
1713     \sa setCommitString()
1714 */
1715 QInputMethodEvent::QInputMethodEvent()
1716     : QEvent(QEvent::InputMethod), replace_from(0), replace_length(0)
1717 {
1718 }
1719
1720 /*!
1721     Construcs an event of type QEvent::InputMethod. The
1722     preedit text is set to \a preeditText, the attributes to
1723     \a attributes.
1724
1725     The commitString(), replacementStart(), and replacementLength()
1726     values can be set using setCommitString().
1727
1728     \sa preeditString(), attributes()
1729 */
1730 QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes)
1731     : QEvent(QEvent::InputMethod), preedit(preeditText), attrs(attributes),
1732       replace_from(0), replace_length(0)
1733 {
1734 }
1735
1736 /*!
1737     Constructs a copy of \a other.
1738 */
1739 QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other)
1740     : QEvent(QEvent::InputMethod), preedit(other.preedit), attrs(other.attrs),
1741       commit(other.commit), replace_from(other.replace_from), replace_length(other.replace_length)
1742 {
1743 }
1744
1745 /*!
1746     Sets the commit string to \a commitString.
1747
1748     The commit string is the text that should get added to (or
1749     replace parts of) the text of the editor widget. It usually is a
1750     result of the input operations and has to be inserted to the
1751     widgets text directly before the preedit string.
1752
1753     If the commit string should replace parts of the of the text in
1754     the editor, \a replaceLength specifies the number of
1755     characters to be replaced. \a replaceFrom specifies the position
1756     at which characters are to be replaced relative from the start of
1757     the preedit string.
1758
1759     \sa commitString(), replacementStart(), replacementLength()
1760 */
1761 void QInputMethodEvent::setCommitString(const QString &commitString, int replaceFrom, int replaceLength)
1762 {
1763     commit = commitString;
1764     replace_from = replaceFrom;
1765     replace_length = replaceLength;
1766 }
1767
1768 /*!
1769     \fn const QList<Attribute> &QInputMethodEvent::attributes() const
1770
1771     Returns the list of attributes passed to the QInputMethodEvent
1772     constructor. The attributes control the visual appearance of the
1773     preedit string (the visual appearance of text outside the preedit
1774     string is controlled by the widget only).
1775
1776     \sa preeditString(), Attribute
1777 */
1778
1779 /*!
1780     \fn const QString &QInputMethodEvent::preeditString() const
1781
1782     Returns the preedit text, i.e. the text before the user started
1783     editing it.
1784
1785     \sa commitString(), attributes()
1786 */
1787
1788 /*!
1789     \fn const QString &QInputMethodEvent::commitString() const
1790
1791     Returns the text that should get added to (or replace parts of)
1792     the text of the editor widget. It usually is a result of the
1793     input operations and has to be inserted to the widgets text
1794     directly before the preedit string.
1795
1796     \sa setCommitString(), preeditString(), replacementStart(), replacementLength()
1797 */
1798
1799 /*!
1800     \fn int QInputMethodEvent::replacementStart() const
1801
1802     Returns the position at which characters are to be replaced relative
1803     from the start of the preedit string.
1804
1805     \sa replacementLength(), setCommitString()
1806 */
1807
1808 /*!
1809     \fn int QInputMethodEvent::replacementLength() const
1810
1811     Returns the number of characters to be replaced in the preedit
1812     string.
1813
1814     \sa replacementStart(), setCommitString()
1815 */
1816
1817 /*!
1818     \class QInputMethodQueryEvent
1819     \since 5.0
1820     \inmodule QtGui
1821
1822     \brief The QInputMethodQueryEvent class provides an event sent by the input context to input objects.
1823
1824     It is used by the
1825     input method to query a set of properties of the object to be
1826     able to support complex input method operations as support for
1827     surrounding text and reconversions.
1828
1829     queries() specifies which properties are queried.
1830
1831     The object should call setValue() on the event to fill in the requested
1832     data before calling accept().
1833 */
1834
1835 /*!
1836     \fn Qt::InputMethodQueries QInputMethodQueryEvent::queries() const
1837
1838     Returns the properties queried by the event.
1839  */
1840
1841 /*!
1842     Constructs a query event for properties given by \a queries.
1843  */
1844 QInputMethodQueryEvent::QInputMethodQueryEvent(Qt::InputMethodQueries queries)
1845     : QEvent(InputMethodQuery),
1846       m_queries(queries)
1847 {
1848 }
1849
1850 /*!
1851     \internal
1852  */
1853 QInputMethodQueryEvent::~QInputMethodQueryEvent()
1854 {
1855 }
1856
1857 /*!
1858     Sets property \a query to \a value.
1859  */
1860 void QInputMethodQueryEvent::setValue(Qt::InputMethodQuery query, const QVariant &value)
1861 {
1862     for (int i = 0; i < m_values.size(); ++i) {
1863         if (m_values.at(i).query == query) {
1864             m_values[i].value = value;
1865             return;
1866         }
1867     }
1868     QueryPair pair = { query, value };
1869     m_values.append(pair);
1870 }
1871
1872 /*!
1873     Returns value of the property \a query.
1874  */
1875 QVariant QInputMethodQueryEvent::value(Qt::InputMethodQuery query) const
1876 {
1877     for (int i = 0; i < m_values.size(); ++i)
1878         if (m_values.at(i).query == query)
1879             return m_values.at(i).value;
1880     return QVariant();
1881 }
1882
1883 #ifndef QT_NO_TABLETEVENT
1884
1885 /*!
1886     \class QTabletEvent
1887     \brief The QTabletEvent class contains parameters that describe a Tablet event.
1888     \inmodule QtGui
1889
1890     \ingroup events
1891
1892     Tablet Events are generated from a Wacom tablet. Most of the time you will
1893     want to deal with events from the tablet as if they were events from a
1894     mouse; for example, you would retrieve the cursor position with x(), y(),
1895     pos(), globalX(), globalY(), and globalPos(). In some situations you may
1896     wish to retrieve the extra information provided by the tablet device
1897     driver; for example, you might want to do subpixeling with higher
1898     resolution coordinates or you may want to adjust color brightness based on
1899     pressure.  QTabletEvent allows you to read the pressure(), the xTilt(), and
1900     yTilt(), as well as the type of device being used with device() (see
1901     \l{TabletDevice}). It can also give you the minimum and maximum values for
1902     each device's pressure and high resolution coordinates.
1903
1904     A tablet event contains a special accept flag that indicates whether the
1905     receiver wants the event. You should call QTabletEvent::accept() if you
1906     handle the tablet event; otherwise it will be sent to the parent widget.
1907     The exception are TabletEnterProximity and TabletLeaveProximity events,
1908     these are only sent to QApplication and don't check whether or not they are
1909     accepted.
1910
1911     The QWidget::setEnabled() function can be used to enable or
1912     disable mouse and keyboard events for a widget.
1913
1914     The event handler QWidget::tabletEvent() receives all three types of
1915     tablet events. Qt will first send a tabletEvent then, if it is not
1916     accepted, it will send a mouse event. This allows applications that
1917     don't utilize tablets to use a tablet like a mouse, while also
1918     enabling those who want to use both tablets and mouses differently.
1919
1920     \section1 Notes for X11 Users
1921
1922     Qt uses the following hard-coded names to identify tablet
1923     devices from the xorg.conf file on X11 (apart from IRIX):
1924     'stylus', 'pen', and 'eraser'. If the devices have other names,
1925     they will not be picked up Qt.
1926 */
1927
1928 /*!
1929     \enum QTabletEvent::TabletDevice
1930
1931     This enum defines what type of device is generating the event.
1932
1933     \value NoDevice    No device, or an unknown device.
1934     \value Puck    A Puck (a device that is similar to a flat mouse with
1935     a transparent circle with cross-hairs).
1936     \value Stylus  A Stylus.
1937     \value Airbrush An airbrush
1938     \value FourDMouse A 4D Mouse.
1939     \value RotationStylus A special stylus that also knows about rotation
1940            (a 6D stylus). \since 4.1
1941     \omitvalue XFreeEraser
1942 */
1943
1944 /*!
1945     \enum QTabletEvent::PointerType
1946
1947     This enum defines what type of point is generating the event.
1948
1949     \value UnknownPointer    An unknown device.
1950     \value Pen    Tip end of a stylus-like device (the narrow end of the pen).
1951     \value Cursor  Any puck-like device.
1952     \value Eraser  Eraser end of a stylus-like device (the broad end of the pen).
1953
1954     \sa pointerType()
1955 */
1956
1957 /*!
1958   Construct a tablet event of the given \a type.
1959
1960   The \a pos parameter indicates where the event occurred in the
1961   widget; \a globalPos is the corresponding position in absolute
1962   coordinates.
1963
1964   \a pressure contains the pressure exerted on the \a device.
1965
1966   \a pointerType describes the type of pen that is being used.
1967
1968   \a xTilt and \a yTilt contain the device's degree of tilt from the
1969   x and y axes respectively.
1970
1971   \a keyState specifies which keyboard modifiers are pressed (e.g.,
1972   \uicontrol{Ctrl}).
1973
1974   The \a uniqueID parameter contains the unique ID for the current device.
1975
1976   The \a z parameter contains the coordinate of the device on the tablet, this
1977   is usually given by a wheel on 4D mouse. If the device does not support a
1978   Z-axis, pass zero here.
1979
1980   The \a tangentialPressure parameter contins the tangential pressure of an air
1981   brush. If the device does not support tangential pressure, pass 0 here.
1982
1983   \a rotation contains the device's rotation in degrees. 4D mice support
1984   rotation. If the device does not support rotation, pass 0 here.
1985
1986   \sa pos(), globalPos(), device(), pressure(), xTilt(), yTilt(), uniqueId(), rotation(),
1987       tangentialPressure(), z()
1988 */
1989
1990 QTabletEvent::QTabletEvent(Type type, const QPointF &pos, const QPointF &globalPos,
1991                            int device, int pointerType,
1992                            qreal pressure, int xTilt, int yTilt, qreal tangentialPressure,
1993                            qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID)
1994     : QInputEvent(type, keyState),
1995       mPos(pos),
1996       mGPos(globalPos),
1997       mDev(device),
1998       mPointerType(pointerType),
1999       mXT(xTilt),
2000       mYT(yTilt),
2001       mZ(z),
2002       mPress(pressure),
2003       mTangential(tangentialPressure),
2004       mRot(rotation),
2005       mUnique(uniqueID),
2006       mExtra(0)
2007 {
2008 }
2009
2010 /*!
2011     \internal
2012 */
2013 QTabletEvent::~QTabletEvent()
2014 {
2015 }
2016
2017 /*!
2018     \fn TabletDevices QTabletEvent::device() const
2019
2020     Returns the type of device that generated the event.
2021
2022     \sa TabletDevice
2023 */
2024
2025 /*!
2026     \fn PointerType QTabletEvent::pointerType() const
2027
2028     Returns the type of point that generated the event.
2029 */
2030
2031 /*!
2032     \fn qreal QTabletEvent::tangentialPressure() const
2033
2034     Returns the tangential pressure for the device.  This is typically given by a finger
2035     wheel on an airbrush tool.  The range is from -1.0 to 1.0. 0.0 indicates a
2036     neutral position.  Current airbrushes can only move in the positive
2037     direction from the neutrual position. If the device does not support
2038     tangential pressure, this value is always 0.0.
2039
2040     \sa pressure()
2041 */
2042
2043 /*!
2044     \fn qreal QTabletEvent::rotation() const
2045
2046     Returns the rotation of the current device in degress. This is usually
2047     given by a 4D Mouse. If the device doesn't support rotation this value is
2048     always 0.0.
2049
2050 */
2051
2052 /*!
2053     \fn qreal QTabletEvent::pressure() const
2054
2055     Returns the pressure for the device. 0.0 indicates that the stylus is not
2056     on the tablet, 1.0 indicates the maximum amount of pressure for the stylus.
2057
2058     \sa tangentialPressure()
2059 */
2060
2061 /*!
2062     \fn int QTabletEvent::xTilt() const
2063
2064     Returns the angle between the device (a pen, for example) and the
2065     perpendicular in the direction of the x axis.
2066     Positive values are towards the tablet's physical right. The angle
2067     is in the range -60 to +60 degrees.
2068
2069     \image qtabletevent-tilt.png
2070
2071     \sa yTilt()
2072 */
2073
2074 /*!
2075     \fn int QTabletEvent::yTilt() const
2076
2077     Returns the angle between the device (a pen, for example) and the
2078     perpendicular in the direction of the y axis.
2079     Positive values are towards the bottom of the tablet. The angle is
2080     within the range -60 to +60 degrees.
2081
2082     \sa xTilt()
2083 */
2084
2085 /*!
2086     \fn QPoint QTabletEvent::pos() const
2087
2088     Returns the position of the device, relative to the widget that
2089     received the event.
2090
2091     If you move widgets around in response to mouse events, use
2092     globalPos() instead of this function.
2093
2094     \sa x(), y(), globalPos()
2095 */
2096
2097 /*!
2098     \fn int QTabletEvent::x() const
2099
2100     Returns the x position of the device, relative to the widget that
2101     received the event.
2102
2103     \sa y(), pos()
2104 */
2105
2106 /*!
2107     \fn int QTabletEvent::y() const
2108
2109     Returns the y position of the device, relative to the widget that
2110     received the event.
2111
2112     \sa x(), pos()
2113 */
2114
2115 /*!
2116     \fn int QTabletEvent::z() const
2117
2118     Returns the z position of the device. Typically this is represented by a
2119     wheel on a 4D Mouse. If the device does not support a Z-axis, this value is
2120     always zero. This is \b not the same as pressure.
2121
2122     \sa pressure()
2123 */
2124
2125 /*!
2126     \fn QPoint QTabletEvent::globalPos() const
2127
2128     Returns the global position of the device \e{at the time of the
2129     event}. This is important on asynchronous windows systems like X11;
2130     whenever you move your widgets around in response to mouse events,
2131     globalPos() can differ significantly from the current position
2132     QCursor::pos().
2133
2134     \sa globalX(), globalY(), hiResGlobalPos()
2135 */
2136
2137 /*!
2138     \fn int QTabletEvent::globalX() const
2139
2140     Returns the global x position of the mouse pointer at the time of
2141     the event.
2142
2143     \sa globalY(), globalPos(), hiResGlobalX()
2144 */
2145
2146 /*!
2147     \fn int QTabletEvent::globalY() const
2148
2149     Returns the global y position of the tablet device at the time of
2150     the event.
2151
2152     \sa globalX(), globalPos(), hiResGlobalY()
2153 */
2154
2155 /*!
2156     \fn qint64 QTabletEvent::uniqueId() const
2157
2158     Returns a unique ID for the current device, making it possible
2159     to differentiate between multiple devices being used at the same
2160     time on the tablet.
2161
2162     Support of this feature is dependent on the tablet.
2163
2164     Values for the same device may vary from OS to OS.
2165
2166     Later versions of the Wacom driver for Linux will now report
2167     the ID information. If you have a tablet that supports unique ID
2168     and are not getting the information on Linux, consider upgrading
2169     your driver.
2170
2171     As of Qt 4.2, the unique ID is the same regardless of the orientation
2172     of the pen. Earlier versions would report a different value when using
2173     the eraser-end versus the pen-end of the stylus on some OS's.
2174
2175     \sa pointerType()
2176 */
2177
2178 /*!
2179     \fn const QPointF &QTabletEvent::hiResGlobalPos() const
2180
2181     The high precision coordinates delivered from the tablet expressed.
2182     Sub pixeling information is in the fractional part of the QPointF.
2183
2184     \sa globalPos(), hiResGlobalX(), hiResGlobalY()
2185 */
2186
2187 /*!
2188     \fn qreal &QTabletEvent::hiResGlobalX() const
2189
2190     The high precision x position of the tablet device.
2191 */
2192
2193 /*!
2194     \fn qreal &QTabletEvent::hiResGlobalY() const
2195
2196     The high precision y position of the tablet device.
2197 */
2198
2199 /*!
2200     \fn const QPointF &QTabletEvent::posF() const
2201
2202     Returns the position of the device, relative to the widget that
2203     received the event.
2204
2205     If you move widgets around in response to mouse events, use
2206     globalPosF() instead of this function.
2207
2208     \sa globalPosF()
2209 */
2210
2211 /*!
2212     \fn const QPointF &QTabletEvent::globalPosF() const
2213
2214     Returns the global position of the device \e{at the time of the
2215     event}. This is important on asynchronous windows systems like X11;
2216     whenever you move your widgets around in response to mouse events,
2217     globalPosF() can differ significantly from the current position
2218     QCursor::pos().
2219
2220     \sa posF()
2221 */
2222
2223 #endif // QT_NO_TABLETEVENT
2224
2225 #ifndef QT_NO_DRAGANDDROP
2226 /*!
2227     Creates a QDragMoveEvent of the required \a type indicating
2228     that the mouse is at position \a pos given within a widget.
2229
2230     The mouse and keyboard states are specified by \a buttons and
2231     \a modifiers, and the \a actions describe the types of drag
2232     and drop operation that are possible.
2233     The drag data is passed as MIME-encoded information in \a data.
2234
2235     \warning Do not attempt to create a QDragMoveEvent yourself.
2236     These objects rely on Qt's internal state.
2237 */
2238 QDragMoveEvent::QDragMoveEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
2239                                Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
2240     : QDropEvent(pos, actions, data, buttons, modifiers, type)
2241     , rect(pos, QSize(1, 1))
2242 {}
2243
2244 /*!
2245     Destroys the event.
2246 */
2247 QDragMoveEvent::~QDragMoveEvent()
2248 {
2249 }
2250
2251 /*!
2252     \fn void QDragMoveEvent::accept(const QRect &rectangle)
2253
2254     The same as accept(), but also notifies that future moves will
2255     also be acceptable if they remain within the \a rectangle
2256     given on the widget. This can improve performance, but may
2257     also be ignored by the underlying system.
2258
2259     If the rectangle is empty, drag move events will be sent
2260     continuously. This is useful if the source is scrolling in a
2261     timer event.
2262 */
2263
2264 /*!
2265     \fn void QDragMoveEvent::accept()
2266
2267     \overload
2268
2269     Calls QDropEvent::accept().
2270 */
2271
2272 /*!
2273     \fn void QDragMoveEvent::ignore()
2274
2275     \overload
2276
2277     Calls QDropEvent::ignore().
2278 */
2279
2280 /*!
2281     \fn void QDragMoveEvent::ignore(const QRect &rectangle)
2282
2283     The opposite of the accept(const QRect&) function.
2284     Moves within the \a rectangle are not acceptable, and will be
2285     ignored.
2286 */
2287
2288 /*!
2289     \fn QRect QDragMoveEvent::answerRect() const
2290
2291     Returns the rectangle in the widget where the drop will occur if accepted.
2292     You can use this information to restrict drops to certain places on the
2293     widget.
2294 */
2295
2296
2297 /*!
2298     \class QDropEvent
2299     \ingroup events
2300     \ingroup draganddrop
2301     \inmodule QtGui
2302
2303     \brief The QDropEvent class provides an event which is sent when a
2304     drag and drop action is completed.
2305
2306     When a widget \l{QWidget::setAcceptDrops()}{accepts drop events}, it will
2307     receive this event if it has accepted the most recent QDragEnterEvent or
2308     QDragMoveEvent sent to it.
2309
2310     The drop event contains a proposed action, available from proposedAction(), for
2311     the widget to either accept or ignore. If the action can be handled by the
2312     widget, you should call the acceptProposedAction() function. Since the
2313     proposed action can be a combination of \l Qt::DropAction values, it may be
2314     useful to either select one of these values as a default action or ask
2315     the user to select their preferred action.
2316
2317     If the proposed drop action is not suitable, perhaps because your custom
2318     widget does not support that action, you can replace it with any of the
2319     \l{possibleActions()}{possible drop actions} by calling setDropAction()
2320     with your preferred action. If you set a value that is not present in the
2321     bitwise OR combination of values returned by possibleActions(), the default
2322     copy action will be used. Once a replacement drop action has been set, call
2323     accept() instead of acceptProposedAction() to complete the drop operation.
2324
2325     The mimeData() function provides the data dropped on the widget in a QMimeData
2326     object. This contains information about the MIME type of the data in addition to
2327     the data itself.
2328
2329     \sa QMimeData, QDrag, {Drag and Drop}
2330 */
2331
2332 /*!
2333     \fn const QMimeData *QDropEvent::mimeData() const
2334
2335     Returns the data that was dropped on the widget and its associated MIME
2336     type information.
2337 */
2338
2339 /*!
2340     Constructs a drop event of a certain \a type corresponding to a
2341     drop at the point specified by \a pos in the destination widget's
2342     coordinate system.
2343
2344     The \a actions indicate which types of drag and drop operation can
2345     be performed, and the drag data is stored as MIME-encoded data in \a data.
2346
2347     The states of the mouse buttons and keyboard modifiers at the time of
2348     the drop are specified by \a buttons and \a modifiers.
2349 */ // ### pos is in which coordinate system?
2350 QDropEvent::QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data,
2351                        Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
2352     : QEvent(type), p(pos), mouseState(buttons),
2353       modState(modifiers), act(actions),
2354       mdata(data)
2355 {
2356     default_action = QGuiApplicationPrivate::platformIntegration()->drag()->defaultAction(act, modifiers);
2357     drop_action = default_action;
2358     ignore();
2359 }
2360
2361 /*! \internal */
2362 QDropEvent::~QDropEvent()
2363 {
2364 }
2365
2366
2367 /*!
2368     If the source of the drag operation is a widget in this
2369     application, this function returns that source; otherwise it
2370     returns 0. The source of the operation is the first parameter to
2371     the QDrag object used instantiate the drag.
2372
2373     This is useful if your widget needs special behavior when dragging
2374     to itself.
2375
2376     \sa QDrag::QDrag()
2377 */
2378 QObject* QDropEvent::source() const
2379 {
2380     if (const QDragManager *manager = QDragManager::self())
2381         return manager->source();
2382     return 0;
2383 }
2384
2385
2386 void QDropEvent::setDropAction(Qt::DropAction action)
2387 {
2388     if (!(action & act) && action != Qt::IgnoreAction)
2389         action = default_action;
2390     drop_action = action;
2391 }
2392
2393 /*!
2394     \fn QPoint QDropEvent::pos() const
2395
2396     Returns the position where the drop was made.
2397 */
2398
2399 /*!
2400     \fn const QPointF& QDropEvent::posF() const
2401
2402     Returns the position where the drop was made.
2403 */
2404
2405 /*!
2406     \fn Qt::MouseButtons QDropEvent::mouseButtons() const
2407
2408     Returns the mouse buttons that are pressed..
2409 */
2410
2411 /*!
2412     \fn Qt::KeyboardModifiers QDropEvent::keyboardModifiers() const
2413
2414     Returns the modifier keys that are pressed.
2415 */
2416
2417 /*!
2418     \fn void QDropEvent::setDropAction(Qt::DropAction action)
2419
2420     Sets the \a action to be performed on the data by the target.
2421     Use this to override the \l{proposedAction()}{proposed action}
2422     with one of the \l{possibleActions()}{possible actions}.
2423
2424     If you set a drop action that is not one of the possible actions, the
2425     drag and drop operation will default to a copy operation.
2426
2427     Once you have supplied a replacement drop action, call accept()
2428     instead of acceptProposedAction().
2429
2430     \sa dropAction()
2431 */
2432
2433 /*!
2434     \fn Qt::DropAction QDropEvent::dropAction() const
2435
2436     Returns the action to be performed on the data by the target. This may be
2437     different from the action supplied in proposedAction() if you have called
2438     setDropAction() to explicitly choose a drop action.
2439
2440     \sa setDropAction()
2441 */
2442
2443 /*!
2444     \fn Qt::DropActions QDropEvent::possibleActions() const
2445
2446     Returns an OR-combination of possible drop actions.
2447
2448     \sa dropAction()
2449 */
2450
2451 /*!
2452     \fn Qt::DropAction QDropEvent::proposedAction() const
2453
2454     Returns the proposed drop action.
2455
2456     \sa dropAction()
2457 */
2458
2459 /*!
2460     \fn void QDropEvent::acceptProposedAction()
2461
2462     Sets the drop action to be the proposed action.
2463
2464     \sa setDropAction(), proposedAction(), {QEvent::accept()}{accept()}
2465 */
2466
2467 /*!
2468     \class QDragEnterEvent
2469     \brief The QDragEnterEvent class provides an event which is sent
2470     to a widget when a drag and drop action enters it.
2471
2472     \ingroup events
2473     \ingroup draganddrop
2474     \inmodule QtGui
2475
2476     A widget must accept this event in order to receive the \l
2477     {QDragMoveEvent}{drag move events} that are sent while the drag
2478     and drop action is in progress. The drag enter event is always
2479     immediately followed by a drag move event.
2480
2481     QDragEnterEvent inherits most of its functionality from
2482     QDragMoveEvent, which in turn inherits most of its functionality
2483     from QDropEvent.
2484
2485     \sa QDragLeaveEvent, QDragMoveEvent, QDropEvent
2486 */
2487
2488 /*!
2489     Constructs a QDragEnterEvent that represents a drag entering a
2490     widget at the given \a point with mouse and keyboard states specified by
2491     \a buttons and \a modifiers.
2492
2493     The drag data is passed as MIME-encoded information in \a data, and the
2494     specified \a actions describe the possible types of drag and drop
2495     operation that can be performed.
2496
2497     \warning Do not create a QDragEnterEvent yourself since these
2498     objects rely on Qt's internal state.
2499 */
2500 QDragEnterEvent::QDragEnterEvent(const QPoint& point, Qt::DropActions actions, const QMimeData *data,
2501                                  Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
2502     : QDragMoveEvent(point, actions, data, buttons, modifiers, DragEnter)
2503 {}
2504
2505 /*! \internal
2506 */
2507 QDragEnterEvent::~QDragEnterEvent()
2508 {
2509 }
2510
2511 /*!
2512     \class QDragMoveEvent
2513     \brief The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress.
2514
2515     \ingroup events
2516     \ingroup draganddrop
2517     \inmodule QtGui
2518
2519     A widget will receive drag move events repeatedly while the drag
2520     is within its boundaries, if it accepts
2521     \l{QWidget::setAcceptDrops()}{drop events} and \l
2522     {QWidget::dragEnterEvent()}{enter events}. The widget should
2523     examine the event to see what kind of data it
2524     \l{QDragMoveEvent::provides()}{provides}, and call the accept()
2525     function to accept the drop if appropriate.
2526
2527     The rectangle supplied by the answerRect() function can be used to restrict
2528     drops to certain parts of the widget. For example, we can check whether the
2529     rectangle intersects with the geometry of a certain child widget and only
2530     call \l{QDropEvent::acceptProposedAction()}{acceptProposedAction()} if that
2531     is the case.
2532
2533     Note that this class inherits most of its functionality from
2534     QDropEvent.
2535
2536     \sa QDragEnterEvent, QDragLeaveEvent, QDropEvent
2537 */
2538
2539 /*!
2540     \class QDragLeaveEvent
2541     \brief The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leaves it.
2542
2543     \ingroup events
2544     \ingroup draganddrop
2545     \inmodule QtGui
2546
2547     This event is always preceded by a QDragEnterEvent and a series
2548     of \l{QDragMoveEvent}s. It is not sent if a QDropEvent is sent
2549     instead.
2550
2551     \sa QDragEnterEvent, QDragMoveEvent, QDropEvent
2552 */
2553
2554 /*!
2555     Constructs a QDragLeaveEvent.
2556
2557     \warning Do not create a QDragLeaveEvent yourself since these
2558     objects rely on Qt's internal state.
2559 */
2560 QDragLeaveEvent::QDragLeaveEvent()
2561     : QEvent(DragLeave)
2562 {}
2563
2564 /*! \internal
2565 */
2566 QDragLeaveEvent::~QDragLeaveEvent()
2567 {
2568 }
2569 #endif // QT_NO_DRAGANDDROP
2570
2571 /*!
2572     \class QHelpEvent
2573     \brief The QHelpEvent class provides an event that is used to request helpful information
2574     about a particular point in a widget.
2575
2576     \ingroup events
2577     \ingroup helpsystem
2578     \inmodule QtGui
2579
2580     This event can be intercepted in applications to provide tooltips
2581     or "What's This?" help for custom widgets. The type() can be
2582     either QEvent::ToolTip or QEvent::WhatsThis.
2583
2584     \sa QToolTip, QWhatsThis, QStatusTipEvent, QWhatsThisClickedEvent
2585 */
2586
2587 /*!
2588     Constructs a help event with the given \a type corresponding to the
2589     widget-relative position specified by \a pos and the global position
2590     specified by \a globalPos.
2591
2592     \a type must be either QEvent::ToolTip or QEvent::WhatsThis.
2593
2594     \sa pos(), globalPos()
2595 */
2596 QHelpEvent::QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos)
2597     : QEvent(type), p(pos), gp(globalPos)
2598 {}
2599
2600 /*!
2601     \fn int QHelpEvent::x() const
2602
2603     Same as pos().x().
2604
2605     \sa y(), pos(), globalPos()
2606 */
2607
2608 /*!
2609     \fn int QHelpEvent::y() const
2610
2611     Same as pos().y().
2612
2613     \sa x(), pos(), globalPos()
2614 */
2615
2616 /*!
2617     \fn int QHelpEvent::globalX() const
2618
2619     Same as globalPos().x().
2620
2621     \sa x(), globalY(), globalPos()
2622 */
2623
2624 /*!
2625     \fn int QHelpEvent::globalY() const
2626
2627     Same as globalPos().y().
2628
2629     \sa y(), globalX(), globalPos()
2630 */
2631
2632 /*!
2633     \fn const QPoint &QHelpEvent::pos()  const
2634
2635     Returns the mouse cursor position when the event was generated,
2636     relative to the widget to which the event is dispatched.
2637
2638     \sa globalPos(), x(), y()
2639 */
2640
2641 /*!
2642     \fn const QPoint &QHelpEvent::globalPos() const
2643
2644     Returns the mouse cursor position when the event was generated
2645     in global coordinates.
2646
2647     \sa pos(), globalX(), globalY()
2648 */
2649
2650 /*! \internal
2651 */
2652 QHelpEvent::~QHelpEvent()
2653 {
2654 }
2655
2656 #ifndef QT_NO_STATUSTIP
2657
2658 /*!
2659     \class QStatusTipEvent
2660     \brief The QStatusTipEvent class provides an event that is used to show messages in a status bar.
2661
2662     \ingroup events
2663     \ingroup helpsystem
2664     \inmodule QtGui
2665
2666     Status tips can be set on a widget using the
2667     QWidget::setStatusTip() function.  They are shown in the status
2668     bar when the mouse cursor enters the widget. For example:
2669
2670     \table 100%
2671     \row
2672     \li
2673     \snippet qstatustipevent/main.cpp 1
2674     \dots
2675     \snippet qstatustipevent/main.cpp 3
2676     \li
2677     \image qstatustipevent-widget.png Widget with status tip.
2678     \endtable
2679
2680     Status tips can also be set on actions using the
2681     QAction::setStatusTip() function:
2682
2683     \table 100%
2684     \row
2685     \li
2686     \snippet qstatustipevent/main.cpp 0
2687     \snippet qstatustipevent/main.cpp 2
2688     \dots
2689     \snippet qstatustipevent/main.cpp 3
2690     \li
2691     \image qstatustipevent-action.png Action with status tip.
2692     \endtable
2693
2694     Finally, status tips are supported for the item view classes
2695     through the Qt::StatusTipRole enum value.
2696
2697     \sa QStatusBar, QHelpEvent, QWhatsThisClickedEvent
2698 */
2699
2700 /*!
2701     Constructs a status tip event with the text specified by \a tip.
2702
2703     \sa tip()
2704 */
2705 QStatusTipEvent::QStatusTipEvent(const QString &tip)
2706     : QEvent(StatusTip), s(tip)
2707 {}
2708
2709 /*! \internal
2710 */
2711 QStatusTipEvent::~QStatusTipEvent()
2712 {
2713 }
2714
2715 /*!
2716     \fn QString QStatusTipEvent::tip() const
2717
2718     Returns the message to show in the status bar.
2719
2720     \sa QStatusBar::showMessage()
2721 */
2722
2723 #endif // QT_NO_STATUSTIP
2724
2725 #ifndef QT_NO_WHATSTHIS
2726
2727 /*!
2728     \class QWhatsThisClickedEvent
2729     \brief The QWhatsThisClickedEvent class provides an event that
2730     can be used to handle hyperlinks in a "What's This?" text.
2731
2732     \ingroup events
2733     \ingroup helpsystem
2734     \inmodule QtGui
2735
2736     \sa QWhatsThis, QHelpEvent, QStatusTipEvent
2737 */
2738
2739 /*!
2740     Constructs an event containing a URL specified by \a href when a link
2741     is clicked in a "What's This?" message.
2742
2743     \sa href()
2744 */
2745 QWhatsThisClickedEvent::QWhatsThisClickedEvent(const QString &href)
2746     : QEvent(WhatsThisClicked), s(href)
2747 {}
2748
2749 /*! \internal
2750 */
2751 QWhatsThisClickedEvent::~QWhatsThisClickedEvent()
2752 {
2753 }
2754
2755 /*!
2756     \fn QString QWhatsThisClickedEvent::href() const
2757
2758     Returns the URL that was clicked by the user in the "What's
2759     This?" text.
2760 */
2761
2762 #endif // QT_NO_WHATSTHIS
2763
2764 #ifndef QT_NO_ACTION
2765
2766 /*!
2767     \class QActionEvent
2768     \brief The QActionEvent class provides an event that is generated
2769     when a QAction is added, removed, or changed.
2770
2771     \ingroup events
2772     \inmodule QtGui
2773
2774     Actions can be added to widgets using QWidget::addAction(). This
2775     generates an \l ActionAdded event, which you can handle to provide
2776     custom behavior. For example, QToolBar reimplements
2777     QWidget::actionEvent() to create \l{QToolButton}s for the
2778     actions.
2779
2780     \sa QAction, QWidget::addAction(), QWidget::removeAction(), QWidget::actions()
2781 */
2782
2783 /*!
2784     Constructs an action event. The \a type can be \l ActionChanged,
2785     \l ActionAdded, or \l ActionRemoved.
2786
2787     \a action is the action that is changed, added, or removed. If \a
2788     type is ActionAdded, the action is to be inserted before the
2789     action \a before. If \a before is 0, the action is appended.
2790 */
2791 QActionEvent::QActionEvent(int type, QAction *action, QAction *before)
2792     : QEvent(static_cast<QEvent::Type>(type)), act(action), bef(before)
2793 {}
2794
2795 /*! \internal
2796 */
2797 QActionEvent::~QActionEvent()
2798 {
2799 }
2800
2801 /*!
2802     \fn QAction *QActionEvent::action() const
2803
2804     Returns the action that is changed, added, or removed.
2805
2806     \sa before()
2807 */
2808
2809 /*!
2810     \fn QAction *QActionEvent::before() const
2811
2812     If type() is \l ActionAdded, returns the action that should
2813     appear before action(). If this function returns 0, the action
2814     should be appended to already existing actions on the same
2815     widget.
2816
2817     \sa action(), QWidget::actions()
2818 */
2819
2820 #endif // QT_NO_ACTION
2821
2822 /*!
2823     \class QHideEvent
2824     \brief The QHideEvent class provides an event which is sent after a widget is hidden.
2825
2826     \ingroup events
2827     \inmodule QtGui
2828
2829     This event is sent just before QWidget::hide() returns, and also
2830     when a top-level window has been hidden (iconified) by the user.
2831
2832     If spontaneous() is true, the event originated outside the
2833     application. In this case, the user hid the window using the
2834     window manager controls, either by iconifying the window or by
2835     switching to another virtual desktop where the window isn't
2836     visible. The window will become hidden but not withdrawn. If the
2837     window was iconified, QWidget::isMinimized() returns true.
2838
2839     \sa QShowEvent
2840 */
2841
2842 /*!
2843     Constructs a QHideEvent.
2844 */
2845 QHideEvent::QHideEvent()
2846     : QEvent(Hide)
2847 {}
2848
2849 /*! \internal
2850 */
2851 QHideEvent::~QHideEvent()
2852 {
2853 }
2854
2855 /*!
2856     \class QShowEvent
2857     \brief The QShowEvent class provides an event that is sent when a widget is shown.
2858
2859     \ingroup events
2860     \inmodule QtGui
2861
2862     There are two kinds of show events: show events caused by the
2863     window system (spontaneous), and internal show events. Spontaneous (QEvent::spontaneous())
2864     show events are sent just after the window system shows the
2865     window; they are also sent when a top-level window is redisplayed
2866     after being iconified. Internal show events are delivered just
2867     before the widget becomes visible.
2868
2869     \sa QHideEvent
2870 */
2871
2872 /*!
2873     Constructs a QShowEvent.
2874 */
2875 QShowEvent::QShowEvent()
2876     : QEvent(Show)
2877 {}
2878
2879 /*! \internal
2880 */
2881 QShowEvent::~QShowEvent()
2882 {
2883 }
2884
2885 /*!
2886     \class QFileOpenEvent
2887     \brief The QFileOpenEvent class provides an event that will be
2888     sent when there is a request to open a file or a URL.
2889
2890     \ingroup events
2891     \inmodule QtGui
2892
2893     File open events will be sent to the QApplication::instance()
2894     when the operating system requests that a file or URL should be opened.
2895     This is a high-level event that can be caused by different user actions
2896     depending on the user's desktop environment; for example, double
2897     clicking on an file icon in the Finder on Mac OS X.
2898
2899     This event is only used to notify the application of a request.
2900     It may be safely ignored.
2901
2902     \note This class is currently supported for Mac OS X only.
2903 */
2904
2905 /*!
2906     \internal
2907
2908     Constructs a file open event for the given \a file.
2909 */
2910 QFileOpenEvent::QFileOpenEvent(const QString &file)
2911     : QEvent(FileOpen), f(file), m_url(QUrl::fromLocalFile(file))
2912 {
2913 }
2914
2915 /*!
2916     \internal
2917
2918     Constructs a file open event for the given \a url.
2919 */
2920 QFileOpenEvent::QFileOpenEvent(const QUrl &url)
2921     : QEvent(FileOpen), f(url.toLocalFile()), m_url(url)
2922 {
2923 }
2924
2925
2926 /*! \internal
2927 */
2928 QFileOpenEvent::~QFileOpenEvent()
2929 {
2930 }
2931
2932 /*!
2933     \fn QString QFileOpenEvent::file() const
2934
2935     Returns the file that is being opened.
2936 */
2937
2938 /*!
2939     \fn QUrl QFileOpenEvent::url() const
2940
2941     Returns the url that is being opened.
2942
2943     \since 4.6
2944 */
2945
2946 /*!
2947     \fn bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
2948
2949     Opens a QFile on the \a file referenced by this event in the mode specified
2950     by \a flags. Returns true if successful; otherwise returns false.
2951
2952     This is necessary as some files cannot be opened by name, but require specific
2953     information stored in this event.
2954
2955     \since 4.8
2956 */
2957 bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
2958 {
2959     file.setFileName(f);
2960     return file.open(flags);
2961 }
2962
2963 #ifndef QT_NO_TOOLBAR
2964 /*!
2965     \internal
2966     \class QToolBarChangeEvent
2967     \brief The QToolBarChangeEvent class provides an event that is
2968     sent whenever a the toolbar button is clicked on Mac OS X.
2969
2970     \ingroup events
2971     \inmodule QtGui
2972
2973     The QToolBarChangeEvent is sent when the toolbar button is clicked. On Mac
2974     OS X, this is the long oblong button on the right side of the window
2975     title bar. The default implementation is to toggle the appearance (hidden or
2976     shown) of the associated toolbars for the window.
2977 */
2978
2979 /*!
2980     \internal
2981
2982     Construct a QToolBarChangeEvent given the current button state in \a state.
2983 */
2984 QToolBarChangeEvent::QToolBarChangeEvent(bool t)
2985     : QEvent(ToolBarChange), tog(t)
2986 {}
2987
2988 /*! \internal
2989 */
2990 QToolBarChangeEvent::~QToolBarChangeEvent()
2991 {
2992 }
2993
2994 /*!
2995     \fn bool QToolBarChangeEvent::toggle() const
2996     \internal
2997 */
2998
2999 /*
3000     \fn Qt::ButtonState QToolBarChangeEvent::state() const
3001
3002     Returns the keyboard modifier flags at the time of the event.
3003
3004     The returned value is a selection of the following values,
3005     combined using the OR operator:
3006     Qt::ShiftButton, Qt::ControlButton, Qt::MetaButton, and Qt::AltButton.
3007 */
3008
3009 #endif // QT_NO_TOOLBAR
3010
3011 #ifndef QT_NO_SHORTCUT
3012
3013 /*!
3014     Constructs a shortcut event for the given \a key press,
3015     associated with the QShortcut ID \a id.
3016
3017     \a ambiguous specifies whether there is more than one QShortcut
3018     for the same key sequence.
3019 */
3020 QShortcutEvent::QShortcutEvent(const QKeySequence &key, int id, bool ambiguous)
3021     : QEvent(Shortcut), sequence(key), ambig(ambiguous), sid(id)
3022 {
3023 }
3024
3025 /*!
3026     Destroys the event object.
3027 */
3028 QShortcutEvent::~QShortcutEvent()
3029 {
3030 }
3031
3032 #endif // QT_NO_SHORTCUT
3033
3034 #ifndef QT_NO_DEBUG_STREAM
3035 QDebug operator<<(QDebug dbg, const QEvent *e) {
3036     // More useful event output could be added here
3037     if (!e)
3038         return dbg << "QEvent(this = 0x0)";
3039     const char *n = 0;
3040     switch (e->type()) {
3041     case QEvent::Timer:
3042         n = "Timer";
3043         break;
3044     case QEvent::MouseButtonPress:
3045     case QEvent::MouseMove:
3046     case QEvent::MouseButtonRelease:
3047     case QEvent::MouseButtonDblClick:
3048     {
3049         const QMouseEvent *me = static_cast<const QMouseEvent*>(e);
3050         switch(me->type()) {
3051         case QEvent::MouseButtonPress:
3052             n = "MouseButtonPress";
3053             break;
3054         case QEvent::MouseMove:
3055             n = "MouseMove";
3056             break;
3057         case QEvent::MouseButtonRelease:
3058             n = "MouseButtonRelease";
3059             break;
3060         case QEvent::MouseButtonDblClick:
3061         default:
3062             n = "MouseButtonDblClick";
3063             break;
3064         }
3065         dbg.nospace() << "QMouseEvent("  << n
3066                       << ", " << me->button()
3067                       << ", " << hex << (int)me->buttons()
3068                       << ", " << hex << (int)me->modifiers()
3069                       << ')';
3070     }
3071     return dbg.space();
3072
3073 #ifndef QT_NO_TOOLTIP
3074     case QEvent::ToolTip:
3075         n = "ToolTip";
3076         break;
3077 #endif
3078     case QEvent::WindowActivate:
3079         n = "WindowActivate";
3080         break;
3081     case QEvent::WindowDeactivate:
3082         n = "WindowDeactivate";
3083         break;
3084     case QEvent::ActivationChange:
3085         n = "ActivationChange";
3086         break;
3087 #ifndef QT_NO_WHEELEVENT
3088     case QEvent::Wheel:
3089         dbg.nospace() << "QWheelEvent("
3090                       << static_cast<const QWheelEvent *>(e)->pixelDelta()
3091                       << static_cast<const QWheelEvent *>(e)->angleDelta()
3092                       << ')';
3093         return dbg.space();
3094 #endif
3095     case QEvent::KeyPress:
3096     case QEvent::KeyRelease:
3097     case QEvent::ShortcutOverride:
3098         {
3099             const QKeyEvent *ke = static_cast<const QKeyEvent*>(e);
3100             switch(ke->type()) {
3101             case QEvent::ShortcutOverride:
3102                 n = "ShortcutOverride";
3103                 break;
3104             case QEvent::KeyRelease:
3105                 n = "KeyRelease";
3106                 break;
3107             case QEvent::KeyPress:
3108             default:
3109                 n = "KeyPress";
3110                 break;
3111             }
3112             dbg.nospace() << "QKeyEvent("  << n
3113                           << ", " << hex << ke->key()
3114                           << ", " << hex << (int)ke->modifiers()
3115                           << ", \"" << ke->text()
3116                           << "\", " << ke->isAutoRepeat()
3117                           << ", " << ke->count()
3118                           << ')';
3119         }
3120         return dbg.space();
3121     case QEvent::FocusIn:
3122         n = "FocusIn";
3123         break;
3124     case QEvent::FocusOut:
3125         n = "FocusOut";
3126         break;
3127     case QEvent::Enter:
3128         n = "Enter";
3129         break;
3130     case QEvent::Leave:
3131         n = "Leave";
3132         break;
3133     case QEvent::PaletteChange:
3134         n = "PaletteChange";
3135         break;
3136     case QEvent::PolishRequest:
3137         n = "PolishRequest";
3138         break;
3139     case QEvent::Polish:
3140         n = "Polish";
3141         break;
3142     case QEvent::UpdateRequest:
3143         n = "UpdateRequest";
3144         break;
3145     case QEvent::Paint:
3146         n = "Paint";
3147         break;
3148     case QEvent::Move:
3149         n = "Move";
3150         break;
3151     case QEvent::Resize:
3152         n = "Resize";
3153         break;
3154     case QEvent::Create:
3155         n = "Create";
3156         break;
3157     case QEvent::Destroy:
3158         n = "Destroy";
3159         break;
3160     case QEvent::Close:
3161         n = "Close";
3162         break;
3163     case QEvent::Quit:
3164         n = "Quit";
3165         break;
3166     case QEvent::FileOpen:
3167         n = "FileOpen";
3168         break;
3169     case QEvent::Show:
3170         n = "Show";
3171         break;
3172     case QEvent::ShowToParent:
3173         n = "ShowToParent";
3174         break;
3175     case QEvent::Hide:
3176         n = "Hide";
3177         break;
3178     case QEvent::HideToParent:
3179         n = "HideToParent";
3180         break;
3181     case QEvent::None:
3182         n = "None";
3183         break;
3184     case QEvent::ParentChange:
3185         n = "ParentChange";
3186         break;
3187     case QEvent::ParentAboutToChange:
3188         n = "ParentAboutToChange";
3189         break;
3190     case QEvent::HoverEnter:
3191         n = "HoverEnter";
3192         break;
3193     case QEvent::HoverMove:
3194         n = "HoverMove";
3195         break;
3196     case QEvent::HoverLeave:
3197         n = "HoverLeave";
3198         break;
3199     case QEvent::ZOrderChange:
3200         n = "ZOrderChange";
3201         break;
3202     case QEvent::StyleChange:
3203         n = "StyleChange";
3204         break;
3205     case QEvent::DragEnter:
3206         n = "DragEnter";
3207         break;
3208     case QEvent::DragMove:
3209         n = "DragMove";
3210         break;
3211     case QEvent::DragLeave:
3212         n = "DragLeave";
3213         break;
3214     case QEvent::Drop:
3215         n = "Drop";
3216         break;
3217     case QEvent::GraphicsSceneMouseMove:
3218         n = "GraphicsSceneMouseMove";
3219         break;
3220     case QEvent::GraphicsSceneMousePress:
3221         n = "GraphicsSceneMousePress";
3222         break;
3223     case QEvent::GraphicsSceneMouseRelease:
3224         n = "GraphicsSceneMouseRelease";
3225         break;
3226     case QEvent::GraphicsSceneMouseDoubleClick:
3227         n = "GraphicsSceneMouseDoubleClick";
3228         break;
3229     case QEvent::GraphicsSceneContextMenu:
3230         n = "GraphicsSceneContextMenu";
3231         break;
3232     case QEvent::GraphicsSceneHoverEnter:
3233         n = "GraphicsSceneHoverEnter";
3234         break;
3235     case QEvent::GraphicsSceneHoverMove:
3236         n = "GraphicsSceneHoverMove";
3237         break;
3238     case QEvent::GraphicsSceneHoverLeave:
3239         n = "GraphicsSceneHoverLeave";
3240         break;
3241     case QEvent::GraphicsSceneHelp:
3242         n = "GraphicsSceneHelp";
3243         break;
3244     case QEvent::GraphicsSceneDragEnter:
3245         n = "GraphicsSceneDragEnter";
3246         break;
3247     case QEvent::GraphicsSceneDragMove:
3248         n = "GraphicsSceneDragMove";
3249         break;
3250     case QEvent::GraphicsSceneDragLeave:
3251         n = "GraphicsSceneDragLeave";
3252         break;
3253     case QEvent::GraphicsSceneDrop:
3254         n = "GraphicsSceneDrop";
3255         break;
3256     case QEvent::GraphicsSceneWheel:
3257         n = "GraphicsSceneWheel";
3258         break;
3259     case QEvent::GraphicsSceneResize:
3260         n = "GraphicsSceneResize";
3261         break;
3262     case QEvent::GraphicsSceneMove:
3263         n = "GraphicsSceneMove";
3264         break;
3265     case QEvent::CursorChange:
3266         n = "CursorChange";
3267         break;
3268     case QEvent::ToolTipChange:
3269         n = "ToolTipChange";
3270         break;
3271     case QEvent::StatusTip:
3272         n = "StatusTip";
3273         break;
3274     case QEvent::WhatsThis:
3275         n = "WhatsThis";
3276         break;
3277     case QEvent::FontChange:
3278         n = "FontChange";
3279         break;
3280     case QEvent::Style:
3281         n = "Style";
3282         break;
3283     case QEvent::KeyboardLayoutChange:
3284         n = "KeyboardLayoutChange";
3285         break;
3286     case QEvent::DynamicPropertyChange:
3287         n = "DynamicPropertyChange";
3288         break;
3289     case QEvent::GrabMouse:
3290         n = "GrabMouse";
3291         break;
3292     case QEvent::UngrabMouse:
3293         n = "UngrabMouse";
3294         break;
3295     case QEvent::GrabKeyboard:
3296         n = "GrabKeyboard";
3297         break;
3298     case QEvent::UngrabKeyboard:
3299         n = "UngrabKeyboard";
3300         break;
3301     case QEvent::ChildAdded: n = n ? n : "ChildAdded";
3302     case QEvent::ChildPolished: n = n ? n : "ChildPolished";
3303     case QEvent::ChildRemoved: n = n ? n : "ChildRemoved";
3304         dbg.nospace() << "QChildEvent(" << n << ", " << (static_cast<const QChildEvent*>(e))->child();
3305         return dbg.space();
3306 #ifndef QT_NO_GESTURES
3307     case QEvent::Gesture:
3308         n = "Gesture";
3309         break;
3310 #endif
3311     default:
3312         dbg.nospace() << "QEvent(" << (const void *)e << ", type = " << e->type() << ')';
3313         return dbg.space();
3314     }
3315
3316     dbg.nospace() << 'Q' << n << "Event(" << (const void *)e << ')';
3317     return dbg.space();
3318 }
3319 #endif
3320
3321 /*!
3322     \class QShortcutEvent
3323     \brief The QShortcutEvent class provides an event which is generated when
3324     the user presses a key combination.
3325
3326     \ingroup events
3327     \inmodule QtGui
3328
3329     Normally you don't need to use this class directly; QShortcut
3330     provides a higher-level interface to handle shortcut keys.
3331
3332     \sa QShortcut
3333 */
3334
3335 /*!
3336     \fn const QKeySequence &QShortcutEvent::key() const
3337
3338     Returns the key sequence that triggered the event.
3339 */
3340
3341 /*!
3342     \fn int QShortcutEvent::shortcutId() const
3343
3344     Returns the ID of the QShortcut object for which this event was
3345     generated.
3346
3347     \sa QShortcut::id()
3348 */
3349
3350 /*!
3351     \fn bool QShortcutEvent::isAmbiguous() const
3352
3353     Returns true if the key sequence that triggered the event is
3354     ambiguous.
3355
3356     \sa QShortcut::activatedAmbiguously()
3357 */
3358
3359 /*!
3360     \class QWindowStateChangeEvent
3361     \ingroup events
3362     \inmodule QtGui
3363
3364     \brief The QWindowStateChangeEvent class provides the window state before a
3365     window state change.
3366 */
3367
3368 /*! \fn Qt::WindowStates QWindowStateChangeEvent::oldState() const
3369
3370     Returns the state of the window before the change.
3371 */
3372
3373 /*! \internal
3374  */
3375 QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates s, bool isOverride)
3376     : QEvent(WindowStateChange), ostate(s), m_override(isOverride)
3377 {
3378 }
3379
3380 /*! \internal
3381  */
3382 bool QWindowStateChangeEvent::isOverride() const
3383 {
3384     return m_override;
3385 }
3386
3387 /*! \internal
3388 */
3389 QWindowStateChangeEvent::~QWindowStateChangeEvent()
3390 {
3391 }
3392
3393
3394 /*!
3395     \class QTouchEvent
3396     \brief The QTouchEvent class contains parameters that describe a touch event.
3397     \since 4.6
3398     \ingroup events
3399     \ingroup touch
3400     \inmodule QtGui
3401
3402     \section1 Enabling Touch Events
3403
3404     Touch events occur when pressing, releasing, or moving one or more touch points on a touch
3405     device (such as a touch-screen or track-pad). To receive touch events, widgets have to have the
3406     Qt::WA_AcceptTouchEvents attribute set and graphics items need to have the
3407     \l{QGraphicsItem::setAcceptTouchEvents()}{acceptTouchEvents} attribute set to true.
3408
3409     When using QAbstractScrollArea based widgets, you should enable the Qt::WA_AcceptTouchEvents
3410     attribute on the scroll area's \l{QAbstractScrollArea::viewport()}{viewport}.
3411
3412     Similarly to QMouseEvent, Qt automatically grabs each touch point on the first press inside a
3413     widget, and the widget will receive all updates for the touch point until it is released.
3414     Note that it is possible for a widget to receive events for numerous touch points, and that
3415     multiple widgets may be receiving touch events at the same time.
3416
3417     \section1 Event Handling
3418
3419     All touch events are of type QEvent::TouchBegin, QEvent::TouchUpdate, QEvent::TouchEnd or
3420     QEvent::TouchCancel. Reimplement QWidget::event() or QAbstractScrollArea::viewportEvent() for
3421     widgets and QGraphicsItem::sceneEvent() for items in a graphics view to receive touch events.
3422
3423     Unlike widgets, QWindows receive touch events always, there is no need to opt in. When working
3424     directly with a QWindow, it is enough to reimplement QWindow::touchEvent().
3425
3426     The QEvent::TouchUpdate and QEvent::TouchEnd events are sent to the widget or item that
3427     accepted the QEvent::TouchBegin event. If the QEvent::TouchBegin event is not accepted and not
3428     filtered by an event filter, then no further touch events are sent until the next
3429     QEvent::TouchBegin.
3430
3431     Some systems may send an event of type QEvent::TouchCancel. Upon receiving this event
3432     applications are requested to ignore the entire active touch sequence. For example in a
3433     composited system the compositor may decide to treat certain gestures as system-wide
3434     gestures. Whenever such a decision is made (the gesture is recognized), the clients will be
3435     notified with a QEvent::TouchCancel event so they can update their state accordingly.
3436
3437     The touchPoints() function returns a list of all touch points contained in the event. Note that
3438     this list may be empty, for example in case of a QEvent::TouchCancel event. Information about
3439     each touch point can be retrieved using the QTouchEvent::TouchPoint class. The
3440     Qt::TouchPointState enum describes the different states that a touch point may have.
3441
3442     \note The list of touchPoints() will never be partial: A touch event will always contain a touch
3443     point for each existing physical touch contacts targetting the window or widget to which the
3444     event is sent. For instance, assuming that all touches target the same window or widget, an
3445     event with a condition of touchPoints().count()==2 is guaranteed to imply that the number of
3446     fingers touching the touchscreen or touchpad is exactly two.
3447
3448     \section1 Event Delivery and Propagation
3449
3450     By default, QGuiApplication translates the first touch point in a QTouchEvent into
3451     a QMouseEvent. This makes it possible to enable touch events on existing widgets that do not
3452     normally handle QTouchEvent. See below for information on some special considerations needed
3453     when doing this.
3454
3455     QEvent::TouchBegin is the first touch event sent to a widget. The QEvent::TouchBegin event
3456     contains a special accept flag that indicates whether the receiver wants the event. By default,
3457     the event is accepted. You should call ignore() if the touch event is not handled by your
3458     widget. The QEvent::TouchBegin event is propagated up the parent widget chain until a widget
3459     accepts it with accept(), or an event filter consumes it. For QGraphicsItems, the
3460     QEvent::TouchBegin event is propagated to items under the mouse (similar to mouse event
3461     propagation for QGraphicsItems).
3462
3463     \section1 Touch Point Grouping
3464
3465     As mentioned above, it is possible that several widgets can be receiving QTouchEvents at the
3466     same time. However, Qt makes sure to never send duplicate QEvent::TouchBegin events to the same
3467     widget, which could theoretically happen during propagation if, for example, the user touched 2
3468     separate widgets in a QGroupBox and both widgets ignored the QEvent::TouchBegin event.
3469
3470     To avoid this, Qt will group new touch points together using the following rules:
3471
3472     \list
3473
3474     \li When the first touch point is detected, the destination widget is determined firstly by the
3475     location on screen and secondly by the propagation rules.
3476
3477     \li When additional touch points are detected, Qt first looks to see if there are any active
3478     touch points on any ancestor or descendent of the widget under the new touch point. If there
3479     are, the new touch point is grouped with the first, and the new touch point will be sent in a
3480     single QTouchEvent to the widget that handled the first touch point. (The widget under the new
3481     touch point will not receive an event).
3482
3483     \endlist
3484
3485     This makes it possible for sibling widgets to handle touch events independently while making
3486     sure that the sequence of QTouchEvents is always correct.
3487
3488     \section1 Mouse Events and Touch Event synthesizing
3489
3490     QTouchEvent delivery is independent from that of QMouseEvent. The application flags
3491     Qt::AA_SynthesizeTouchForUnhandledMouseEvents and Qt::AA_SynthesizeMouseForUnhandledTouchEvents
3492     can be used to enable or disable automatic synthesizing of touch events to mouse events and
3493     mouse events to touch events.
3494
3495     \section1 Caveats
3496
3497     \list
3498
3499     \li As mentioned above, enabling touch events means multiple widgets can be receiving touch
3500     events simultaneously. Combined with the default QWidget::event() handling for QTouchEvents,
3501     this gives you great flexibility in designing touch user interfaces. Be aware of the
3502     implications. For example, it is possible that the user is moving a QSlider with one finger and
3503     pressing a QPushButton with another. The signals emitted by these widgets will be
3504     interleaved.
3505
3506     \li Recursion into the event loop using one of the exec() methods (e.g., QDialog::exec() or
3507     QMenu::exec()) in a QTouchEvent event handler is not supported. Since there are multiple event
3508     recipients, recursion may cause problems, including but not limited to lost events
3509     and unexpected infinite recursion.
3510
3511     \li QTouchEvents are not affected by a \l{QWidget::grabMouse()}{mouse grab} or an
3512     \l{QApplication::activePopupWidget()}{active pop-up widget}. The behavior of QTouchEvents is
3513     undefined when opening a pop-up or grabbing the mouse while there are more than one active touch
3514     points.
3515
3516     \endlist
3517
3518     \sa QTouchEvent::TouchPoint, Qt::TouchPointState, Qt::WA_AcceptTouchEvents,
3519     QGraphicsItem::acceptTouchEvents()
3520 */
3521
3522 /*! \enum QTouchEvent::DeviceType
3523     \obsolete
3524
3525     This enum represents the type of device that generated a QTouchEvent.
3526
3527     This enum has been deprecated. Use QTouchDevice::DeviceType instead.
3528     \omitvalue TouchPad
3529     \omitvalue TouchScreen
3530
3531     \sa QTouchDevice::DeviceType, QTouchDevice::type(), QTouchEvent::device()
3532 */
3533
3534 /*!
3535     Constructs a QTouchEvent with the given \a eventType, \a device, and
3536     \a touchPoints. The \a touchPointStates and \a modifiers
3537     are the current touch point states and keyboard modifiers at the time of
3538     the event.
3539 */
3540 QTouchEvent::QTouchEvent(QEvent::Type eventType,
3541                          QTouchDevice *device,
3542                          Qt::KeyboardModifiers modifiers,
3543                          Qt::TouchPointStates touchPointStates,
3544                          const QList<QTouchEvent::TouchPoint> &touchPoints)
3545     : QInputEvent(eventType, modifiers),
3546       _window(0),
3547       _target(0),
3548       _device(device),
3549       _touchPointStates(touchPointStates),
3550       _touchPoints(touchPoints)
3551 { }
3552
3553 /*!
3554     Destroys the QTouchEvent.
3555 */
3556 QTouchEvent::~QTouchEvent()
3557 { }
3558
3559 /*! \fn QWindow *QTouchEvent::window() const
3560
3561     Returns the window on which the event occurred. Useful for doing
3562     global-local mapping on data like rawScreenPositions() which,
3563     for performance reasons, only stores the global positions in the
3564     touch event.
3565 */
3566
3567 /*! \fn QObject *QTouchEvent::target() const
3568
3569     Returns the target object within the window on which the event occurred.
3570     This is typically a QWidget or a QQuickItem. May be 0 when no specific target is available.
3571 */
3572
3573 /*! \fn QTouchEvent::DeviceType QTouchEvent::deviceType() const
3574     \obsolete
3575
3576     Returns the touch device Type, which is of type \l {QTouchEvent::DeviceType} {DeviceType}.
3577
3578     This function has been deprecated. Use QTouchDevice::type() instead.
3579
3580     \sa QTouchDevice::type(), QTouchEvent::device()
3581 */
3582
3583 /*! \fn Qt::TouchPointStates QTouchEvent::touchPointStates() const
3584
3585     Returns a bitwise OR of all the touch point states for this event.
3586 */
3587
3588 /*! \fn const QList<QTouchEvent::TouchPoint> &QTouchEvent::touchPoints() const
3589
3590     Returns the list of touch points contained in the touch event.
3591 */
3592
3593 /*! \fn QTouchDevice* QTouchEvent::device() const
3594
3595     Returns the touch device from which this touch event originates.
3596 */
3597
3598 /*! \fn void QTouchEvent::setWindow(QWindow *window)
3599
3600     \internal
3601
3602     Sets the window for this event.
3603 */
3604
3605 /*! \fn void QTouchEvent::setTarget(QObject *target)
3606
3607     \internal
3608
3609     Sets the target within the window (typically a widget) for this event.
3610 */
3611
3612 /*! \fn void QTouchEvent::setTouchPointStates(Qt::TouchPointStates touchPointStates)
3613
3614     \internal
3615
3616     Sets a bitwise OR of all the touch point states for this event.
3617 */
3618
3619 /*! \fn void QTouchEvent::setTouchPoints(const QList<QTouchEvent::TouchPoint> &touchPoints)
3620
3621     \internal
3622
3623     Sets the list of touch points for this event.
3624 */
3625
3626 /*! \fn void QTouchEvent::setDevice(QTouchDevice *adevice)
3627
3628     \internal
3629
3630     Sets the device to \a adevice.
3631 */
3632
3633 /*! \class QTouchEvent::TouchPoint
3634     \brief The TouchPoint class provides information about a touch point in a QTouchEvent.
3635     \since 4.6
3636     \inmodule QtGui
3637 */
3638
3639 /*! \enum TouchPoint::InfoFlag
3640
3641     The values of this enum describe additional information about a touch point.
3642
3643     \value Pen Indicates that the contact has been made by a designated pointing device (e.g. a pen) instead of a finger.
3644 */
3645
3646 /*!
3647     \internal
3648
3649     Constructs a QTouchEvent::TouchPoint for use in a QTouchEvent.
3650 */
3651 QTouchEvent::TouchPoint::TouchPoint(int id)
3652     : d(new QTouchEventTouchPointPrivate(id))
3653 { }
3654
3655 /*!
3656     \fn TouchPoint::TouchPoint(const TouchPoint &other)
3657     \internal
3658
3659     Constructs a copy of \a other.
3660 */
3661 QTouchEvent::TouchPoint::TouchPoint(const QTouchEvent::TouchPoint &other)
3662     : d(other.d)
3663 {
3664     d->ref.ref();
3665 }
3666
3667 /*!
3668     \internal
3669
3670     Destroys the QTouchEvent::TouchPoint.
3671 */
3672 QTouchEvent::TouchPoint::~TouchPoint()
3673 {
3674     if (d && !d->ref.deref())
3675         delete d;
3676 }
3677
3678 /*!
3679     Returns the id number of this touch point.
3680
3681     Do not assume that id numbers start at zero or that they are sequential.
3682     Such an assumption is often false due to the way the underlying drivers work.
3683 */
3684 int QTouchEvent::TouchPoint::id() const
3685 {
3686     return d->id;
3687 }
3688
3689 /*!
3690     Returns the current state of this touch point.
3691 */
3692 Qt::TouchPointState QTouchEvent::TouchPoint::state() const
3693 {
3694     return Qt::TouchPointState(int(d->state));
3695 }
3696
3697 /*!
3698     Returns the position of this touch point, relative to the widget
3699     or QGraphicsItem that received the event.
3700
3701     \sa startPos(), lastPos(), screenPos(), scenePos(), normalizedPos()
3702 */
3703 QPointF QTouchEvent::TouchPoint::pos() const
3704 {
3705     return d->rect.center();
3706 }
3707
3708 /*!
3709     Returns the scene position of this touch point.
3710
3711     The scene position is the position in QGraphicsScene coordinates
3712     if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
3713     reimplementation, and identical to the screen position for
3714     widgets.
3715
3716     \sa startScenePos(), lastScenePos(), pos()
3717 */
3718 QPointF QTouchEvent::TouchPoint::scenePos() const
3719 {
3720     return d->sceneRect.center();
3721 }
3722
3723 /*!
3724     Returns the screen position of this touch point.
3725
3726     \sa startScreenPos(), lastScreenPos(), pos()
3727 */
3728 QPointF QTouchEvent::TouchPoint::screenPos() const
3729 {
3730     return d->screenRect.center();
3731 }
3732
3733 /*!
3734     Returns the normalized position of this touch point.
3735
3736     The coordinates are normalized to the size of the touch device,
3737     i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
3738
3739     \sa startNormalizedPos(), lastNormalizedPos(), pos()
3740 */
3741 QPointF QTouchEvent::TouchPoint::normalizedPos() const
3742 {
3743     return d->normalizedPos;
3744 }
3745
3746 /*!
3747     Returns the starting position of this touch point, relative to the
3748     widget or QGraphicsItem that received the event.
3749
3750     \sa pos(), lastPos()
3751 */
3752 QPointF QTouchEvent::TouchPoint::startPos() const
3753 {
3754     return d->startPos;
3755 }
3756
3757 /*!
3758     Returns the starting scene position of this touch point.
3759
3760     The scene position is the position in QGraphicsScene coordinates
3761     if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
3762     reimplementation, and identical to the screen position for
3763     widgets.
3764
3765     \sa scenePos(), lastScenePos()
3766 */
3767 QPointF QTouchEvent::TouchPoint::startScenePos() const
3768 {
3769     return d->startScenePos;
3770 }
3771
3772 /*!
3773     Returns the starting screen position of this touch point.
3774
3775     \sa screenPos(), lastScreenPos()
3776 */
3777 QPointF QTouchEvent::TouchPoint::startScreenPos() const
3778 {
3779     return d->startScreenPos;
3780 }
3781
3782 /*!
3783     Returns the normalized starting position of this touch point.
3784
3785     The coordinates are normalized to the size of the touch device,
3786     i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
3787
3788     \sa normalizedPos(), lastNormalizedPos()
3789 */
3790 QPointF QTouchEvent::TouchPoint::startNormalizedPos() const
3791 {
3792     return d->startNormalizedPos;
3793 }
3794
3795 /*!
3796     Returns the position of this touch point from the previous touch
3797     event, relative to the widget or QGraphicsItem that received the event.
3798
3799     \sa pos(), startPos()
3800 */
3801 QPointF QTouchEvent::TouchPoint::lastPos() const
3802 {
3803     return d->lastPos;
3804 }
3805
3806 /*!
3807     Returns the scene position of this touch point from the previous
3808     touch event.
3809
3810     The scene position is the position in QGraphicsScene coordinates
3811     if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
3812     reimplementation, and identical to the screen position for
3813     widgets.
3814
3815     \sa scenePos(), startScenePos()
3816 */
3817 QPointF QTouchEvent::TouchPoint::lastScenePos() const
3818 {
3819     return d->lastScenePos;
3820 }
3821
3822 /*!
3823     Returns the screen position of this touch point from the previous
3824     touch event.
3825
3826     \sa screenPos(), startScreenPos()
3827 */
3828 QPointF QTouchEvent::TouchPoint::lastScreenPos() const
3829 {
3830     return d->lastScreenPos;
3831 }
3832
3833 /*!
3834     Returns the normalized position of this touch point from the
3835     previous touch event.
3836
3837     The coordinates are normalized to the size of the touch device,
3838     i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
3839
3840     \sa normalizedPos(), startNormalizedPos()
3841 */
3842 QPointF QTouchEvent::TouchPoint::lastNormalizedPos() const
3843 {
3844     return d->lastNormalizedPos;
3845 }
3846
3847 /*!
3848     Returns the rect for this touch point, relative to the widget
3849     or QGraphicsItem that received the event. The rect is centered
3850     around the point returned by pos().
3851
3852     \note This function returns an empty rect if the device does not report touch point sizes.
3853 */
3854 QRectF QTouchEvent::TouchPoint::rect() const
3855 {
3856     return d->rect;
3857 }
3858
3859 /*!
3860     Returns the rect for this touch point in scene coordinates.
3861
3862     \note This function returns an empty rect if the device does not report touch point sizes.
3863
3864     \sa scenePos(), rect()
3865 */
3866 QRectF QTouchEvent::TouchPoint::sceneRect() const
3867 {
3868     return d->sceneRect;
3869 }
3870
3871 /*!
3872     Returns the rect for this touch point in screen coordinates.
3873
3874     \note This function returns an empty rect if the device does not report touch point sizes.
3875
3876     \sa screenPos(), rect()
3877 */
3878 QRectF QTouchEvent::TouchPoint::screenRect() const
3879 {
3880     return d->screenRect;
3881 }
3882
3883 /*!
3884     Returns the pressure of this touch point. The return value is in
3885     the range 0.0 to 1.0.
3886 */
3887 qreal QTouchEvent::TouchPoint::pressure() const
3888 {
3889     return d->pressure;
3890 }
3891
3892 /*!
3893     Returns a velocity vector for this touch point.
3894     The vector is in the screen's coordinate system, using pixels per seconds for the magnitude.
3895
3896     \note The returned vector is only valid if the touch device's capabilities include QTouchDevice::Velocity.
3897
3898     \sa QTouchDevice::capabilities(), device()
3899 */
3900 QVector2D QTouchEvent::TouchPoint::velocity() const
3901 {
3902     return d->velocity;
3903 }
3904
3905 /*!
3906   Returns additional information about the touch point.
3907
3908   \sa QTouchEvent::TouchPoint::InfoFlags
3909   */
3910 QTouchEvent::TouchPoint::InfoFlags QTouchEvent::TouchPoint::flags() const
3911 {
3912     return d->flags;
3913 }
3914
3915 /*!
3916   \since 5.0
3917   Returns the raw, unfiltered positions for the touch point. The positions are in native screen coordinates.
3918   To get local coordinates you can use mapFromGlobal() of the QWindow returned by QTouchEvent::window().
3919
3920   \note Returns an empty vector if the touch device's capabilities do not include QTouchDevice::RawPositions.
3921
3922   \note Native screen coordinates refer to the native orientation of the screen which, in case of
3923   mobile devices, is typically portrait. This means that on systems capable of screen orientation
3924   changes the positions in this list will not reflect the current orientation (unlike pos(),
3925   screenPos(), etc.) and will always be reported in the native orientation.
3926
3927   \sa QTouchDevice::capabilities(), device(), window()
3928   */
3929 QVector<QPointF> QTouchEvent::TouchPoint::rawScreenPositions() const
3930 {
3931     return d->rawScreenPositions;
3932 }
3933
3934 /*! \internal */
3935 void QTouchEvent::TouchPoint::setId(int id)
3936 {
3937     if (d->ref.load() != 1)
3938         d = d->detach();
3939     d->id = id;
3940 }
3941
3942 /*! \internal */
3943 void QTouchEvent::TouchPoint::setState(Qt::TouchPointStates state)
3944 {
3945     if (d->ref.load() != 1)
3946         d = d->detach();
3947     d->state = state;
3948 }
3949
3950 /*! \internal */
3951 void QTouchEvent::TouchPoint::setPos(const QPointF &pos)
3952 {
3953     if (d->ref.load() != 1)
3954         d = d->detach();
3955     d->rect.moveCenter(pos);
3956 }
3957
3958 /*! \internal */
3959 void QTouchEvent::TouchPoint::setScenePos(const QPointF &scenePos)
3960 {
3961     if (d->ref.load() != 1)
3962         d = d->detach();
3963     d->sceneRect.moveCenter(scenePos);
3964 }
3965
3966 /*! \internal */
3967 void QTouchEvent::TouchPoint::setScreenPos(const QPointF &screenPos)
3968 {
3969     if (d->ref.load() != 1)
3970         d = d->detach();
3971     d->screenRect.moveCenter(screenPos);
3972 }
3973
3974 /*! \internal */
3975 void QTouchEvent::TouchPoint::setNormalizedPos(const QPointF &normalizedPos)
3976 {
3977     if (d->ref.load() != 1)
3978         d = d->detach();
3979     d->normalizedPos = normalizedPos;
3980 }
3981
3982 /*! \internal */
3983 void QTouchEvent::TouchPoint::setStartPos(const QPointF &startPos)
3984 {
3985     if (d->ref.load() != 1)
3986         d = d->detach();
3987     d->startPos = startPos;
3988 }
3989
3990 /*! \internal */
3991 void QTouchEvent::TouchPoint::setStartScenePos(const QPointF &startScenePos)
3992 {
3993     if (d->ref.load() != 1)
3994         d = d->detach();
3995     d->startScenePos = startScenePos;
3996 }
3997
3998 /*! \internal */
3999 void QTouchEvent::TouchPoint::setStartScreenPos(const QPointF &startScreenPos)
4000 {
4001     if (d->ref.load() != 1)
4002         d = d->detach();
4003     d->startScreenPos = startScreenPos;
4004 }
4005
4006 /*! \internal */
4007 void QTouchEvent::TouchPoint::setStartNormalizedPos(const QPointF &startNormalizedPos)
4008 {
4009     if (d->ref.load() != 1)
4010         d = d->detach();
4011     d->startNormalizedPos = startNormalizedPos;
4012 }
4013
4014 /*! \internal */
4015 void QTouchEvent::TouchPoint::setLastPos(const QPointF &lastPos)
4016 {
4017     if (d->ref.load() != 1)
4018         d = d->detach();
4019     d->lastPos = lastPos;
4020 }
4021
4022 /*! \internal */
4023 void QTouchEvent::TouchPoint::setLastScenePos(const QPointF &lastScenePos)
4024 {
4025     if (d->ref.load() != 1)
4026         d = d->detach();
4027     d->lastScenePos = lastScenePos;
4028 }
4029
4030 /*! \internal */
4031 void QTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastScreenPos)
4032 {
4033     if (d->ref.load() != 1)
4034         d = d->detach();
4035     d->lastScreenPos = lastScreenPos;
4036 }
4037
4038 /*! \internal */
4039 void QTouchEvent::TouchPoint::setLastNormalizedPos(const QPointF &lastNormalizedPos)
4040 {
4041     if (d->ref.load() != 1)
4042         d = d->detach();
4043     d->lastNormalizedPos = lastNormalizedPos;
4044 }
4045
4046 /*! \internal */
4047 void QTouchEvent::TouchPoint::setRect(const QRectF &rect)
4048 {
4049     if (d->ref.load() != 1)
4050         d = d->detach();
4051     d->rect = rect;
4052 }
4053
4054 /*! \internal */
4055 void QTouchEvent::TouchPoint::setSceneRect(const QRectF &sceneRect)
4056 {
4057     if (d->ref.load() != 1)
4058         d = d->detach();
4059     d->sceneRect = sceneRect;
4060 }
4061
4062 /*! \internal */
4063 void QTouchEvent::TouchPoint::setScreenRect(const QRectF &screenRect)
4064 {
4065     if (d->ref.load() != 1)
4066         d = d->detach();
4067     d->screenRect = screenRect;
4068 }
4069
4070 /*! \internal */
4071 void QTouchEvent::TouchPoint::setPressure(qreal pressure)
4072 {
4073     if (d->ref.load() != 1)
4074         d = d->detach();
4075     d->pressure = pressure;
4076 }
4077
4078 /*! \internal */
4079 void QTouchEvent::TouchPoint::setVelocity(const QVector2D &v)
4080 {
4081     if (d->ref.load() != 1)
4082         d = d->detach();
4083     d->velocity = v;
4084 }
4085
4086 /*! \internal */
4087 void QTouchEvent::TouchPoint::setRawScreenPositions(const QVector<QPointF> &positions)
4088 {
4089     if (d->ref.load() != 1)
4090         d = d->detach();
4091     d->rawScreenPositions = positions;
4092 }
4093
4094 /*!
4095     \internal
4096 */
4097 void QTouchEvent::TouchPoint::setFlags(InfoFlags flags)
4098 {
4099     if (d->ref.load() != 1)
4100         d = d->detach();
4101     d->flags = flags;
4102 }
4103
4104 /*!
4105     \fn TouchPoint &TouchPoint::operator=(const TouchPoint &other)
4106     \internal
4107  */
4108
4109 /*!
4110     \fn void QTouchEvent::TouchPoint::swap(TouchPoint &other);
4111     \internal
4112 */
4113
4114 /*!
4115     \class QScrollPrepareEvent
4116     \since 4.8
4117     \ingroup events
4118     \inmodule QtGui
4119
4120     \brief The QScrollPrepareEvent class is send in preparation of a scrolling.
4121
4122     The scroll prepare event is send before scrolling (usually by QScroller) is started.
4123     The object receiving this event should set viewportSize, maxContentPos and contentPos.
4124     It also should accept this event to indicate that scrolling should be started.
4125
4126     It is not guaranteed that a QScrollEvent will be send after an acceepted
4127     QScrollPrepareEvent, e.g. in a case where the maximum content position is (0,0).
4128
4129     \sa QScrollEvent, QScroller
4130 */
4131
4132 /*!
4133     Creates new QScrollPrepareEvent
4134     The \a startPos is the position of a touch or mouse event that started the scrolling.
4135 */
4136 QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos)
4137     : QEvent(QEvent::ScrollPrepare), m_target(0), m_startPos(startPos)
4138 {
4139 }
4140
4141 /*!
4142     Destroys QScrollEvent.
4143 */
4144 QScrollPrepareEvent::~QScrollPrepareEvent()
4145 {
4146 }
4147
4148 /*!
4149     Returns the position of the touch or mouse event that started the scrolling.
4150 */
4151 QPointF QScrollPrepareEvent::startPos() const
4152 {
4153     return m_startPos;
4154 }
4155
4156 /*!
4157     Returns size of the area that is to be scrolled as set by setViewportSize
4158
4159     \sa setViewportSize()
4160 */
4161 QSizeF QScrollPrepareEvent::viewportSize() const
4162 {
4163     return m_viewportSize;
4164 }
4165
4166 /*!
4167     Returns the range of coordinates for the content as set by setContentPosRange().
4168 */
4169 QRectF QScrollPrepareEvent::contentPosRange() const
4170 {
4171     return m_contentPosRange;
4172 }
4173
4174 /*!
4175     Returns the current position of the content as set by setContentPos.
4176 */
4177 QPointF QScrollPrepareEvent::contentPos() const
4178 {
4179     return m_contentPos;
4180 }
4181
4182
4183 /*!
4184     Sets the size of the area that is to be scrolled to \a size.
4185
4186     \sa viewportSize()
4187 */
4188 void QScrollPrepareEvent::setViewportSize(const QSizeF &size)
4189 {
4190     m_viewportSize = size;
4191 }
4192
4193 /*!
4194     Sets the range of content coordinates to \a rect.
4195
4196     \sa contentPosRange()
4197 */
4198 void QScrollPrepareEvent::setContentPosRange(const QRectF &rect)
4199 {
4200     m_contentPosRange = rect;
4201 }
4202
4203 /*!
4204     Sets the current content position to \a pos.
4205
4206     \sa contentPos()
4207 */
4208 void QScrollPrepareEvent::setContentPos(const QPointF &pos)
4209 {
4210     m_contentPos = pos;
4211 }
4212
4213
4214 /*!
4215     \class QScrollEvent
4216     \since 4.8
4217     \ingroup events
4218     \inmodule QtGui
4219
4220     \brief The QScrollEvent class is send when scrolling.
4221
4222     The scroll event is send to indicate that the receiver should be scrolled.
4223     Usually the receiver should be something visual like QWidget or QGraphicsObject.
4224
4225     Some care should be taken that no conflicting QScrollEvents are sent from two
4226     sources. Using QScroller::scrollTo is save however.
4227
4228     \sa QScrollPrepareEvent, QScroller
4229 */
4230
4231 /*!
4232     \enum QScrollEvent::ScrollState
4233
4234     This enum describes the states a scroll event can have.
4235
4236     \value ScrollStarted Set for the first scroll event of a scroll activity.
4237
4238     \value ScrollUpdated Set for all but the first and the last scroll event of a scroll activity.
4239
4240     \value ScrollFinished Set for the last scroll event of a scroll activity.
4241
4242     \sa QScrollEvent::scrollState()
4243 */
4244
4245 /*!
4246     Creates a new QScrollEvent
4247     \a contentPos is the new content position, \a overshootDistance is the
4248     new overshoot distance while \a scrollState indicates if this scroll
4249     event is the first one, the last one or some event in between.
4250 */
4251 QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, ScrollState scrollState)
4252     : QEvent(QEvent::Scroll), m_contentPos(contentPos), m_overshoot(overshootDistance), m_state(scrollState)
4253 {
4254 }
4255
4256 /*!
4257     Destroys QScrollEvent.
4258 */
4259 QScrollEvent::~QScrollEvent()
4260 {
4261 }
4262
4263 /*!
4264     Returns the new scroll position.
4265 */
4266 QPointF QScrollEvent::contentPos() const
4267 {
4268     return m_contentPos;
4269 }
4270
4271 /*!
4272     Returns the new overshoot distance.
4273     See QScroller for an explanation of the term overshoot.
4274
4275     \sa QScroller
4276 */
4277 QPointF QScrollEvent::overshootDistance() const
4278 {
4279     return m_overshoot;
4280 }
4281
4282 /*!
4283     Returns the current scroll state as a combination of ScrollStateFlag values.
4284     ScrollStarted (or ScrollFinished) will be set, if this scroll event is the first (or last) event in a scrolling activity.
4285     Please note that both values can be set at the same time, if the activity consists of a single QScrollEvent.
4286     All other scroll events in between will have their state set to ScrollUpdated.
4287
4288     A widget could for example revert selections when scrolling is started and stopped.
4289 */
4290 QScrollEvent::ScrollState QScrollEvent::scrollState() const
4291 {
4292     return m_state;
4293 }
4294
4295 /*!
4296     Creates a new QScreenOrientationChangeEvent
4297     \a orientation is the new orientation of the screen.
4298 */
4299 QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation screenOrientation)
4300     : QEvent(QEvent::OrientationChange), m_screen(screen), m_orientation(screenOrientation)
4301 {
4302 }
4303
4304 /*!
4305     Destroys QScreenOrientationChangeEvent.
4306 */
4307 QScreenOrientationChangeEvent::~QScreenOrientationChangeEvent()
4308 {
4309 }
4310
4311 /*!
4312     Returns the screen whose orientation changed.
4313 */
4314 QScreen *QScreenOrientationChangeEvent::screen() const
4315 {
4316     return m_screen;
4317 }
4318
4319 /*!
4320     Returns the orientation of the screen.
4321 */
4322 Qt::ScreenOrientation QScreenOrientationChangeEvent::orientation() const
4323 {
4324     return m_orientation;
4325 }
4326
4327 QT_END_NAMESPACE