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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
use objc2_quartz_core::*;

use crate::*;

// NS_ENUM
#[deprecated = "The segmentedControlStyle property no longer has any effect"]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UISegmentedControlStyle(pub NSInteger);
impl UISegmentedControlStyle {
    #[deprecated = "The segmentedControlStyle property no longer has any effect"]
    #[doc(alias = "UISegmentedControlStylePlain")]
    pub const Plain: Self = Self(0);
    #[deprecated = "The segmentedControlStyle property no longer has any effect"]
    #[doc(alias = "UISegmentedControlStyleBordered")]
    pub const Bordered: Self = Self(1);
    #[deprecated = "The segmentedControlStyle property no longer has any effect"]
    #[doc(alias = "UISegmentedControlStyleBar")]
    pub const Bar: Self = Self(2);
    #[deprecated = "The segmentedControlStyle property no longer has any effect"]
    #[doc(alias = "UISegmentedControlStyleBezeled")]
    pub const Bezeled: Self = Self(3);
}

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

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

pub const UISegmentedControlNoSegment: c_int = -1;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UISegmentedControlSegment(pub NSInteger);
impl UISegmentedControlSegment {
    #[doc(alias = "UISegmentedControlSegmentAny")]
    pub const Any: Self = Self(0);
    #[doc(alias = "UISegmentedControlSegmentLeft")]
    pub const Left: Self = Self(1);
    #[doc(alias = "UISegmentedControlSegmentCenter")]
    pub const Center: Self = Self(2);
    #[doc(alias = "UISegmentedControlSegmentRight")]
    pub const Right: Self = Self(3);
    #[doc(alias = "UISegmentedControlSegmentAlone")]
    pub const Alone: Self = Self(4);
}

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

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

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
    pub struct UISegmentedControl;

    #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
    unsafe impl ClassType for UISegmentedControl {
        #[inherits(UIView, UIResponder, NSObject)]
        type Super = UIControl;
        type Mutability = MainThreadOnly;
    }
);

#[cfg(all(
    feature = "UIControl",
    feature = "UIResponder",
    feature = "UIView",
    feature = "objc2-quartz-core"
))]
#[cfg(not(target_os = "watchos"))]
unsafe impl CALayerDelegate for UISegmentedControl {}

#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
unsafe impl NSCoding for UISegmentedControl {}

#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
unsafe impl NSObjectProtocol for UISegmentedControl {}

#[cfg(all(
    feature = "UIAppearance",
    feature = "UIControl",
    feature = "UIResponder",
    feature = "UIView"
))]
unsafe impl UIAppearance for UISegmentedControl {}

#[cfg(all(
    feature = "UIAppearance",
    feature = "UIControl",
    feature = "UIResponder",
    feature = "UIView"
))]
unsafe impl UIAppearanceContainer for UISegmentedControl {}

#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
unsafe impl UICoordinateSpace for UISegmentedControl {}

#[cfg(all(
    feature = "UIControl",
    feature = "UIDynamicBehavior",
    feature = "UIResponder",
    feature = "UIView"
))]
unsafe impl UIDynamicItem for UISegmentedControl {}

#[cfg(all(
    feature = "UIControl",
    feature = "UIFocus",
    feature = "UIResponder",
    feature = "UIView"
))]
unsafe impl UIFocusEnvironment for UISegmentedControl {}

#[cfg(all(
    feature = "UIControl",
    feature = "UIFocus",
    feature = "UIResponder",
    feature = "UIView"
))]
unsafe impl UIFocusItem for UISegmentedControl {}

#[cfg(all(
    feature = "UIControl",
    feature = "UIFocus",
    feature = "UIResponder",
    feature = "UIView"
))]
unsafe impl UIFocusItemContainer for UISegmentedControl {}

#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
unsafe impl UIResponderStandardEditActions for UISegmentedControl {}

#[cfg(all(
    feature = "UIControl",
    feature = "UIResponder",
    feature = "UITraitCollection",
    feature = "UIView"
))]
unsafe impl UITraitEnvironment for UISegmentedControl {}

extern_methods!(
    #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
    unsafe impl UISegmentedControl {
        #[method_id(@__retain_semantics Init initWithFrame:)]
        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;

        #[method_id(@__retain_semantics Init initWithCoder:)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

        #[method_id(@__retain_semantics Init initWithItems:)]
        pub unsafe fn initWithItems(
            this: Allocated<Self>,
            items: Option<&NSArray>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
        #[method_id(@__retain_semantics Init initWithFrame:actions:)]
        pub unsafe fn initWithFrame_actions(
            this: Allocated<Self>,
            frame: CGRect,
            actions: &NSArray<UIAction>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
        #[method(insertSegmentWithAction:atIndex:animated:)]
        pub unsafe fn insertSegmentWithAction_atIndex_animated(
            &self,
            action: &UIAction,
            segment: NSUInteger,
            animated: bool,
        );

        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
        #[method(setAction:forSegmentAtIndex:)]
        pub unsafe fn setAction_forSegmentAtIndex(&self, action: &UIAction, segment: NSUInteger);

        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
        #[method_id(@__retain_semantics Other actionForSegmentAtIndex:)]
        pub unsafe fn actionForSegmentAtIndex(
            &self,
            segment: NSUInteger,
        ) -> Option<Retained<UIAction>>;

        #[cfg(feature = "UIAction")]
        #[method(segmentIndexForActionIdentifier:)]
        pub unsafe fn segmentIndexForActionIdentifier(
            &self,
            action_identifier: &UIActionIdentifier,
        ) -> NSInteger;

        #[deprecated = "The segmentedControlStyle property no longer has any effect"]
        #[method(segmentedControlStyle)]
        pub unsafe fn segmentedControlStyle(&self) -> UISegmentedControlStyle;

        #[deprecated = "The segmentedControlStyle property no longer has any effect"]
        #[method(setSegmentedControlStyle:)]
        pub unsafe fn setSegmentedControlStyle(
            &self,
            segmented_control_style: UISegmentedControlStyle,
        );

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

        #[method(setMomentary:)]
        pub unsafe fn setMomentary(&self, momentary: bool);

        #[method(numberOfSegments)]
        pub unsafe fn numberOfSegments(&self) -> NSUInteger;

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

        #[method(setApportionsSegmentWidthsByContent:)]
        pub unsafe fn setApportionsSegmentWidthsByContent(
            &self,
            apportions_segment_widths_by_content: bool,
        );

        #[method(insertSegmentWithTitle:atIndex:animated:)]
        pub unsafe fn insertSegmentWithTitle_atIndex_animated(
            &self,
            title: Option<&NSString>,
            segment: NSUInteger,
            animated: bool,
        );

        #[cfg(feature = "UIImage")]
        #[method(insertSegmentWithImage:atIndex:animated:)]
        pub unsafe fn insertSegmentWithImage_atIndex_animated(
            &self,
            image: Option<&UIImage>,
            segment: NSUInteger,
            animated: bool,
        );

        #[method(removeSegmentAtIndex:animated:)]
        pub unsafe fn removeSegmentAtIndex_animated(&self, segment: NSUInteger, animated: bool);

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

        #[method(setTitle:forSegmentAtIndex:)]
        pub unsafe fn setTitle_forSegmentAtIndex(
            &self,
            title: Option<&NSString>,
            segment: NSUInteger,
        );

        #[method_id(@__retain_semantics Other titleForSegmentAtIndex:)]
        pub unsafe fn titleForSegmentAtIndex(
            &self,
            segment: NSUInteger,
        ) -> Option<Retained<NSString>>;

        #[cfg(feature = "UIImage")]
        #[method(setImage:forSegmentAtIndex:)]
        pub unsafe fn setImage_forSegmentAtIndex(
            &self,
            image: Option<&UIImage>,
            segment: NSUInteger,
        );

        #[cfg(feature = "UIImage")]
        #[method_id(@__retain_semantics Other imageForSegmentAtIndex:)]
        pub unsafe fn imageForSegmentAtIndex(
            &self,
            segment: NSUInteger,
        ) -> Option<Retained<UIImage>>;

        #[method(setWidth:forSegmentAtIndex:)]
        pub unsafe fn setWidth_forSegmentAtIndex(&self, width: CGFloat, segment: NSUInteger);

        #[method(widthForSegmentAtIndex:)]
        pub unsafe fn widthForSegmentAtIndex(&self, segment: NSUInteger) -> CGFloat;

        #[method(setContentOffset:forSegmentAtIndex:)]
        pub unsafe fn setContentOffset_forSegmentAtIndex(
            &self,
            offset: CGSize,
            segment: NSUInteger,
        );

        #[method(contentOffsetForSegmentAtIndex:)]
        pub unsafe fn contentOffsetForSegmentAtIndex(&self, segment: NSUInteger) -> CGSize;

        #[method(setEnabled:forSegmentAtIndex:)]
        pub unsafe fn setEnabled_forSegmentAtIndex(&self, enabled: bool, segment: NSUInteger);

        #[method(isEnabledForSegmentAtIndex:)]
        pub unsafe fn isEnabledForSegmentAtIndex(&self, segment: NSUInteger) -> bool;

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

        #[method(setSelectedSegmentIndex:)]
        pub unsafe fn setSelectedSegmentIndex(&self, selected_segment_index: NSInteger);

        #[cfg(feature = "UIColor")]
        #[method_id(@__retain_semantics Other selectedSegmentTintColor)]
        pub unsafe fn selectedSegmentTintColor(&self) -> Option<Retained<UIColor>>;

        #[cfg(feature = "UIColor")]
        #[method(setSelectedSegmentTintColor:)]
        pub unsafe fn setSelectedSegmentTintColor(
            &self,
            selected_segment_tint_color: Option<&UIColor>,
        );

        #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
        #[method(setBackgroundImage:forState:barMetrics:)]
        pub unsafe fn setBackgroundImage_forState_barMetrics(
            &self,
            background_image: Option<&UIImage>,
            state: UIControlState,
            bar_metrics: UIBarMetrics,
        );

        #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
        #[method_id(@__retain_semantics Other backgroundImageForState:barMetrics:)]
        pub unsafe fn backgroundImageForState_barMetrics(
            &self,
            state: UIControlState,
            bar_metrics: UIBarMetrics,
        ) -> Option<Retained<UIImage>>;

        #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
        #[method(setDividerImage:forLeftSegmentState:rightSegmentState:barMetrics:)]
        pub unsafe fn setDividerImage_forLeftSegmentState_rightSegmentState_barMetrics(
            &self,
            divider_image: Option<&UIImage>,
            left_state: UIControlState,
            right_state: UIControlState,
            bar_metrics: UIBarMetrics,
        );

        #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
        #[method_id(@__retain_semantics Other dividerImageForLeftSegmentState:rightSegmentState:barMetrics:)]
        pub unsafe fn dividerImageForLeftSegmentState_rightSegmentState_barMetrics(
            &self,
            left_state: UIControlState,
            right_state: UIControlState,
            bar_metrics: UIBarMetrics,
        ) -> Option<Retained<UIImage>>;

        #[method(setTitleTextAttributes:forState:)]
        pub unsafe fn setTitleTextAttributes_forState(
            &self,
            attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
            state: UIControlState,
        );

        #[method_id(@__retain_semantics Other titleTextAttributesForState:)]
        pub unsafe fn titleTextAttributesForState(
            &self,
            state: UIControlState,
        ) -> Option<Retained<NSDictionary<NSAttributedStringKey, AnyObject>>>;

        #[cfg(all(feature = "UIBarCommon", feature = "UIGeometry"))]
        #[method(setContentPositionAdjustment:forSegmentType:barMetrics:)]
        pub unsafe fn setContentPositionAdjustment_forSegmentType_barMetrics(
            &self,
            adjustment: UIOffset,
            left_center_right_or_alone: UISegmentedControlSegment,
            bar_metrics: UIBarMetrics,
        );

        #[cfg(all(feature = "UIBarCommon", feature = "UIGeometry"))]
        #[method(contentPositionAdjustmentForSegmentType:barMetrics:)]
        pub unsafe fn contentPositionAdjustmentForSegmentType_barMetrics(
            &self,
            left_center_right_or_alone: UISegmentedControlSegment,
            bar_metrics: UIBarMetrics,
        ) -> UIOffset;
    }
);

extern_methods!(
    /// Methods declared on superclass `UIControl`
    #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
    unsafe impl UISegmentedControl {
        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
        #[method_id(@__retain_semantics Init initWithFrame:primaryAction:)]
        pub unsafe fn initWithFrame_primaryAction(
            this: Allocated<Self>,
            frame: CGRect,
            primary_action: Option<&UIAction>,
        ) -> Retained<Self>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
    unsafe impl UISegmentedControl {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    }
);

extern_methods!(
    /// SpringLoading
    #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
    unsafe impl UISegmentedControl {}
);

#[cfg(all(
    feature = "UIControl",
    feature = "UIResponder",
    feature = "UISpringLoadedInteractionSupporting",
    feature = "UIView"
))]
unsafe impl UISpringLoadedInteractionSupporting for UISegmentedControl {}