source: trunk/src/gui/kernel/qcursor_win.cpp

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 18.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include <private/qcursor_p.h>
43#include <qbitmap.h>
44#include <qcursor.h>
45
46#ifndef QT_NO_CURSOR
47
48#include <qimage.h>
49#include <qt_windows.h>
50#include <private/qapplication_p.h>
51
52QT_BEGIN_NAMESPACE
53
54/*****************************************************************************
55 Internal QCursorData class
56 *****************************************************************************/
57
58QCursorData::QCursorData(Qt::CursorShape s)
59 : cshape(s), bm(0), bmm(0), hx(0), hy(0), hcurs(0)
60{
61 ref = 1;
62}
63
64QCursorData::~QCursorData()
65{
66 delete bm;
67 delete bmm;
68#if !defined(Q_WS_WINCE) || defined(GWES_ICONCURS)
69 if (hcurs)
70 DestroyCursor(hcurs);
71#endif
72}
73
74
75QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
76{
77 if (!QCursorData::initialized)
78 QCursorData::initialize();
79 if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) {
80 qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)");
81 QCursorData *c = qt_cursorTable[0];
82 c->ref.ref();
83 return c;
84 }
85 QCursorData *d = new QCursorData;
86 d->bm = new QBitmap(bitmap);
87 d->bmm = new QBitmap(mask);
88 d->hcurs = 0;
89 d->cshape = Qt::BitmapCursor;
90 d->hx = hotX >= 0 ? hotX : bitmap.width()/2;
91 d->hy = hotY >= 0 ? hotY : bitmap.height()/2;
92 return d;
93}
94
95HCURSOR QCursor::handle() const
96{
97 if (!QCursorData::initialized)
98 QCursorData::initialize();
99 if (!d->hcurs)
100 d->update();
101 return d->hcurs;
102}
103
104QCursor::QCursor(HCURSOR handle)
105{
106 d = new QCursorData(Qt::CustomCursor);
107 d->hcurs = handle;
108}
109
110#endif //QT_NO_CURSOR
111
112QPoint QCursor::pos()
113{
114 POINT p;
115 GetCursorPos(&p);
116 return QPoint(p.x, p.y);
117}
118
119void QCursor::setPos(int x, int y)
120{
121 SetCursorPos(x, y);
122}
123
124#ifndef QT_NO_CURSOR
125
126extern HBITMAP qt_createIconMask(const QBitmap &bitmap);
127
128static HCURSOR create32BitCursor(const QPixmap &pixmap, int hx, int hy)
129{
130 HCURSOR cur = 0;
131#if !defined(Q_WS_WINCE)
132 QBitmap mask = pixmap.mask();
133 if (mask.isNull()) {
134 mask = QBitmap(pixmap.size());
135 mask.fill(Qt::color1);
136 }
137
138 HBITMAP ic = pixmap.toWinHBITMAP(QPixmap::Alpha);
139 HBITMAP im = qt_createIconMask(mask);
140
141 ICONINFO ii;
142 ii.fIcon = 0;
143 ii.xHotspot = hx;
144 ii.yHotspot = hy;
145 ii.hbmMask = im;
146 ii.hbmColor = ic;
147
148 cur = CreateIconIndirect(&ii);
149
150 DeleteObject(ic);
151 DeleteObject(im);
152#elif defined(GWES_ICONCURS)
153 QImage bbits, mbits;
154 bool invb, invm;
155 bbits = pixmap.toImage().convertToFormat(QImage::Format_Mono);
156 mbits = pixmap.toImage().convertToFormat(QImage::Format_Mono);
157 invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1));
158 invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1));
159
160 int sysW = GetSystemMetrics(SM_CXCURSOR);
161 int sysH = GetSystemMetrics(SM_CYCURSOR);
162 int sysN = qMax(1, sysW / 8);
163 int n = qMax(1, bbits.width() / 8);
164 int h = bbits.height();
165
166 uchar* xBits = new uchar[sysH * sysN];
167 uchar* xMask = new uchar[sysH * sysN];
168 int x = 0;
169 for (int i = 0; i < sysH; ++i) {
170 if (i >= h) {
171 memset(&xBits[x] , 255, sysN);
172 memset(&xMask[x] , 0, sysN);
173 x += sysN;
174 } else {
175 int fillWidth = n > sysN ? sysN : n;
176 uchar *bits = bbits.scanLine(i);
177 uchar *mask = mbits.scanLine(i);
178 for (int j = 0; j < fillWidth; ++j) {
179 uchar b = bits[j];
180 uchar m = mask[j];
181 if (invb)
182 b ^= 0xFF;
183 if (invm)
184 m ^= 0xFF;
185 xBits[x] = ~m;
186 xMask[x] = b ^ m;
187 ++x;
188 }
189 for (int j = fillWidth; j < sysN; ++j ) {
190 xBits[x] = 255;
191 xMask[x] = 0;
192 ++x;
193 }
194 }
195 }
196
197 cur = CreateCursor(qWinAppInst(), hx, hy, sysW, sysH,
198 xBits, xMask);
199#else
200 Q_UNUSED(pixmap);
201 Q_UNUSED(hx);
202 Q_UNUSED(hy);
203#endif
204 return cur;
205}
206
207void QCursorData::update()
208{
209 if (!QCursorData::initialized)
210 QCursorData::initialize();
211 if (hcurs)
212 return;
213
214 if (cshape == Qt::BitmapCursor && !pixmap.isNull()) {
215 hcurs = create32BitCursor(pixmap, hx, hy);
216 if (hcurs)
217 return;
218 }
219
220
221 // Non-standard Windows cursors are created from bitmaps
222
223 static const uchar vsplit_bits[] = {
224 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
225 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
226 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
227 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
228 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
229 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
230 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
231 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
232 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
233 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
234 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
235 static const uchar vsplitm_bits[] = {
236 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
237 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
238 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
239 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
240 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
241 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
242 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
243 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00,
244 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
245 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
246 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
247 static const uchar hsplit_bits[] = {
248 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
249 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
250 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
251 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
252 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03,
253 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00,
254 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
255 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
256 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 hsplitm_bits[] = {
260 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
261 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
262 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
263 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00,
264 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
265 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00,
266 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
267 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
268 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 static const uchar phand_bits[] = {
272 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00,
273 0x80, 0x04, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00,
274 0x80, 0x1c, 0x00, 0x00, 0x80, 0xe4, 0x00, 0x00, 0x80, 0x24, 0x03, 0x00,
275 0x80, 0x24, 0x05, 0x00, 0xb8, 0x24, 0x09, 0x00, 0xc8, 0x00, 0x09, 0x00,
276 0x88, 0x00, 0x08, 0x00, 0x90, 0x00, 0x08, 0x00, 0xa0, 0x00, 0x08, 0x00,
277 0x20, 0x00, 0x08, 0x00, 0x40, 0x00, 0x08, 0x00, 0x40, 0x00, 0x04, 0x00,
278 0x80, 0x00, 0x04, 0x00, 0x80, 0x00, 0x04, 0x00, 0x00, 0x01, 0x02, 0x00,
279 0x00, 0x01, 0x02, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
280 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 };
283
284 static const uchar phandm_bits[] = {
285 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00,
286 0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00,
287 0x80, 0x1f, 0x00, 0x00, 0x80, 0xff, 0x00, 0x00, 0x80, 0xff, 0x03, 0x00,
288 0x80, 0xff, 0x07, 0x00, 0xb8, 0xff, 0x0f, 0x00, 0xf8, 0xff, 0x0f, 0x00,
289 0xf8, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0x0f, 0x00, 0xe0, 0xff, 0x0f, 0x00,
290 0xe0, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0x07, 0x00,
291 0x80, 0xff, 0x07, 0x00, 0x80, 0xff, 0x07, 0x00, 0x00, 0xff, 0x03, 0x00,
292 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x03, 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
297 static const uchar openhand_bits[] = {
298 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
299 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
300 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00};
301 static const uchar openhandm_bits[] = {
302 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff,
303 0xf6,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f,
304 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00};
305 static const uchar closedhand_bits[] = {
306 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50,
307 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,
308 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00};
309 static const uchar closedhandm_bits[] = {
310 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,
311 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
312 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
313
314 static const uchar * const cursor_bits32[] = {
315 vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits,
316 phand_bits, phandm_bits
317 };
318
319 wchar_t *sh = 0;
320 switch (cshape) { // map to windows cursor
321 case Qt::ArrowCursor:
322 sh = IDC_ARROW;
323 break;
324 case Qt::UpArrowCursor:
325 sh = IDC_UPARROW;
326 break;
327 case Qt::CrossCursor:
328 sh = IDC_CROSS;
329 break;
330 case Qt::WaitCursor:
331 sh = IDC_WAIT;
332 break;
333 case Qt::IBeamCursor:
334 sh = IDC_IBEAM;
335 break;
336 case Qt::SizeVerCursor:
337 sh = IDC_SIZENS;
338 break;
339 case Qt::SizeHorCursor:
340 sh = IDC_SIZEWE;
341 break;
342 case Qt::SizeBDiagCursor:
343 sh = IDC_SIZENESW;
344 break;
345 case Qt::SizeFDiagCursor:
346 sh = IDC_SIZENWSE;
347 break;
348 case Qt::SizeAllCursor:
349 sh = IDC_SIZEALL;
350 break;
351 case Qt::ForbiddenCursor:
352 sh = IDC_NO;
353 break;
354 case Qt::WhatsThisCursor:
355 sh = IDC_HELP;
356 break;
357 case Qt::BusyCursor:
358 sh = IDC_APPSTARTING;
359 break;
360 case Qt::PointingHandCursor:
361 sh = IDC_HAND;
362 break;
363 case Qt::BlankCursor:
364 case Qt::SplitVCursor:
365 case Qt::SplitHCursor:
366 case Qt::OpenHandCursor:
367 case Qt::ClosedHandCursor:
368 case Qt::BitmapCursor: {
369 QImage bbits, mbits;
370 bool invb, invm;
371 if (cshape == Qt::BlankCursor) {
372 bbits = QImage(32, 32, QImage::Format_Mono);
373 bbits.fill(0); // ignore color table
374 mbits = bbits.copy();
375 hx = hy = 16;
376 invb = invm = false;
377 } else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) {
378 bool open = cshape == Qt::OpenHandCursor;
379 QBitmap cb = QBitmap::fromData(QSize(16, 16), open ? openhand_bits : closedhand_bits);
380 QBitmap cm = QBitmap::fromData(QSize(16, 16), open ? openhandm_bits : closedhandm_bits);
381 bbits = cb.toImage().convertToFormat(QImage::Format_Mono);
382 mbits = cm.toImage().convertToFormat(QImage::Format_Mono);
383 hx = hy = 8;
384 invb = invm = false;
385 } else if (cshape != Qt::BitmapCursor) {
386 int i = cshape - Qt::SplitVCursor;
387 QBitmap cb = QBitmap::fromData(QSize(32, 32), cursor_bits32[i * 2]);
388 QBitmap cm = QBitmap::fromData(QSize(32, 32), cursor_bits32[i * 2 + 1]);
389 bbits = cb.toImage().convertToFormat(QImage::Format_Mono);
390 mbits = cm.toImage().convertToFormat(QImage::Format_Mono);
391 if (cshape == Qt::PointingHandCursor) {
392 hx = 7;
393 hy = 0;
394 } else
395 hx = hy = 16;
396 invb = invm = false;
397 } else {
398 bbits = bm->toImage().convertToFormat(QImage::Format_Mono);
399 mbits = bmm->toImage().convertToFormat(QImage::Format_Mono);
400 invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1));
401 invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1));
402 }
403 int n = qMax(1, bbits.width() / 8);
404 int h = bbits.height();
405#if !defined(Q_WS_WINCE)
406 uchar* xBits = new uchar[h * n];
407 uchar* xMask = new uchar[h * n];
408 int x = 0;
409 for (int i = 0; i < h; ++i) {
410 uchar *bits = bbits.scanLine(i);
411 uchar *mask = mbits.scanLine(i);
412 for (int j = 0; j < n; ++j) {
413 uchar b = bits[j];
414 uchar m = mask[j];
415 if (invb)
416 b ^= 0xff;
417 if (invm)
418 m ^= 0xff;
419 xBits[x] = ~m;
420 xMask[x] = b ^ m;
421 ++x;
422 }
423 }
424 hcurs = CreateCursor(qWinAppInst(), hx, hy, bbits.width(), bbits.height(),
425 xBits, xMask);
426 delete [] xBits;
427 delete [] xMask;
428#elif defined(GWES_ICONCURS) // Q_WS_WINCE
429 // Windows CE only supports fixed cursor size.
430 int sysW = GetSystemMetrics(SM_CXCURSOR);
431 int sysH = GetSystemMetrics(SM_CYCURSOR);
432 int sysN = qMax(1, sysW / 8);
433 uchar* xBits = new uchar[sysH * sysN];
434 uchar* xMask = new uchar[sysH * sysN];
435 int x = 0;
436 for (int i = 0; i < sysH; ++i) {
437 if (i >= h) {
438 memset(&xBits[x] , 255, sysN);
439 memset(&xMask[x] , 0, sysN);
440 x += sysN;
441 } else {
442 int fillWidth = n > sysN ? sysN : n;
443 uchar *bits = bbits.scanLine(i);
444 uchar *mask = mbits.scanLine(i);
445 for (int j = 0; j < fillWidth; ++j) {
446 uchar b = bits[j];
447 uchar m = mask[j];
448 if (invb)
449 b ^= 0xFF;
450 if (invm)
451 m ^= 0xFF;
452 xBits[x] = ~m;
453 xMask[x] = b ^ m;
454 ++x;
455 }
456 for (int j = fillWidth; j < sysN; ++j ) {
457 xBits[x] = 255;
458 xMask[x] = 0;
459 ++x;
460 }
461 }
462 }
463
464 hcurs = CreateCursor(qWinAppInst(), hx, hy, sysW, sysH,
465 xBits, xMask);
466 delete [] xBits;
467 delete [] xMask;
468#else
469 Q_UNUSED(n);
470 Q_UNUSED(h);
471#endif
472 return;
473 }
474 case Qt::DragCopyCursor:
475 case Qt::DragMoveCursor:
476 case Qt::DragLinkCursor: {
477 QPixmap pixmap = QApplicationPrivate::instance()->getPixmapCursor(cshape);
478 hcurs = create32BitCursor(pixmap, hx, hy);
479 }
480 default:
481 qWarning("QCursor::update: Invalid cursor shape %d", cshape);
482 return;
483 }
484#ifdef Q_WS_WINCE
485 hcurs = LoadCursor(0, sh);
486#else
487 hcurs = (HCURSOR)LoadImage(0, sh, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
488#endif
489}
490
491QT_END_NAMESPACE
492#endif // QT_NO_CURSOR
Note: See TracBrowser for help on using the repository browser.