File indexing completed on 2025-01-18 10:07:21
0001
0002
0003
0004 #ifndef QCOREEVENT_H
0005 #define QCOREEVENT_H
0006
0007 #include <QtCore/qnamespace.h>
0008 #include <QtCore/qbytearray.h>
0009 #include <QtCore/qobjectdefs.h>
0010
0011 QT_BEGIN_NAMESPACE
0012
0013 #define Q_EVENT_DISABLE_COPY(Class) \
0014 protected: \
0015 Class(const Class &) = default; \
0016 Class(Class &&) = delete; \
0017 Class &operator=(const Class &other) = default; \
0018 Class &operator=(Class &&) = delete
0019
0020 #define Q_DECL_EVENT_COMMON(Class) \
0021 protected: \
0022 Class(const Class &); \
0023 Class(Class &&) = delete; \
0024 Class &operator=(const Class &other) = default; \
0025 Class &operator=(Class &&) = delete; \
0026 public: \
0027 Class* clone() const override; \
0028 ~Class() override; \
0029 private:
0030
0031 #define Q_IMPL_EVENT_COMMON(Class) \
0032 Class::Class(const Class &) = default; \
0033 Class::~Class() = default; \
0034 Class* Class::clone() const \
0035 { \
0036 auto c = new Class(*this); \
0037 [[maybe_unused]] QEvent *e = c; \
0038 \
0039 Q_ASSERT(reinterpret_cast<quintptr>(c) == reinterpret_cast<quintptr>(e)); \
0040 return c; \
0041 }
0042
0043 class QEventPrivate;
0044 class Q_CORE_EXPORT QEvent
0045 {
0046 Q_GADGET
0047 QDOC_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
0048
0049 Q_EVENT_DISABLE_COPY(QEvent);
0050 public:
0051 enum Type {
0052
0053
0054
0055
0056
0057
0058 None = 0,
0059 Timer = 1,
0060 MouseButtonPress = 2,
0061 MouseButtonRelease = 3,
0062 MouseButtonDblClick = 4,
0063 MouseMove = 5,
0064 KeyPress = 6,
0065 KeyRelease = 7,
0066 FocusIn = 8,
0067 FocusOut = 9,
0068 FocusAboutToChange = 23,
0069 Enter = 10,
0070 Leave = 11,
0071 Paint = 12,
0072 Move = 13,
0073 Resize = 14,
0074 Create = 15,
0075 Destroy = 16,
0076 Show = 17,
0077 Hide = 18,
0078 Close = 19,
0079 Quit = 20,
0080 ParentChange = 21,
0081 ParentAboutToChange = 131,
0082 ThreadChange = 22,
0083 WindowActivate = 24,
0084 WindowDeactivate = 25,
0085 ShowToParent = 26,
0086 HideToParent = 27,
0087 Wheel = 31,
0088 WindowTitleChange = 33,
0089 WindowIconChange = 34,
0090 ApplicationWindowIconChange = 35,
0091 ApplicationFontChange = 36,
0092 ApplicationLayoutDirectionChange = 37,
0093 ApplicationPaletteChange = 38,
0094 PaletteChange = 39,
0095 Clipboard = 40,
0096 Speech = 42,
0097 MetaCall = 43,
0098 SockAct = 50,
0099 WinEventAct = 132,
0100 DeferredDelete = 52,
0101 DragEnter = 60,
0102 DragMove = 61,
0103 DragLeave = 62,
0104 Drop = 63,
0105 DragResponse = 64,
0106 ChildAdded = 68,
0107 ChildPolished = 69,
0108 ChildRemoved = 71,
0109 ShowWindowRequest = 73,
0110 PolishRequest = 74,
0111 Polish = 75,
0112 LayoutRequest = 76,
0113 UpdateRequest = 77,
0114 UpdateLater = 78,
0115
0116 EmbeddingControl = 79,
0117 ActivateControl = 80,
0118 DeactivateControl = 81,
0119 ContextMenu = 82,
0120 InputMethod = 83,
0121 TabletMove = 87,
0122 LocaleChange = 88,
0123 LanguageChange = 89,
0124 LayoutDirectionChange = 90,
0125 Style = 91,
0126 TabletPress = 92,
0127 TabletRelease = 93,
0128 OkRequest = 94,
0129 HelpRequest = 95,
0130
0131 IconDrag = 96,
0132
0133 FontChange = 97,
0134 EnabledChange = 98,
0135 ActivationChange = 99,
0136 StyleChange = 100,
0137 IconTextChange = 101,
0138 ModifiedChange = 102,
0139 MouseTrackingChange = 109,
0140
0141 WindowBlocked = 103,
0142 WindowUnblocked = 104,
0143 WindowStateChange = 105,
0144
0145 ReadOnlyChange = 106,
0146
0147 ToolTip = 110,
0148 WhatsThis = 111,
0149 StatusTip = 112,
0150
0151 ActionChanged = 113,
0152 ActionAdded = 114,
0153 ActionRemoved = 115,
0154
0155 FileOpen = 116,
0156
0157 Shortcut = 117,
0158 ShortcutOverride = 51,
0159
0160 WhatsThisClicked = 118,
0161
0162 ToolBarChange = 120,
0163
0164 ApplicationActivate = 121,
0165 ApplicationActivated = ApplicationActivate,
0166 ApplicationDeactivate = 122,
0167 ApplicationDeactivated = ApplicationDeactivate,
0168
0169 QueryWhatsThis = 123,
0170 EnterWhatsThisMode = 124,
0171 LeaveWhatsThisMode = 125,
0172
0173 ZOrderChange = 126,
0174
0175 HoverEnter = 127,
0176 HoverLeave = 128,
0177 HoverMove = 129,
0178
0179
0180
0181 #ifdef QT_KEYPAD_NAVIGATION
0182 EnterEditFocus = 150,
0183 LeaveEditFocus = 151,
0184 #endif
0185 AcceptDropsChange = 152,
0186
0187 ZeroTimerEvent = 154,
0188
0189 GraphicsSceneMouseMove = 155,
0190 GraphicsSceneMousePress = 156,
0191 GraphicsSceneMouseRelease = 157,
0192 GraphicsSceneMouseDoubleClick = 158,
0193 GraphicsSceneContextMenu = 159,
0194 GraphicsSceneHoverEnter = 160,
0195 GraphicsSceneHoverMove = 161,
0196 GraphicsSceneHoverLeave = 162,
0197 GraphicsSceneHelp = 163,
0198 GraphicsSceneDragEnter = 164,
0199 GraphicsSceneDragMove = 165,
0200 GraphicsSceneDragLeave = 166,
0201 GraphicsSceneDrop = 167,
0202 GraphicsSceneWheel = 168,
0203 GraphicsSceneLeave = 220,
0204
0205 KeyboardLayoutChange = 169,
0206
0207 DynamicPropertyChange = 170,
0208
0209 TabletEnterProximity = 171,
0210 TabletLeaveProximity = 172,
0211
0212 NonClientAreaMouseMove = 173,
0213 NonClientAreaMouseButtonPress = 174,
0214 NonClientAreaMouseButtonRelease = 175,
0215 NonClientAreaMouseButtonDblClick = 176,
0216
0217 MacSizeChange = 177,
0218
0219 ContentsRectChange = 178,
0220
0221 MacGLWindowChange = 179,
0222
0223 FutureCallOut = 180,
0224
0225 GraphicsSceneResize = 181,
0226 GraphicsSceneMove = 182,
0227
0228 CursorChange = 183,
0229 ToolTipChange = 184,
0230
0231 NetworkReplyUpdated = 185,
0232
0233 GrabMouse = 186,
0234 UngrabMouse = 187,
0235 GrabKeyboard = 188,
0236 UngrabKeyboard = 189,
0237
0238 StateMachineSignal = 192,
0239 StateMachineWrapped = 193,
0240
0241 TouchBegin = 194,
0242 TouchUpdate = 195,
0243 TouchEnd = 196,
0244
0245 #ifndef QT_NO_GESTURES
0246 NativeGesture = 197,
0247 #endif
0248 RequestSoftwareInputPanel = 199,
0249 CloseSoftwareInputPanel = 200,
0250
0251 WinIdChange = 203,
0252 #ifndef QT_NO_GESTURES
0253 Gesture = 198,
0254 GestureOverride = 202,
0255 #endif
0256 ScrollPrepare = 204,
0257 Scroll = 205,
0258
0259 Expose = 206,
0260
0261 InputMethodQuery = 207,
0262 OrientationChange = 208,
0263
0264 TouchCancel = 209,
0265
0266 ThemeChange = 210,
0267
0268 SockClose = 211,
0269
0270 PlatformPanel = 212,
0271
0272 StyleAnimationUpdate = 213,
0273 ApplicationStateChange = 214,
0274
0275 WindowChangeInternal = 215,
0276 ScreenChangeInternal = 216,
0277
0278 PlatformSurface = 217,
0279
0280 Pointer = 218,
0281
0282 TabletTrackingChange = 219,
0283
0284
0285 WindowAboutToChangeInternal = 221,
0286
0287 DevicePixelRatioChange = 222,
0288
0289 ChildWindowAdded = 223,
0290 ChildWindowRemoved = 224,
0291 ParentWindowAboutToChange = 225,
0292 ParentWindowChange = 226,
0293
0294
0295
0296
0297 User = 1000,
0298 MaxUser = 65535
0299 };
0300 Q_ENUM(Type)
0301
0302 explicit QEvent(Type type);
0303 virtual ~QEvent();
0304 inline Type type() const { return static_cast<Type>(t); }
0305 inline bool spontaneous() const { return m_spont; }
0306
0307 inline virtual void setAccepted(bool accepted) { m_accept = accepted; }
0308 inline bool isAccepted() const { return m_accept; }
0309
0310 inline void accept() { m_accept = true; }
0311 inline void ignore() { m_accept = false; }
0312
0313 inline bool isInputEvent() const noexcept { return m_inputEvent; }
0314 inline bool isPointerEvent() const noexcept { return m_pointerEvent; }
0315 inline bool isSinglePointEvent() const noexcept { return m_singlePointEvent; }
0316
0317 static int registerEventType(int hint = -1) noexcept;
0318
0319 virtual QEvent *clone() const;
0320
0321 protected:
0322 struct InputEventTag { explicit InputEventTag() = default; };
0323 QEvent(Type type, InputEventTag) : QEvent(type) { m_inputEvent = true; }
0324 struct PointerEventTag { explicit PointerEventTag() = default; };
0325 QEvent(Type type, PointerEventTag) : QEvent(type, InputEventTag{}) { m_pointerEvent = true; }
0326 struct SinglePointEventTag { explicit SinglePointEventTag() = default; };
0327 QEvent(Type type, SinglePointEventTag) : QEvent(type, PointerEventTag{}) { m_singlePointEvent = true; }
0328 quint16 t;
0329
0330 private:
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342 bool m_posted = false;
0343 bool m_spont = false;
0344 bool m_accept = true;
0345 bool m_unused = false;
0346 quint16 m_reserved : 13;
0347 quint16 m_inputEvent : 1;
0348 quint16 m_pointerEvent : 1;
0349 quint16 m_singlePointEvent : 1;
0350
0351 friend class QCoreApplication;
0352 friend class QCoreApplicationPrivate;
0353 friend class QThreadData;
0354 friend class QApplication;
0355 friend class QGraphicsScenePrivate;
0356
0357 friend class QSpontaneKeyEvent;
0358
0359 Q_ALWAYS_INLINE
0360 void setSpontaneous() { m_spont = true; }
0361 };
0362
0363 class Q_CORE_EXPORT QTimerEvent : public QEvent
0364 {
0365 Q_DECL_EVENT_COMMON(QTimerEvent)
0366 public:
0367 explicit QTimerEvent(int timerId);
0368 int timerId() const { return id; }
0369
0370 protected:
0371 int id;
0372 };
0373
0374 class QObject;
0375
0376 class Q_CORE_EXPORT QChildEvent : public QEvent
0377 {
0378 Q_DECL_EVENT_COMMON(QChildEvent)
0379 public:
0380 QChildEvent(Type type, QObject *child);
0381
0382 QObject *child() const { return c; }
0383 bool added() const { return type() == ChildAdded; }
0384 bool polished() const { return type() == ChildPolished; }
0385 bool removed() const { return type() == ChildRemoved; }
0386
0387 protected:
0388 QObject *c;
0389 };
0390
0391 class Q_CORE_EXPORT QDynamicPropertyChangeEvent : public QEvent
0392 {
0393 Q_DECL_EVENT_COMMON(QDynamicPropertyChangeEvent)
0394 public:
0395 explicit QDynamicPropertyChangeEvent(const QByteArray &name);
0396
0397 inline QByteArray propertyName() const { return n; }
0398
0399 private:
0400 QByteArray n;
0401 };
0402
0403 QT_END_NAMESPACE
0404
0405 #endif