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