Qt 4.8
Classes | Functions
qcursor.h File Reference
#include <QtCore/qpoint.h>
#include <QtGui/qwindowdefs.h>

Go to the source code of this file.

Classes

class  QCursor
 The QCursor class provides a mouse cursor with an arbitrary shape. More...
 

Functions

Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &outS, const QCursor &cursor)
 
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &inS, QCursor &cursor)
 
void qt_mac_set_cursor (const QCursor *c)
 

Function Documentation

◆ operator<<()

Q_GUI_EXPORT QDataStream& operator<< ( QDataStream outS,
const QCursor cursor 
)
related

Definition at line 255 of file qcursor.cpp.

256 {
257  s << (qint16)c.shape(); // write shape id to stream
258  if (c.shape() == Qt::BitmapCursor) { // bitmap cursor
259  bool isPixmap = false;
260  if (s.version() >= 7) {
261  isPixmap = !c.pixmap().isNull();
262  s << isPixmap;
263  }
264  if (isPixmap)
265  s << c.pixmap();
266  else
267  s << *c.bitmap() << *c.mask();
268  s << c.hotSpot();
269  }
270  return s;
271 }
unsigned char c[8]
Definition: qnumeric_p.h:62
short qint16
Definition: qglobal.h:935

◆ operator>>()

Q_GUI_EXPORT QDataStream& operator>> ( QDataStream inS,
QCursor cursor 
)
related

Definition at line 285 of file qcursor.cpp.

286 {
287  qint16 shape;
288  s >> shape; // read shape id from stream
289  if (shape == Qt::BitmapCursor) { // read bitmap cursor
290  bool isPixmap = false;
291  if (s.version() >= 7)
292  s >> isPixmap;
293  if (isPixmap) {
294  QPixmap pm;
295  QPoint hot;
296  s >> pm >> hot;
297  c = QCursor(pm, hot.x(), hot.y());
298  } else {
299  QBitmap bm, bmm;
300  QPoint hot;
301  s >> bm >> bmm >> hot;
302  c = QCursor(bm, bmm, hot.x(), hot.y());
303  }
304  } else {
305  c.setShape((Qt::CursorShape)shape); // create cursor with shape
306  }
307  return s;
308 }
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
unsigned char c[8]
Definition: qnumeric_p.h:62
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
short qint16
Definition: qglobal.h:935
CursorShape
Definition: qnamespace.h:1262
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71

◆ qt_mac_set_cursor()

void qt_mac_set_cursor ( const QCursor c)

Definition at line 108 of file qcursor_mac.mm.

Referenced by qt_mac_updateCursorWithWidgetUnderMouse().

109 {
110 #ifdef QT_MAC_USE_COCOA
112  [static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(*c)) set];
113 #else
114  if (!c) {
115  currentCursor = 0;
116  return;
117  }
118  c->handle(); //force the cursor to get loaded, if it's not
119 
120  if(currentCursor && currentCursor->type == QCursorData::TYPE_ThemeCursor
121  && currentCursor->curs.tc.anim)
122  currentCursor->curs.tc.anim->stop();
123  if(c->d->type == QCursorData::TYPE_ImageCursor) {
124  [static_cast<NSCursor *>(c->d->curs.cp.nscursor) set];
125  } else if(c->d->type == QCursorData::TYPE_ThemeCursor) {
126  if(SetAnimatedThemeCursor(c->d->curs.tc.curs, 0) == themeBadCursorIndexErr) {
127  SetThemeCursor(c->d->curs.tc.curs);
128  } else {
129  if(!c->d->curs.tc.anim)
130  c->d->curs.tc.anim = new QMacAnimateCursor;
131  c->d->curs.tc.anim->start(c->d->curs.tc.curs);
132  }
133  }
134 
135  currentCursor = c->d;
136 #endif
137 }
HCURSOR_or_HANDLE handle() const
Returns a platform-specific cursor handle.
Definition: qcursor_mac.mm:301
void * qt_mac_nsCursorForQCursor(const QCursor &c)
Definition: qcursor_mac.mm:100
static QCursorData * currentCursor
Definition: qcursor_mac.mm:106
QCursorData * d
Definition: qcursor.h:141