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 | #ifndef QPLATFORMCURSOR_H |
4 | #define QPLATFORMCURSOR_H |
5 | |
6 | // |
7 | // W A R N I N G |
8 | // ------------- |
9 | // |
10 | // This file is part of the QPA API and is not meant to be used |
11 | // in applications. Usage of this API may make your code |
12 | // source and binary incompatible with future versions of Qt. |
13 | // |
14 | |
15 | #include <QtGui/qtguiglobal.h> |
16 | #include <QtCore/QList> |
17 | #include <QtGui/QImage> |
18 | #include <QtGui/QMouseEvent> |
19 | #include <QtCore/QWeakPointer> |
20 | #include <QtCore/QObject> |
21 | #include <qpa/qplatformscreen.h> |
22 | #include <QtGui/QCursor> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | |
27 | // Cursor graphics management |
28 | class Q_GUI_EXPORT QPlatformCursorImage { |
29 | public: |
30 | QPlatformCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) |
31 | { set(data, mask, width, height, hotX, hotY); } |
32 | QImage * image() { return &cursorImage; } |
33 | QPoint hotspot() const { return hot; } |
34 | void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); |
35 | void set(const QImage &image, int hx, int hy); |
36 | void set(Qt::CursorShape); |
37 | private: |
38 | static void createSystemCursor(int id); |
39 | QImage cursorImage; |
40 | QPoint hot; |
41 | }; |
42 | |
43 | class Q_GUI_EXPORT QPlatformCursor : public QObject { |
44 | public: |
45 | Q_DISABLE_COPY_MOVE(QPlatformCursor) |
46 | |
47 | enum Capability { |
48 | OverrideCursor = 0x1 |
49 | }; |
50 | Q_DECLARE_FLAGS(Capabilities, Capability) |
51 | |
52 | QPlatformCursor(); |
53 | |
54 | // input methods |
55 | virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } |
56 | #ifndef QT_NO_CURSOR |
57 | virtual void changeCursor(QCursor * windowCursor, QWindow * window) = 0; |
58 | virtual void setOverrideCursor(const QCursor &); |
59 | virtual void clearOverrideCursor(); |
60 | #endif // QT_NO_CURSOR |
61 | virtual QPoint pos() const; |
62 | virtual void setPos(const QPoint &pos); |
63 | virtual QSize size() const; |
64 | |
65 | static Capabilities capabilities() { return m_capabilities; } |
66 | static void setCapabilities(Capabilities c) { m_capabilities = c; } |
67 | static void setCapability(Capability c) { m_capabilities.setFlag(flag: c); } |
68 | |
69 | private: |
70 | friend void qt_qpa_set_cursor(QWidget * w, bool force); |
71 | friend class QApplicationPrivate; |
72 | |
73 | static Capabilities m_capabilities; |
74 | }; |
75 | |
76 | Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformCursor::Capabilities) |
77 | |
78 | QT_END_NAMESPACE |
79 | |
80 | #endif // QPLATFORMCURSOR_H |
81 | |