1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtCore module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QCOREEVENT_H
41#define QCOREEVENT_H
42
43#include <QtCore/qnamespace.h>
44#include <QtCore/qbytearray.h>
45#include <QtCore/qobjectdefs.h>
46
47QT_BEGIN_NAMESPACE
48
49
50class QEventPrivate;
51class Q_CORE_EXPORT QEvent // event base class
52{
53 Q_GADGET
54 QDOC_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
55public:
56 enum Type {
57 /*
58 If you get a strange compiler error on the line with None,
59 it's probably because you're also including X11 headers,
60 which #define the symbol None. Put the X11 includes after
61 the Qt includes to solve this problem.
62 */
63 None = 0, // invalid event
64 Timer = 1, // timer event
65 MouseButtonPress = 2, // mouse button pressed
66 MouseButtonRelease = 3, // mouse button released
67 MouseButtonDblClick = 4, // mouse button double click
68 MouseMove = 5, // mouse move
69 KeyPress = 6, // key pressed
70 KeyRelease = 7, // key released
71 FocusIn = 8, // keyboard focus received
72 FocusOut = 9, // keyboard focus lost
73 FocusAboutToChange = 23, // keyboard focus is about to be lost
74 Enter = 10, // mouse enters widget
75 Leave = 11, // mouse leaves widget
76 Paint = 12, // paint widget
77 Move = 13, // move widget
78 Resize = 14, // resize widget
79 Create = 15, // after widget creation
80 Destroy = 16, // during widget destruction
81 Show = 17, // widget is shown
82 Hide = 18, // widget is hidden
83 Close = 19, // request to close widget
84 Quit = 20, // request to quit application
85 ParentChange = 21, // widget has been reparented
86 ParentAboutToChange = 131, // sent just before the parent change is done
87 ThreadChange = 22, // object has changed threads
88 WindowActivate = 24, // window was activated
89 WindowDeactivate = 25, // window was deactivated
90 ShowToParent = 26, // widget is shown to parent
91 HideToParent = 27, // widget is hidden to parent
92 Wheel = 31, // wheel event
93 WindowTitleChange = 33, // window title changed
94 WindowIconChange = 34, // icon changed
95 ApplicationWindowIconChange = 35, // application icon changed
96 ApplicationFontChange = 36, // application font changed
97 ApplicationLayoutDirectionChange = 37, // application layout direction changed
98 ApplicationPaletteChange = 38, // application palette changed
99 PaletteChange = 39, // widget palette changed
100 Clipboard = 40, // internal clipboard event
101 Speech = 42, // reserved for speech input
102 MetaCall = 43, // meta call event
103 SockAct = 50, // socket activation
104 WinEventAct = 132, // win event activation
105 DeferredDelete = 52, // deferred delete event
106 DragEnter = 60, // drag moves into widget
107 DragMove = 61, // drag moves in widget
108 DragLeave = 62, // drag leaves or is cancelled
109 Drop = 63, // actual drop
110 DragResponse = 64, // drag accepted/rejected
111 ChildAdded = 68, // new child widget
112 ChildPolished = 69, // polished child widget
113 ChildRemoved = 71, // deleted child widget
114 ShowWindowRequest = 73, // widget's window should be mapped
115 PolishRequest = 74, // widget should be polished
116 Polish = 75, // widget is polished
117 LayoutRequest = 76, // widget should be relayouted
118 UpdateRequest = 77, // widget should be repainted
119 UpdateLater = 78, // request update() later
120
121 EmbeddingControl = 79, // ActiveX embedding
122 ActivateControl = 80, // ActiveX activation
123 DeactivateControl = 81, // ActiveX deactivation
124 ContextMenu = 82, // context popup menu
125 InputMethod = 83, // input method
126 TabletMove = 87, // Wacom tablet event
127 LocaleChange = 88, // the system locale changed
128 LanguageChange = 89, // the application language changed
129 LayoutDirectionChange = 90, // the layout direction changed
130 Style = 91, // internal style event
131 TabletPress = 92, // tablet press
132 TabletRelease = 93, // tablet release
133 OkRequest = 94, // CE (Ok) button pressed
134 HelpRequest = 95, // CE (?) button pressed
135
136 IconDrag = 96, // proxy icon dragged
137
138 FontChange = 97, // font has changed
139 EnabledChange = 98, // enabled state has changed
140 ActivationChange = 99, // window activation has changed
141 StyleChange = 100, // style has changed
142 IconTextChange = 101, // icon text has changed. Deprecated.
143 ModifiedChange = 102, // modified state has changed
144 MouseTrackingChange = 109, // mouse tracking state has changed
145
146 WindowBlocked = 103, // window is about to be blocked modally
147 WindowUnblocked = 104, // windows modal blocking has ended
148 WindowStateChange = 105,
149
150 ReadOnlyChange = 106, // readonly state has changed
151
152 ToolTip = 110,
153 WhatsThis = 111,
154 StatusTip = 112,
155
156 ActionChanged = 113,
157 ActionAdded = 114,
158 ActionRemoved = 115,
159
160 FileOpen = 116, // file open request
161
162 Shortcut = 117, // shortcut triggered
163 ShortcutOverride = 51, // shortcut override request
164
165 WhatsThisClicked = 118,
166
167 ToolBarChange = 120, // toolbar visibility toggled
168
169 ApplicationActivate = 121, // deprecated. Use ApplicationStateChange instead.
170 ApplicationActivated = ApplicationActivate, // deprecated
171 ApplicationDeactivate = 122, // deprecated. Use ApplicationStateChange instead.
172 ApplicationDeactivated = ApplicationDeactivate, // deprecated
173
174 QueryWhatsThis = 123, // query what's this widget help
175 EnterWhatsThisMode = 124,
176 LeaveWhatsThisMode = 125,
177
178 ZOrderChange = 126, // child widget has had its z-order changed
179
180 HoverEnter = 127, // mouse cursor enters a hover widget
181 HoverLeave = 128, // mouse cursor leaves a hover widget
182 HoverMove = 129, // mouse cursor move inside a hover widget
183
184 // last event id used = 132
185
186#ifdef QT_KEYPAD_NAVIGATION
187 EnterEditFocus = 150, // enter edit mode in keypad navigation
188 LeaveEditFocus = 151, // enter edit mode in keypad navigation
189#endif
190 AcceptDropsChange = 152,
191
192 ZeroTimerEvent = 154, // Used for Windows Zero timer events
193
194 GraphicsSceneMouseMove = 155, // GraphicsView
195 GraphicsSceneMousePress = 156,
196 GraphicsSceneMouseRelease = 157,
197 GraphicsSceneMouseDoubleClick = 158,
198 GraphicsSceneContextMenu = 159,
199 GraphicsSceneHoverEnter = 160,
200 GraphicsSceneHoverMove = 161,
201 GraphicsSceneHoverLeave = 162,
202 GraphicsSceneHelp = 163,
203 GraphicsSceneDragEnter = 164,
204 GraphicsSceneDragMove = 165,
205 GraphicsSceneDragLeave = 166,
206 GraphicsSceneDrop = 167,
207 GraphicsSceneWheel = 168,
208
209 KeyboardLayoutChange = 169, // keyboard layout changed
210
211 DynamicPropertyChange = 170, // A dynamic property was changed through setProperty/property
212
213 TabletEnterProximity = 171,
214 TabletLeaveProximity = 172,
215
216 NonClientAreaMouseMove = 173,
217 NonClientAreaMouseButtonPress = 174,
218 NonClientAreaMouseButtonRelease = 175,
219 NonClientAreaMouseButtonDblClick = 176,
220
221 MacSizeChange = 177, // when the Qt::WA_Mac{Normal,Small,Mini}Size changes
222
223 ContentsRectChange = 178, // sent by QWidget::setContentsMargins (internal)
224
225 MacGLWindowChange = 179, // Internal! the window of the GLWidget has changed
226
227 FutureCallOut = 180,
228
229 GraphicsSceneResize = 181,
230 GraphicsSceneMove = 182,
231
232 CursorChange = 183,
233 ToolTipChange = 184,
234
235 NetworkReplyUpdated = 185, // Internal for QNetworkReply
236
237 GrabMouse = 186,
238 UngrabMouse = 187,
239 GrabKeyboard = 188,
240 UngrabKeyboard = 189,
241
242 StateMachineSignal = 192,
243 StateMachineWrapped = 193,
244
245 TouchBegin = 194,
246 TouchUpdate = 195,
247 TouchEnd = 196,
248
249#ifndef QT_NO_GESTURES
250 NativeGesture = 197, // QtGui native gesture
251#endif
252 RequestSoftwareInputPanel = 199,
253 CloseSoftwareInputPanel = 200,
254
255 WinIdChange = 203,
256#ifndef QT_NO_GESTURES
257 Gesture = 198,
258 GestureOverride = 202,
259#endif
260 ScrollPrepare = 204,
261 Scroll = 205,
262
263 Expose = 206,
264
265 InputMethodQuery = 207,
266 OrientationChange = 208, // Screen orientation has changed
267
268 TouchCancel = 209,
269
270 ThemeChange = 210,
271
272 SockClose = 211, // socket closed
273
274 PlatformPanel = 212,
275
276 StyleAnimationUpdate = 213, // style animation target should be updated
277 ApplicationStateChange = 214,
278
279 WindowChangeInternal = 215, // internal for QQuickWidget
280 ScreenChangeInternal = 216,
281
282 PlatformSurface = 217, // Platform surface created or about to be destroyed
283
284 Pointer = 218, // Qt 5: QQuickPointerEvent; Qt 6: unused so far
285
286 TabletTrackingChange = 219, // tablet tracking state has changed
287
288 // 512 reserved for Qt Jambi's MetaCall event
289 // 513 reserved for Qt Jambi's DeleteOnMainThread event
290
291 User = 1000, // first user event id
292 MaxUser = 65535 // last user event id
293 };
294 Q_ENUM(Type)
295
296 explicit QEvent(Type type);
297 QEvent(const QEvent &other);
298 virtual ~QEvent();
299 QEvent &operator=(const QEvent &other);
300 inline Type type() const { return static_cast<Type>(t); }
301 inline bool spontaneous() const { return spont; }
302
303 inline virtual void setAccepted(bool accepted) { m_accept = accepted; }
304 inline bool isAccepted() const { return m_accept; }
305
306 inline void accept() { m_accept = true; }
307 inline void ignore() { m_accept = false; }
308
309 inline bool isInputEvent() const noexcept { return m_inputEvent; }
310 inline bool isPointerEvent() const noexcept { return m_pointerEvent; }
311
312 static int registerEventType(int hint = -1) noexcept;
313
314protected:
315 struct InputEventTag { explicit InputEventTag() = default; };
316 QEvent(Type type, InputEventTag) : QEvent(type) { m_inputEvent = true; }
317 struct PointerEventTag { explicit PointerEventTag() = default; };
318 QEvent(Type type, PointerEventTag) : QEvent(type, InputEventTag{}) { m_pointerEvent = true; }
319 QEventPrivate *d;
320 ushort t;
321
322private:
323 ushort posted : 1;
324 ushort spont : 1;
325 ushort m_accept : 1;
326 ushort m_inputEvent : 1;
327 ushort m_pointerEvent : 1;
328 ushort reserved : 11;
329
330 friend class QCoreApplication;
331 friend class QCoreApplicationPrivate;
332 friend class QThreadData;
333 friend class QApplication;
334#if QT_CONFIG(shortcut)
335 friend class QShortcutMap;
336#endif
337 friend class QGraphicsView;
338 friend class QGraphicsScene;
339 friend class QGraphicsScenePrivate;
340 // from QtTest:
341 friend class QSpontaneKeyEvent;
342 // needs this:
343 Q_ALWAYS_INLINE
344 void setSpontaneous() { spont = true; }
345};
346
347class Q_CORE_EXPORT QTimerEvent : public QEvent
348{
349public:
350 explicit QTimerEvent(int timerId);
351 ~QTimerEvent();
352 int timerId() const { return id; }
353
354protected:
355 int id;
356};
357
358class QObject;
359
360class Q_CORE_EXPORT QChildEvent : public QEvent
361{
362public:
363 QChildEvent(Type type, QObject *child);
364 ~QChildEvent();
365 QObject *child() const { return c; }
366 bool added() const { return type() == ChildAdded; }
367 bool polished() const { return type() == ChildPolished; }
368 bool removed() const { return type() == ChildRemoved; }
369
370protected:
371 QObject *c;
372};
373
374class Q_CORE_EXPORT QDynamicPropertyChangeEvent : public QEvent
375{
376public:
377 explicit QDynamicPropertyChangeEvent(const QByteArray &name);
378 ~QDynamicPropertyChangeEvent();
379
380 inline QByteArray propertyName() const { return n; }
381
382private:
383 QByteArray n;
384};
385
386class Q_CORE_EXPORT QDeferredDeleteEvent : public QEvent
387{
388public:
389 explicit QDeferredDeleteEvent();
390 ~QDeferredDeleteEvent();
391 int loopLevel() const { return level; }
392
393private:
394 int level;
395 friend class QCoreApplication;
396};
397
398QT_END_NAMESPACE
399
400#endif // QCOREEVENT_H
401