lib/sys/src/apple/cocoa.zig

daab053ee43316e1809a84551d573ddd1e5bf3d2

 1 const std = @import("std");
 2 const apple = @import("root.zig");
 3 
 4 pub const NSPoint = extern struct {
 5     x: apple.coregraphics.CGFloat,
 6     y: apple.coregraphics.CGFloat,
 7 };
 8 
 9 pub const NSSize = extern struct {
10     width: apple.coregraphics.CGFloat,
11     height: apple.coregraphics.CGFloat,
12 };
13 
14 pub const NSRect = extern struct {
15     origin: NSPoint,
16     size: NSSize,
17 };
18 
19 pub const NSEventTypeLeftMouseDown: apple.foundation.NSUInteger = 1;
20 pub const NSEventTypeLeftMouseUp: apple.foundation.NSUInteger = 2;
21 pub const NSEventTypeRightMouseDown: apple.foundation.NSUInteger = 3;
22 pub const NSEventTypeRightMouseUp: apple.foundation.NSUInteger = 4;
23 pub const NSEventTypeMouseMoved: apple.foundation.NSUInteger = 5;
24 pub const NSEventTypeLeftMouseDragged: apple.foundation.NSUInteger = 6;
25 pub const NSEventTypeRightMouseDragged: apple.foundation.NSUInteger = 7;
26 pub const NSEventTypeKeyDown: apple.foundation.NSUInteger = 10;
27 pub const NSEventTypeKeyUp: apple.foundation.NSUInteger = 11;
28 pub const NSEventTypeFlagsChanged: apple.foundation.NSUInteger = 12;
29 pub const NSEventTypeScrollWheel: apple.foundation.NSUInteger = 22;
30 pub const NSEventTypeOtherMouseDown: apple.foundation.NSUInteger = 25;
31 pub const NSEventTypeOtherMouseUp: apple.foundation.NSUInteger = 26;
32 pub const NSEventTypeOtherMouseDragged: apple.foundation.NSUInteger = 27;
33 
34 pub const NSEventModifierFlagCapsLock: apple.foundation.NSUInteger = 1 << 16;
35 pub const NSEventModifierFlagShift: apple.foundation.NSUInteger = 1 << 17;
36 pub const NSEventModifierFlagControl: apple.foundation.NSUInteger = 1 << 18;
37 pub const NSEventModifierFlagOption: apple.foundation.NSUInteger = 1 << 19;
38 pub const NSEventModifierFlagCommand: apple.foundation.NSUInteger = 1 << 20;
39 
40 pub const NSWindowStyleMaskTitled: apple.foundation.NSUInteger = 1 << 0;
41 pub const NSWindowStyleMaskClosable: apple.foundation.NSUInteger = 1 << 1;
42 pub const NSWindowStyleMaskMiniaturizable: apple.foundation.NSUInteger = 1 << 2;
43 pub const NSWindowStyleMaskResizable: apple.foundation.NSUInteger = 1 << 3;
44 
45 pub const NSAnyEventMask: apple.foundation.NSUInteger = std.math.maxInt(apple.foundation.NSUInteger);
46 
47 test "Cocoa 64-bit geometry matches the Apple ABI" {
48     try std.testing.expectEqual(@as(usize, 16), @sizeOf(NSPoint));
49     try std.testing.expectEqual(@as(usize, 16), @sizeOf(NSSize));
50     try std.testing.expectEqual(@as(usize, 32), @sizeOf(NSRect));
51     try std.testing.expectEqual(@as(usize, 8), @alignOf(NSRect));
52     try std.testing.expectEqual(@as(usize, 0), @offsetOf(NSRect, "origin"));
53     try std.testing.expectEqual(@as(usize, 16), @offsetOf(NSRect, "size"));
54 }