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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSMatrixMode(pub NSUInteger);
impl NSMatrixMode {
    pub const NSRadioModeMatrix: Self = Self(0);
    pub const NSHighlightModeMatrix: Self = Self(1);
    pub const NSListModeMatrix: Self = Self(2);
    pub const NSTrackModeMatrix: Self = Self(3);
}

unsafe impl Encode for NSMatrixMode {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSMatrixMode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
    pub struct NSMatrix;

    #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
    unsafe impl ClassType for NSMatrix {
        #[inherits(NSView, NSResponder, NSObject)]
        type Super = NSControl;
        type Mutability = MainThreadOnly;
    }
);

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSView"
))]
unsafe impl NSAccessibility for NSMatrix {}

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSView"
))]
unsafe impl NSAccessibilityElementProtocol for NSMatrix {}

#[cfg(all(
    feature = "NSAnimation",
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSView"
))]
unsafe impl NSAnimatablePropertyContainer for NSMatrix {}

#[cfg(all(
    feature = "NSAppearance",
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSView"
))]
unsafe impl NSAppearanceCustomization for NSMatrix {}

#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
unsafe impl NSCoding for NSMatrix {}

#[cfg(all(
    feature = "NSControl",
    feature = "NSDragging",
    feature = "NSResponder",
    feature = "NSView"
))]
unsafe impl NSDraggingDestination for NSMatrix {}

#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
unsafe impl NSObjectProtocol for NSMatrix {}

#[cfg(all(
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSUserInterfaceItemIdentification",
    feature = "NSView"
))]
unsafe impl NSUserInterfaceItemIdentification for NSMatrix {}

#[cfg(all(
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSUserInterfaceValidation",
    feature = "NSView"
))]
unsafe impl NSUserInterfaceValidations for NSMatrix {}

#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
unsafe impl NSViewToolTipOwner for NSMatrix {}

extern_methods!(
    #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
    unsafe impl NSMatrix {
        #[method_id(@__retain_semantics Init initWithFrame:)]
        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Id<Self>;

        #[cfg(feature = "NSCell")]
        #[method_id(@__retain_semantics Init initWithFrame:mode:prototype:numberOfRows:numberOfColumns:)]
        pub unsafe fn initWithFrame_mode_prototype_numberOfRows_numberOfColumns(
            this: Allocated<Self>,
            frame_rect: NSRect,
            mode: NSMatrixMode,
            cell: &NSCell,
            rows_high: NSInteger,
            cols_wide: NSInteger,
        ) -> Id<Self>;

        #[method_id(@__retain_semantics Init initWithFrame:mode:cellClass:numberOfRows:numberOfColumns:)]
        pub unsafe fn initWithFrame_mode_cellClass_numberOfRows_numberOfColumns(
            this: Allocated<Self>,
            frame_rect: NSRect,
            mode: NSMatrixMode,
            factory_id: Option<&AnyClass>,
            rows_high: NSInteger,
            cols_wide: NSInteger,
        ) -> Id<Self>;

        #[method(cellClass)]
        pub unsafe fn cellClass(&self) -> &'static AnyClass;

        #[method(setCellClass:)]
        pub unsafe fn setCellClass(&self, cell_class: &AnyClass);

        #[cfg(feature = "NSCell")]
        #[method_id(@__retain_semantics Other prototype)]
        pub unsafe fn prototype(&self) -> Option<Id<NSCell>>;

        #[cfg(feature = "NSCell")]
        #[method(setPrototype:)]
        pub unsafe fn setPrototype(&self, prototype: Option<&NSCell>);

        #[cfg(feature = "NSCell")]
        #[method_id(@__retain_semantics Other makeCellAtRow:column:)]
        pub unsafe fn makeCellAtRow_column(&self, row: NSInteger, col: NSInteger) -> Id<NSCell>;

        #[method(mode)]
        pub unsafe fn mode(&self) -> NSMatrixMode;

        #[method(setMode:)]
        pub unsafe fn setMode(&self, mode: NSMatrixMode);

        #[method(allowsEmptySelection)]
        pub unsafe fn allowsEmptySelection(&self) -> bool;

        #[method(setAllowsEmptySelection:)]
        pub unsafe fn setAllowsEmptySelection(&self, allows_empty_selection: bool);

        #[method(sendAction:to:forAllCells:)]
        pub unsafe fn sendAction_to_forAllCells(
            &self,
            selector: Sel,
            object: &AnyObject,
            flag: bool,
        );

        #[cfg(feature = "NSCell")]
        #[method_id(@__retain_semantics Other cells)]
        pub unsafe fn cells(&self) -> Id<NSArray<NSCell>>;

        #[method(sortUsingSelector:)]
        pub unsafe fn sortUsingSelector(&self, comparator: Sel);

        #[method(sortUsingFunction:context:)]
        pub unsafe fn sortUsingFunction_context(
            &self,
            compare: unsafe extern "C" fn(
                NonNull<AnyObject>,
                NonNull<AnyObject>,
                *mut c_void,
            ) -> NSInteger,
            context: *mut c_void,
        );

        #[cfg(feature = "NSCell")]
        #[method_id(@__retain_semantics Other selectedCell)]
        pub unsafe fn selectedCell(&self) -> Option<Id<NSCell>>;

        #[cfg(feature = "NSCell")]
        #[method_id(@__retain_semantics Other selectedCells)]
        pub unsafe fn selectedCells(&self) -> Id<NSArray<NSCell>>;

        #[method(selectedRow)]
        pub unsafe fn selectedRow(&self) -> NSInteger;

        #[method(selectedColumn)]
        pub unsafe fn selectedColumn(&self) -> NSInteger;

        #[method(isSelectionByRect)]
        pub unsafe fn isSelectionByRect(&self) -> bool;

        #[method(setSelectionByRect:)]
        pub unsafe fn setSelectionByRect(&self, selection_by_rect: bool);

        #[method(setSelectionFrom:to:anchor:highlight:)]
        pub unsafe fn setSelectionFrom_to_anchor_highlight(
            &self,
            start_pos: NSInteger,
            end_pos: NSInteger,
            anchor_pos: NSInteger,
            lit: bool,
        );

        #[method(deselectSelectedCell)]
        pub unsafe fn deselectSelectedCell(&self);

        #[method(deselectAllCells)]
        pub unsafe fn deselectAllCells(&self);

        #[method(selectCellAtRow:column:)]
        pub unsafe fn selectCellAtRow_column(&self, row: NSInteger, col: NSInteger);

        #[method(selectAll:)]
        pub unsafe fn selectAll(&self, sender: Option<&AnyObject>);

        #[method(selectCellWithTag:)]
        pub unsafe fn selectCellWithTag(&self, tag: NSInteger) -> bool;

        #[method(cellSize)]
        pub unsafe fn cellSize(&self) -> NSSize;

        #[method(setCellSize:)]
        pub unsafe fn setCellSize(&self, cell_size: NSSize);

        #[method(intercellSpacing)]
        pub unsafe fn intercellSpacing(&self) -> NSSize;

        #[method(setIntercellSpacing:)]
        pub unsafe fn setIntercellSpacing(&self, intercell_spacing: NSSize);

        #[method(setScrollable:)]
        pub unsafe fn setScrollable(&self, flag: bool);

        #[cfg(feature = "NSColor")]
        #[method_id(@__retain_semantics Other backgroundColor)]
        pub unsafe fn backgroundColor(&self) -> Id<NSColor>;

        #[cfg(feature = "NSColor")]
        #[method(setBackgroundColor:)]
        pub unsafe fn setBackgroundColor(&self, background_color: &NSColor);

        #[cfg(feature = "NSColor")]
        #[method_id(@__retain_semantics Other cellBackgroundColor)]
        pub unsafe fn cellBackgroundColor(&self) -> Option<Id<NSColor>>;

        #[cfg(feature = "NSColor")]
        #[method(setCellBackgroundColor:)]
        pub unsafe fn setCellBackgroundColor(&self, cell_background_color: Option<&NSColor>);

        #[method(drawsCellBackground)]
        pub unsafe fn drawsCellBackground(&self) -> bool;

        #[method(setDrawsCellBackground:)]
        pub unsafe fn setDrawsCellBackground(&self, draws_cell_background: bool);

        #[method(drawsBackground)]
        pub unsafe fn drawsBackground(&self) -> bool;

        #[method(setDrawsBackground:)]
        pub unsafe fn setDrawsBackground(&self, draws_background: bool);

        #[method(setState:atRow:column:)]
        pub unsafe fn setState_atRow_column(
            &self,
            value: NSInteger,
            row: NSInteger,
            col: NSInteger,
        );

        #[method(getNumberOfRows:columns:)]
        pub unsafe fn getNumberOfRows_columns(
            &self,
            row_count: *mut NSInteger,
            col_count: *mut NSInteger,
        );

        #[method(numberOfRows)]
        pub unsafe fn numberOfRows(&self) -> NSInteger;

        #[method(numberOfColumns)]
        pub unsafe fn numberOfColumns(&self) -> NSInteger;

        #[cfg(feature = "NSCell")]
        #[method_id(@__retain_semantics Other cellAtRow:column:)]
        pub unsafe fn cellAtRow_column(&self, row: NSInteger, col: NSInteger)
            -> Option<Id<NSCell>>;

        #[method(cellFrameAtRow:column:)]
        pub unsafe fn cellFrameAtRow_column(&self, row: NSInteger, col: NSInteger) -> NSRect;

        #[cfg(feature = "NSCell")]
        #[method(getRow:column:ofCell:)]
        pub unsafe fn getRow_column_ofCell(
            &self,
            row: NonNull<NSInteger>,
            col: NonNull<NSInteger>,
            cell: &NSCell,
        ) -> bool;

        #[method(getRow:column:forPoint:)]
        pub unsafe fn getRow_column_forPoint(
            &self,
            row: NonNull<NSInteger>,
            col: NonNull<NSInteger>,
            point: NSPoint,
        ) -> bool;

        #[method(renewRows:columns:)]
        pub unsafe fn renewRows_columns(&self, new_rows: NSInteger, new_cols: NSInteger);

        #[cfg(feature = "NSCell")]
        #[method(putCell:atRow:column:)]
        pub unsafe fn putCell_atRow_column(
            &self,
            new_cell: &NSCell,
            row: NSInteger,
            col: NSInteger,
        );

        #[method(addRow)]
        pub unsafe fn addRow(&self);

        #[cfg(feature = "NSCell")]
        #[method(addRowWithCells:)]
        pub unsafe fn addRowWithCells(&self, new_cells: &NSArray<NSCell>);

        #[method(insertRow:)]
        pub unsafe fn insertRow(&self, row: NSInteger);

        #[cfg(feature = "NSCell")]
        #[method(insertRow:withCells:)]
        pub unsafe fn insertRow_withCells(
            &self,
            row: NSInteger,
            new_cells: Option<&NSArray<NSCell>>,
        );

        #[method(removeRow:)]
        pub unsafe fn removeRow(&self, row: NSInteger);

        #[method(addColumn)]
        pub unsafe fn addColumn(&self);

        #[cfg(feature = "NSCell")]
        #[method(addColumnWithCells:)]
        pub unsafe fn addColumnWithCells(&self, new_cells: &NSArray<NSCell>);

        #[method(insertColumn:)]
        pub unsafe fn insertColumn(&self, column: NSInteger);

        #[cfg(feature = "NSCell")]
        #[method(insertColumn:withCells:)]
        pub unsafe fn insertColumn_withCells(
            &self,
            column: NSInteger,
            new_cells: Option<&NSArray<NSCell>>,
        );

        #[method(removeColumn:)]
        pub unsafe fn removeColumn(&self, col: NSInteger);

        #[cfg(feature = "NSCell")]
        #[method_id(@__retain_semantics Other cellWithTag:)]
        pub unsafe fn cellWithTag(&self, tag: NSInteger) -> Option<Id<NSCell>>;

        #[method(doubleAction)]
        pub unsafe fn doubleAction(&self) -> Option<Sel>;

        #[method(setDoubleAction:)]
        pub unsafe fn setDoubleAction(&self, double_action: Option<Sel>);

        #[method(autosizesCells)]
        pub unsafe fn autosizesCells(&self) -> bool;

        #[method(setAutosizesCells:)]
        pub unsafe fn setAutosizesCells(&self, autosizes_cells: bool);

        #[method(sizeToCells)]
        pub unsafe fn sizeToCells(&self);

        #[method(setValidateSize:)]
        pub unsafe fn setValidateSize(&self, flag: bool);

        #[method(drawCellAtRow:column:)]
        pub unsafe fn drawCellAtRow_column(&self, row: NSInteger, col: NSInteger);

        #[method(highlightCell:atRow:column:)]
        pub unsafe fn highlightCell_atRow_column(&self, flag: bool, row: NSInteger, col: NSInteger);

        #[method(isAutoscroll)]
        pub unsafe fn isAutoscroll(&self) -> bool;

        #[method(setAutoscroll:)]
        pub unsafe fn setAutoscroll(&self, autoscroll: bool);

        #[method(scrollCellToVisibleAtRow:column:)]
        pub unsafe fn scrollCellToVisibleAtRow_column(&self, row: NSInteger, col: NSInteger);

        #[method(mouseDownFlags)]
        pub unsafe fn mouseDownFlags(&self) -> NSInteger;

        #[cfg(feature = "NSEvent")]
        #[method(mouseDown:)]
        pub unsafe fn mouseDown(&self, event: &NSEvent);

        #[cfg(feature = "NSEvent")]
        #[method(performKeyEquivalent:)]
        pub unsafe fn performKeyEquivalent(&self, event: &NSEvent) -> bool;

        #[method(sendAction)]
        pub unsafe fn sendAction(&self) -> bool;

        #[method(sendDoubleAction)]
        pub unsafe fn sendDoubleAction(&self);

        #[method_id(@__retain_semantics Other delegate)]
        pub unsafe fn delegate(&self) -> Option<Id<ProtocolObject<dyn NSMatrixDelegate>>>;

        #[method(setDelegate:)]
        pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSMatrixDelegate>>);

        #[cfg(feature = "NSText")]
        #[method(textShouldBeginEditing:)]
        pub unsafe fn textShouldBeginEditing(&self, text_object: &NSText) -> bool;

        #[cfg(feature = "NSText")]
        #[method(textShouldEndEditing:)]
        pub unsafe fn textShouldEndEditing(&self, text_object: &NSText) -> bool;

        #[method(textDidBeginEditing:)]
        pub unsafe fn textDidBeginEditing(&self, notification: &NSNotification);

        #[method(textDidEndEditing:)]
        pub unsafe fn textDidEndEditing(&self, notification: &NSNotification);

        #[method(textDidChange:)]
        pub unsafe fn textDidChange(&self, notification: &NSNotification);

        #[method(selectText:)]
        pub unsafe fn selectText(&self, sender: Option<&AnyObject>);

        #[cfg(feature = "NSCell")]
        #[method_id(@__retain_semantics Other selectTextAtRow:column:)]
        pub unsafe fn selectTextAtRow_column(
            &self,
            row: NSInteger,
            col: NSInteger,
        ) -> Option<Id<NSCell>>;

        #[cfg(feature = "NSEvent")]
        #[method(acceptsFirstMouse:)]
        pub unsafe fn acceptsFirstMouse(&self, event: Option<&NSEvent>) -> bool;

        #[method(resetCursorRects)]
        pub unsafe fn resetCursorRects(&self);

        #[cfg(feature = "NSCell")]
        #[method(setToolTip:forCell:)]
        pub unsafe fn setToolTip_forCell(&self, tool_tip_string: Option<&NSString>, cell: &NSCell);

        #[cfg(feature = "NSCell")]
        #[method_id(@__retain_semantics Other toolTipForCell:)]
        pub unsafe fn toolTipForCell(&self, cell: &NSCell) -> Option<Id<NSString>>;

        #[method(autorecalculatesCellSize)]
        pub unsafe fn autorecalculatesCellSize(&self) -> bool;

        #[method(setAutorecalculatesCellSize:)]
        pub unsafe fn setAutorecalculatesCellSize(&self, autorecalculates_cell_size: bool);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSControl`
    #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
    unsafe impl NSMatrix {
        #[method_id(@__retain_semantics Init initWithCoder:)]
        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Option<Id<Self>>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSResponder`
    #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
    unsafe impl NSMatrix {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
    unsafe impl NSMatrix {
        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Id<Self>;
    }
);

extern_methods!(
    /// NSKeyboardUI
    #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
    unsafe impl NSMatrix {
        #[method(tabKeyTraversesCells)]
        pub unsafe fn tabKeyTraversesCells(&self) -> bool;

        #[method(setTabKeyTraversesCells:)]
        pub unsafe fn setTabKeyTraversesCells(&self, tab_key_traverses_cells: bool);

        #[cfg(feature = "NSCell")]
        #[method_id(@__retain_semantics Other keyCell)]
        pub unsafe fn keyCell(&self) -> Option<Id<NSCell>>;

        #[cfg(feature = "NSCell")]
        #[method(setKeyCell:)]
        pub unsafe fn setKeyCell(&self, key_cell: Option<&NSCell>);
    }
);

extern_protocol!(
    #[cfg(feature = "NSControl")]
    pub unsafe trait NSMatrixDelegate: NSControlTextEditingDelegate {}

    #[cfg(feature = "NSControl")]
    unsafe impl ProtocolType for dyn NSMatrixDelegate {}
);