Qt 4.8
qcursor_win.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
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 
53 
54 /*****************************************************************************
55  Internal QCursorData class
56  *****************************************************************************/
57 
59  : cshape(s), bm(0), bmm(0), hx(0), hy(0), hcurs(0)
60 {
61  ref = 1;
62 }
63 
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 
75 QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
76 {
79  if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) {
80  qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)");
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;
90  d->hx = hotX >= 0 ? hotX : bitmap.width()/2;
91  d->hy = hotY >= 0 ? hotY : bitmap.height()/2;
92  return d;
93 }
94 
96 {
99  if (!d->hcurs)
100  d->update();
101  return d->hcurs;
102 }
103 
105 {
106  d = new QCursorData(Qt::CustomCursor);
107  d->hcurs = handle;
108 }
109 
110 #endif //QT_NO_CURSOR
111 
113 {
114  POINT p;
115  GetCursorPos(&p);
116  return QPoint(p.x, p.y);
117 }
118 
119 void QCursor::setPos(int x, int y)
120 {
121  SetCursorPos(x, y);
122 }
123 
124 #ifndef QT_NO_CURSOR
125 
126 extern HBITMAP qt_createIconMask(const QBitmap &bitmap);
127 
128 static 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 
207 void QCursorData::update()
208 {
211  if (hcurs)
212  return;
213 
214  if (cshape == Qt::BitmapCursor && !pixmap.isNull()) {
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[] = {
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;
361  sh = IDC_HAND;
362  break;
363  case Qt::BlankCursor:
364  case Qt::SplitVCursor:
365  case Qt::SplitHCursor:
366  case Qt::OpenHandCursor:
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;
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);
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]);
392  hx = 7;
393  hy = 0;
394  } else
395  hx = hy = 16;
396  invb = invm = false;
397  } else {
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: {
478  hcurs = create32BitCursor(pixmap, hx, hy);
479  }
480  return;
481  default:
482  qWarning("QCursor::update: Invalid cursor shape %d", cshape);
483  return;
484  }
485 #ifdef Q_WS_WINCE
486  hcurs = LoadCursor(0, sh);
487 #else
488  hcurs = (HCURSOR)LoadImage(0, sh, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
489 #endif
490 }
491 
493 #endif // QT_NO_CURSOR
HCURSOR_or_HANDLE handle() const
Returns a platform-specific cursor handle.
Definition: qcursor_mac.mm:301
double d
Definition: qnumeric_p.h:62
QImage toImage() const
Converts the pixmap to a QImage.
Definition: qpixmap.cpp:542
static const uchar hsplit_bits[]
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
Definition: qimage.cpp:1410
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
static const uchar closedhandm_bits[]
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
static const uchar phand_bits[]
#define IDC_IBEAM
static const uchar vsplit_bits[]
short hy
Definition: qcursor_p.h:91
#define IDC_SIZENWSE
QPixmap pixmap
Definition: qcursor_p.h:90
HICON HCURSOR
#define LR_SHARED
Definition: qt_windows.h:147
static const uchar openhandm_bits[]
void fill(uint pixel)
Fills the entire image with the given pixelValue.
Definition: qimage.cpp:2032
#define IDC_WAIT
static QBitmap fromData(const QSize &size, const uchar *bits, QImage::Format monoFormat=QImage::Format_MonoLSB)
Constructs a bitmap with the given size, and sets the contents to the bits supplied.
Definition: qbitmap.cpp:318
static const uchar openhand_bits[]
static QApplicationPrivate * instance()
#define IDC_SIZENESW
bool ref()
Atomically increments the value of this QAtomicInt.
static bool initialized
Definition: qcursor_p.h:125
int depth() const
Returns the depth of the pixmap.
Definition: qpixmap.cpp:695
#define IDC_ARROW
static void setPos(int x, int y)
Moves the cursor (hot spot) to the global screen position (x, y).
Definition: qcursor_mac.mm:315
#define IDC_APPSTARTING
#define IDC_SIZEALL
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
static const uchar closedhand_bits[]
static const uchar phandm_bits[]
HCURSOR hcurs
Definition: qcursor_p.h:98
static HCURSOR create32BitCursor(const QPixmap &pixmap, int hx, int hy)
static QCursorData * setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
Definition: qcursor_mac.mm:278
unsigned char uchar
Definition: qglobal.h:994
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static const uchar hsplitm_bits[]
#define IDC_SIZEWE
QCursorData(Qt::CursorShape s=Qt::ArrowCursor)
Definition: qcursor_mac.mm:253
#define IDC_NO
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
QCursorData * qt_cursorTable[Qt::LastCursor+1]
Definition: qcursor.cpp:398
#define LR_DEFAULTSIZE
Definition: qt_windows.h:144
static const uchar vsplitm_bits[]
#define IDC_HAND
Definition: qt_windows.h:113
void update()
Creates the cursor.
Definition: qcursor_mac.mm:387
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition: qpixmap.cpp:1080
Q_GUI_EXPORT_INLINE int qGray(int r, int g, int b)
Definition: qrgb.h:75
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
Qt::CursorShape cshape
Definition: qcursor_p.h:88
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
Definition: qimage.cpp:3966
HBITMAP toWinHBITMAP(HBitmapFormat format=NoAlpha) const
It is the caller&#39;s responsibility to free the HBITMAP data after use.
QBitmap mask() const
Extracts a bitmap mask from the pixmap&#39;s alpha channel.
Definition: qpixmap.cpp:2077
int colorCount() const
Returns the size of the color table for the image.
Definition: qimage.cpp:1656
QPixmap getPixmapCursor(Qt::CursorShape cshape)
CursorShape
Definition: qnamespace.h:1262
#define SM_CYCURSOR
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
short hx
Definition: qcursor_p.h:91
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QBitmap * bmm
Definition: qcursor_p.h:89
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
Q_CORE_EXPORT HINSTANCE qWinAppInst()
HBITMAP qt_createIconMask(const QBitmap &bitmap)
static void initialize()
Definition: qcursor.cpp:417
QAtomicInt ref
Definition: qcursor_p.h:87
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QCursor()
Constructs a cursor with the default arrow shape.
Definition: qcursor.cpp:433
#define IDC_UPARROW
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
#define IDC_SIZENS
#define SM_CXCURSOR
#define IDC_HELP
QBitmap * bm
Definition: qcursor_p.h:89
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QRgb color(int i) const
Returns the color in the color table at index i.
Definition: qimage.cpp:1829
#define IDC_CROSS
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition: qimage.cpp:1886
int open(const char *, int,...)
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310