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