1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct NSGridCellPlacement(pub NSInteger);
17impl NSGridCellPlacement {
18 #[doc(alias = "NSGridCellPlacementInherited")]
19 pub const Inherited: Self = Self(0);
20 #[doc(alias = "NSGridCellPlacementNone")]
21 pub const None: Self = Self(1);
22 #[doc(alias = "NSGridCellPlacementLeading")]
23 pub const Leading: Self = Self(2);
24 #[doc(alias = "NSGridCellPlacementTop")]
25 pub const Top: Self = Self(NSGridCellPlacement::Leading.0);
26 #[doc(alias = "NSGridCellPlacementTrailing")]
27 pub const Trailing: Self = Self(3);
28 #[doc(alias = "NSGridCellPlacementBottom")]
29 pub const Bottom: Self = Self(NSGridCellPlacement::Trailing.0);
30 #[doc(alias = "NSGridCellPlacementCenter")]
31 pub const Center: Self = Self(4);
32 #[doc(alias = "NSGridCellPlacementFill")]
33 pub const Fill: Self = Self(5);
34}
35
36unsafe impl Encode for NSGridCellPlacement {
37 const ENCODING: Encoding = NSInteger::ENCODING;
38}
39
40unsafe impl RefEncode for NSGridCellPlacement {
41 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44#[repr(transparent)]
47#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
48pub struct NSGridRowAlignment(pub NSInteger);
49impl NSGridRowAlignment {
50 #[doc(alias = "NSGridRowAlignmentInherited")]
51 pub const Inherited: Self = Self(0);
52 #[doc(alias = "NSGridRowAlignmentNone")]
53 pub const None: Self = Self(1);
54 #[doc(alias = "NSGridRowAlignmentFirstBaseline")]
55 pub const FirstBaseline: Self = Self(2);
56 #[doc(alias = "NSGridRowAlignmentLastBaseline")]
57 pub const LastBaseline: Self = Self(3);
58}
59
60unsafe impl Encode for NSGridRowAlignment {
61 const ENCODING: Encoding = NSInteger::ENCODING;
62}
63
64unsafe impl RefEncode for NSGridRowAlignment {
65 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
66}
67
68extern "C" {
69 #[cfg(feature = "objc2-core-foundation")]
71 pub static NSGridViewSizeForContent: CGFloat;
72}
73
74extern_class!(
75 #[unsafe(super(NSView, NSResponder, NSObject))]
77 #[derive(Debug, PartialEq, Eq, Hash)]
78 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
79 pub struct NSGridView;
80);
81
82#[cfg(all(
83 feature = "NSAccessibilityProtocols",
84 feature = "NSResponder",
85 feature = "NSView"
86))]
87unsafe impl NSAccessibility for NSGridView {}
88
89#[cfg(all(
90 feature = "NSAccessibilityProtocols",
91 feature = "NSResponder",
92 feature = "NSView"
93))]
94unsafe impl NSAccessibilityElementProtocol for NSGridView {}
95
96#[cfg(all(feature = "NSAnimation", feature = "NSResponder", feature = "NSView"))]
97unsafe impl NSAnimatablePropertyContainer for NSGridView {}
98
99#[cfg(all(feature = "NSAppearance", feature = "NSResponder", feature = "NSView"))]
100unsafe impl NSAppearanceCustomization for NSGridView {}
101
102#[cfg(all(feature = "NSResponder", feature = "NSView"))]
103unsafe impl NSCoding for NSGridView {}
104
105#[cfg(all(feature = "NSDragging", feature = "NSResponder", feature = "NSView"))]
106unsafe impl NSDraggingDestination for NSGridView {}
107
108#[cfg(all(feature = "NSResponder", feature = "NSView"))]
109unsafe impl NSObjectProtocol for NSGridView {}
110
111#[cfg(all(
112 feature = "NSResponder",
113 feature = "NSUserInterfaceItemIdentification",
114 feature = "NSView"
115))]
116unsafe impl NSUserInterfaceItemIdentification for NSGridView {}
117
118#[cfg(all(feature = "NSResponder", feature = "NSView"))]
119impl NSGridView {
120 extern_methods!(
121 #[unsafe(method(initWithFrame:))]
122 #[unsafe(method_family = init)]
123 pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
124
125 #[unsafe(method(initWithCoder:))]
126 #[unsafe(method_family = init)]
127 pub unsafe fn initWithCoder(
128 this: Allocated<Self>,
129 coder: &NSCoder,
130 ) -> Option<Retained<Self>>;
131
132 #[unsafe(method(gridViewWithNumberOfColumns:rows:))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn gridViewWithNumberOfColumns_rows(
135 column_count: NSInteger,
136 row_count: NSInteger,
137 mtm: MainThreadMarker,
138 ) -> Retained<Self>;
139
140 #[unsafe(method(gridViewWithViews:))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn gridViewWithViews(
143 rows: &NSArray<NSArray<NSView>>,
144 mtm: MainThreadMarker,
145 ) -> Retained<Self>;
146
147 #[unsafe(method(numberOfRows))]
148 #[unsafe(method_family = none)]
149 pub unsafe fn numberOfRows(&self) -> NSInteger;
150
151 #[unsafe(method(numberOfColumns))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn numberOfColumns(&self) -> NSInteger;
154
155 #[unsafe(method(rowAtIndex:))]
156 #[unsafe(method_family = none)]
157 pub unsafe fn rowAtIndex(&self, index: NSInteger) -> Retained<NSGridRow>;
158
159 #[unsafe(method(indexOfRow:))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn indexOfRow(&self, row: &NSGridRow) -> NSInteger;
162
163 #[unsafe(method(columnAtIndex:))]
164 #[unsafe(method_family = none)]
165 pub unsafe fn columnAtIndex(&self, index: NSInteger) -> Retained<NSGridColumn>;
166
167 #[unsafe(method(indexOfColumn:))]
168 #[unsafe(method_family = none)]
169 pub unsafe fn indexOfColumn(&self, column: &NSGridColumn) -> NSInteger;
170
171 #[unsafe(method(cellAtColumnIndex:rowIndex:))]
172 #[unsafe(method_family = none)]
173 pub unsafe fn cellAtColumnIndex_rowIndex(
174 &self,
175 column_index: NSInteger,
176 row_index: NSInteger,
177 ) -> Retained<NSGridCell>;
178
179 #[unsafe(method(cellForView:))]
180 #[unsafe(method_family = none)]
181 pub unsafe fn cellForView(&self, view: &NSView) -> Option<Retained<NSGridCell>>;
182
183 #[unsafe(method(addRowWithViews:))]
184 #[unsafe(method_family = none)]
185 pub unsafe fn addRowWithViews(&self, views: &NSArray<NSView>) -> Retained<NSGridRow>;
186
187 #[unsafe(method(insertRowAtIndex:withViews:))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn insertRowAtIndex_withViews(
190 &self,
191 index: NSInteger,
192 views: &NSArray<NSView>,
193 ) -> Retained<NSGridRow>;
194
195 #[unsafe(method(moveRowAtIndex:toIndex:))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn moveRowAtIndex_toIndex(&self, from_index: NSInteger, to_index: NSInteger);
198
199 #[unsafe(method(removeRowAtIndex:))]
200 #[unsafe(method_family = none)]
201 pub unsafe fn removeRowAtIndex(&self, index: NSInteger);
202
203 #[unsafe(method(addColumnWithViews:))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn addColumnWithViews(&self, views: &NSArray<NSView>) -> Retained<NSGridColumn>;
206
207 #[unsafe(method(insertColumnAtIndex:withViews:))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn insertColumnAtIndex_withViews(
210 &self,
211 index: NSInteger,
212 views: &NSArray<NSView>,
213 ) -> Retained<NSGridColumn>;
214
215 #[unsafe(method(moveColumnAtIndex:toIndex:))]
216 #[unsafe(method_family = none)]
217 pub unsafe fn moveColumnAtIndex_toIndex(&self, from_index: NSInteger, to_index: NSInteger);
218
219 #[unsafe(method(removeColumnAtIndex:))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn removeColumnAtIndex(&self, index: NSInteger);
222
223 #[unsafe(method(xPlacement))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn xPlacement(&self) -> NSGridCellPlacement;
226
227 #[unsafe(method(setXPlacement:))]
229 #[unsafe(method_family = none)]
230 pub unsafe fn setXPlacement(&self, x_placement: NSGridCellPlacement);
231
232 #[unsafe(method(yPlacement))]
233 #[unsafe(method_family = none)]
234 pub unsafe fn yPlacement(&self) -> NSGridCellPlacement;
235
236 #[unsafe(method(setYPlacement:))]
238 #[unsafe(method_family = none)]
239 pub unsafe fn setYPlacement(&self, y_placement: NSGridCellPlacement);
240
241 #[unsafe(method(rowAlignment))]
242 #[unsafe(method_family = none)]
243 pub unsafe fn rowAlignment(&self) -> NSGridRowAlignment;
244
245 #[unsafe(method(setRowAlignment:))]
247 #[unsafe(method_family = none)]
248 pub unsafe fn setRowAlignment(&self, row_alignment: NSGridRowAlignment);
249
250 #[cfg(feature = "objc2-core-foundation")]
251 #[unsafe(method(rowSpacing))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn rowSpacing(&self) -> CGFloat;
254
255 #[cfg(feature = "objc2-core-foundation")]
256 #[unsafe(method(setRowSpacing:))]
258 #[unsafe(method_family = none)]
259 pub unsafe fn setRowSpacing(&self, row_spacing: CGFloat);
260
261 #[cfg(feature = "objc2-core-foundation")]
262 #[unsafe(method(columnSpacing))]
263 #[unsafe(method_family = none)]
264 pub unsafe fn columnSpacing(&self) -> CGFloat;
265
266 #[cfg(feature = "objc2-core-foundation")]
267 #[unsafe(method(setColumnSpacing:))]
269 #[unsafe(method_family = none)]
270 pub unsafe fn setColumnSpacing(&self, column_spacing: CGFloat);
271
272 #[unsafe(method(mergeCellsInHorizontalRange:verticalRange:))]
273 #[unsafe(method_family = none)]
274 pub unsafe fn mergeCellsInHorizontalRange_verticalRange(
275 &self,
276 h_range: NSRange,
277 v_range: NSRange,
278 );
279 );
280}
281
282#[cfg(all(feature = "NSResponder", feature = "NSView"))]
284impl NSGridView {
285 extern_methods!(
286 #[unsafe(method(init))]
287 #[unsafe(method_family = init)]
288 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
289 );
290}
291
292#[cfg(all(feature = "NSResponder", feature = "NSView"))]
294impl NSGridView {
295 extern_methods!(
296 #[unsafe(method(new))]
297 #[unsafe(method_family = new)]
298 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
299 );
300}
301
302extern_class!(
303 #[unsafe(super(NSObject))]
305 #[thread_kind = MainThreadOnly]
306 #[derive(Debug, PartialEq, Eq, Hash)]
307 pub struct NSGridRow;
308);
309
310unsafe impl NSCoding for NSGridRow {}
311
312unsafe impl NSObjectProtocol for NSGridRow {}
313
314impl NSGridRow {
315 extern_methods!(
316 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
317 #[unsafe(method(gridView))]
318 #[unsafe(method_family = none)]
319 pub unsafe fn gridView(&self) -> Option<Retained<NSGridView>>;
320
321 #[unsafe(method(numberOfCells))]
322 #[unsafe(method_family = none)]
323 pub unsafe fn numberOfCells(&self) -> NSInteger;
324
325 #[unsafe(method(cellAtIndex:))]
326 #[unsafe(method_family = none)]
327 pub unsafe fn cellAtIndex(&self, index: NSInteger) -> Retained<NSGridCell>;
328
329 #[unsafe(method(yPlacement))]
330 #[unsafe(method_family = none)]
331 pub unsafe fn yPlacement(&self) -> NSGridCellPlacement;
332
333 #[unsafe(method(setYPlacement:))]
335 #[unsafe(method_family = none)]
336 pub unsafe fn setYPlacement(&self, y_placement: NSGridCellPlacement);
337
338 #[unsafe(method(rowAlignment))]
339 #[unsafe(method_family = none)]
340 pub unsafe fn rowAlignment(&self) -> NSGridRowAlignment;
341
342 #[unsafe(method(setRowAlignment:))]
344 #[unsafe(method_family = none)]
345 pub unsafe fn setRowAlignment(&self, row_alignment: NSGridRowAlignment);
346
347 #[cfg(feature = "objc2-core-foundation")]
348 #[unsafe(method(height))]
349 #[unsafe(method_family = none)]
350 pub unsafe fn height(&self) -> CGFloat;
351
352 #[cfg(feature = "objc2-core-foundation")]
353 #[unsafe(method(setHeight:))]
355 #[unsafe(method_family = none)]
356 pub unsafe fn setHeight(&self, height: CGFloat);
357
358 #[cfg(feature = "objc2-core-foundation")]
359 #[unsafe(method(topPadding))]
360 #[unsafe(method_family = none)]
361 pub unsafe fn topPadding(&self) -> CGFloat;
362
363 #[cfg(feature = "objc2-core-foundation")]
364 #[unsafe(method(setTopPadding:))]
366 #[unsafe(method_family = none)]
367 pub unsafe fn setTopPadding(&self, top_padding: CGFloat);
368
369 #[cfg(feature = "objc2-core-foundation")]
370 #[unsafe(method(bottomPadding))]
371 #[unsafe(method_family = none)]
372 pub unsafe fn bottomPadding(&self) -> CGFloat;
373
374 #[cfg(feature = "objc2-core-foundation")]
375 #[unsafe(method(setBottomPadding:))]
377 #[unsafe(method_family = none)]
378 pub unsafe fn setBottomPadding(&self, bottom_padding: CGFloat);
379
380 #[unsafe(method(isHidden))]
381 #[unsafe(method_family = none)]
382 pub unsafe fn isHidden(&self) -> bool;
383
384 #[unsafe(method(setHidden:))]
386 #[unsafe(method_family = none)]
387 pub unsafe fn setHidden(&self, hidden: bool);
388
389 #[unsafe(method(mergeCellsInRange:))]
390 #[unsafe(method_family = none)]
391 pub unsafe fn mergeCellsInRange(&self, range: NSRange);
392 );
393}
394
395impl NSGridRow {
397 extern_methods!(
398 #[unsafe(method(init))]
399 #[unsafe(method_family = init)]
400 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
401
402 #[unsafe(method(new))]
403 #[unsafe(method_family = new)]
404 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
405 );
406}
407
408extern_class!(
409 #[unsafe(super(NSObject))]
411 #[thread_kind = MainThreadOnly]
412 #[derive(Debug, PartialEq, Eq, Hash)]
413 pub struct NSGridColumn;
414);
415
416unsafe impl NSCoding for NSGridColumn {}
417
418unsafe impl NSObjectProtocol for NSGridColumn {}
419
420impl NSGridColumn {
421 extern_methods!(
422 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
423 #[unsafe(method(gridView))]
424 #[unsafe(method_family = none)]
425 pub unsafe fn gridView(&self) -> Option<Retained<NSGridView>>;
426
427 #[unsafe(method(numberOfCells))]
428 #[unsafe(method_family = none)]
429 pub unsafe fn numberOfCells(&self) -> NSInteger;
430
431 #[unsafe(method(cellAtIndex:))]
432 #[unsafe(method_family = none)]
433 pub unsafe fn cellAtIndex(&self, index: NSInteger) -> Retained<NSGridCell>;
434
435 #[unsafe(method(xPlacement))]
436 #[unsafe(method_family = none)]
437 pub unsafe fn xPlacement(&self) -> NSGridCellPlacement;
438
439 #[unsafe(method(setXPlacement:))]
441 #[unsafe(method_family = none)]
442 pub unsafe fn setXPlacement(&self, x_placement: NSGridCellPlacement);
443
444 #[cfg(feature = "objc2-core-foundation")]
445 #[unsafe(method(width))]
446 #[unsafe(method_family = none)]
447 pub unsafe fn width(&self) -> CGFloat;
448
449 #[cfg(feature = "objc2-core-foundation")]
450 #[unsafe(method(setWidth:))]
452 #[unsafe(method_family = none)]
453 pub unsafe fn setWidth(&self, width: CGFloat);
454
455 #[cfg(feature = "objc2-core-foundation")]
456 #[unsafe(method(leadingPadding))]
457 #[unsafe(method_family = none)]
458 pub unsafe fn leadingPadding(&self) -> CGFloat;
459
460 #[cfg(feature = "objc2-core-foundation")]
461 #[unsafe(method(setLeadingPadding:))]
463 #[unsafe(method_family = none)]
464 pub unsafe fn setLeadingPadding(&self, leading_padding: CGFloat);
465
466 #[cfg(feature = "objc2-core-foundation")]
467 #[unsafe(method(trailingPadding))]
468 #[unsafe(method_family = none)]
469 pub unsafe fn trailingPadding(&self) -> CGFloat;
470
471 #[cfg(feature = "objc2-core-foundation")]
472 #[unsafe(method(setTrailingPadding:))]
474 #[unsafe(method_family = none)]
475 pub unsafe fn setTrailingPadding(&self, trailing_padding: CGFloat);
476
477 #[unsafe(method(isHidden))]
478 #[unsafe(method_family = none)]
479 pub unsafe fn isHidden(&self) -> bool;
480
481 #[unsafe(method(setHidden:))]
483 #[unsafe(method_family = none)]
484 pub unsafe fn setHidden(&self, hidden: bool);
485
486 #[unsafe(method(mergeCellsInRange:))]
487 #[unsafe(method_family = none)]
488 pub unsafe fn mergeCellsInRange(&self, range: NSRange);
489 );
490}
491
492impl NSGridColumn {
494 extern_methods!(
495 #[unsafe(method(init))]
496 #[unsafe(method_family = init)]
497 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
498
499 #[unsafe(method(new))]
500 #[unsafe(method_family = new)]
501 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
502 );
503}
504
505extern_class!(
506 #[unsafe(super(NSObject))]
508 #[thread_kind = MainThreadOnly]
509 #[derive(Debug, PartialEq, Eq, Hash)]
510 pub struct NSGridCell;
511);
512
513unsafe impl NSCoding for NSGridCell {}
514
515unsafe impl NSObjectProtocol for NSGridCell {}
516
517impl NSGridCell {
518 extern_methods!(
519 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
520 #[unsafe(method(contentView))]
521 #[unsafe(method_family = none)]
522 pub unsafe fn contentView(&self) -> Option<Retained<NSView>>;
523
524 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
525 #[unsafe(method(setContentView:))]
527 #[unsafe(method_family = none)]
528 pub unsafe fn setContentView(&self, content_view: Option<&NSView>);
529
530 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
531 #[unsafe(method(emptyContentView))]
532 #[unsafe(method_family = none)]
533 pub unsafe fn emptyContentView(mtm: MainThreadMarker) -> Retained<NSView>;
534
535 #[unsafe(method(row))]
536 #[unsafe(method_family = none)]
537 pub unsafe fn row(&self) -> Option<Retained<NSGridRow>>;
538
539 #[unsafe(method(column))]
540 #[unsafe(method_family = none)]
541 pub unsafe fn column(&self) -> Option<Retained<NSGridColumn>>;
542
543 #[unsafe(method(xPlacement))]
544 #[unsafe(method_family = none)]
545 pub unsafe fn xPlacement(&self) -> NSGridCellPlacement;
546
547 #[unsafe(method(setXPlacement:))]
549 #[unsafe(method_family = none)]
550 pub unsafe fn setXPlacement(&self, x_placement: NSGridCellPlacement);
551
552 #[unsafe(method(yPlacement))]
553 #[unsafe(method_family = none)]
554 pub unsafe fn yPlacement(&self) -> NSGridCellPlacement;
555
556 #[unsafe(method(setYPlacement:))]
558 #[unsafe(method_family = none)]
559 pub unsafe fn setYPlacement(&self, y_placement: NSGridCellPlacement);
560
561 #[unsafe(method(rowAlignment))]
562 #[unsafe(method_family = none)]
563 pub unsafe fn rowAlignment(&self) -> NSGridRowAlignment;
564
565 #[unsafe(method(setRowAlignment:))]
567 #[unsafe(method_family = none)]
568 pub unsafe fn setRowAlignment(&self, row_alignment: NSGridRowAlignment);
569
570 #[cfg(feature = "NSLayoutConstraint")]
571 #[unsafe(method(customPlacementConstraints))]
572 #[unsafe(method_family = none)]
573 pub unsafe fn customPlacementConstraints(&self) -> Retained<NSArray<NSLayoutConstraint>>;
574
575 #[cfg(feature = "NSLayoutConstraint")]
576 #[unsafe(method(setCustomPlacementConstraints:))]
578 #[unsafe(method_family = none)]
579 pub unsafe fn setCustomPlacementConstraints(
580 &self,
581 custom_placement_constraints: &NSArray<NSLayoutConstraint>,
582 );
583 );
584}
585
586impl NSGridCell {
588 extern_methods!(
589 #[unsafe(method(init))]
590 #[unsafe(method_family = init)]
591 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
592
593 #[unsafe(method(new))]
594 #[unsafe(method_family = new)]
595 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
596 );
597}