Qt 4.8
qcursor.h
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 #ifndef QCURSOR_H
43 #define QCURSOR_H
44 
45 #include <QtCore/qpoint.h>
46 #include <QtGui/qwindowdefs.h>
47 
49 
51 
52 QT_MODULE(Gui)
53 
54 class QVariant;
55 
56 /*
57  ### The fake cursor has to go first with old qdoc.
58 */
59 #ifdef QT_NO_CURSOR
60 
62 {
63 public:
64  static QPoint pos();
65  static void setPos(int x, int y);
66  inline static void setPos(const QPoint &p) { setPos(p.x(), p.y()); }
67 private:
68  QCursor();
69 };
70 
71 #endif // QT_NO_CURSOR
72 
73 #ifndef QT_NO_CURSOR
74 
75 class QCursorData;
76 class QBitmap;
77 class QPixmap;
78 
79 #if defined(Q_WS_MAC)
80 void qt_mac_set_cursor(const QCursor *c);
81 #endif
82 #if defined(Q_OS_SYMBIAN)
83 extern void qt_symbian_show_pointer_sprite();
84 extern void qt_symbian_hide_pointer_sprite();
85 extern void qt_symbian_set_pointer_sprite(const QCursor& cursor);
86 extern void qt_symbian_move_cursor_sprite();
87 #endif
88 
90 {
91 public:
92  QCursor();
93  QCursor(Qt::CursorShape shape);
94  QCursor(const QBitmap &bitmap, const QBitmap &mask, int hotX=-1, int hotY=-1);
95  QCursor(const QPixmap &pixmap, int hotX=-1, int hotY=-1);
96  QCursor(const QCursor &cursor);
97  ~QCursor();
98  QCursor &operator=(const QCursor &cursor);
99 #ifdef Q_COMPILER_RVALUE_REFS
100  inline QCursor &operator=(QCursor &&other)
101  { qSwap(d, other.d); return *this; }
102 #endif
103  operator QVariant() const;
104 
105  Qt::CursorShape shape() const;
106  void setShape(Qt::CursorShape newShape);
107 
108  const QBitmap *bitmap() const;
109  const QBitmap *mask() const;
110  QPixmap pixmap() const;
111  QPoint hotSpot() const;
112 
113  static QPoint pos();
114  static void setPos(int x, int y);
115  inline static void setPos(const QPoint &p) { setPos(p.x(), p.y()); }
116 
117 #ifdef qdoc
118  HCURSOR_or_HANDLE handle() const;
119  QCursor(HCURSOR cursor);
120  QCursor(Qt::HANDLE cursor);
121 #endif
122 
123 #ifndef qdoc
124 #if defined(Q_WS_WIN)
125  HCURSOR handle() const;
126  QCursor(HCURSOR cursor);
127 #elif defined(Q_WS_X11)
128  Qt::HANDLE handle() const;
129  QCursor(Qt::HANDLE cursor);
130  static int x11Screen();
131 #elif defined(Q_WS_MAC)
132  Qt::HANDLE handle() const;
133 #elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
134  int handle() const;
135 #elif defined(Q_OS_SYMBIAN)
136  Qt::HANDLE handle() const;
137 #endif
138 #endif
139 
140 private:
142 #if defined(Q_WS_MAC)
143  friend void *qt_mac_nsCursorForQCursor(const QCursor &c);
144  friend void qt_mac_set_cursor(const QCursor *c);
145  friend void qt_mac_updateCursorWithWidgetUnderMouse(QWidget *widgetUnderMouse);
146 #endif
147 #if defined(Q_OS_SYMBIAN)
148  friend void qt_symbian_show_pointer_sprite();
149  friend void qt_symbian_hide_pointer_sprite();
150  friend void qt_symbian_set_pointer_sprite(const QCursor& cursor);
151  friend void qt_symbian_move_cursor_sprite();
152 #endif
153 };
154 
155 #ifdef QT3_SUPPORT
156 // CursorShape is defined in X11/X.h
157 #ifdef CursorShape
158 #define X_CursorShape CursorShape
159 #undef CursorShape
160 #endif
161 typedef Qt::CursorShape QCursorShape;
162 #ifdef X_CursorShape
163 #define CursorShape X_CursorShape
164 #endif
165 #endif
166 
167 /*****************************************************************************
168  QCursor stream functions
169  *****************************************************************************/
170 #ifndef QT_NO_DATASTREAM
171 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &outS, const QCursor &cursor);
173 #endif
174 #endif // QT_NO_CURSOR
175 
177 
179 
180 #endif // QCURSOR_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
void qt_mac_updateCursorWithWidgetUnderMouse(QWidget *widgetUnderMouse)
Definition: qcursor_mac.mm:144
double d
Definition: qnumeric_p.h:62
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
void * qt_mac_nsCursorForQCursor(const QCursor &c)
Definition: qcursor_mac.mm:100
HICON HCURSOR
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
Q_GUI_EXPORT QDataStream & operator<<(QDataStream &outS, const QCursor &cursor)
Definition: qcursor.cpp:255
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
void * HANDLE
Definition: qnamespace.h:1671
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
CursorShape
Definition: qnamespace.h:1262
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QCursorData * d
Definition: qcursor.h:141
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
Q_GUI_EXPORT QDataStream & operator>>(QDataStream &inS, QCursor &cursor)
Definition: qcursor.cpp:285
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
#define QT_END_HEADER
Definition: qglobal.h:137
static void setPos(const QPoint &p)
Moves the cursor (hot spot) to the global screen position at point p.
Definition: qcursor.h:115
void qt_mac_set_cursor(const QCursor *c)
Definition: qcursor_mac.mm:108