~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/kernel/qevent.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

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