Line data Source code
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 :
47 : QT_BEGIN_NAMESPACE
48 :
49 :
50 : class QEventPrivate;
51 : class Q_CORE_EXPORT QEvent // event base class
52 : {
53 : Q_GADGET
54 : QDOC_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
55 : public:
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 : MacGLClearDrawable = 191, // Internal Cocoa, the window has changed, so we must clear
242 :
243 : StateMachineSignal = 192,
244 : StateMachineWrapped = 193,
245 :
246 : TouchBegin = 194,
247 : TouchUpdate = 195,
248 : TouchEnd = 196,
249 :
250 : #ifndef QT_NO_GESTURES
251 : NativeGesture = 197, // QtGui native gesture
252 : #endif
253 : RequestSoftwareInputPanel = 199,
254 : CloseSoftwareInputPanel = 200,
255 :
256 : WinIdChange = 203,
257 : #ifndef QT_NO_GESTURES
258 : Gesture = 198,
259 : GestureOverride = 202,
260 : #endif
261 : ScrollPrepare = 204,
262 : Scroll = 205,
263 :
264 : Expose = 206,
265 :
266 : InputMethodQuery = 207,
267 : OrientationChange = 208, // Screen orientation has changed
268 :
269 : TouchCancel = 209,
270 :
271 : ThemeChange = 210,
272 :
273 : SockClose = 211, // socket closed
274 :
275 : PlatformPanel = 212,
276 :
277 : StyleAnimationUpdate = 213, // style animation target should be updated
278 : ApplicationStateChange = 214,
279 :
280 : WindowChangeInternal = 215, // internal for QQuickWidget
281 : ScreenChangeInternal = 216,
282 :
283 : PlatformSurface = 217, // Platform surface created or about to be destroyed
284 :
285 : Pointer = 218, // QQuickPointerEvent; ### Qt 6: QPointerEvent
286 :
287 : TabletTrackingChange = 219, // tablet tracking state has changed
288 :
289 : // 512 reserved for Qt Jambi's MetaCall event
290 : // 513 reserved for Qt Jambi's DeleteOnMainThread event
291 :
292 : User = 1000, // first user event id
293 : MaxUser = 65535 // last user event id
294 : };
295 : Q_ENUM(Type)
296 :
297 : explicit QEvent(Type type);
298 : QEvent(const QEvent &other);
299 : virtual ~QEvent();
300 : QEvent &operator=(const QEvent &other);
301 0 : inline Type type() const { return static_cast<Type>(t); }
302 : inline bool spontaneous() const { return spont; }
303 :
304 : inline void setAccepted(bool accepted) { m_accept = accepted; }
305 : inline bool isAccepted() const { return m_accept; }
306 :
307 : inline void accept() { m_accept = true; }
308 : inline void ignore() { m_accept = false; }
309 :
310 : static int registerEventType(int hint = -1) Q_DECL_NOTHROW;
311 :
312 : protected:
313 : QEventPrivate *d;
314 : ushort t;
315 :
316 : private:
317 : ushort posted : 1;
318 : ushort spont : 1;
319 : ushort m_accept : 1;
320 : ushort reserved : 13;
321 :
322 : friend class QCoreApplication;
323 : friend class QCoreApplicationPrivate;
324 : friend class QThreadData;
325 : friend class QApplication;
326 : friend class QShortcutMap;
327 : friend class QGraphicsView;
328 : friend class QGraphicsScene;
329 : friend class QGraphicsScenePrivate;
330 : // from QtTest:
331 : friend class QSpontaneKeyEvent;
332 : // needs this:
333 : Q_ALWAYS_INLINE
334 : void setSpontaneous() { spont = true; }
335 : };
336 :
337 : class Q_CORE_EXPORT QTimerEvent : public QEvent
338 : {
339 : public:
340 : explicit QTimerEvent( int timerId );
341 : ~QTimerEvent();
342 : int timerId() const { return id; }
343 : protected:
344 : int id;
345 : };
346 :
347 : class QObject;
348 :
349 : class Q_CORE_EXPORT QChildEvent : public QEvent
350 : {
351 : public:
352 : QChildEvent( Type type, QObject *child );
353 : ~QChildEvent();
354 : QObject *child() const { return c; }
355 : bool added() const { return type() == ChildAdded; }
356 : bool polished() const { return type() == ChildPolished; }
357 : bool removed() const { return type() == ChildRemoved; }
358 : protected:
359 : QObject *c;
360 : };
361 :
362 : class Q_CORE_EXPORT QDynamicPropertyChangeEvent : public QEvent
363 : {
364 : public:
365 : explicit QDynamicPropertyChangeEvent(const QByteArray &name);
366 : ~QDynamicPropertyChangeEvent();
367 :
368 : inline QByteArray propertyName() const { return n; }
369 :
370 : private:
371 : QByteArray n;
372 : };
373 :
374 : class Q_CORE_EXPORT QDeferredDeleteEvent : public QEvent
375 : {
376 : public:
377 : explicit QDeferredDeleteEvent();
378 : ~QDeferredDeleteEvent();
379 : int loopLevel() const { return level; }
380 : private:
381 : int level;
382 : friend class QCoreApplication;
383 : };
384 :
385 : QT_END_NAMESPACE
386 :
387 : #endif // QCOREEVENT_H
|