-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
app_kit.zig
233 lines (209 loc) · 9.39 KB
/
app_kit.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
const ca = @import("quartz_core.zig");
const cf = @import("core_foundation.zig");
const ns = @import("foundation.zig");
const cg = @import("core_graphics.zig");
const objc = @import("objc.zig");
pub const applicationMain = NSApplicationMain;
extern fn NSApplicationMain(argc: c_int, argv: [*]*c_char) c_int;
// ------------------------------------------------------------------------------------------------
// Shared
pub const ErrorDomain = ns.ErrorDomain;
pub const ErrorUserInfoKey = ns.ErrorUserInfoKey;
pub const Integer = ns.Integer;
pub const NotificationName = ns.NotificationName;
pub const TimeInterval = ns.TimeInterval;
pub const UInteger = ns.UInteger;
pub const unichar = ns.unichar;
pub const Range = ns.Range;
pub const StringEncoding = ns.StringEncoding;
pub const StringTransform = ns.StringTransform;
pub const StringEncodingDetectionOptionsKey = ns.StringEncodingDetectionOptionsKey;
pub const Array = ns.Array;
pub const String = ns.String;
// ------------------------------------------------------------------------------------------------
// Types
pub const ModalResponse = *String;
pub const PasteboardType = *String;
pub const AboutPanelOptionKey = *String;
pub const ModalSession = *opaque {};
pub const PrintInfoAttributeKey = *String;
pub const Rect = cg.Rect;
pub const Point = cg.Point;
pub const Size = cg.Size;
pub const RunLoopMode = *String;
pub const PrinterPaperName = *String;
pub const PrintJobDispositionValue = *String;
pub const InterfaceStyle = UInteger;
pub const TouchBarItemIdentifier = *String;
pub const TouchBarCustomizationIdentifier = *String;
pub const TouchBarItemPriority = f32;
pub const DeviceDescriptionKey = *String;
pub const PrinterTypeName = *String;
pub const PrintInfoSettingKey = *String;
pub const AccessibilityActionName = *String;
pub const AccessibilityAttributeName = *String;
pub const ExceptionName = *String;
pub const ImageName = *String;
pub const NibName = *String;
pub const WindowFrameAutosaveName = *String;
pub const AccessibilityParameterizedAttributeName = *String;
pub const UserInterfaceItemIdentifier = *String;
pub const BackingStoreType = UInteger;
pub const BackingStoreRetained: BackingStoreType = 0;
pub const BackingStoreNonretained: BackingStoreType = 1;
pub const BackingStoreBuffered: BackingStoreType = 2;
pub const WindowStyleMask = UInteger;
pub const WindowStyleMaskBorderless: WindowStyleMask = 0;
pub const WindowStyleMaskTitled: WindowStyleMask = 1;
pub const WindowStyleMaskClosable: WindowStyleMask = 2;
pub const WindowStyleMaskMiniaturizable: WindowStyleMask = 4;
pub const WindowStyleMaskResizable: WindowStyleMask = 8;
pub const WindowStyleMaskTexturedBackground: WindowStyleMask = 256;
pub const WindowStyleMaskUnifiedTitleAndToolbar: WindowStyleMask = 4096;
pub const WindowStyleMaskFullScreen: WindowStyleMask = 16384;
pub const WindowStyleMaskFullSizeContentView: WindowStyleMask = 32768;
pub const WindowStyleMaskUtilityWindow: WindowStyleMask = 16;
pub const WindowStyleMaskDocModalWindow: WindowStyleMask = 64;
pub const WindowStyleMaskNonactivatingPanel: WindowStyleMask = 128;
pub const WindowStyleMaskHUDWindow: WindowStyleMask = 8192;
pub const Application = opaque {
pub const InternalInfo = objc.ExternClass("NSApplication", @This(), Responder, &.{});
pub const as = InternalInfo.as;
pub const retain = InternalInfo.retain;
pub const release = InternalInfo.release;
pub const autorelease = InternalInfo.autorelease;
pub const new = InternalInfo.new;
pub const alloc = InternalInfo.alloc;
pub const allocInit = InternalInfo.allocInit;
pub fn run(self_: *@This()) void {
return objc.msgSend(self_, "run", void, .{});
}
pub fn sharedApplication() *Application {
return objc.msgSend(@This().InternalInfo.class(), "sharedApplication", *Application, .{});
}
pub fn setDelegate(self_: *@This(), delegate_: ?*ApplicationDelegate) void {
return objc.msgSend(self_, "setDelegate:", void, .{delegate_});
}
};
pub const Responder = opaque {
pub const InternalInfo = objc.ExternClass("NSResponder", @This(), ObjectInterface, &.{});
pub const as = InternalInfo.as;
pub const retain = InternalInfo.retain;
pub const release = InternalInfo.release;
pub const autorelease = InternalInfo.autorelease;
pub const new = InternalInfo.new;
pub const alloc = InternalInfo.alloc;
pub const allocInit = InternalInfo.allocInit;
};
pub const Window = opaque {
pub const InternalInfo = objc.ExternClass("NSWindow", @This(), Responder, &.{});
pub const as = InternalInfo.as;
pub const retain = InternalInfo.retain;
pub const release = InternalInfo.release;
pub const autorelease = InternalInfo.autorelease;
pub const new = InternalInfo.new;
pub const alloc = InternalInfo.alloc;
pub const allocInit = InternalInfo.allocInit;
pub fn initWithContentRect_styleMask_backing_defer_screen(self_: *@This(), contentRect_: Rect, style_: WindowStyleMask, backingStoreType_: BackingStoreType, flag_: bool, screen_: ?*Screen) *@This() {
return objc.msgSend(self_, "initWithContentRect:styleMask:backing:defer:screen:", *@This(), .{ contentRect_, style_, backingStoreType_, flag_, screen_ });
}
pub fn makeKeyAndOrderFront(self_: *@This(), sender_: ?*objc.Id) void {
return objc.msgSend(self_, "makeKeyAndOrderFront:", void, .{sender_});
}
pub fn contentView(self_: *@This()) ?*View {
return objc.msgSend(self_, "contentView", ?*View, .{});
}
pub fn isReleasedWhenClosed(self_: *@This()) bool {
return objc.msgSend(self_, "isReleasedWhenClosed", bool, .{});
}
pub fn setReleasedWhenClosed(self_: *@This(), releasedWhenClosed_: bool) void {
return objc.msgSend(self_, "setReleasedWhenClosed:", void, .{releasedWhenClosed_});
}
pub fn isVisible(self_: *@This()) bool {
return objc.msgSend(self_, "isVisible", bool, .{});
}
pub fn setIsVisible(self_: *@This(), flag_: bool) void {
return objc.msgSend(self_, "setIsVisible:", void, .{flag_});
}
};
pub const Notification = opaque {
pub const InternalInfo = objc.ExternClass("NSNotification", @This(), ObjectInterface, &.{});
pub const as = InternalInfo.as;
pub const retain = InternalInfo.retain;
pub const release = InternalInfo.release;
pub const autorelease = InternalInfo.autorelease;
pub const new = InternalInfo.new;
pub const alloc = InternalInfo.alloc;
pub const allocInit = InternalInfo.allocInit;
pub fn name(self_: *@This()) NotificationName {
return objc.msgSend(self_, "name", NotificationName, .{});
}
pub fn object(self_: *@This()) ?*objc.Id {
return objc.msgSend(self_, "object", ?*objc.Id, .{});
}
};
pub const ObjectInterface = opaque {
pub const InternalInfo = objc.ExternClass("NSObject", @This(), objc.Id, &.{});
pub const as = InternalInfo.as;
pub const retain = InternalInfo.retain;
pub const release = InternalInfo.release;
pub const autorelease = InternalInfo.autorelease;
pub const new = InternalInfo.new;
pub const alloc = InternalInfo.alloc;
pub const allocInit = InternalInfo.allocInit;
pub fn copy(self_: *@This()) *objc.Id {
return objc.msgSend(self_, "copy", *objc.Id, .{});
}
};
pub const View = opaque {
pub const InternalInfo = objc.ExternClass("NSView", @This(), Responder, &.{});
pub const as = InternalInfo.as;
pub const retain = InternalInfo.retain;
pub const release = InternalInfo.release;
pub const autorelease = InternalInfo.autorelease;
pub const new = InternalInfo.new;
pub const alloc = InternalInfo.alloc;
pub const allocInit = InternalInfo.allocInit;
pub fn layer(self_: *@This()) *ca.Layer {
return objc.msgSend(self_, "layer", *ca.Layer, .{});
}
pub fn setLayer(self_: *@This(), layer_: *ca.Layer) void {
return objc.msgSend(self_, "setLayer:", void, .{layer_});
}
};
pub const Screen = opaque {
pub const InternalInfo = objc.ExternClass("NSScreen", @This(), ObjectInterface, &.{});
pub const as = InternalInfo.as;
pub const retain = InternalInfo.retain;
pub const release = InternalInfo.release;
pub const autorelease = InternalInfo.autorelease;
pub const new = InternalInfo.new;
pub const alloc = InternalInfo.alloc;
pub const allocInit = InternalInfo.allocInit;
pub fn screens() *Array(*Screen) {
return objc.msgSend(@This().InternalInfo.class(), "screens", *Array(*Screen), .{});
}
pub fn mainScreen() ?*Screen {
return objc.msgSend(@This().InternalInfo.class(), "mainScreen", ?*Screen, .{});
}
};
pub const ApplicationDelegate = opaque {
pub const InternalInfo = objc.ExternProtocol(@This(), &.{ ObjectProtocol, ObjectProtocol });
pub const as = InternalInfo.as;
pub const retain = InternalInfo.retain;
pub const release = InternalInfo.release;
pub const autorelease = InternalInfo.autorelease;
pub fn applicationDidFinishLaunching(self_: *@This(), notification_: *Notification) void {
return objc.msgSend(self_, "applicationDidFinishLaunching:", void, .{notification_});
}
};
pub const ObjectProtocol = opaque {
pub const InternalInfo = objc.ExternProtocol(@This(), &.{});
pub const as = InternalInfo.as;
pub const retain = InternalInfo.retain;
pub const release = InternalInfo.release;
pub const autorelease = InternalInfo.autorelease;
pub fn retainCount(self_: *@This()) UInteger {
return objc.msgSend(self_, "retainCount", UInteger, .{});
}
};