1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QCURSOR_H
5#define QCURSOR_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtCore/qpoint.h>
9#include <QtGui/qwindowdefs.h>
10#include <QtGui/qbitmap.h>
11
12QT_BEGIN_NAMESPACE
13
14
15class QVariant;
16class QScreen;
17
18/*
19 ### The fake cursor has to go first with old qdoc.
20*/
21#ifdef QT_NO_CURSOR
22
23class Q_GUI_EXPORT QCursor
24{
25public:
26 static QPoint pos();
27 static QPoint pos(const QScreen *screen);
28 static void setPos(int x, int y);
29 static void setPos(QScreen *screen, int x, int y);
30 inline static void setPos(const QPoint &p) { setPos(p.x(), p.y()); }
31private:
32 QCursor();
33};
34
35#endif // QT_NO_CURSOR
36
37#ifndef QT_NO_CURSOR
38
39class QCursorData;
40class QBitmap;
41class QPixmap;
42
43
44class Q_GUI_EXPORT QCursor
45{
46public:
47 QCursor();
48 QCursor(Qt::CursorShape shape);
49 QCursor(const QBitmap &bitmap, const QBitmap &mask, int hotX=-1, int hotY=-1);
50 explicit QCursor(const QPixmap &pixmap, int hotX=-1, int hotY=-1);
51 QCursor(const QCursor &cursor);
52 ~QCursor();
53 QCursor &operator=(const QCursor &cursor);
54 QCursor(QCursor &&other) noexcept : d(std::exchange(obj&: other.d, new_val: nullptr)) {}
55 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QCursor)
56
57 void swap(QCursor &other) noexcept { qt_ptr_swap(lhs&: d, rhs&: other.d); }
58
59 operator QVariant() const;
60
61 Qt::CursorShape shape() const;
62 void setShape(Qt::CursorShape newShape);
63
64#if QT_DEPRECATED_SINCE(6, 0)
65 QT_DEPRECATED_VERSION_X_6_0("Use the overload without argument instead.")
66 QBitmap bitmap(Qt::ReturnByValueConstant) const { return bitmap(); }
67 QT_DEPRECATED_VERSION_X_6_0("Use the overload without argument instead.")
68 QBitmap mask(Qt::ReturnByValueConstant) const { return mask(); }
69#endif // QT_DEPRECATED_SINCE(6, 0)
70 QBitmap bitmap() const;
71 QBitmap mask() const;
72
73 QPixmap pixmap() const;
74 QPoint hotSpot() const;
75
76 static QPoint pos();
77 static QPoint pos(const QScreen *screen);
78 static void setPos(int x, int y);
79 static void setPos(QScreen *screen, int x, int y);
80 inline static void setPos(const QPoint &p) { setPos(x: p.x(), y: p.y()); }
81 inline static void setPos(QScreen *screen, const QPoint &p) { setPos(screen, x: p.x(), y: p.y()); }
82
83private:
84 friend Q_GUI_EXPORT bool operator==(const QCursor &lhs, const QCursor &rhs) noexcept;
85 friend inline bool operator!=(const QCursor &lhs, const QCursor &rhs) noexcept { return !(lhs == rhs); }
86 QCursorData *d;
87};
88Q_DECLARE_SHARED(QCursor)
89
90/*****************************************************************************
91 QCursor stream functions
92 *****************************************************************************/
93#ifndef QT_NO_DATASTREAM
94Q_GUI_EXPORT QDataStream &operator<<(QDataStream &outS, const QCursor &cursor);
95Q_GUI_EXPORT QDataStream &operator>>(QDataStream &inS, QCursor &cursor);
96#endif
97
98#ifndef QT_NO_DEBUG_STREAM
99Q_GUI_EXPORT QDebug operator<<(QDebug, const QCursor &);
100#endif
101
102#endif // QT_NO_CURSOR
103
104QT_END_NAMESPACE
105
106#endif // QCURSOR_H
107

source code of qtbase/src/gui/kernel/qcursor.h