QtBase  v6.3.1
qnativeevents.h
Go to the documentation of this file.
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 test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
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 General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 
29 #ifndef Q_NATIVE_INPUT
30 #define Q_NATIVE_INPUT
31 
32 #include <QtCore>
33 
35 namespace Qt {
36 namespace Native {
38 }}
40 
41 // ----------------------------------------------------------------------------
42 // Declare a set of native events that can be used to communicate with
43 // client applications in an platform independent way
44 // ----------------------------------------------------------------------------
45 
47 {
48 public:
49  static const int eventId = 1;
50 
51  QNativeEvent(Qt::KeyboardModifiers modifiers = Qt::NoModifier);
52  virtual ~QNativeEvent() {}
53  virtual int id() const { return eventId; }
54  virtual QString toString() const = 0;
55  Qt::KeyboardModifiers modifiers; // Yields for mouse events too.
56 };
57 
59 public:
60  static const int eventId = 2;
61 
63  QNativeMouseEvent(QPoint globalPos, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
64  virtual ~QNativeMouseEvent() {}
65  virtual int id() const { return eventId; }
66 
68 };
69 
71 public:
72  static const int eventId = 4;
73 
77  virtual int id() const { return eventId; }
78  virtual QString toString() const;
79 };
80 
82 public:
83  static const int eventId = 8;
84 
88  virtual int id() const { return eventId; }
89  virtual QString toString() const;
90 
93 };
94 
96 public:
97  static const int eventId = 16;
98 
102  virtual int id() const { return eventId; }
103  virtual QString toString() const;
104 };
105 
107 public:
108  static const int eventId = 32;
109 
111  QNativeMouseWheelEvent(QPoint globalPos, int delta, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
113  virtual int id() const { return eventId; }
114  virtual QString toString() const;
115 
116  int delta;
117 };
118 
120  public:
121  static const int eventId = 64;
122 
124  QNativeKeyEvent(int nativeKeyCode, bool press, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
125  QNativeKeyEvent(int nativeKeyCode, bool press, QChar character, Qt::KeyboardModifiers modifiers);
126  virtual ~QNativeKeyEvent() {}
127  virtual int id() const { return eventId; }
128  virtual QString toString() const;
129 
131  bool press;
133 
134  // Some Qt to Native mappings:
135  static int Key_A;
136  static int Key_B;
137  static int Key_C;
138  static int Key_1;
139  static int Key_Backspace;
140  static int Key_Enter;
141  static int Key_Del;
142 };
143 
145 public:
146  static const int eventId = 128;
147 
148  QNativeModifierEvent(Qt::KeyboardModifiers modifiers = Qt::NoModifier, int nativeKeyCode = 0);
150  virtual int id() const { return eventId; }
151  virtual QString toString() const;
152 
154 };
155 
156 // ----------------------------------------------------------------------------
157 // Declare a set of related output / input functions for convenience:
158 // ----------------------------------------------------------------------------
159 
162 
171 
178 
179 // ----------------------------------------------------------------------------
180 // Declare the main class that is supposed to be sub-classed by components
181 // that are to receive native events
182 // ----------------------------------------------------------------------------
183 
185 {
186  public:
187  QNativeInput(bool subscribe = true);
188  virtual ~QNativeInput();
189 
190  // Callback methods. Should be implemented by interested sub-classes:
191  void notify(QNativeEvent *event);
192  virtual void nativeEvent(QNativeEvent *event);
201 
202  // The following methods will differ in implementation from OS to OS:
209  // sendNativeEvent will NOT differ from OS to OS.
211 
212  // The following methods will differ in implementation from OS to OS:
215 };
216 
217 #endif // Q_NATIVE_INPUT
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:84
operator>>(QDataStream &ds, qfloat16 &f)
Definition: qfloat16.cpp:344
operator<<(QDataStream &ds, qfloat16 f)
Definition: qfloat16.cpp:327
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:65
Qt::KeyboardModifiers modifiers
Definition: qnativeevents.h:55
virtual int id() const
Definition: qnativeevents.h:53
QNativeEvent(Qt::KeyboardModifiers modifiers=Qt::NoModifier)
static const int eventId
Definition: qnativeevents.h:49
virtual ~QNativeEvent()
Definition: qnativeevents.h:52
virtual QString toString() const =0
virtual void nativeMouseReleaseEvent(QNativeMouseButtonEvent *)
virtual ~QNativeInput()
static Qt::Native::Status sendNativeMouseWheelEvent(const QNativeMouseWheelEvent &event)
QNativeInput(bool subscribe=true)
Qt::Native::Status subscribeForNativeEvents()
void notify(QNativeEvent *event)
static Qt::Native::Status sendNativeMouseDragEvent(const QNativeMouseDragEvent &event)
virtual void nativeKeyPressEvent(QNativeKeyEvent *)
static Qt::Native::Status sendNativeEvent(const QNativeEvent &event)
virtual void nativeEvent(QNativeEvent *event)
static Qt::Native::Status sendNativeMouseButtonEvent(const QNativeMouseButtonEvent &event)
virtual void nativeModifierEvent(QNativeModifierEvent *)
virtual void nativeMouseMoveEvent(QNativeMouseMoveEvent *)
virtual void nativeMouseWheelEvent(QNativeMouseWheelEvent *)
virtual void nativeMousePressEvent(QNativeMouseButtonEvent *)
static Qt::Native::Status sendNativeModifierEvent(const QNativeModifierEvent &event)
static Qt::Native::Status sendNativeKeyEvent(const QNativeKeyEvent &event)
virtual void nativeMouseDragEvent(QNativeMouseDragEvent *)
static Qt::Native::Status sendNativeMouseMoveEvent(const QNativeMouseMoveEvent &event)
Qt::Native::Status unsubscribeForNativeEvents()
virtual void nativeKeyReleaseEvent(QNativeKeyEvent *)
static int Key_A
static int Key_C
virtual ~QNativeKeyEvent()
virtual QString toString() const
static int Key_Backspace
virtual int id() const
static int Key_Enter
static const int eventId
static int Key_B
static int Key_1
static int Key_Del
virtual int id() const
virtual QString toString() const
static const int eventId
virtual ~QNativeModifierEvent()
QNativeModifierEvent(Qt::KeyboardModifiers modifiers=Qt::NoModifier, int nativeKeyCode=0)
static const int eventId
Definition: qnativeevents.h:83
virtual QString toString() const
virtual ~QNativeMouseButtonEvent()
Definition: qnativeevents.h:87
Qt::MouseButton button
Definition: qnativeevents.h:91
virtual int id() const
Definition: qnativeevents.h:88
virtual ~QNativeMouseDragEvent()
virtual QString toString() const
static const int eventId
Definition: qnativeevents.h:97
virtual int id() const
virtual ~QNativeMouseEvent()
Definition: qnativeevents.h:64
virtual int id() const
Definition: qnativeevents.h:65
static const int eventId
Definition: qnativeevents.h:60
virtual ~QNativeMouseMoveEvent()
Definition: qnativeevents.h:76
virtual int id() const
Definition: qnativeevents.h:77
static const int eventId
Definition: qnativeevents.h:72
virtual QString toString() const
virtual QString toString() const
virtual int id() const
static const int eventId
virtual ~QNativeMouseWheelEvent()
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:52
The QString class provides a Unicode character string.
Definition: qstring.h:388
The QTextStream class provides a convenient interface for reading and writing text.
Definition: qtextstream.h:62
double e
Definition: qnamespace.h:55
MouseButton
Definition: qnamespace.h:81
@ NoModifier
Definition: qnamespace.h:1074
struct _cl_event * event
Definition: qopenglext.h:2998
GLdouble s
[6]
Definition: qopenglext.h:235