Skip to content

Commit 1e5b394

Browse files
foxnneemidoots
authored andcommitted
Add NSCursor
1 parent 236d1f0 commit 1e5b394

File tree

2 files changed

+127
-1
lines changed

2 files changed

+127
-1
lines changed

generator.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -2018,7 +2018,7 @@ fn generateAppKit(generator: anytype) !void {
20182018
// try generator.addInterface("NSCloseCommand");
20192019
try generator.addInterface("NSColor");
20202020
// try generator.addInterface("NSColorSpace");
2021-
// try generator.addInterface("NSCursor");
2021+
try generator.addInterface("NSCursor");
20222022
// try generator.addInterface("NSDraggingItem");
20232023
// try generator.addInterface("NSDrawer");
20242024
// try generator.addInterface("NSEnumerator");

src/app_kit.zig

+126
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,132 @@ pub const Color = opaque {
346346
}
347347
};
348348

349+
pub const Cursor = opaque {
350+
pub const InternalInfo = objc.ExternClass("NSCursor", @This(), ObjectInterface, &.{});
351+
pub const as = InternalInfo.as;
352+
pub const retain = InternalInfo.retain;
353+
pub const release = InternalInfo.release;
354+
pub const autorelease = InternalInfo.autorelease;
355+
pub const new = InternalInfo.new;
356+
pub const alloc = InternalInfo.alloc;
357+
pub const allocInit = InternalInfo.allocInit;
358+
359+
// pub fn initWithImage_hotSpot(self_: *@This(), newImage_: *Image, point_: Point) *@This() {
360+
// return objc.msgSend(self_, "initWithImage:hotSpot:", *@This(), .{ newImage_, point_ });
361+
// }
362+
// pub fn initWithCoder(self_: *@This(), coder_: *Coder) *@This() {
363+
// return objc.msgSend(self_, "initWithCoder:", *@This(), .{coder_});
364+
// }
365+
pub fn hide() void {
366+
return objc.msgSend(@This().InternalInfo.class(), "hide", void, .{});
367+
}
368+
pub fn unhide() void {
369+
return objc.msgSend(@This().InternalInfo.class(), "unhide", void, .{});
370+
}
371+
pub fn setHiddenUntilMouseMoves(flag_: bool) void {
372+
return objc.msgSend(@This().InternalInfo.class(), "setHiddenUntilMouseMoves:", void, .{flag_});
373+
}
374+
pub fn pop() void {
375+
return objc.msgSend(@This().InternalInfo.class(), "pop", void, .{});
376+
}
377+
pub fn push(self_: *@This()) void {
378+
return objc.msgSend(self_, "push", void, .{});
379+
}
380+
// pub fn pop(self_: *@This()) void {
381+
// return objc.msgSend(self_, "pop", void, .{});
382+
// }
383+
pub fn set(self_: *@This()) void {
384+
return objc.msgSend(self_, "set", void, .{});
385+
}
386+
pub fn currentCursor() *Cursor {
387+
return objc.msgSend(@This().InternalInfo.class(), "currentCursor", *Cursor, .{});
388+
}
389+
pub fn currentSystemCursor() *Cursor {
390+
return objc.msgSend(@This().InternalInfo.class(), "currentSystemCursor", *Cursor, .{});
391+
}
392+
pub fn arrowCursor() *Cursor {
393+
return objc.msgSend(@This().InternalInfo.class(), "arrowCursor", *Cursor, .{});
394+
}
395+
pub fn IBeamCursor() *Cursor {
396+
return objc.msgSend(@This().InternalInfo.class(), "IBeamCursor", *Cursor, .{});
397+
}
398+
pub fn pointingHandCursor() *Cursor {
399+
return objc.msgSend(@This().InternalInfo.class(), "pointingHandCursor", *Cursor, .{});
400+
}
401+
pub fn closedHandCursor() *Cursor {
402+
return objc.msgSend(@This().InternalInfo.class(), "closedHandCursor", *Cursor, .{});
403+
}
404+
pub fn openHandCursor() *Cursor {
405+
return objc.msgSend(@This().InternalInfo.class(), "openHandCursor", *Cursor, .{});
406+
}
407+
pub fn resizeLeftCursor() *Cursor {
408+
return objc.msgSend(@This().InternalInfo.class(), "resizeLeftCursor", *Cursor, .{});
409+
}
410+
pub fn resizeRightCursor() *Cursor {
411+
return objc.msgSend(@This().InternalInfo.class(), "resizeRightCursor", *Cursor, .{});
412+
}
413+
pub fn resizeLeftRightCursor() *Cursor {
414+
return objc.msgSend(@This().InternalInfo.class(), "resizeLeftRightCursor", *Cursor, .{});
415+
}
416+
pub fn resizeUpCursor() *Cursor {
417+
return objc.msgSend(@This().InternalInfo.class(), "resizeUpCursor", *Cursor, .{});
418+
}
419+
pub fn resizeDownCursor() *Cursor {
420+
return objc.msgSend(@This().InternalInfo.class(), "resizeDownCursor", *Cursor, .{});
421+
}
422+
pub fn resizeUpDownCursor() *Cursor {
423+
return objc.msgSend(@This().InternalInfo.class(), "resizeUpDownCursor", *Cursor, .{});
424+
}
425+
pub fn crosshairCursor() *Cursor {
426+
return objc.msgSend(@This().InternalInfo.class(), "crosshairCursor", *Cursor, .{});
427+
}
428+
pub fn disappearingItemCursor() *Cursor {
429+
return objc.msgSend(@This().InternalInfo.class(), "disappearingItemCursor", *Cursor, .{});
430+
}
431+
pub fn operationNotAllowedCursor() *Cursor {
432+
return objc.msgSend(@This().InternalInfo.class(), "operationNotAllowedCursor", *Cursor, .{});
433+
}
434+
pub fn dragLinkCursor() *Cursor {
435+
return objc.msgSend(@This().InternalInfo.class(), "dragLinkCursor", *Cursor, .{});
436+
}
437+
pub fn dragCopyCursor() *Cursor {
438+
return objc.msgSend(@This().InternalInfo.class(), "dragCopyCursor", *Cursor, .{});
439+
}
440+
pub fn contextualMenuCursor() *Cursor {
441+
return objc.msgSend(@This().InternalInfo.class(), "contextualMenuCursor", *Cursor, .{});
442+
}
443+
pub fn IBeamCursorForVerticalLayout() *Cursor {
444+
return objc.msgSend(@This().InternalInfo.class(), "IBeamCursorForVerticalLayout", *Cursor, .{});
445+
}
446+
// pub fn image(self_: *@This()) *Image {
447+
// return objc.msgSend(self_, "image", *Image, .{});
448+
// }
449+
pub fn hotSpot(self_: *@This()) Point {
450+
return objc.msgSend(self_, "hotSpot", Point, .{});
451+
}
452+
// pub fn initWithImage_foregroundColorHint_backgroundColorHint_hotSpot(self_: *@This(), newImage_: *Image, fg_: ?*Color, bg_: ?*Color, hotSpot_: Point) *@This() {
453+
// return objc.msgSend(self_, "initWithImage:foregroundColorHint:backgroundColorHint:hotSpot:", *@This(), .{ newImage_, fg_, bg_, hotSpot_ });
454+
// }
455+
pub fn setOnMouseExited(self_: *@This(), flag_: bool) void {
456+
return objc.msgSend(self_, "setOnMouseExited:", void, .{flag_});
457+
}
458+
pub fn setOnMouseEntered(self_: *@This(), flag_: bool) void {
459+
return objc.msgSend(self_, "setOnMouseEntered:", void, .{flag_});
460+
}
461+
pub fn mouseEntered(self_: *@This(), event_: *Event) void {
462+
return objc.msgSend(self_, "mouseEntered:", void, .{event_});
463+
}
464+
pub fn mouseExited(self_: *@This(), event_: *Event) void {
465+
return objc.msgSend(self_, "mouseExited:", void, .{event_});
466+
}
467+
pub fn isSetOnMouseExited(self_: *@This()) bool {
468+
return objc.msgSend(self_, "isSetOnMouseExited", bool, .{});
469+
}
470+
pub fn isSetOnMouseEntered(self_: *@This()) bool {
471+
return objc.msgSend(self_, "isSetOnMouseEntered", bool, .{});
472+
}
473+
};
474+
349475
pub const Screen = opaque {
350476
pub const InternalInfo = objc.ExternClass("NSScreen", @This(), ObjectInterface, &.{});
351477
pub const as = InternalInfo.as;

0 commit comments

Comments
 (0)