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 QtGui 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 | #include "qplatformcursor.h" |
40 | |
41 | #include <QPainter> |
42 | #include <QBitmap> |
43 | #include <QGuiApplication> |
44 | #include <QScreen> |
45 | #include <qpa/qplatformscreen.h> |
46 | #include <private/qguiapplication_p.h> |
47 | |
48 | #include <QDebug> |
49 | |
50 | QT_BEGIN_NAMESPACE |
51 | |
52 | /*! |
53 | \class QPlatformCursor |
54 | \since 5.0 |
55 | \internal |
56 | \preliminary |
57 | \ingroup qpa |
58 | |
59 | \brief The QPlatformCursor class provides information about |
60 | pointer device events (movement, buttons), and requests to change |
61 | the currently displayed cursor. |
62 | |
63 | Note that QPlatformCursor does not include any graphics for |
64 | display. An application that sets a QCursor may provide its own |
65 | graphics. |
66 | |
67 | \sa QPlatformCursorImage |
68 | */ |
69 | |
70 | /*! |
71 | \fn virtual void QPlatformCursor::pointerEvent(const QMouseEvent & event) |
72 | |
73 | This method is called by Qt whenever a QMouseEvent is generated by the |
74 | underlying pointer input. \a event is a reference to the QMouseEvent in |
75 | question. A default do-nothing implementation is provided. |
76 | */ |
77 | |
78 | /*! |
79 | \fn virtual void QPlatformCursor::changeCursor(QCursor * windowCursor, QWindow * window) |
80 | |
81 | \brief This method is called by Qt whenever the cursor graphic should be changed. |
82 | |
83 | Implementation of this method is mandatory for a subclass of QPlatformCursor. |
84 | |
85 | \a windowCursor is a pointer to the QCursor that should be displayed. |
86 | |
87 | To unset the cursor of \a window, \nullptr is passed. This means \a window does not have |
88 | a cursor set and the cursor of a the first parent window which has a cursor explicitly |
89 | set or the system default cursor should take effect. |
90 | |
91 | \a window is a pointer to the window currently displayed at QCursor::pos(). Note |
92 | that this may be \nullptr if the current position is not occupied by a displayed widget. |
93 | |
94 | \sa QCursor::pos() |
95 | */ |
96 | |
97 | /*! |
98 | \enum QPlatformCursor::Capability |
99 | \since 5.10 |
100 | |
101 | \value OverrideCursor Indicates that the platform implements |
102 | QPlatformCursor::setOverrideCursor() and |
103 | QPlatformCursor::clearOverrideCursor(). |
104 | */ |
105 | |
106 | QPlatformCursor::Capabilities QPlatformCursor::m_capabilities = { }; |
107 | |
108 | /*! |
109 | \fn QPlatformCursor::QPlatformCursor() |
110 | |
111 | Constructs a QPlatformCursor. |
112 | */ |
113 | QPlatformCursor::QPlatformCursor() |
114 | { |
115 | } |
116 | |
117 | QPoint QPlatformCursor::pos() const |
118 | { |
119 | // As a fallback return the last mouse position seen by QGuiApplication. |
120 | return QGuiApplicationPrivate::lastCursorPosition.toPoint(); |
121 | } |
122 | |
123 | void QPlatformCursor::setPos(const QPoint &pos) |
124 | { |
125 | static bool firstCall = true; |
126 | if (firstCall) { |
127 | firstCall = false; |
128 | qWarning(msg: "This plugin does not support QCursor::setPos()" |
129 | "; emulating movement within the application." ); |
130 | } |
131 | QWindowSystemInterface::handleMouseEvent(window: nullptr, local: pos, global: pos, state: Qt::NoButton, button: Qt::NoButton, type: QEvent::MouseMove); |
132 | } |
133 | |
134 | /*! |
135 | Returns the size of the cursor, in native pixels. |
136 | */ |
137 | QSize QPlatformCursor::size() const |
138 | { |
139 | return QSize(16, 16); |
140 | } |
141 | |
142 | // End of display and pointer event handling code |
143 | // Beginning of built-in cursor graphics |
144 | // from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp |
145 | |
146 | /*! |
147 | \class QPlatformCursorImage |
148 | \since 5.0 |
149 | \internal |
150 | \preliminary |
151 | \ingroup qpa |
152 | |
153 | \brief The QPlatformCursorImage class provides a set of graphics |
154 | intended to be used as cursors. |
155 | |
156 | \sa QPlatformCursor |
157 | */ |
158 | |
159 | static QPlatformCursorImage *systemCursorTable[Qt::LastCursor+1]; |
160 | static bool systemCursorTableInit = false; |
161 | |
162 | // 16 x 16 |
163 | static const uchar cur_arrow_bits[] = { |
164 | 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08, |
165 | 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22, |
166 | 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 }; |
167 | static const uchar mcur_arrow_bits[] = { |
168 | 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f, |
169 | 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e, |
170 | 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 }; |
171 | |
172 | static const unsigned char cur_up_arrow_bits[] = { |
173 | 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04, |
174 | 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, |
175 | 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01}; |
176 | static const unsigned char mcur_up_arrow_bits[] = { |
177 | 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07, |
178 | 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, |
179 | 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01}; |
180 | |
181 | static const unsigned char cur_cross_bits[] = { |
182 | 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, |
183 | 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, |
184 | 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00}; |
185 | static const unsigned char mcur_cross_bits[] = { |
186 | 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, |
187 | 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, |
188 | 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00}; |
189 | |
190 | static const uchar cur_ibeam_bits[] = { |
191 | 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, |
192 | 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, |
193 | 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 }; |
194 | static const uchar mcur_ibeam_bits[] = { |
195 | 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, |
196 | 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, |
197 | 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 }; |
198 | |
199 | static const uchar cur_ver_bits[] = { |
200 | 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, |
201 | 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, |
202 | 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; |
203 | static const uchar mcur_ver_bits[] = { |
204 | 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, |
205 | 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, |
206 | 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; |
207 | |
208 | static const uchar cur_hor_bits[] = { |
209 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, |
210 | 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, |
211 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
212 | static const uchar mcur_hor_bits[] = { |
213 | 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, |
214 | 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, |
215 | 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; |
216 | static const uchar cur_bdiag_bits[] = { |
217 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, |
218 | 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, |
219 | 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
220 | static const uchar mcur_bdiag_bits[] = { |
221 | 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, |
222 | 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, |
223 | 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; |
224 | static const uchar cur_fdiag_bits[] = { |
225 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, |
226 | 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, |
227 | 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; |
228 | static const uchar mcur_fdiag_bits[] = { |
229 | 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, |
230 | 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, |
231 | 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; |
232 | |
233 | // 20 x 20 |
234 | static const uchar forbidden_bits[] = { |
235 | 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, |
236 | 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, |
237 | 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, |
238 | 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; |
239 | |
240 | static const uchar forbiddenm_bits[] = { |
241 | 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, |
242 | 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, |
243 | 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, |
244 | 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; |
245 | |
246 | // 32 x 32 |
247 | static const uchar wait_data_bits[] = { |
248 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
249 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, |
250 | 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00, |
251 | 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, |
252 | 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00, |
253 | 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00, |
254 | 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00, |
255 | 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00, |
256 | 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, |
257 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
258 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
259 | static const uchar wait_mask_bits[] = { |
260 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
261 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, |
262 | 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00, |
263 | 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, |
264 | 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00, |
265 | 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00, |
266 | 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, |
267 | 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, |
268 | 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, |
269 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
270 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
271 | |
272 | static const uchar hsplit_bits[] = { |
273 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
274 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
275 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, |
276 | 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, |
277 | 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, |
278 | 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, |
279 | 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, |
280 | 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, |
281 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
282 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
283 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
284 | static const uchar hsplitm_bits[] = { |
285 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
286 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
287 | 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, |
288 | 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, |
289 | 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, |
290 | 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, |
291 | 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, |
292 | 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, |
293 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
294 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
295 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
296 | static const uchar vsplit_bits[] = { |
297 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
298 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
299 | 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, |
300 | 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, |
301 | 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, |
302 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, |
303 | 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, |
304 | 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, |
305 | 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
306 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
307 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
308 | static const uchar vsplitm_bits[] = { |
309 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
310 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, |
311 | 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, |
312 | 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, |
313 | 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, |
314 | 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, |
315 | 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, |
316 | 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, |
317 | 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, |
318 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
319 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
320 | static const uchar phand_bits[] = { |
321 | 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, |
322 | 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00, |
323 | 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00, |
324 | 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00, |
325 | 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
326 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
327 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
328 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
329 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
330 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
331 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
332 | static const uchar phandm_bits[] = { |
333 | 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, |
334 | 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, |
335 | 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, |
336 | 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, |
337 | 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, |
338 | 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
339 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
340 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
341 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
342 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
343 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
344 | |
345 | static const uchar size_all_data_bits[] = { |
346 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
347 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
348 | 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, |
349 | 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, |
350 | 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00, |
351 | 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00, |
352 | 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, |
353 | 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, |
354 | 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
355 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
356 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
357 | static const uchar size_all_mask_bits[] = { |
358 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
359 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, |
360 | 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, |
361 | 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00, |
362 | 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01, |
363 | 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00, |
364 | 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00, |
365 | 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, |
366 | 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
367 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
368 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
369 | |
370 | static const uchar whatsthis_bits[] = { |
371 | 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, |
372 | 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, |
373 | 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, |
374 | 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, |
375 | 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, |
376 | 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, |
377 | 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
378 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
379 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
380 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
381 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; |
382 | static const uchar whatsthism_bits[] = { |
383 | 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, |
384 | 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, |
385 | 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, |
386 | 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, |
387 | 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, |
388 | 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, |
389 | 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
390 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
391 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
392 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
393 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; |
394 | |
395 | static const uchar busy_bits[] = { |
396 | 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, |
397 | 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, |
398 | 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, |
399 | 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, |
400 | 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, |
401 | 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, |
402 | 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, |
403 | 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, |
404 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
405 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
406 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
407 | static const uchar busym_bits[] = { |
408 | 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, |
409 | 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, |
410 | 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, |
411 | 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, |
412 | 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, |
413 | 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, |
414 | 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, |
415 | 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, |
416 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
417 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
418 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
419 | |
420 | // 16 x 16 |
421 | static const uchar openhand_bits[] = { |
422 | 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, |
423 | 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, |
424 | 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; |
425 | static const uchar openhandm_bits[] = { |
426 | 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, |
427 | 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, |
428 | 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; |
429 | static const uchar closedhand_bits[] = { |
430 | 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, |
431 | 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, |
432 | 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; |
433 | static const uchar closedhandm_bits[] = { |
434 | 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, |
435 | 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, |
436 | 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; |
437 | |
438 | void QPlatformCursorImage::createSystemCursor(int id) |
439 | { |
440 | if (!systemCursorTableInit) { |
441 | for (int i = 0; i <= Qt::LastCursor; i++) |
442 | systemCursorTable[i] = nullptr; |
443 | systemCursorTableInit = true; |
444 | } |
445 | switch (id) { |
446 | // 16x16 cursors |
447 | case Qt::ArrowCursor: |
448 | systemCursorTable[Qt::ArrowCursor] = |
449 | new QPlatformCursorImage(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0); |
450 | break; |
451 | |
452 | case Qt::UpArrowCursor: |
453 | systemCursorTable[Qt::UpArrowCursor] = |
454 | new QPlatformCursorImage(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0); |
455 | break; |
456 | |
457 | case Qt::CrossCursor: |
458 | systemCursorTable[Qt::CrossCursor] = |
459 | new QPlatformCursorImage(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7); |
460 | break; |
461 | |
462 | case Qt::IBeamCursor: |
463 | systemCursorTable[Qt::IBeamCursor] = |
464 | new QPlatformCursorImage(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7); |
465 | break; |
466 | |
467 | case Qt::SizeVerCursor: |
468 | systemCursorTable[Qt::SizeVerCursor] = |
469 | new QPlatformCursorImage(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7); |
470 | break; |
471 | |
472 | case Qt::SizeHorCursor: |
473 | systemCursorTable[Qt::SizeHorCursor] = |
474 | new QPlatformCursorImage(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7); |
475 | break; |
476 | |
477 | case Qt::SizeBDiagCursor: |
478 | systemCursorTable[Qt::SizeBDiagCursor] = |
479 | new QPlatformCursorImage(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7); |
480 | break; |
481 | |
482 | case Qt::SizeFDiagCursor: |
483 | systemCursorTable[Qt::SizeFDiagCursor] = |
484 | new QPlatformCursorImage(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7); |
485 | break; |
486 | |
487 | case Qt::BlankCursor: |
488 | systemCursorTable[Qt::BlankCursor] = |
489 | new QPlatformCursorImage(nullptr, nullptr, 0, 0, 0, 0); |
490 | break; |
491 | |
492 | // 20x20 cursors |
493 | case Qt::ForbiddenCursor: |
494 | systemCursorTable[Qt::ForbiddenCursor] = |
495 | new QPlatformCursorImage(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10); |
496 | break; |
497 | |
498 | // 32x32 cursors |
499 | case Qt::WaitCursor: |
500 | systemCursorTable[Qt::WaitCursor] = |
501 | new QPlatformCursorImage(wait_data_bits, wait_mask_bits, 32, 32, 15, 15); |
502 | break; |
503 | |
504 | case Qt::SplitVCursor: |
505 | systemCursorTable[Qt::SplitVCursor] = |
506 | new QPlatformCursorImage(vsplit_bits, vsplitm_bits, 32, 32, 15, 15); |
507 | break; |
508 | |
509 | case Qt::SplitHCursor: |
510 | systemCursorTable[Qt::SplitHCursor] = |
511 | new QPlatformCursorImage(hsplit_bits, hsplitm_bits, 32, 32, 15, 15); |
512 | break; |
513 | |
514 | case Qt::SizeAllCursor: |
515 | systemCursorTable[Qt::SizeAllCursor] = |
516 | new QPlatformCursorImage(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15); |
517 | break; |
518 | |
519 | case Qt::PointingHandCursor: |
520 | systemCursorTable[Qt::PointingHandCursor] = |
521 | new QPlatformCursorImage(phand_bits, phandm_bits, 32, 32, 0, 0); |
522 | break; |
523 | |
524 | case Qt::WhatsThisCursor: |
525 | systemCursorTable[Qt::WhatsThisCursor] = |
526 | new QPlatformCursorImage(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0); |
527 | break; |
528 | case Qt::BusyCursor: |
529 | systemCursorTable[Qt::BusyCursor] = |
530 | new QPlatformCursorImage(busy_bits, busym_bits, 32, 32, 0, 0); |
531 | break; |
532 | |
533 | case Qt::OpenHandCursor: |
534 | systemCursorTable[Qt::OpenHandCursor] = |
535 | new QPlatformCursorImage(openhand_bits, openhandm_bits, 16, 16, 8, 8); |
536 | break; |
537 | case Qt::ClosedHandCursor: |
538 | systemCursorTable[Qt::ClosedHandCursor] = |
539 | new QPlatformCursorImage(closedhand_bits, closedhandm_bits, 16, 16, 8, 8); |
540 | break; |
541 | default: |
542 | qWarning(msg: "Unknown system cursor %d" , id); |
543 | } |
544 | } |
545 | |
546 | /*! |
547 | \fn void QPlatformCursorImage::set(Qt::CursorShape id) |
548 | |
549 | \brief Calling this method sets the cursor image to the specified shape |
550 | |
551 | \a id is one of the defined Qt::CursorShape values. |
552 | |
553 | If id is invalid, Qt::BitmapCursor, or unknown by the implementation, |
554 | Qt::ArrowCursor is used instead. |
555 | */ |
556 | |
557 | void QPlatformCursorImage::set(Qt::CursorShape id) |
558 | { |
559 | QPlatformCursorImage *cursor = nullptr; |
560 | if (unsigned(id) <= unsigned(Qt::LastCursor)) { |
561 | if (!systemCursorTable[id]) |
562 | createSystemCursor(id); |
563 | cursor = systemCursorTable[id]; |
564 | } |
565 | |
566 | if (cursor == nullptr) { |
567 | if (!systemCursorTable[Qt::ArrowCursor]) |
568 | createSystemCursor(id: Qt::ArrowCursor); |
569 | cursor = systemCursorTable[Qt::ArrowCursor]; |
570 | } |
571 | cursorImage = cursor->cursorImage; |
572 | hot = cursor->hot; |
573 | } |
574 | |
575 | /*! |
576 | Sets the cursor image to the given \a image, with the hotspot at the |
577 | point specified by (\a hx, \a hy). |
578 | */ |
579 | |
580 | void QPlatformCursorImage::set(const QImage &image, int hx, int hy) |
581 | { |
582 | hot.setX(hx); |
583 | hot.setY(hy); |
584 | cursorImage = image; |
585 | } |
586 | |
587 | /*! |
588 | \fn void QPlatformCursorImage::set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy) |
589 | |
590 | Sets the cursor image to the graphic represented by the combination of |
591 | \a data and \a mask, with dimensions given by \a width and \a height and a |
592 | hotspot at the point specified by (\a hx, \a hy). |
593 | |
594 | The image data specified by \a data must be supplied in the format |
595 | described by QImage::Format_Indexed8. |
596 | |
597 | The corresponding mask data specified by \a mask must be supplied in a |
598 | character array containing packed 1 bit per pixel format data, with any |
599 | padding bits at the end of the array. Bits of value 0 represent transparent |
600 | pixels in the image data. |
601 | */ |
602 | void QPlatformCursorImage::set(const uchar *data, const uchar *mask, |
603 | int width, int height, int hx, int hy) |
604 | { |
605 | hot.setX(hx); |
606 | hot.setY(hy); |
607 | |
608 | cursorImage = QImage(width,height, QImage::Format_Indexed8); |
609 | |
610 | if (!width || !height || !data || !mask || cursorImage.isNull()) |
611 | return; |
612 | |
613 | cursorImage.setColorCount(3); |
614 | cursorImage.setColor(i: 0, c: 0xff000000); |
615 | cursorImage.setColor(i: 1, c: 0xffffffff); |
616 | cursorImage.setColor(i: 2, c: 0x00000000); |
617 | |
618 | int bytesPerLine = (width + 7) / 8; |
619 | int p = 0; |
620 | int d, m; |
621 | |
622 | int x = -1, w = 0; |
623 | |
624 | uchar *cursor_data = cursorImage.bits(); |
625 | int bpl = cursorImage.bytesPerLine(); |
626 | for (int i = 0; i < height; i++) |
627 | { |
628 | for (int j = 0; j < bytesPerLine; j++, data++, mask++) |
629 | { |
630 | for (int b = 0; b < 8 && j*8+b < width; b++) |
631 | { |
632 | d = *data & (1 << b); |
633 | m = *mask & (1 << b); |
634 | if (d && m) p = 0; |
635 | else if (!d && m) p = 1; |
636 | else p = 2; |
637 | cursor_data[j*8+b] = p; |
638 | |
639 | // calc region |
640 | if (x < 0 && m) |
641 | x = j*8+b; |
642 | else if (x >= 0 && !m) { |
643 | x = -1; |
644 | w = 0; |
645 | } |
646 | if (m) |
647 | w++; |
648 | } |
649 | } |
650 | if (x >= 0) { |
651 | x = -1; |
652 | w = 0; |
653 | } |
654 | cursor_data += bpl; |
655 | } |
656 | |
657 | } |
658 | |
659 | /*! |
660 | \fn QPlatformCursorImage::QPlatformCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) |
661 | |
662 | Sets the cursor image to the graphic represented by the combination of |
663 | \a data and \a mask, with dimensions given by \a width and \a height and a |
664 | hotspot at the point specified by (\a hotX, \a hotY). |
665 | |
666 | \sa set() |
667 | */ |
668 | |
669 | /*! |
670 | \fn QImage *QPlatformCursorImage::image() |
671 | |
672 | \brief Return the cursor graphic as a pointer to a QImage |
673 | */ |
674 | |
675 | /*! |
676 | \fn QPoint QPlatformCursorImage::hotspot() const |
677 | |
678 | \brief Return the cursor's hotspot |
679 | */ |
680 | |
681 | #ifndef QT_NO_CURSOR |
682 | /*! |
683 | Reimplement this function in subclass to set an override cursor |
684 | on the associated screen and return true to indicate success. |
685 | |
686 | This function can be implemented on platforms where the cursor is a |
687 | property of the application or the screen rather than a property |
688 | of the window. On these platforms, the OverrideCursor capability |
689 | should be set. |
690 | |
691 | \sa QGuiApplication::setOverrideCursor(), Capabilities |
692 | |
693 | \since 5.10 |
694 | */ |
695 | void QPlatformCursor::setOverrideCursor(const QCursor &) |
696 | { |
697 | } |
698 | |
699 | /*! |
700 | Reimplement this function in subclass to clear the override cursor. |
701 | |
702 | \sa QGuiApplication::clearOverrideCursor(), Capabilities |
703 | |
704 | \since 5.10 |
705 | */ |
706 | void QPlatformCursor::clearOverrideCursor() |
707 | { |
708 | } |
709 | #endif // QT_NO_CURSOR |
710 | |
711 | QT_END_NAMESPACE |
712 | |