objc2-app-kit 0.3.2

Bindings to the AppKit framework
Documentation
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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssegmentswitchtracking?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSSegmentSwitchTracking(pub NSUInteger);
impl NSSegmentSwitchTracking {
    #[doc(alias = "NSSegmentSwitchTrackingSelectOne")]
    pub const SelectOne: Self = Self(0);
    #[doc(alias = "NSSegmentSwitchTrackingSelectAny")]
    pub const SelectAny: Self = Self(1);
    #[doc(alias = "NSSegmentSwitchTrackingMomentary")]
    pub const Momentary: Self = Self(2);
    #[doc(alias = "NSSegmentSwitchTrackingMomentaryAccelerator")]
    pub const MomentaryAccelerator: Self = Self(3);
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssegmentstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSSegmentStyle(pub NSInteger);
impl NSSegmentStyle {
    #[doc(alias = "NSSegmentStyleAutomatic")]
    pub const Automatic: Self = Self(0);
    #[doc(alias = "NSSegmentStyleRounded")]
    pub const Rounded: Self = Self(1);
    #[doc(alias = "NSSegmentStyleRoundRect")]
    pub const RoundRect: Self = Self(3);
    #[doc(alias = "NSSegmentStyleTexturedSquare")]
    pub const TexturedSquare: Self = Self(4);
    #[doc(alias = "NSSegmentStyleSmallSquare")]
    pub const SmallSquare: Self = Self(6);
    #[doc(alias = "NSSegmentStyleSeparated")]
    pub const Separated: Self = Self(8);
    #[doc(alias = "NSSegmentStyleTexturedRounded")]
    pub const TexturedRounded: Self = Self(2);
    #[doc(alias = "NSSegmentStyleCapsule")]
    pub const Capsule: Self = Self(5);
}

unsafe impl Encode for NSSegmentStyle {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

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

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssegmentdistribution?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSSegmentDistribution(pub NSInteger);
impl NSSegmentDistribution {
    /// Dynamically sized segments will be sized to fit their contents, any remaining space will be left blank. This style is equivalent to the way segments were distributed on older systems.
    #[doc(alias = "NSSegmentDistributionFit")]
    pub const Fit: Self = Self(0);
    /// Dynamically sized segments will be sized to fill the available space, with extra space being distributed equally among them. Default value.
    #[doc(alias = "NSSegmentDistributionFill")]
    pub const Fill: Self = Self(1);
    /// Dynamically sized segments will be sized to fill the available space, and kept the same size as each other.
    #[doc(alias = "NSSegmentDistributionFillEqually")]
    pub const FillEqually: Self = Self(2);
    /// Dynamically sized segments will be sized to fill the available space, and kept proportional to their fitting size.
    #[doc(alias = "NSSegmentDistributionFillProportionally")]
    pub const FillProportionally: Self = Self(3);
}

unsafe impl Encode for NSSegmentDistribution {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssegmentedcontrol?language=objc)
    #[unsafe(super(NSControl, NSView, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
    pub struct NSSegmentedControl;
);

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

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

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

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

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

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

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

#[cfg(all(
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSUserInterfaceCompression",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSUserInterfaceCompression for NSSegmentedControl {}
);

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

#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSSegmentedControl {
    extern_methods!(
        #[unsafe(method(segmentCount))]
        #[unsafe(method_family = none)]
        pub fn segmentCount(&self) -> NSInteger;

        /// Setter for [`segmentCount`][Self::segmentCount].
        #[unsafe(method(setSegmentCount:))]
        #[unsafe(method_family = none)]
        pub fn setSegmentCount(&self, segment_count: NSInteger);

        #[unsafe(method(selectedSegment))]
        #[unsafe(method_family = none)]
        pub fn selectedSegment(&self) -> NSInteger;

        /// Setter for [`selectedSegment`][Self::selectedSegment].
        #[unsafe(method(setSelectedSegment:))]
        #[unsafe(method_family = none)]
        pub fn setSelectedSegment(&self, selected_segment: NSInteger);

        #[unsafe(method(selectSegmentWithTag:))]
        #[unsafe(method_family = none)]
        pub fn selectSegmentWithTag(&self, tag: NSInteger) -> bool;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(setWidth:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setWidth_forSegment(&self, width: CGFloat, segment: NSInteger);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(widthForSegment:))]
        #[unsafe(method_family = none)]
        pub fn widthForSegment(&self, segment: NSInteger) -> CGFloat;

        #[cfg(feature = "NSImage")]
        #[unsafe(method(setImage:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setImage_forSegment(&self, image: Option<&NSImage>, segment: NSInteger);

        #[cfg(feature = "NSImage")]
        #[unsafe(method(imageForSegment:))]
        #[unsafe(method_family = none)]
        pub fn imageForSegment(&self, segment: NSInteger) -> Option<Retained<NSImage>>;

        #[cfg(feature = "NSCell")]
        #[unsafe(method(setImageScaling:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setImageScaling_forSegment(&self, scaling: NSImageScaling, segment: NSInteger);

        #[cfg(feature = "NSCell")]
        #[unsafe(method(imageScalingForSegment:))]
        #[unsafe(method_family = none)]
        pub fn imageScalingForSegment(&self, segment: NSInteger) -> NSImageScaling;

        #[unsafe(method(setLabel:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setLabel_forSegment(&self, label: &NSString, segment: NSInteger);

        #[unsafe(method(labelForSegment:))]
        #[unsafe(method_family = none)]
        pub fn labelForSegment(&self, segment: NSInteger) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSMenu")]
        #[unsafe(method(setMenu:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setMenu_forSegment(&self, menu: Option<&NSMenu>, segment: NSInteger);

        #[cfg(feature = "NSMenu")]
        #[unsafe(method(menuForSegment:))]
        #[unsafe(method_family = none)]
        pub fn menuForSegment(&self, segment: NSInteger) -> Option<Retained<NSMenu>>;

        #[unsafe(method(setSelected:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setSelected_forSegment(&self, selected: bool, segment: NSInteger);

        #[unsafe(method(isSelectedForSegment:))]
        #[unsafe(method_family = none)]
        pub fn isSelectedForSegment(&self, segment: NSInteger) -> bool;

        #[unsafe(method(setEnabled:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setEnabled_forSegment(&self, enabled: bool, segment: NSInteger);

        #[unsafe(method(isEnabledForSegment:))]
        #[unsafe(method_family = none)]
        pub fn isEnabledForSegment(&self, segment: NSInteger) -> bool;

        #[unsafe(method(setToolTip:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setToolTip_forSegment(&self, tool_tip: Option<&NSString>, segment: NSInteger);

        #[unsafe(method(toolTipForSegment:))]
        #[unsafe(method_family = none)]
        pub fn toolTipForSegment(&self, segment: NSInteger) -> Option<Retained<NSString>>;

        #[unsafe(method(setTag:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setTag_forSegment(&self, tag: NSInteger, segment: NSInteger);

        #[unsafe(method(tagForSegment:))]
        #[unsafe(method_family = none)]
        pub fn tagForSegment(&self, segment: NSInteger) -> NSInteger;

        #[unsafe(method(setShowsMenuIndicator:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setShowsMenuIndicator_forSegment(
            &self,
            shows_menu_indicator: bool,
            segment: NSInteger,
        );

        #[unsafe(method(showsMenuIndicatorForSegment:))]
        #[unsafe(method_family = none)]
        pub fn showsMenuIndicatorForSegment(&self, segment: NSInteger) -> bool;

        #[unsafe(method(segmentStyle))]
        #[unsafe(method_family = none)]
        pub fn segmentStyle(&self) -> NSSegmentStyle;

        /// Setter for [`segmentStyle`][Self::segmentStyle].
        #[unsafe(method(setSegmentStyle:))]
        #[unsafe(method_family = none)]
        pub fn setSegmentStyle(&self, segment_style: NSSegmentStyle);

        #[unsafe(method(isSpringLoaded))]
        #[unsafe(method_family = none)]
        pub fn isSpringLoaded(&self) -> bool;

        /// Setter for [`isSpringLoaded`][Self::isSpringLoaded].
        #[unsafe(method(setSpringLoaded:))]
        #[unsafe(method_family = none)]
        pub fn setSpringLoaded(&self, spring_loaded: bool);

        #[unsafe(method(trackingMode))]
        #[unsafe(method_family = none)]
        pub fn trackingMode(&self) -> NSSegmentSwitchTracking;

        /// Setter for [`trackingMode`][Self::trackingMode].
        #[unsafe(method(setTrackingMode:))]
        #[unsafe(method_family = none)]
        pub fn setTrackingMode(&self, tracking_mode: NSSegmentSwitchTracking);

        #[unsafe(method(doubleValueForSelectedSegment))]
        #[unsafe(method_family = none)]
        pub fn doubleValueForSelectedSegment(&self) -> c_double;

        #[cfg(feature = "NSColor")]
        #[unsafe(method(selectedSegmentBezelColor))]
        #[unsafe(method_family = none)]
        pub fn selectedSegmentBezelColor(&self) -> Option<Retained<NSColor>>;

        #[cfg(feature = "NSColor")]
        /// Setter for [`selectedSegmentBezelColor`][Self::selectedSegmentBezelColor].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setSelectedSegmentBezelColor:))]
        #[unsafe(method_family = none)]
        pub fn setSelectedSegmentBezelColor(&self, selected_segment_bezel_color: Option<&NSColor>);

        #[unsafe(method(indexOfSelectedItem))]
        #[unsafe(method_family = none)]
        pub fn indexOfSelectedItem(&self) -> NSInteger;

        #[cfg(feature = "NSText")]
        #[unsafe(method(setAlignment:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setAlignment_forSegment(&self, alignment: NSTextAlignment, segment: NSInteger);

        #[cfg(feature = "NSText")]
        #[unsafe(method(alignmentForSegment:))]
        #[unsafe(method_family = none)]
        pub fn alignmentForSegment(&self, segment: NSInteger) -> NSTextAlignment;

        #[unsafe(method(segmentDistribution))]
        #[unsafe(method_family = none)]
        pub fn segmentDistribution(&self) -> NSSegmentDistribution;

        /// Setter for [`segmentDistribution`][Self::segmentDistribution].
        #[unsafe(method(setSegmentDistribution:))]
        #[unsafe(method_family = none)]
        pub fn setSegmentDistribution(&self, segment_distribution: NSSegmentDistribution);

        #[cfg(feature = "NSUserInterfaceCompression")]
        #[unsafe(method(compressWithPrioritizedCompressionOptions:))]
        #[unsafe(method_family = none)]
        pub fn compressWithPrioritizedCompressionOptions(
            &self,
            prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
        );

        #[cfg(feature = "NSUserInterfaceCompression")]
        #[unsafe(method(minimumSizeWithPrioritizedCompressionOptions:))]
        #[unsafe(method_family = none)]
        pub fn minimumSizeWithPrioritizedCompressionOptions(
            &self,
            prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
        ) -> NSSize;

        #[cfg(feature = "NSUserInterfaceCompression")]
        #[unsafe(method(activeCompressionOptions))]
        #[unsafe(method_family = none)]
        pub fn activeCompressionOptions(&self) -> Retained<NSUserInterfaceCompressionOptions>;

        #[unsafe(method(borderShape))]
        #[unsafe(method_family = none)]
        pub fn borderShape(&self) -> NSControlBorderShape;

        /// Setter for [`borderShape`][Self::borderShape].
        #[unsafe(method(setBorderShape:))]
        #[unsafe(method_family = none)]
        pub fn setBorderShape(&self, border_shape: NSControlBorderShape);
    );
}

/// Methods declared on superclass `NSControl`.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSSegmentedControl {
    extern_methods!(
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;
    );
}

/// Methods declared on superclass `NSResponder`.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSSegmentedControl {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSSegmentedControl {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

/// NSSegmentedControlConvenience.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSSegmentedControl {
    extern_methods!(
        /// Creates a standard segmented control containing one segment for each of the provided labels.
        ///
        /// Parameter `labels`: An array of localized label strings to use for the control's segments.
        ///
        /// Parameter `trackingMode`: The selection mode for the control. The NSSegmentSwitchTracking enum describes the possible values and their effects.
        ///
        /// Parameter `target`: The target object that receives action messages from the control.
        ///
        /// Parameter `action`: The action message sent by the control.
        ///
        /// Returns: An initialized segmented control.
        ///
        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `action` must be a valid selector.
        #[unsafe(method(segmentedControlWithLabels:trackingMode:target:action:))]
        #[unsafe(method_family = none)]
        pub unsafe fn segmentedControlWithLabels_trackingMode_target_action(
            labels: &NSArray<NSString>,
            tracking_mode: NSSegmentSwitchTracking,
            target: Option<&AnyObject>,
            action: Option<Sel>,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[cfg(feature = "NSImage")]
        /// Creates a standard segmented control containing one segment for each of the provided images. To ensure accessibility for this control, set the accessibilityDescription property on each of the provided images.
        ///
        /// Parameter `images`: An array of image objects to use for the control's segments.
        ///
        /// Parameter `trackingMode`: The selection mode for the control. The NSSegmentSwitchTracking enum describes the possible values and their effects.
        ///
        /// Parameter `target`: The target object that receives action messages from the control.
        ///
        /// Parameter `action`: The action message sent by the control.
        ///
        /// Returns: An initialized segmented control.
        ///
        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `action` must be a valid selector.
        #[unsafe(method(segmentedControlWithImages:trackingMode:target:action:))]
        #[unsafe(method_family = none)]
        pub unsafe fn segmentedControlWithImages_trackingMode_target_action(
            images: &NSArray<NSImage>,
            tracking_mode: NSSegmentSwitchTracking,
            target: Option<&AnyObject>,
            action: Option<Sel>,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;
    );
}