23 #import "precompiled.h"
26 #import <AppKit/NSCursor.h>
27 #import <AppKit/NSImage.h>
28 #import <ApplicationServices/ApplicationServices.h>
33 NSBitmapImageRep* bitmap = [[NSBitmapImageRep alloc]
34 initWithBitmapDataPlanes:0 pixelsWide:w pixelsHigh:h
35 bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO
36 colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:w*4 bitsPerPixel:0];
39 debug_printf(L
"sys_cursor_create: Error creating NSBitmapImageRep!\n");
44 [bitmap getBitmapDataPlanes:planes];
45 const u8* bgra =
static_cast<const u8*
>(bgra_img);
47 for (
int i = 0; i < w*h*4; i += 4)
55 NSImage* image = [[NSImage alloc] init];
59 debug_printf(L
"sys_cursor_create: Error creating NSImage!\n");
63 [image addRepresentation:bitmap];
65 NSCursor* impl = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(hx, hy)];
70 debug_printf(L
"sys_cursor_create: Error creating NSCursor!\n");
81 NSCursor* impl =
static_cast<NSCursor*
>(cursor);
88 static u8 empty_bgra[] = {0, 0, 0, 0};
95 NSCursor* impl =
static_cast<NSCursor*
>(cursor);
Status sys_cursor_create(int w, int h, void *bgra_img, int hx, int hy, sys_cursor *cursor)
Create a cursor from the given color image.
Status sys_cursor_reset()
reset any cached cursor data.
Status sys_cursor_create_empty(sys_cursor *cursor)
Create a transparent cursor (used to hide the system cursor).
i64 Status
Error handling system.
Status sys_cursor_set(sys_cursor cursor)
override the current system cursor.
Status sys_cursor_free(sys_cursor cursor)
destroy the indicated cursor and frees its resources.
void debug_printf(const wchar_t *fmt,...)
write a formatted string to the debug channel, subject to filtering (see below).