10#include <QtGui/private/qcoregraphics_p.h>
12#include <QtGui/QBitmap>
14#if !defined(QT_APPLE_NO_PRIVATE_APIS)
16+ (
id)_windowResizeNorthWestSouthEastCursor;
17+ (
id)_windowResizeNorthEastSouthWestCursor;
18+ (
id)_windowResizeNorthSouthCursor;
19+ (
id)_windowResizeEastWestCursor;
43 NSCursor *cocoaCursor = convertCursor(
cursor);
46 static_cast<QCocoaWindow *
>(platformWindow)->setWindowCursor(cocoaCursor);
60 CGEventRef
e = CGEventCreateMouseEvent(
nullptr, kCGEventMouseMoved,
pos, kCGMouseButtonLeft);
61 CGEventPost(kCGHIDEventTap,
e);
68 NSCursor *cocoaCursor = NSCursor.currentSystemCursor;
71 NSImage *cursorImage = cocoaCursor.image;
75 QSizeF size = QSizeF::fromCGSize(cursorImage.size);
76 NSUserDefaults *
defaults = NSUserDefaults.standardUserDefaults;
77 NSDictionary *accessSettings = [defaults persistentDomainForName:@"com.apple.universalaccess"];
78 if (accessSettings == nil)
81 float sizeScale = [accessSettings[@"mouseDriverCursorSize"] floatValue];
83 size.rwidth() *= sizeScale;
84 size.rheight() *= sizeScale;
96 NSCursor *cocoaCursor = nil;
101 cocoaCursor= [NSCursor arrowCursor];
104 cocoaCursor = [NSCursor operationNotAllowedCursor];
107 cocoaCursor = [NSCursor crosshairCursor];
110 cocoaCursor = [NSCursor IBeamCursor];
114 cocoaCursor = [NSCursor pointingHandCursor];
117 cocoaCursor = [NSCursor resizeUpDownCursor];
120 cocoaCursor = [NSCursor resizeLeftRightCursor];
123 cocoaCursor = [NSCursor openHandCursor];
126 cocoaCursor = [NSCursor closedHandCursor];
129 cocoaCursor = [NSCursor crosshairCursor];
132 cocoaCursor = [NSCursor dragCopyCursor];
135 cocoaCursor = [NSCursor dragLinkCursor];
137#if !defined(QT_APPLE_NO_PRIVATE_APIS)
139 if ([NSCursor respondsToSelector:@
selector(_windowResizeNorthSouthCursor)])
140 cocoaCursor = [NSCursor _windowResizeNorthSouthCursor];
143 if ([NSCursor respondsToSelector:@
selector(_windowResizeEastWestCursor)])
144 cocoaCursor = [NSCursor _windowResizeEastWestCursor];
147 if ([NSCursor respondsToSelector:@
selector(_windowResizeNorthEastSouthWestCursor)])
148 cocoaCursor = [NSCursor _windowResizeNorthEastSouthWestCursor];
151 if ([NSCursor respondsToSelector:@
selector(_windowResizeNorthWestSouthEastCursor)])
152 cocoaCursor = [NSCursor _windowResizeNorthWestSouthEastCursor];
162 cocoaCursor = m_cursors.
value(newShape);
164 [cocoaCursor release];
168 cocoaCursor = createCursorData(
cursor);
170 return [NSCursor arrowCursor];
172 m_cursors.
insert(newShape, cocoaCursor);
189#define QT_USE_APPROXIMATE_CURSORS
190#ifdef QT_USE_APPROXIMATE_CURSORS
192 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0,
193 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x0f, 0xf0,
194 0x07, 0xe0, 0x03, 0xc0, 0x01, 0x80, 0x00, 0x00 };
196 0x00, 0x00, 0x03, 0x80, 0x07, 0xc0, 0x0f, 0xe0, 0x1f, 0xf0, 0x3f, 0xf8,
197 0x7f, 0xfc, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x7f, 0xfc, 0x3f, 0xf8,
198 0x1f, 0xf0, 0x0f, 0xe0, 0x07, 0xc0, 0x03, 0x80 };
201 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x20, 0x18, 0x30,
202 0x38, 0x38, 0x7f, 0xfc, 0x7f, 0xfc, 0x38, 0x38, 0x18, 0x30, 0x08, 0x20,
203 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
205 0x00, 0x00, 0x00, 0x00, 0x04, 0x40, 0x0c, 0x60, 0x1c, 0x70, 0x3c, 0x78,
206 0x7f, 0xfc, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0x7f, 0xfc, 0x3c, 0x78,
207 0x1c, 0x70, 0x0c, 0x60, 0x04, 0x40, 0x00, 0x00 };
210 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf8, 0x00, 0xf8, 0x00, 0x78,
211 0x00, 0xf8, 0x01, 0xd8, 0x23, 0x88, 0x37, 0x00, 0x3e, 0x00, 0x3c, 0x00,
212 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00 };
214 0x00, 0x00, 0x00, 0x00, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, 0xfc,
215 0x41, 0xfc, 0x63, 0xfc, 0x77, 0xdc, 0x7f, 0x8c, 0x7f, 0x04, 0x7e, 0x00,
216 0x7f, 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x00, 0x00 };
219 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, 0x00,
220 0x37, 0x00, 0x23, 0x88, 0x01, 0xd8, 0x00, 0xf8, 0x00, 0x78, 0x00, 0xf8,
221 0x01, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
223 0x00, 0x00, 0x7f, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7e, 0x00, 0x7f, 0x04,
224 0x7f, 0x8c, 0x77, 0xdc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, 0xfc,
225 0x03, 0xfc, 0x07, 0xfc, 0x00, 0x00, 0x00, 0x00 };
228 0x00, 0x80, 0x01, 0x40, 0x01, 0x40, 0x02, 0x20, 0x02, 0x20, 0x04, 0x10,
229 0x04, 0x10, 0x08, 0x08, 0x0f, 0x78, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40,
230 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0 };
232 0x00, 0x80, 0x01, 0xc0, 0x01, 0xc0, 0x03, 0xe0, 0x03, 0xe0, 0x07, 0xf0,
233 0x07, 0xf0, 0x0f, 0xf8, 0x0f, 0xf8, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0,
234 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0 };
236 const uchar *cursorData =
nullptr;
237 const uchar *cursorMaskData =
nullptr;
245 return createCursorFromPixmap(
cursor->
pixmap(), hotspot);
250 return createCursorFromPixmap(
pixmap);
254 return createCursorFromPixmap(
pixmap, hotspot);
262 return createCursorFromPixmap(
pixmap, hotspot);
264#define QT_USE_APPROXIMATE_CURSORS
265#ifdef QT_USE_APPROXIMATE_CURSORS
301 return (createCursorFromBitmap(
bitmap,
mask, hotspot));
312 for (
int row = 0;
row < finalCursor.height(); ++
row) {
315 QRgb *finalData =
reinterpret_cast<QRgb *
>(finalCursor.scanLine(
row));
316 for (
int col = 0; col < finalCursor.width(); ++col) {
317 if (bmmData[col] == 0xff000000 && bmData[col] == 0xffffffff) {
318 finalData[col] = 0xffffffff;
319 }
else if (bmmData[col] == 0xff000000 && bmData[col] == 0xffffffff) {
320 finalData[col] = 0x7f000000;
321 }
else if (bmmData[col] == 0xffffffff && bmData[col] == 0xffffffff) {
322 finalData[col] = 0x00000000;
324 finalData[col] = 0xff000000;
334 NSPoint hotSpot = NSMakePoint(hotspot.
x(), hotspot.
y());
335 auto *
image = [NSImage imageFromQImage:pixmap.toImage()];
336 return [[NSCursor alloc] initWithImage:image hotSpot:hotSpot];
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.
void setPos(const QPoint &position) override
void changeCursor(QCursor *cursor, QWindow *window) override
This method is called by Qt whenever the cursor graphic should be changed.
QSize size() const override
Returns the size of the cursor, in native pixels.
QPoint pos() const override
static QPointF mapFromNative(CGPoint pos, QCocoaScreen *screen=QCocoaScreen::primaryScreen())
The QCursor class provides a mouse cursor with an arbitrary shape.
QBitmap bitmap() const
Returns the cursor bitmap, or a null bitmap if it is one of the standard cursors.
QPixmap pixmap() const
Returns the cursor pixmap.
Qt::CursorShape shape() const
Returns the cursor shape identifier.
QPoint hotSpot() const
Returns the cursor hot spot, or (0, 0) if it is one of the standard cursors.
QBitmap mask() const
Returns the cursor bitmap mask, or a null bitmap if it is one of the standard cursors.
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
const_iterator constBegin() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
T value(const Key &key) const noexcept
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const &
Native interface for QPlatformWindow on \macos. \inmodule QtGui.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
Combined button and popup list for selecting options.
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
GLenum GLenum GLsizei void * row
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
QFile defaults(defaultsPath)
QFileSelector selector
[1]