nomen-lang 0.7.1 → 0.9.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.
- package/audit_runtime.c +12 -2
- package/core/System/Arena.nm +8 -1
- package/core/System/Buffer.nm +397 -8
- package/core/System/ClassBuffer.nm +156 -0
- package/core/System/Controls/Alert.nm +326 -0
- package/core/System/Controls/App.nm +147 -0
- package/core/System/Controls/Button.nm +119 -1
- package/core/System/Controls/CheckBox.nm +25 -1
- package/core/System/Controls/ColorPicker.nm +307 -0
- package/core/System/Controls/ComboBox.nm +430 -0
- package/core/System/Controls/Container.nm +843 -9
- package/core/System/Controls/Control.nm +443 -0
- package/core/System/Controls/DatePicker.nm +288 -0
- package/core/System/Controls/Form.nm +70 -0
- package/core/System/Controls/GroupBox.nm +267 -0
- package/core/System/Controls/ImageView.nm +311 -0
- package/core/System/Controls/LevelIndicator.nm +305 -0
- package/core/System/Controls/ListView.nm +633 -0
- package/core/System/Controls/Menu.nm +428 -0
- package/core/System/Controls/NumberInput.nm +56 -0
- package/core/System/Controls/OtpInput.nm +50 -0
- package/core/System/Controls/OutlineView.nm +598 -0
- package/core/System/Controls/Pagination.nm +142 -0
- package/core/System/Controls/Popover.nm +296 -0
- package/core/System/Controls/Progress.nm +348 -0
- package/core/System/Controls/Radio.nm +292 -0
- package/core/System/Controls/Scrollable.nm +584 -0
- package/core/System/Controls/SearchField.nm +326 -0
- package/core/System/Controls/SecureField.nm +344 -0
- package/core/System/Controls/Segmented.nm +380 -0
- package/core/System/Controls/Select.nm +340 -0
- package/core/System/Controls/Separator.nm +198 -0
- package/core/System/Controls/Sheet.nm +329 -0
- package/core/System/Controls/Slider.nm +315 -0
- package/core/System/Controls/Spinner.nm +287 -0
- package/core/System/Controls/SplitView.nm +509 -0
- package/core/System/Controls/Stepper.nm +349 -0
- package/core/System/Controls/Switch.nm +259 -0
- package/core/System/Controls/Table.nm +833 -0
- package/core/System/Controls/Tabs.nm +500 -0
- package/core/System/Controls/Text.nm +108 -11
- package/core/System/Controls/TextBox.nm +113 -2
- package/core/System/Controls/TextView.nm +329 -0
- package/core/System/Controls/Toggle.nm +346 -0
- package/core/System/Controls/Toolbar.nm +501 -0
- package/core/System/Controls/Tooltip.nm +76 -0
- package/core/System/Controls/Window.nm +1548 -91
- package/core/System/LinkedList.nm +8 -1
- package/core/System/List.nm +97 -7
- package/core/System/Map.nm +191 -18
- package/core/System/Mutex.nm +4 -4
- package/core/System/Random.nm +3 -4
- package/core/System/Set.nm +101 -13
- package/core/System/StableList.nm +371 -0
- package/core/System/Stream/Directory.nm +2 -2
- package/core/System/Stream/File.nm +2 -2
- package/core/System/Stream/Http.nm +2 -2
- package/core/System/String.nm +10 -5
- package/core/System/StringBuilder.nm +213 -2
- package/core/System/Text/CharIndex.nm +9 -9
- package/core/System/Text/Json.nm +60 -46
- package/core/System/Text/JsonTree.nm +120 -92
- package/core/System/Text/Regex.nm +23 -18
- package/core/System/Text/Utf8.nm +5 -5
- package/core/System/float.nm +36 -22
- package/core/System/int.nm +80 -28
- package/core/System/int16.nm +11 -0
- package/core/System/int32.nm +11 -0
- package/core/System/int64.nm +11 -0
- package/core/System/int8.nm +11 -0
- package/core/System/uint.nm +11 -0
- package/core/System/uint16.nm +11 -0
- package/core/System/uint32.nm +11 -0
- package/core/System/uint64.nm +11 -0
- package/core/System/uint8.nm +11 -0
- package/core/docs/System/StringBuilder.md +6 -0
- package/core/docs/System/Text/JsonTree.md +3 -2
- package/dist/index.mjs +38332 -30604
- package/package.json +1 -1
- package/src/bench_loop.nm +9 -9
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A browsable date picker (year/month/day)
|
|
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
|
+
* The value travels as epoch seconds (UTC) — an absolute time, so the
|
|
10
|
+
* platform's display timezone is irrelevant to the round trip. The default
|
|
11
|
+
* macOS style is TextFieldAndStepper (a compact one-line picker): the
|
|
12
|
+
* ClockAndCalendar style renders as a ~148px-tall inline calendar on modern
|
|
13
|
+
* macOS, which no row-height layout can host. A browsable calendar GRID as a
|
|
14
|
+
* layout widget is Tier 3; this is the native picker.
|
|
15
|
+
**/
|
|
16
|
+
pub mv struct DatePicker: Control {
|
|
17
|
+
var uint64 handle = 0
|
|
18
|
+
|
|
19
|
+
pub func #init = (self, Window window) {
|
|
20
|
+
```
|
|
21
|
+
#arch: c
|
|
22
|
+
#platform: macos
|
|
23
|
+
id dp = ((id(*)(id, SEL, CGRect))objc_msgSend)(
|
|
24
|
+
((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSDatePicker"), sel_registerName("alloc")),
|
|
25
|
+
sel_registerName("initWithFrame:"),
|
|
26
|
+
((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 140, 32));
|
|
27
|
+
((void(*)(id, SEL, long))objc_msgSend)(
|
|
28
|
+
dp, sel_registerName("setDatePickerStyle:"), 0); // NSDatePickerStyleTextFieldAndStepper = 0
|
|
29
|
+
((void(*)(id, SEL, unsigned long))objc_msgSend)(
|
|
30
|
+
dp, sel_registerName("setDatePickerElements:"), 0x1cUL); // Year|Month|Day
|
|
31
|
+
id contentView = ((id(*)(id, SEL))objc_msgSend)(
|
|
32
|
+
(id)window->handle, sel_registerName("contentView"));
|
|
33
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
34
|
+
contentView, sel_registerName("addSubview:"), dp);
|
|
35
|
+
self.handle = (uint64_t)dp;
|
|
36
|
+
```
|
|
37
|
+
```
|
|
38
|
+
#arch: aarch64_use_c
|
|
39
|
+
#platform: macos
|
|
40
|
+
id dp = ((id(*)(id, SEL, CGRect))objc_msgSend)(
|
|
41
|
+
((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSDatePicker"), sel_registerName("alloc")),
|
|
42
|
+
sel_registerName("initWithFrame:"),
|
|
43
|
+
((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 140, 32));
|
|
44
|
+
((void(*)(id, SEL, long))objc_msgSend)(
|
|
45
|
+
dp, sel_registerName("setDatePickerStyle:"), 0); // NSDatePickerStyleTextFieldAndStepper = 0
|
|
46
|
+
((void(*)(id, SEL, unsigned long))objc_msgSend)(
|
|
47
|
+
dp, sel_registerName("setDatePickerElements:"), 0x1cUL); // Year|Month|Day
|
|
48
|
+
id contentView = ((id(*)(id, SEL))objc_msgSend)(
|
|
49
|
+
(id)window->handle, sel_registerName("contentView"));
|
|
50
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
51
|
+
contentView, sel_registerName("addSubview:"), dp);
|
|
52
|
+
self->handle = (uint64_t)dp;
|
|
53
|
+
```
|
|
54
|
+
```
|
|
55
|
+
#arch: c
|
|
56
|
+
#platform: ios
|
|
57
|
+
id dp = ((id(*)(id, SEL, CGRect))objc_msgSend)(
|
|
58
|
+
((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UIDatePicker"), sel_registerName("alloc")),
|
|
59
|
+
sel_registerName("initWithFrame:"),
|
|
60
|
+
((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 120));
|
|
61
|
+
((void(*)(id, SEL, long))objc_msgSend)(
|
|
62
|
+
dp, sel_registerName("setDatePickerMode:"), 1); // UIDatePickerModeDate = 1
|
|
63
|
+
id parentView = ((id(*)(id, SEL))objc_msgSend)(
|
|
64
|
+
((id(*)(id, SEL))objc_msgSend)(
|
|
65
|
+
(id)window->handle, sel_registerName("rootViewController")),
|
|
66
|
+
sel_registerName("view"));
|
|
67
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
68
|
+
parentView, sel_registerName("addSubview:"), dp);
|
|
69
|
+
self.handle = (uint64_t)dp;
|
|
70
|
+
```
|
|
71
|
+
```
|
|
72
|
+
#arch: aarch64_use_c
|
|
73
|
+
#platform: ios
|
|
74
|
+
id dp = ((id(*)(id, SEL, CGRect))objc_msgSend)(
|
|
75
|
+
((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UIDatePicker"), sel_registerName("alloc")),
|
|
76
|
+
sel_registerName("initWithFrame:"),
|
|
77
|
+
((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 120));
|
|
78
|
+
((void(*)(id, SEL, long))objc_msgSend)(
|
|
79
|
+
dp, sel_registerName("setDatePickerMode:"), 1); // UIDatePickerModeDate = 1
|
|
80
|
+
id parentView = ((id(*)(id, SEL))objc_msgSend)(
|
|
81
|
+
((id(*)(id, SEL))objc_msgSend)(
|
|
82
|
+
(id)window->handle, sel_registerName("rootViewController")),
|
|
83
|
+
sel_registerName("view"));
|
|
84
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
85
|
+
parentView, sel_registerName("addSubview:"), dp);
|
|
86
|
+
self->handle = (uint64_t)dp;
|
|
87
|
+
```
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
pub func set_frame = (ref self, int x, int y, int width, int height) {
|
|
91
|
+
```
|
|
92
|
+
#arch: c
|
|
93
|
+
#platform: macos
|
|
94
|
+
((void(*)(id, SEL, CGRect))objc_msgSend)(
|
|
95
|
+
(id)self->handle, sel_registerName("setFrame:"),
|
|
96
|
+
((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
|
|
97
|
+
```
|
|
98
|
+
```
|
|
99
|
+
#arch: aarch64_use_c
|
|
100
|
+
#platform: macos
|
|
101
|
+
((void(*)(id, SEL, CGRect))objc_msgSend)(
|
|
102
|
+
(id)self->handle, sel_registerName("setFrame:"),
|
|
103
|
+
((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
|
|
104
|
+
```
|
|
105
|
+
```
|
|
106
|
+
#arch: c
|
|
107
|
+
#platform: ios
|
|
108
|
+
((void(*)(id, SEL, CGRect))objc_msgSend)(
|
|
109
|
+
(id)self->handle, sel_registerName("setFrame:"),
|
|
110
|
+
((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
|
|
111
|
+
```
|
|
112
|
+
```
|
|
113
|
+
#arch: aarch64_use_c
|
|
114
|
+
#platform: ios
|
|
115
|
+
((void(*)(id, SEL, CGRect))objc_msgSend)(
|
|
116
|
+
(id)self->handle, sel_registerName("setFrame:"),
|
|
117
|
+
((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
|
|
118
|
+
```
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Set the picker to an absolute time (epoch seconds, UTC).
|
|
122
|
+
pub func set_time = (self, int64 seconds) {
|
|
123
|
+
```
|
|
124
|
+
#arch: c
|
|
125
|
+
#platform: macos
|
|
126
|
+
id date = ((id(*)(id, SEL, double))objc_msgSend)(
|
|
127
|
+
(id)objc_getClass("NSDate"), sel_registerName("dateWithTimeIntervalSince1970:"), (double)seconds);
|
|
128
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
129
|
+
(id)self->handle, sel_registerName("setDateValue:"), date);
|
|
130
|
+
```
|
|
131
|
+
```
|
|
132
|
+
#arch: aarch64_use_c
|
|
133
|
+
#platform: macos
|
|
134
|
+
id date = ((id(*)(id, SEL, double))objc_msgSend)(
|
|
135
|
+
(id)objc_getClass("NSDate"), sel_registerName("dateWithTimeIntervalSince1970:"), (double)seconds);
|
|
136
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
137
|
+
(id)self->handle, sel_registerName("setDateValue:"), date);
|
|
138
|
+
```
|
|
139
|
+
```
|
|
140
|
+
#arch: c
|
|
141
|
+
#platform: ios
|
|
142
|
+
id date = ((id(*)(id, SEL, double))objc_msgSend)(
|
|
143
|
+
(id)objc_getClass("NSDate"), sel_registerName("dateWithTimeIntervalSince1970:"), (double)seconds);
|
|
144
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
145
|
+
(id)self->handle, sel_registerName("setDate:"), date);
|
|
146
|
+
```
|
|
147
|
+
```
|
|
148
|
+
#arch: aarch64_use_c
|
|
149
|
+
#platform: ios
|
|
150
|
+
id date = ((id(*)(id, SEL, double))objc_msgSend)(
|
|
151
|
+
(id)objc_getClass("NSDate"), sel_registerName("dateWithTimeIntervalSince1970:"), (double)seconds);
|
|
152
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
153
|
+
(id)self->handle, sel_registerName("setDate:"), date);
|
|
154
|
+
```
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// The picker's current value as epoch seconds (UTC).
|
|
158
|
+
pub func time = (self, out int64) {
|
|
159
|
+
```
|
|
160
|
+
#arch: c
|
|
161
|
+
#platform: macos
|
|
162
|
+
id date = ((id(*)(id, SEL))objc_msgSend)(
|
|
163
|
+
(id)self->handle, sel_registerName("dateValue"));
|
|
164
|
+
double since = ((double(*)(id, SEL))objc_msgSend)(
|
|
165
|
+
date, sel_registerName("timeIntervalSince1970"));
|
|
166
|
+
return (long long)since;
|
|
167
|
+
```
|
|
168
|
+
```
|
|
169
|
+
#arch: aarch64_use_c
|
|
170
|
+
#platform: macos
|
|
171
|
+
id date = ((id(*)(id, SEL))objc_msgSend)(
|
|
172
|
+
(id)self->handle, sel_registerName("dateValue"));
|
|
173
|
+
double since = ((double(*)(id, SEL))objc_msgSend)(
|
|
174
|
+
date, sel_registerName("timeIntervalSince1970"));
|
|
175
|
+
return (long long)since;
|
|
176
|
+
```
|
|
177
|
+
```
|
|
178
|
+
#arch: c
|
|
179
|
+
#platform: ios
|
|
180
|
+
id date = ((id(*)(id, SEL))objc_msgSend)(
|
|
181
|
+
(id)self->handle, sel_registerName("date"));
|
|
182
|
+
double since = ((double(*)(id, SEL))objc_msgSend)(
|
|
183
|
+
date, sel_registerName("timeIntervalSince1970"));
|
|
184
|
+
return (long long)since;
|
|
185
|
+
```
|
|
186
|
+
```
|
|
187
|
+
#arch: aarch64_use_c
|
|
188
|
+
#platform: ios
|
|
189
|
+
id date = ((id(*)(id, SEL))objc_msgSend)(
|
|
190
|
+
(id)self->handle, sel_registerName("date"));
|
|
191
|
+
double since = ((double(*)(id, SEL))objc_msgSend)(
|
|
192
|
+
date, sel_registerName("timeIntervalSince1970"));
|
|
193
|
+
return (long long)since;
|
|
194
|
+
```
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
pub func set_hidden = (self, bool hidden) {
|
|
198
|
+
```
|
|
199
|
+
#arch: c
|
|
200
|
+
#platform: macos
|
|
201
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
202
|
+
(id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
|
|
203
|
+
```
|
|
204
|
+
```
|
|
205
|
+
#arch: aarch64_use_c
|
|
206
|
+
#platform: macos
|
|
207
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
208
|
+
(id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
|
|
209
|
+
```
|
|
210
|
+
```
|
|
211
|
+
#arch: c
|
|
212
|
+
#platform: ios
|
|
213
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
214
|
+
(id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
|
|
215
|
+
```
|
|
216
|
+
```
|
|
217
|
+
#arch: aarch64_use_c
|
|
218
|
+
#platform: ios
|
|
219
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
220
|
+
(id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
|
|
221
|
+
```
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// ── Control trait conformance ──
|
|
225
|
+
pub func intrinsic_size = (self, out Size) {
|
|
226
|
+
var [w, h] = native_intrinsic(self.handle)
|
|
227
|
+
var s = Size()
|
|
228
|
+
s.width = w
|
|
229
|
+
s.height = h
|
|
230
|
+
return s
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
pub func measure = (self, BoxConstraints constraints, out Size) {
|
|
234
|
+
var Size s = self.intrinsic_size()
|
|
235
|
+
if s.width > constraints.max_width {
|
|
236
|
+
s.width = constraints.max_width
|
|
237
|
+
}
|
|
238
|
+
if s.width < constraints.min_width {
|
|
239
|
+
s.width = constraints.min_width
|
|
240
|
+
}
|
|
241
|
+
if s.height > constraints.max_height {
|
|
242
|
+
s.height = constraints.max_height
|
|
243
|
+
}
|
|
244
|
+
if s.height < constraints.min_height {
|
|
245
|
+
s.height = constraints.min_height
|
|
246
|
+
}
|
|
247
|
+
return s
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
func #destroy = () {
|
|
251
|
+
```
|
|
252
|
+
#arch: c
|
|
253
|
+
#platform: macos
|
|
254
|
+
if (self->handle) {
|
|
255
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
|
|
256
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
|
|
257
|
+
self->handle = 0;
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
```
|
|
261
|
+
#arch: aarch64_use_c
|
|
262
|
+
#platform: macos
|
|
263
|
+
if (self->handle) {
|
|
264
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
|
|
265
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
|
|
266
|
+
self->handle = 0;
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
```
|
|
270
|
+
#arch: c
|
|
271
|
+
#platform: ios
|
|
272
|
+
if (self->handle) {
|
|
273
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
|
|
274
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
|
|
275
|
+
self->handle = 0;
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
```
|
|
279
|
+
#arch: aarch64_use_c
|
|
280
|
+
#platform: ios
|
|
281
|
+
if (self->handle) {
|
|
282
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
|
|
283
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
|
|
284
|
+
self->handle = 0;
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
}
|
|
288
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A labeled group of rows — GroupBox + Label rows composed
|
|
3
|
+
*
|
|
4
|
+
* PURE COMPOSITION (GUI_PLAN Tier 3 "reachable earlier"): no new native
|
|
5
|
+
* control, no drawing — a GroupBox draws the framed, titled panel while a
|
|
6
|
+
* padded vstack of label+control rows lays out ON TOP of it: both live in
|
|
7
|
+
* a ZStack node of the caller's grid (same rect; the later child paints on
|
|
8
|
+
* top), so the whole assembly lays out in the caller's single
|
|
9
|
+
* `grid.layout(win)` pass.
|
|
10
|
+
*
|
|
11
|
+
* Rows are added BEFORE the first layout: `add_row` pairs one of four
|
|
12
|
+
* pre-created labels with a control handle the caller owns (up to 4 rows).
|
|
13
|
+
* Hit-test the row controls through their own handles, as everywhere else.
|
|
14
|
+
**/
|
|
15
|
+
pub mv struct Form {
|
|
16
|
+
var GroupBox box
|
|
17
|
+
var Text l0
|
|
18
|
+
var Text l1
|
|
19
|
+
var Text l2
|
|
20
|
+
var Text l3
|
|
21
|
+
var rows = 0
|
|
22
|
+
var int rows_stack = -1
|
|
23
|
+
|
|
24
|
+
pub func #init = (self, Window window, string title) {
|
|
25
|
+
self.box = GroupBox(window, title)
|
|
26
|
+
self.l0 = Text(window)
|
|
27
|
+
self.l1 = Text(window)
|
|
28
|
+
self.l2 = Text(window)
|
|
29
|
+
self.l3 = Text(window)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Wire the assembly into the caller's grid under `parent`: the box
|
|
33
|
+
// fills the rect, the rows sit on top of it inset by the padding (which
|
|
34
|
+
// also clears the box's built-in title strip).
|
|
35
|
+
pub func add_to = (ref self, ref Container grid, int parent, int span) {
|
|
36
|
+
var int zs = grid.add_zstack(parent, span)
|
|
37
|
+
grid.add_to(zs, self.box.handle, 0, 0, 1, 1)
|
|
38
|
+
var int blk = grid.add_block_to(zs, 24, 1)
|
|
39
|
+
self.rows_stack = grid.add_vstack(blk, 8, 1)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Append a row: `label` on the left (intrinsic width), the caller's
|
|
43
|
+
// control filling the rest at `control_h` tall. Up to 4 rows.
|
|
44
|
+
pub func add_row = (ref self, ref Container grid, string label, uint64 control, int control_h) {
|
|
45
|
+
var uint64 label_handle = 0
|
|
46
|
+
if self.rows == 0 {
|
|
47
|
+
self.l0.set_text(label)
|
|
48
|
+
label_handle = self.l0.handle
|
|
49
|
+
}
|
|
50
|
+
if self.rows == 1 {
|
|
51
|
+
self.l1.set_text(label)
|
|
52
|
+
label_handle = self.l1.handle
|
|
53
|
+
}
|
|
54
|
+
if self.rows == 2 {
|
|
55
|
+
self.l2.set_text(label)
|
|
56
|
+
label_handle = self.l2.handle
|
|
57
|
+
}
|
|
58
|
+
if self.rows == 3 {
|
|
59
|
+
self.l3.set_text(label)
|
|
60
|
+
label_handle = self.l3.handle
|
|
61
|
+
}
|
|
62
|
+
if self.rows > 3 {
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
var int row = grid.add_hstack(self.rows_stack, 8, 1)
|
|
66
|
+
grid.add_to_intrinsic(row, label_handle, 1)
|
|
67
|
+
grid.add_to(row, control, 0, control_h, 1, 1)
|
|
68
|
+
self.rows += 1
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A labeled bordered box that gives forms a section frame for free
|
|
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
|
+
* NSBox in its primary style with a title. macOS-only — iOS has no boxed
|
|
10
|
+
* group view (TODO stubs; see GUI_PLAN Tier 1 #17).
|
|
11
|
+
**/
|
|
12
|
+
pub mv struct GroupBox: Control {
|
|
13
|
+
var uint64 handle = 0
|
|
14
|
+
|
|
15
|
+
pub func #init = (self, Window window, string title) {
|
|
16
|
+
```
|
|
17
|
+
#arch: c
|
|
18
|
+
#platform: macos
|
|
19
|
+
id box = ((id(*)(id, SEL, CGRect))objc_msgSend)(
|
|
20
|
+
((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSBox"), sel_registerName("alloc")),
|
|
21
|
+
sel_registerName("initWithFrame:"),
|
|
22
|
+
((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 240, 120));
|
|
23
|
+
((void(*)(id, SEL, long))objc_msgSend)(
|
|
24
|
+
box, sel_registerName("setBoxType:"), 0); // NSBoxPrimary = 0
|
|
25
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
26
|
+
box, sel_registerName("setTitle:"),
|
|
27
|
+
((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
28
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
|
|
29
|
+
id contentView = ((id(*)(id, SEL))objc_msgSend)(
|
|
30
|
+
(id)window->handle, sel_registerName("contentView"));
|
|
31
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
32
|
+
contentView, sel_registerName("addSubview:"), box);
|
|
33
|
+
self.handle = (uint64_t)box;
|
|
34
|
+
```
|
|
35
|
+
```
|
|
36
|
+
#arch: aarch64_use_c
|
|
37
|
+
#platform: macos
|
|
38
|
+
id box = ((id(*)(id, SEL, CGRect))objc_msgSend)(
|
|
39
|
+
((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSBox"), sel_registerName("alloc")),
|
|
40
|
+
sel_registerName("initWithFrame:"),
|
|
41
|
+
((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 240, 120));
|
|
42
|
+
((void(*)(id, SEL, long))objc_msgSend)(
|
|
43
|
+
box, sel_registerName("setBoxType:"), 0); // NSBoxPrimary = 0
|
|
44
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
45
|
+
box, sel_registerName("setTitle:"),
|
|
46
|
+
((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
47
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
|
|
48
|
+
id contentView = ((id(*)(id, SEL))objc_msgSend)(
|
|
49
|
+
(id)window->handle, sel_registerName("contentView"));
|
|
50
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
51
|
+
contentView, sel_registerName("addSubview:"), box);
|
|
52
|
+
self->handle = (uint64_t)box;
|
|
53
|
+
```
|
|
54
|
+
```
|
|
55
|
+
#arch: c
|
|
56
|
+
#platform: ios
|
|
57
|
+
/* TODO: iOS — no native boxed group view (see GUI_PLAN Tier 1 #17;
|
|
58
|
+
* compose from a titled border drawn by the layout layer if needed). */
|
|
59
|
+
```
|
|
60
|
+
```
|
|
61
|
+
#arch: aarch64_use_c
|
|
62
|
+
#platform: ios
|
|
63
|
+
/* TODO: iOS — no native boxed group view (see GUI_PLAN Tier 1 #17;
|
|
64
|
+
* compose from a titled border drawn by the layout layer if needed). */
|
|
65
|
+
```
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
pub func set_frame = (ref self, int x, int y, int width, int height) {
|
|
69
|
+
```
|
|
70
|
+
#arch: c
|
|
71
|
+
#platform: macos
|
|
72
|
+
((void(*)(id, SEL, CGRect))objc_msgSend)(
|
|
73
|
+
(id)self->handle, sel_registerName("setFrame:"),
|
|
74
|
+
((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
|
|
75
|
+
```
|
|
76
|
+
```
|
|
77
|
+
#arch: aarch64_use_c
|
|
78
|
+
#platform: macos
|
|
79
|
+
((void(*)(id, SEL, CGRect))objc_msgSend)(
|
|
80
|
+
(id)self->handle, sel_registerName("setFrame:"),
|
|
81
|
+
((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
|
|
82
|
+
```
|
|
83
|
+
```
|
|
84
|
+
#arch: c
|
|
85
|
+
#platform: ios
|
|
86
|
+
/* TODO: iOS (see #init) */
|
|
87
|
+
```
|
|
88
|
+
```
|
|
89
|
+
#arch: aarch64_use_c
|
|
90
|
+
#platform: ios
|
|
91
|
+
/* TODO: iOS (see #init) */
|
|
92
|
+
```
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
pub func set_title = (self, string title) {
|
|
96
|
+
```
|
|
97
|
+
#arch: c
|
|
98
|
+
#platform: macos
|
|
99
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
100
|
+
(id)self->handle, sel_registerName("setTitle:"),
|
|
101
|
+
((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
102
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
|
|
103
|
+
```
|
|
104
|
+
```
|
|
105
|
+
#arch: aarch64_use_c
|
|
106
|
+
#platform: macos
|
|
107
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
108
|
+
(id)self->handle, sel_registerName("setTitle:"),
|
|
109
|
+
((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
110
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
|
|
111
|
+
```
|
|
112
|
+
```
|
|
113
|
+
#arch: c
|
|
114
|
+
#platform: ios
|
|
115
|
+
/* TODO: iOS (see #init) */
|
|
116
|
+
```
|
|
117
|
+
```
|
|
118
|
+
#arch: aarch64_use_c
|
|
119
|
+
#platform: ios
|
|
120
|
+
/* TODO: iOS (see #init) */
|
|
121
|
+
```
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
pub func get_title = (self, out string) {
|
|
125
|
+
```
|
|
126
|
+
#arch: c
|
|
127
|
+
#platform: macos
|
|
128
|
+
id str = ((id(*)(id, SEL))objc_msgSend)(
|
|
129
|
+
(id)self->handle, sel_registerName("title"));
|
|
130
|
+
const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
|
|
131
|
+
str, sel_registerName("UTF8String"));
|
|
132
|
+
return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
|
|
133
|
+
```
|
|
134
|
+
```
|
|
135
|
+
#arch: aarch64_use_c
|
|
136
|
+
#platform: macos
|
|
137
|
+
id str = ((id(*)(id, SEL))objc_msgSend)(
|
|
138
|
+
(id)self->handle, sel_registerName("title"));
|
|
139
|
+
const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
|
|
140
|
+
str, sel_registerName("UTF8String"));
|
|
141
|
+
return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
|
|
142
|
+
```
|
|
143
|
+
```
|
|
144
|
+
#arch: c
|
|
145
|
+
#platform: ios
|
|
146
|
+
/* TODO: iOS (see #init) */
|
|
147
|
+
return (nomen_string){ strdup(""), 0 };
|
|
148
|
+
```
|
|
149
|
+
```
|
|
150
|
+
#arch: aarch64_use_c
|
|
151
|
+
#platform: ios
|
|
152
|
+
/* TODO: iOS (see #init) */
|
|
153
|
+
return (nomen_string){ strdup(""), 0 };
|
|
154
|
+
```
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// The NSBoxType (0 = primary/boxed) — exposes the native style for tests
|
|
158
|
+
// and diagnostics.
|
|
159
|
+
pub func box_type = (self, out int) {
|
|
160
|
+
```
|
|
161
|
+
#arch: c
|
|
162
|
+
#platform: macos
|
|
163
|
+
return (int)((long(*)(id, SEL))objc_msgSend)(
|
|
164
|
+
(id)self->handle, sel_registerName("boxType"));
|
|
165
|
+
```
|
|
166
|
+
```
|
|
167
|
+
#arch: aarch64_use_c
|
|
168
|
+
#platform: macos
|
|
169
|
+
return (int)((long(*)(id, SEL))objc_msgSend)(
|
|
170
|
+
(id)self->handle, sel_registerName("boxType"));
|
|
171
|
+
```
|
|
172
|
+
```
|
|
173
|
+
#arch: c
|
|
174
|
+
#platform: ios
|
|
175
|
+
/* TODO: iOS (see #init) */
|
|
176
|
+
return 0;
|
|
177
|
+
```
|
|
178
|
+
```
|
|
179
|
+
#arch: aarch64_use_c
|
|
180
|
+
#platform: ios
|
|
181
|
+
/* TODO: iOS (see #init) */
|
|
182
|
+
return 0;
|
|
183
|
+
```
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
pub func set_hidden = (self, bool hidden) {
|
|
187
|
+
```
|
|
188
|
+
#arch: c
|
|
189
|
+
#platform: macos
|
|
190
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
191
|
+
(id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
|
|
192
|
+
```
|
|
193
|
+
```
|
|
194
|
+
#arch: aarch64_use_c
|
|
195
|
+
#platform: macos
|
|
196
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
197
|
+
(id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
|
|
198
|
+
```
|
|
199
|
+
```
|
|
200
|
+
#arch: c
|
|
201
|
+
#platform: ios
|
|
202
|
+
/* TODO: iOS (see #init) */
|
|
203
|
+
```
|
|
204
|
+
```
|
|
205
|
+
#arch: aarch64_use_c
|
|
206
|
+
#platform: ios
|
|
207
|
+
/* TODO: iOS (see #init) */
|
|
208
|
+
```
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// ── Control trait conformance ──
|
|
212
|
+
pub func intrinsic_size = (self, out Size) {
|
|
213
|
+
var [w, h] = native_intrinsic(self.handle)
|
|
214
|
+
var s = Size()
|
|
215
|
+
s.width = w
|
|
216
|
+
s.height = h
|
|
217
|
+
return s
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
pub func measure = (self, BoxConstraints constraints, out Size) {
|
|
221
|
+
var Size s = self.intrinsic_size()
|
|
222
|
+
if s.width > constraints.max_width {
|
|
223
|
+
s.width = constraints.max_width
|
|
224
|
+
}
|
|
225
|
+
if s.width < constraints.min_width {
|
|
226
|
+
s.width = constraints.min_width
|
|
227
|
+
}
|
|
228
|
+
if s.height > constraints.max_height {
|
|
229
|
+
s.height = constraints.max_height
|
|
230
|
+
}
|
|
231
|
+
if s.height < constraints.min_height {
|
|
232
|
+
s.height = constraints.min_height
|
|
233
|
+
}
|
|
234
|
+
return s
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
func #destroy = () {
|
|
238
|
+
```
|
|
239
|
+
#arch: c
|
|
240
|
+
#platform: macos
|
|
241
|
+
if (self->handle) {
|
|
242
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
|
|
243
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
|
|
244
|
+
self->handle = 0;
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
```
|
|
248
|
+
#arch: aarch64_use_c
|
|
249
|
+
#platform: macos
|
|
250
|
+
if (self->handle) {
|
|
251
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
|
|
252
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
|
|
253
|
+
self->handle = 0;
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
```
|
|
257
|
+
#arch: c
|
|
258
|
+
#platform: ios
|
|
259
|
+
/* TODO: iOS (see #init) */
|
|
260
|
+
```
|
|
261
|
+
```
|
|
262
|
+
#arch: aarch64_use_c
|
|
263
|
+
#platform: ios
|
|
264
|
+
/* TODO: iOS (see #init) */
|
|
265
|
+
```
|
|
266
|
+
}
|
|
267
|
+
}
|