nomen-lang 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/core/System/Buffer.nm +32 -0
  2. package/core/System/ClassBuffer.nm +24 -0
  3. package/core/System/Controls/Alert.nm +326 -0
  4. package/core/System/Controls/App.nm +147 -0
  5. package/core/System/Controls/Button.nm +119 -1
  6. package/core/System/Controls/CheckBox.nm +24 -0
  7. package/core/System/Controls/ColorPicker.nm +307 -0
  8. package/core/System/Controls/ComboBox.nm +430 -0
  9. package/core/System/Controls/Container.nm +837 -9
  10. package/core/System/Controls/Control.nm +443 -0
  11. package/core/System/Controls/DatePicker.nm +288 -0
  12. package/core/System/Controls/Form.nm +70 -0
  13. package/core/System/Controls/GroupBox.nm +267 -0
  14. package/core/System/Controls/ImageView.nm +311 -0
  15. package/core/System/Controls/LevelIndicator.nm +305 -0
  16. package/core/System/Controls/ListView.nm +633 -0
  17. package/core/System/Controls/Menu.nm +428 -0
  18. package/core/System/Controls/NumberInput.nm +56 -0
  19. package/core/System/Controls/OtpInput.nm +50 -0
  20. package/core/System/Controls/OutlineView.nm +598 -0
  21. package/core/System/Controls/Pagination.nm +142 -0
  22. package/core/System/Controls/Popover.nm +296 -0
  23. package/core/System/Controls/Progress.nm +348 -0
  24. package/core/System/Controls/Radio.nm +292 -0
  25. package/core/System/Controls/Scrollable.nm +584 -0
  26. package/core/System/Controls/SearchField.nm +326 -0
  27. package/core/System/Controls/SecureField.nm +344 -0
  28. package/core/System/Controls/Segmented.nm +380 -0
  29. package/core/System/Controls/Select.nm +340 -0
  30. package/core/System/Controls/Separator.nm +198 -0
  31. package/core/System/Controls/Sheet.nm +329 -0
  32. package/core/System/Controls/Slider.nm +315 -0
  33. package/core/System/Controls/Spinner.nm +287 -0
  34. package/core/System/Controls/SplitView.nm +509 -0
  35. package/core/System/Controls/Stepper.nm +349 -0
  36. package/core/System/Controls/Switch.nm +259 -0
  37. package/core/System/Controls/Table.nm +833 -0
  38. package/core/System/Controls/Tabs.nm +500 -0
  39. package/core/System/Controls/Text.nm +108 -11
  40. package/core/System/Controls/TextBox.nm +112 -1
  41. package/core/System/Controls/TextView.nm +329 -0
  42. package/core/System/Controls/Toggle.nm +346 -0
  43. package/core/System/Controls/Toolbar.nm +501 -0
  44. package/core/System/Controls/Tooltip.nm +76 -0
  45. package/core/System/Controls/Window.nm +1549 -91
  46. package/core/System/List.nm +34 -0
  47. package/core/System/Map.nm +21 -4
  48. package/core/System/Set.nm +14 -0
  49. package/dist/index.mjs +3425 -710
  50. package/package.json +1 -1
@@ -0,0 +1,348 @@
1
+ /**
2
+ * A determinate progress bar (with an indeterminate flag)
3
+ *
4
+ * An OWNING STRUCT (STRUCT_PLAN_3 Phase R, tranche 4 — the shape menu): the
5
+ * single field is a platform handle, so the value is movable and its
6
+ * `#destroy` releases what the handle names. The constructor's `self` is
7
+ * the inline instance (the `.` accessor); methods keep the pointer form.
8
+ *
9
+ * Continuous control: the value is normalized 0..1 and polled per frame.
10
+ * For the spinning variant (macOS styles the SAME control differently, iOS
11
+ * uses a distinct class) see `Spinner`.
12
+ **/
13
+ pub mv struct Progress : Control {
14
+ var uint64 handle = 0
15
+
16
+ pub func #init = (self, Window window) {
17
+ ```
18
+ #arch: c
19
+ #platform: macos
20
+ id bar = ((id(*)(id, SEL, CGRect))objc_msgSend)(
21
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSProgressIndicator"), sel_registerName("alloc")),
22
+ sel_registerName("initWithFrame:"),
23
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 20));
24
+ ((void(*)(id, SEL, unsigned long))objc_msgSend)(
25
+ bar, sel_registerName("setControlSize:"), 1); // NSControlSizeSmall = 1
26
+ // NSProgressIndicator defaults to indeterminate; a progress BAR starts
27
+ // determinate with a normalized 0..1 range (the Spinner is the
28
+ // indeterminate variant).
29
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(bar, sel_registerName("setIndeterminate:"), 0);
30
+ ((void(*)(id, SEL, double))objc_msgSend)(bar, sel_registerName("setMinValue:"), 0.0);
31
+ ((void(*)(id, SEL, double))objc_msgSend)(bar, sel_registerName("setMaxValue:"), 1.0);
32
+ ((void(*)(id, SEL, double))objc_msgSend)(bar, sel_registerName("setDoubleValue:"), 0.0);
33
+ id contentView = ((id(*)(id, SEL))objc_msgSend)(
34
+ (id)window->handle, sel_registerName("contentView"));
35
+ ((void(*)(id, SEL, id))objc_msgSend)(
36
+ contentView, sel_registerName("addSubview:"), bar);
37
+ self.handle = (uint64_t)bar;
38
+ ```
39
+ ```
40
+ #arch: aarch64_use_c
41
+ #platform: macos
42
+ id bar = ((id(*)(id, SEL, CGRect))objc_msgSend)(
43
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSProgressIndicator"), sel_registerName("alloc")),
44
+ sel_registerName("initWithFrame:"),
45
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 20));
46
+ ((void(*)(id, SEL, unsigned long))objc_msgSend)(
47
+ bar, sel_registerName("setControlSize:"), 1); // NSControlSizeSmall = 1
48
+ // NSProgressIndicator defaults to indeterminate; a progress BAR starts
49
+ // determinate with a normalized 0..1 range (the Spinner is the
50
+ // indeterminate variant).
51
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(bar, sel_registerName("setIndeterminate:"), 0);
52
+ ((void(*)(id, SEL, double))objc_msgSend)(bar, sel_registerName("setMinValue:"), 0.0);
53
+ ((void(*)(id, SEL, double))objc_msgSend)(bar, sel_registerName("setMaxValue:"), 1.0);
54
+ ((void(*)(id, SEL, double))objc_msgSend)(bar, sel_registerName("setDoubleValue:"), 0.0);
55
+ id contentView = ((id(*)(id, SEL))objc_msgSend)(
56
+ (id)window->handle, sel_registerName("contentView"));
57
+ ((void(*)(id, SEL, id))objc_msgSend)(
58
+ contentView, sel_registerName("addSubview:"), bar);
59
+ self->handle = (uint64_t)bar;
60
+ ```
61
+ ```
62
+ #arch: c
63
+ #platform: ios
64
+ id bar = ((id(*)(id, SEL, CGRect))objc_msgSend)(
65
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UIProgressView"), sel_registerName("alloc")),
66
+ sel_registerName("initWithFrame:"),
67
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 6));
68
+ ((void(*)(id, SEL, float))objc_msgSend)(bar, sel_registerName("setProgress:"), 0.0f);
69
+ id parentView = ((id(*)(id, SEL))objc_msgSend)(
70
+ ((id(*)(id, SEL))objc_msgSend)(
71
+ (id)window->handle, sel_registerName("rootViewController")),
72
+ sel_registerName("view"));
73
+ ((void(*)(id, SEL, id))objc_msgSend)(
74
+ parentView, sel_registerName("addSubview:"), bar);
75
+ self.handle = (uint64_t)bar;
76
+ ```
77
+ ```
78
+ #arch: aarch64_use_c
79
+ #platform: ios
80
+ id bar = ((id(*)(id, SEL, CGRect))objc_msgSend)(
81
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UIProgressView"), sel_registerName("alloc")),
82
+ sel_registerName("initWithFrame:"),
83
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 6));
84
+ ((void(*)(id, SEL, float))objc_msgSend)(bar, sel_registerName("setProgress:"), 0.0f);
85
+ id parentView = ((id(*)(id, SEL))objc_msgSend)(
86
+ ((id(*)(id, SEL))objc_msgSend)(
87
+ (id)window->handle, sel_registerName("rootViewController")),
88
+ sel_registerName("view"));
89
+ ((void(*)(id, SEL, id))objc_msgSend)(
90
+ parentView, sel_registerName("addSubview:"), bar);
91
+ self->handle = (uint64_t)bar;
92
+ ```
93
+ }
94
+
95
+ pub func set_frame = (ref self, int x, int y, int width, int height) {
96
+ ```
97
+ #arch: c
98
+ #platform: macos
99
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
100
+ (id)self->handle, sel_registerName("setFrame:"),
101
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
102
+ ```
103
+ ```
104
+ #arch: aarch64_use_c
105
+ #platform: macos
106
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
107
+ (id)self->handle, sel_registerName("setFrame:"),
108
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
109
+ ```
110
+ ```
111
+ #arch: c
112
+ #platform: ios
113
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
114
+ (id)self->handle, sel_registerName("setFrame:"),
115
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
116
+ ```
117
+ ```
118
+ #arch: aarch64_use_c
119
+ #platform: ios
120
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
121
+ (id)self->handle, sel_registerName("setFrame:"),
122
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
123
+ ```
124
+ }
125
+
126
+ // The filled fraction, 0..1. iOS stores a float (32-bit); the value is
127
+ // therefore only float32-exact there (0.25, 0.5, … are).
128
+ pub func set_value = (self, float value) {
129
+ ```
130
+ #arch: c
131
+ #platform: macos
132
+ ((void(*)(id, SEL, double))objc_msgSend)(
133
+ (id)self->handle, sel_registerName("setDoubleValue:"), value);
134
+ ```
135
+ ```
136
+ #arch: aarch64_use_c
137
+ #platform: macos
138
+ ((void(*)(id, SEL, double))objc_msgSend)(
139
+ (id)self->handle, sel_registerName("setDoubleValue:"), value);
140
+ ```
141
+ ```
142
+ #arch: c
143
+ #platform: ios
144
+ ((void(*)(id, SEL, float))objc_msgSend)(
145
+ (id)self->handle, sel_registerName("setProgress:"), (float)value);
146
+ ```
147
+ ```
148
+ #arch: aarch64_use_c
149
+ #platform: ios
150
+ ((void(*)(id, SEL, float))objc_msgSend)(
151
+ (id)self->handle, sel_registerName("setProgress:"), (float)value);
152
+ ```
153
+ }
154
+
155
+ pub func value = (self, out float) {
156
+ ```
157
+ #arch: c
158
+ #platform: macos
159
+ return ((double(*)(id, SEL))objc_msgSend)(
160
+ (id)self->handle, sel_registerName("doubleValue"));
161
+ ```
162
+ ```
163
+ #arch: aarch64_use_c
164
+ #platform: macos
165
+ return ((double(*)(id, SEL))objc_msgSend)(
166
+ (id)self->handle, sel_registerName("doubleValue"));
167
+ ```
168
+ ```
169
+ #arch: c
170
+ #platform: ios
171
+ return (double)((float(*)(id, SEL))objc_msgSend)(
172
+ (id)self->handle, sel_registerName("progress"));
173
+ ```
174
+ ```
175
+ #arch: aarch64_use_c
176
+ #platform: ios
177
+ return (double)((float(*)(id, SEL))objc_msgSend)(
178
+ (id)self->handle, sel_registerName("progress"));
179
+ ```
180
+ }
181
+
182
+ // Switch between the determinate bar and the barber-pole. Determinate
183
+ // values are kept across the switch; an indeterminate bar animates on
184
+ // its own (no per-frame pump needed).
185
+ pub func set_indeterminate = (self, bool indeterminate) {
186
+ ```
187
+ #arch: c
188
+ #platform: macos
189
+ NSProgressIndicator *bar = (NSProgressIndicator *)self->handle;
190
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
191
+ bar, sel_registerName("setIndeterminate:"), indeterminate ? 1 : 0);
192
+ if (indeterminate) {
193
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(bar, sel_registerName("setUsesThreadedAnimation:"), 1);
194
+ ((void(*)(id, SEL, id))objc_msgSend)(bar, sel_registerName("startAnimation:"), (id)0);
195
+ } else {
196
+ ((void(*)(id, SEL, id))objc_msgSend)(bar, sel_registerName("stopAnimation:"), (id)0);
197
+ }
198
+ ```
199
+ ```
200
+ #arch: aarch64_use_c
201
+ #platform: macos
202
+ NSProgressIndicator *bar = (NSProgressIndicator *)self->handle;
203
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
204
+ bar, sel_registerName("setIndeterminate:"), indeterminate ? 1 : 0);
205
+ if (indeterminate) {
206
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(bar, sel_registerName("setUsesThreadedAnimation:"), 1);
207
+ ((void(*)(id, SEL, id))objc_msgSend)(bar, sel_registerName("startAnimation:"), (id)0);
208
+ } else {
209
+ ((void(*)(id, SEL, id))objc_msgSend)(bar, sel_registerName("stopAnimation:"), (id)0);
210
+ }
211
+ ```
212
+ ```
213
+ #arch: c
214
+ #platform: ios
215
+ // UIProgressView has no indeterminate mode — the flag is accepted and
216
+ // ignored (iOS apps use a Spinner for unknown-length work).
217
+ (void)indeterminate;
218
+ ```
219
+ ```
220
+ #arch: aarch64_use_c
221
+ #platform: ios
222
+ // UIProgressView has no indeterminate mode — the flag is accepted and
223
+ // ignored (iOS apps use a Spinner for unknown-length work).
224
+ (void)indeterminate;
225
+ ```
226
+ }
227
+
228
+ pub func is_indeterminate = (self, out bool) {
229
+ ```
230
+ #arch: c
231
+ #platform: macos
232
+ BOOL flag = ((BOOL(*)(id, SEL))objc_msgSend)(
233
+ (id)self->handle, sel_registerName("isIndeterminate"));
234
+ return flag ? 1 : 0;
235
+ ```
236
+ ```
237
+ #arch: aarch64_use_c
238
+ #platform: macos
239
+ BOOL flag = ((BOOL(*)(id, SEL))objc_msgSend)(
240
+ (id)self->handle, sel_registerName("isIndeterminate"));
241
+ return flag ? 1 : 0;
242
+ ```
243
+ ```
244
+ #arch: c
245
+ #platform: ios
246
+ return 0; // UIProgressView is always determinate
247
+ ```
248
+ ```
249
+ #arch: aarch64_use_c
250
+ #platform: ios
251
+ return 0; // UIProgressView is always determinate
252
+ ```
253
+ }
254
+
255
+ pub func set_hidden = (self, bool hidden) {
256
+ ```
257
+ #arch: c
258
+ #platform: macos
259
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
260
+ (id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
261
+ ```
262
+ ```
263
+ #arch: aarch64_use_c
264
+ #platform: macos
265
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
266
+ (id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
267
+ ```
268
+ ```
269
+ #arch: c
270
+ #platform: ios
271
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
272
+ (id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
273
+ ```
274
+ ```
275
+ #arch: aarch64_use_c
276
+ #platform: ios
277
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
278
+ (id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
279
+ ```
280
+ }
281
+
282
+ // ── Control trait conformance ──
283
+ pub func intrinsic_size = (self, out Size) {
284
+ var [w, h] = native_intrinsic(self.handle)
285
+ var s = Size()
286
+ s.width = w
287
+ s.height = h
288
+ return s
289
+ }
290
+
291
+ pub func measure = (self, BoxConstraints constraints, out Size) {
292
+ var Size s = self.intrinsic_size()
293
+ if s.width > constraints.max_width {
294
+ s.width = constraints.max_width
295
+ }
296
+ if s.width < constraints.min_width {
297
+ s.width = constraints.min_width
298
+ }
299
+ if s.height > constraints.max_height {
300
+ s.height = constraints.max_height
301
+ }
302
+ if s.height < constraints.min_height {
303
+ s.height = constraints.min_height
304
+ }
305
+ return s
306
+ }
307
+
308
+ func #destroy = () {
309
+ ```
310
+ #arch: c
311
+ #platform: macos
312
+ if (self->handle) {
313
+ ((void(*)(id, SEL, id))objc_msgSend)((id)self->handle, sel_registerName("stopAnimation:"), (id)0);
314
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
315
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
316
+ self->handle = 0;
317
+ }
318
+ ```
319
+ ```
320
+ #arch: aarch64_use_c
321
+ #platform: macos
322
+ if (self->handle) {
323
+ ((void(*)(id, SEL, id))objc_msgSend)((id)self->handle, sel_registerName("stopAnimation:"), (id)0);
324
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
325
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
326
+ self->handle = 0;
327
+ }
328
+ ```
329
+ ```
330
+ #arch: c
331
+ #platform: ios
332
+ if (self->handle) {
333
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
334
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
335
+ self->handle = 0;
336
+ }
337
+ ```
338
+ ```
339
+ #arch: aarch64_use_c
340
+ #platform: ios
341
+ if (self->handle) {
342
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
343
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
344
+ self->handle = 0;
345
+ }
346
+ ```
347
+ }
348
+ }
@@ -0,0 +1,292 @@
1
+ /**
2
+ * A radio button (exclusive selection is managed at the Nomen level)
3
+ *
4
+ * An OWNING STRUCT (STRUCT_PLAN_3 Phase R, tranche 4 — the shape menu): the
5
+ * single field is a platform handle, so the value is movable and its
6
+ * `#destroy` releases what the handle names. The constructor's `self` is
7
+ * the inline instance (the `.` accessor); methods keep the pointer form.
8
+ *
9
+ * macOS gives each NSRadioButton its own on/off state but no cross-button
10
+ * exclusivity, and iOS has no radio control at all — GROUP semantics (first
11
+ * selected wins) are the caller's job: check the new selection and uncheck
12
+ * the rest. The control itself is a CheckBox sibling (button type 4,
13
+ * NSRadioButton). iOS defers to Segmented or a checkmark list.
14
+ **/
15
+ pub mv struct Radio : Control {
16
+ var uint64 handle = 0
17
+
18
+ // The `#handle` hook synthesizes `NameHandle` — a copyable, non-owning
19
+ // twin (same public bare-self methods, no destroy) so closures can
20
+ // capture this control without moving it. See GUI.md, "Handles".
21
+ #handle = () {}
22
+
23
+ pub func #init = (self, Window window, string title) {
24
+ ```
25
+ #arch: c
26
+ #platform: macos
27
+ id rb = ((id(*)(id, SEL, CGRect))objc_msgSend)(
28
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSButton"), sel_registerName("alloc")),
29
+ sel_registerName("initWithFrame:"),
30
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 24));
31
+ ((void(*)(id, SEL, unsigned long))objc_msgSend)(
32
+ rb, sel_registerName("setButtonType:"), 4); // NSRadioButton = 4
33
+ ((void(*)(id, SEL, long))objc_msgSend)(
34
+ rb, sel_registerName("setState:"), 0); // NSControlStateValueOff = 0
35
+ ((void(*)(id, SEL, id))objc_msgSend)(
36
+ rb, sel_registerName("setTitle:"),
37
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
38
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
39
+ id contentView = ((id(*)(id, SEL))objc_msgSend)(
40
+ (id)window->handle, sel_registerName("contentView"));
41
+ ((void(*)(id, SEL, id))objc_msgSend)(
42
+ contentView, sel_registerName("addSubview:"), rb);
43
+ self.handle = (uint64_t)rb;
44
+ extern void nomen_control_arm_clicks(unsigned long long);
45
+ nomen_control_arm_clicks((unsigned long long)rb);
46
+ ```
47
+ ```
48
+ #arch: aarch64_use_c
49
+ #platform: macos
50
+ id rb = ((id(*)(id, SEL, CGRect))objc_msgSend)(
51
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSButton"), sel_registerName("alloc")),
52
+ sel_registerName("initWithFrame:"),
53
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 24));
54
+ ((void(*)(id, SEL, unsigned long))objc_msgSend)(
55
+ rb, sel_registerName("setButtonType:"), 4); // NSRadioButton = 4
56
+ ((void(*)(id, SEL, long))objc_msgSend)(
57
+ rb, sel_registerName("setState:"), 0); // NSControlStateValueOff = 0
58
+ ((void(*)(id, SEL, id))objc_msgSend)(
59
+ rb, sel_registerName("setTitle:"),
60
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
61
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
62
+ id contentView = ((id(*)(id, SEL))objc_msgSend)(
63
+ (id)window->handle, sel_registerName("contentView"));
64
+ ((void(*)(id, SEL, id))objc_msgSend)(
65
+ contentView, sel_registerName("addSubview:"), rb);
66
+ self->handle = (uint64_t)rb;
67
+ extern void nomen_control_arm_clicks(unsigned long long) __asm__("nomen_control_arm_clicks");
68
+ nomen_control_arm_clicks((unsigned long long)rb);
69
+ ```
70
+ ```
71
+ #arch: c
72
+ #platform: ios
73
+ /* TODO: iOS — no native radio button; compose from a checkmark list or
74
+ * defer to Segmented (see GUI_PLAN Tier 1 #5). */
75
+ ```
76
+ ```
77
+ #arch: aarch64_use_c
78
+ #platform: ios
79
+ /* TODO: iOS — no native radio button; compose from a checkmark list or
80
+ * defer to Segmented (see GUI_PLAN Tier 1 #5). */
81
+ ```
82
+ }
83
+
84
+ pub func set_frame = (ref self, int x, int y, int width, int height) {
85
+ ```
86
+ #arch: c
87
+ #platform: macos
88
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
89
+ (id)self->handle, sel_registerName("setFrame:"),
90
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
91
+ ```
92
+ ```
93
+ #arch: aarch64_use_c
94
+ #platform: macos
95
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
96
+ (id)self->handle, sel_registerName("setFrame:"),
97
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
98
+ ```
99
+ ```
100
+ #arch: c
101
+ #platform: ios
102
+ /* TODO: iOS (see #init) */
103
+ ```
104
+ ```
105
+ #arch: aarch64_use_c
106
+ #platform: ios
107
+ /* TODO: iOS (see #init) */
108
+ ```
109
+ }
110
+
111
+ pub func set_title = (self, string title) {
112
+ ```
113
+ #arch: c
114
+ #platform: macos
115
+ ((void(*)(id, SEL, id))objc_msgSend)(
116
+ (id)self->handle, sel_registerName("setTitle:"),
117
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
118
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
119
+ ```
120
+ ```
121
+ #arch: aarch64_use_c
122
+ #platform: macos
123
+ ((void(*)(id, SEL, id))objc_msgSend)(
124
+ (id)self->handle, sel_registerName("setTitle:"),
125
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
126
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
127
+ ```
128
+ ```
129
+ #arch: c
130
+ #platform: ios
131
+ /* TODO: iOS (see #init) */
132
+ ```
133
+ ```
134
+ #arch: aarch64_use_c
135
+ #platform: ios
136
+ /* TODO: iOS (see #init) */
137
+ ```
138
+ }
139
+
140
+ pub func set_checked = (self, bool checked) {
141
+ ```
142
+ #arch: c
143
+ #platform: macos
144
+ ((void(*)(id, SEL, long))objc_msgSend)(
145
+ (id)self->handle, sel_registerName("setState:"),
146
+ checked ? 1 : 0); // NSControlStateValueOn = 1, Off = 0
147
+ ```
148
+ ```
149
+ #arch: aarch64_use_c
150
+ #platform: macos
151
+ ((void(*)(id, SEL, long))objc_msgSend)(
152
+ (id)self->handle, sel_registerName("setState:"),
153
+ checked ? 1 : 0); // NSControlStateValueOn = 1, Off = 0
154
+ ```
155
+ ```
156
+ #arch: c
157
+ #platform: ios
158
+ /* TODO: iOS (see #init) */
159
+ ```
160
+ ```
161
+ #arch: aarch64_use_c
162
+ #platform: ios
163
+ /* TODO: iOS (see #init) */
164
+ ```
165
+ }
166
+
167
+ pub func is_checked = (self, out bool) {
168
+ ```
169
+ #arch: c
170
+ #platform: macos
171
+ long state = ((long(*)(id, SEL))objc_msgSend)(
172
+ (id)self->handle, sel_registerName("state"));
173
+ return state == 1; // NSControlStateValueOn = 1
174
+ ```
175
+ ```
176
+ #arch: aarch64_use_c
177
+ #platform: macos
178
+ long state = ((long(*)(id, SEL))objc_msgSend)(
179
+ (id)self->handle, sel_registerName("state"));
180
+ return state == 1; // NSControlStateValueOn = 1
181
+ ```
182
+ ```
183
+ #arch: c
184
+ #platform: ios
185
+ /* TODO: iOS (see #init) */
186
+ return 0;
187
+ ```
188
+ ```
189
+ #arch: aarch64_use_c
190
+ #platform: ios
191
+ /* TODO: iOS (see #init) */
192
+ return 0;
193
+ ```
194
+ }
195
+
196
+ pub func set_hidden = (self, bool hidden) {
197
+ ```
198
+ #arch: c
199
+ #platform: macos
200
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
201
+ (id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
202
+ ```
203
+ ```
204
+ #arch: aarch64_use_c
205
+ #platform: macos
206
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
207
+ (id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
208
+ ```
209
+ ```
210
+ #arch: c
211
+ #platform: ios
212
+ /* TODO: iOS (see #init) */
213
+ ```
214
+ ```
215
+ #arch: aarch64_use_c
216
+ #platform: ios
217
+ /* TODO: iOS (see #init) */
218
+ ```
219
+ }
220
+
221
+ // ── Control trait conformance ──
222
+ // Edge-triggered click poll: true exactly once per click (the record
223
+ // is consumed). Backed by the native target/action queue —
224
+ // nomen_control_arm_clicks arms this control in the constructor — so
225
+ // no coordinates and no hit-testing, and it works inside Scrollables.
226
+ pub func was_clicked = (self, out bool) {
227
+ return nomen_control_take_click(self.handle)
228
+ }
229
+
230
+ // The on_click desugar's drain (docs/HANDLERS.md): the synthesized pump
231
+ // arm polls this per frame. Same edge as was_clicked — register one way
232
+ // or the other, never both (first consumer wins).
233
+ pub func take_click = (self, out bool) {
234
+ return nomen_control_take_click(self.handle)
235
+ }
236
+
237
+ pub func intrinsic_size = (self, out Size) {
238
+ var [w, h] = native_intrinsic(self.handle)
239
+ var s = Size()
240
+ s.width = w
241
+ s.height = h
242
+ return s
243
+ }
244
+
245
+ pub func measure = (self, BoxConstraints constraints, out Size) {
246
+ var Size s = self.intrinsic_size()
247
+ if s.width > constraints.max_width {
248
+ s.width = constraints.max_width
249
+ }
250
+ if s.width < constraints.min_width {
251
+ s.width = constraints.min_width
252
+ }
253
+ if s.height > constraints.max_height {
254
+ s.height = constraints.max_height
255
+ }
256
+ if s.height < constraints.min_height {
257
+ s.height = constraints.min_height
258
+ }
259
+ return s
260
+ }
261
+
262
+ func #destroy = () {
263
+ ```
264
+ #arch: c
265
+ #platform: macos
266
+ if (self->handle) {
267
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
268
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
269
+ self->handle = 0;
270
+ }
271
+ ```
272
+ ```
273
+ #arch: aarch64_use_c
274
+ #platform: macos
275
+ if (self->handle) {
276
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
277
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
278
+ self->handle = 0;
279
+ }
280
+ ```
281
+ ```
282
+ #arch: c
283
+ #platform: ios
284
+ /* TODO: iOS (see #init) */
285
+ ```
286
+ ```
287
+ #arch: aarch64_use_c
288
+ #platform: ios
289
+ /* TODO: iOS (see #init) */
290
+ ```
291
+ }
292
+ }