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