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#[cfg(feature = "objc2-quartz-core")]
10#[cfg(not(target_os = "watchos"))]
11use objc2_quartz_core::*;
12
13use crate::*;
14
15#[deprecated = "The segmentedControlStyle property no longer has any effect"]
18#[repr(transparent)]
19#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
20pub struct UISegmentedControlStyle(pub NSInteger);
21impl UISegmentedControlStyle {
22 #[doc(alias = "UISegmentedControlStylePlain")]
23 #[deprecated = "The segmentedControlStyle property no longer has any effect"]
24 pub const Plain: Self = Self(0);
25 #[doc(alias = "UISegmentedControlStyleBordered")]
26 #[deprecated = "The segmentedControlStyle property no longer has any effect"]
27 pub const Bordered: Self = Self(1);
28 #[doc(alias = "UISegmentedControlStyleBar")]
29 #[deprecated = "The segmentedControlStyle property no longer has any effect"]
30 pub const Bar: Self = Self(2);
31 #[doc(alias = "UISegmentedControlStyleBezeled")]
32 #[deprecated = "The segmentedControlStyle property no longer has any effect"]
33 pub const Bezeled: Self = Self(3);
34}
35
36unsafe impl Encode for UISegmentedControlStyle {
37 const ENCODING: Encoding = NSInteger::ENCODING;
38}
39
40unsafe impl RefEncode for UISegmentedControlStyle {
41 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44pub const UISegmentedControlNoSegment: c_int = -1;
46
47#[repr(transparent)]
50#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
51pub struct UISegmentedControlSegment(pub NSInteger);
52impl UISegmentedControlSegment {
53 #[doc(alias = "UISegmentedControlSegmentAny")]
54 pub const Any: Self = Self(0);
55 #[doc(alias = "UISegmentedControlSegmentLeft")]
56 pub const Left: Self = Self(1);
57 #[doc(alias = "UISegmentedControlSegmentCenter")]
58 pub const Center: Self = Self(2);
59 #[doc(alias = "UISegmentedControlSegmentRight")]
60 pub const Right: Self = Self(3);
61 #[doc(alias = "UISegmentedControlSegmentAlone")]
62 pub const Alone: Self = Self(4);
63}
64
65unsafe impl Encode for UISegmentedControlSegment {
66 const ENCODING: Encoding = NSInteger::ENCODING;
67}
68
69unsafe impl RefEncode for UISegmentedControlSegment {
70 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
71}
72
73extern_class!(
74 #[unsafe(super(UIControl, UIView, UIResponder, NSObject))]
76 #[thread_kind = MainThreadOnly]
77 #[derive(Debug, PartialEq, Eq, Hash)]
78 #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
79 pub struct UISegmentedControl;
80);
81
82#[cfg(all(
83 feature = "UIControl",
84 feature = "UIResponder",
85 feature = "UIView",
86 feature = "objc2-quartz-core"
87))]
88#[cfg(not(target_os = "watchos"))]
89extern_conformance!(
90 unsafe impl CALayerDelegate for UISegmentedControl {}
91);
92
93#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
94extern_conformance!(
95 unsafe impl NSCoding for UISegmentedControl {}
96);
97
98#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
99extern_conformance!(
100 unsafe impl NSObjectProtocol for UISegmentedControl {}
101);
102
103#[cfg(all(
104 feature = "UIAppearance",
105 feature = "UIControl",
106 feature = "UIResponder",
107 feature = "UIView"
108))]
109extern_conformance!(
110 unsafe impl UIAppearance for UISegmentedControl {}
111);
112
113#[cfg(all(
114 feature = "UIAppearance",
115 feature = "UIControl",
116 feature = "UIResponder",
117 feature = "UIView"
118))]
119extern_conformance!(
120 unsafe impl UIAppearanceContainer for UISegmentedControl {}
121);
122
123#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
124extern_conformance!(
125 unsafe impl UICoordinateSpace for UISegmentedControl {}
126);
127
128#[cfg(all(
129 feature = "UIControl",
130 feature = "UIDynamicBehavior",
131 feature = "UIResponder",
132 feature = "UIView"
133))]
134extern_conformance!(
135 unsafe impl UIDynamicItem for UISegmentedControl {}
136);
137
138#[cfg(all(
139 feature = "UIControl",
140 feature = "UIFocus",
141 feature = "UIResponder",
142 feature = "UIView"
143))]
144extern_conformance!(
145 unsafe impl UIFocusEnvironment for UISegmentedControl {}
146);
147
148#[cfg(all(
149 feature = "UIControl",
150 feature = "UIFocus",
151 feature = "UIResponder",
152 feature = "UIView"
153))]
154extern_conformance!(
155 unsafe impl UIFocusItem for UISegmentedControl {}
156);
157
158#[cfg(all(
159 feature = "UIControl",
160 feature = "UIFocus",
161 feature = "UIResponder",
162 feature = "UIView"
163))]
164extern_conformance!(
165 unsafe impl UIFocusItemContainer for UISegmentedControl {}
166);
167
168#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
169extern_conformance!(
170 unsafe impl UIResponderStandardEditActions for UISegmentedControl {}
171);
172
173#[cfg(all(
174 feature = "UIControl",
175 feature = "UIResponder",
176 feature = "UITraitCollection",
177 feature = "UIView"
178))]
179extern_conformance!(
180 unsafe impl UITraitEnvironment for UISegmentedControl {}
181);
182
183#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
184impl UISegmentedControl {
185 extern_methods!(
186 #[cfg(feature = "objc2-core-foundation")]
187 #[unsafe(method(initWithFrame:))]
188 #[unsafe(method_family = init)]
189 pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
190
191 #[unsafe(method(initWithCoder:))]
195 #[unsafe(method_family = init)]
196 pub unsafe fn initWithCoder(
197 this: Allocated<Self>,
198 coder: &NSCoder,
199 ) -> Option<Retained<Self>>;
200
201 #[unsafe(method(initWithItems:))]
207 #[unsafe(method_family = init)]
208 pub unsafe fn initWithItems(
209 this: Allocated<Self>,
210 items: Option<&NSArray>,
211 ) -> Retained<Self>;
212
213 #[cfg(all(
214 feature = "UIAction",
215 feature = "UIMenuElement",
216 feature = "objc2-core-foundation"
217 ))]
218 #[unsafe(method(initWithFrame:actions:))]
220 #[unsafe(method_family = init)]
221 pub fn initWithFrame_actions(
222 this: Allocated<Self>,
223 frame: CGRect,
224 actions: &NSArray<UIAction>,
225 ) -> Retained<Self>;
226
227 #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
228 #[unsafe(method(insertSegmentWithAction:atIndex:animated:))]
230 #[unsafe(method_family = none)]
231 pub fn insertSegmentWithAction_atIndex_animated(
232 &self,
233 action: &UIAction,
234 segment: NSUInteger,
235 animated: bool,
236 );
237
238 #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
239 #[unsafe(method(setAction:forSegmentAtIndex:))]
241 #[unsafe(method_family = none)]
242 pub fn setAction_forSegmentAtIndex(&self, action: &UIAction, segment: NSUInteger);
243
244 #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
245 #[unsafe(method(actionForSegmentAtIndex:))]
247 #[unsafe(method_family = none)]
248 pub fn actionForSegmentAtIndex(&self, segment: NSUInteger) -> Option<Retained<UIAction>>;
249
250 #[cfg(feature = "UIAction")]
251 #[unsafe(method(segmentIndexForActionIdentifier:))]
253 #[unsafe(method_family = none)]
254 pub fn segmentIndexForActionIdentifier(
255 &self,
256 action_identifier: &UIActionIdentifier,
257 ) -> NSInteger;
258
259 #[deprecated = "The segmentedControlStyle property no longer has any effect"]
260 #[unsafe(method(segmentedControlStyle))]
261 #[unsafe(method_family = none)]
262 pub fn segmentedControlStyle(&self) -> UISegmentedControlStyle;
263
264 #[deprecated = "The segmentedControlStyle property no longer has any effect"]
266 #[unsafe(method(setSegmentedControlStyle:))]
267 #[unsafe(method_family = none)]
268 pub fn setSegmentedControlStyle(&self, segmented_control_style: UISegmentedControlStyle);
269
270 #[unsafe(method(isMomentary))]
271 #[unsafe(method_family = none)]
272 pub fn isMomentary(&self) -> bool;
273
274 #[unsafe(method(setMomentary:))]
276 #[unsafe(method_family = none)]
277 pub fn setMomentary(&self, momentary: bool);
278
279 #[unsafe(method(numberOfSegments))]
280 #[unsafe(method_family = none)]
281 pub fn numberOfSegments(&self) -> NSUInteger;
282
283 #[unsafe(method(apportionsSegmentWidthsByContent))]
284 #[unsafe(method_family = none)]
285 pub fn apportionsSegmentWidthsByContent(&self) -> bool;
286
287 #[unsafe(method(setApportionsSegmentWidthsByContent:))]
289 #[unsafe(method_family = none)]
290 pub fn setApportionsSegmentWidthsByContent(
291 &self,
292 apportions_segment_widths_by_content: bool,
293 );
294
295 #[unsafe(method(insertSegmentWithTitle:atIndex:animated:))]
296 #[unsafe(method_family = none)]
297 pub fn insertSegmentWithTitle_atIndex_animated(
298 &self,
299 title: Option<&NSString>,
300 segment: NSUInteger,
301 animated: bool,
302 );
303
304 #[cfg(feature = "UIImage")]
305 #[unsafe(method(insertSegmentWithImage:atIndex:animated:))]
306 #[unsafe(method_family = none)]
307 pub fn insertSegmentWithImage_atIndex_animated(
308 &self,
309 image: Option<&UIImage>,
310 segment: NSUInteger,
311 animated: bool,
312 );
313
314 #[unsafe(method(removeSegmentAtIndex:animated:))]
315 #[unsafe(method_family = none)]
316 pub fn removeSegmentAtIndex_animated(&self, segment: NSUInteger, animated: bool);
317
318 #[unsafe(method(removeAllSegments))]
319 #[unsafe(method_family = none)]
320 pub fn removeAllSegments(&self);
321
322 #[unsafe(method(setTitle:forSegmentAtIndex:))]
323 #[unsafe(method_family = none)]
324 pub fn setTitle_forSegmentAtIndex(&self, title: Option<&NSString>, segment: NSUInteger);
325
326 #[unsafe(method(titleForSegmentAtIndex:))]
327 #[unsafe(method_family = none)]
328 pub fn titleForSegmentAtIndex(&self, segment: NSUInteger) -> Option<Retained<NSString>>;
329
330 #[cfg(feature = "UIImage")]
331 #[unsafe(method(setImage:forSegmentAtIndex:))]
332 #[unsafe(method_family = none)]
333 pub fn setImage_forSegmentAtIndex(&self, image: Option<&UIImage>, segment: NSUInteger);
334
335 #[cfg(feature = "UIImage")]
336 #[unsafe(method(imageForSegmentAtIndex:))]
337 #[unsafe(method_family = none)]
338 pub fn imageForSegmentAtIndex(&self, segment: NSUInteger) -> Option<Retained<UIImage>>;
339
340 #[cfg(feature = "objc2-core-foundation")]
341 #[unsafe(method(setWidth:forSegmentAtIndex:))]
342 #[unsafe(method_family = none)]
343 pub fn setWidth_forSegmentAtIndex(&self, width: CGFloat, segment: NSUInteger);
344
345 #[cfg(feature = "objc2-core-foundation")]
346 #[unsafe(method(widthForSegmentAtIndex:))]
347 #[unsafe(method_family = none)]
348 pub fn widthForSegmentAtIndex(&self, segment: NSUInteger) -> CGFloat;
349
350 #[cfg(feature = "objc2-core-foundation")]
351 #[unsafe(method(setContentOffset:forSegmentAtIndex:))]
352 #[unsafe(method_family = none)]
353 pub fn setContentOffset_forSegmentAtIndex(&self, offset: CGSize, segment: NSUInteger);
354
355 #[cfg(feature = "objc2-core-foundation")]
356 #[unsafe(method(contentOffsetForSegmentAtIndex:))]
357 #[unsafe(method_family = none)]
358 pub fn contentOffsetForSegmentAtIndex(&self, segment: NSUInteger) -> CGSize;
359
360 #[unsafe(method(setEnabled:forSegmentAtIndex:))]
361 #[unsafe(method_family = none)]
362 pub fn setEnabled_forSegmentAtIndex(&self, enabled: bool, segment: NSUInteger);
363
364 #[unsafe(method(isEnabledForSegmentAtIndex:))]
365 #[unsafe(method_family = none)]
366 pub fn isEnabledForSegmentAtIndex(&self, segment: NSUInteger) -> bool;
367
368 #[unsafe(method(selectedSegmentIndex))]
369 #[unsafe(method_family = none)]
370 pub fn selectedSegmentIndex(&self) -> NSInteger;
371
372 #[unsafe(method(setSelectedSegmentIndex:))]
374 #[unsafe(method_family = none)]
375 pub fn setSelectedSegmentIndex(&self, selected_segment_index: NSInteger);
376
377 #[cfg(feature = "UIColor")]
378 #[unsafe(method(selectedSegmentTintColor))]
379 #[unsafe(method_family = none)]
380 pub fn selectedSegmentTintColor(&self) -> Option<Retained<UIColor>>;
381
382 #[cfg(feature = "UIColor")]
383 #[unsafe(method(setSelectedSegmentTintColor:))]
385 #[unsafe(method_family = none)]
386 pub fn setSelectedSegmentTintColor(&self, selected_segment_tint_color: Option<&UIColor>);
387
388 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
389 #[unsafe(method(setBackgroundImage:forState:barMetrics:))]
390 #[unsafe(method_family = none)]
391 pub fn setBackgroundImage_forState_barMetrics(
392 &self,
393 background_image: Option<&UIImage>,
394 state: UIControlState,
395 bar_metrics: UIBarMetrics,
396 );
397
398 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
399 #[unsafe(method(backgroundImageForState:barMetrics:))]
400 #[unsafe(method_family = none)]
401 pub fn backgroundImageForState_barMetrics(
402 &self,
403 state: UIControlState,
404 bar_metrics: UIBarMetrics,
405 ) -> Option<Retained<UIImage>>;
406
407 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
408 #[unsafe(method(setDividerImage:forLeftSegmentState:rightSegmentState:barMetrics:))]
409 #[unsafe(method_family = none)]
410 pub fn setDividerImage_forLeftSegmentState_rightSegmentState_barMetrics(
411 &self,
412 divider_image: Option<&UIImage>,
413 left_state: UIControlState,
414 right_state: UIControlState,
415 bar_metrics: UIBarMetrics,
416 );
417
418 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
419 #[unsafe(method(dividerImageForLeftSegmentState:rightSegmentState:barMetrics:))]
420 #[unsafe(method_family = none)]
421 pub fn dividerImageForLeftSegmentState_rightSegmentState_barMetrics(
422 &self,
423 left_state: UIControlState,
424 right_state: UIControlState,
425 bar_metrics: UIBarMetrics,
426 ) -> Option<Retained<UIImage>>;
427
428 #[unsafe(method(setTitleTextAttributes:forState:))]
432 #[unsafe(method_family = none)]
433 pub unsafe fn setTitleTextAttributes_forState(
434 &self,
435 attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
436 state: UIControlState,
437 );
438
439 #[unsafe(method(titleTextAttributesForState:))]
440 #[unsafe(method_family = none)]
441 pub fn titleTextAttributesForState(
442 &self,
443 state: UIControlState,
444 ) -> Option<Retained<NSDictionary<NSAttributedStringKey, AnyObject>>>;
445
446 #[cfg(all(
447 feature = "UIBarCommon",
448 feature = "UIGeometry",
449 feature = "objc2-core-foundation"
450 ))]
451 #[unsafe(method(setContentPositionAdjustment:forSegmentType:barMetrics:))]
452 #[unsafe(method_family = none)]
453 pub fn setContentPositionAdjustment_forSegmentType_barMetrics(
454 &self,
455 adjustment: UIOffset,
456 left_center_right_or_alone: UISegmentedControlSegment,
457 bar_metrics: UIBarMetrics,
458 );
459
460 #[cfg(all(
461 feature = "UIBarCommon",
462 feature = "UIGeometry",
463 feature = "objc2-core-foundation"
464 ))]
465 #[unsafe(method(contentPositionAdjustmentForSegmentType:barMetrics:))]
466 #[unsafe(method_family = none)]
467 pub fn contentPositionAdjustmentForSegmentType_barMetrics(
468 &self,
469 left_center_right_or_alone: UISegmentedControlSegment,
470 bar_metrics: UIBarMetrics,
471 ) -> UIOffset;
472 );
473}
474
475#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
477impl UISegmentedControl {
478 extern_methods!(
479 #[cfg(all(
480 feature = "UIAction",
481 feature = "UIMenuElement",
482 feature = "objc2-core-foundation"
483 ))]
484 #[unsafe(method(initWithFrame:primaryAction:))]
486 #[unsafe(method_family = init)]
487 pub fn initWithFrame_primaryAction(
488 this: Allocated<Self>,
489 frame: CGRect,
490 primary_action: Option<&UIAction>,
491 ) -> Retained<Self>;
492 );
493}
494
495#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
497impl UISegmentedControl {
498 extern_methods!(
499 #[unsafe(method(init))]
500 #[unsafe(method_family = init)]
501 pub fn init(this: Allocated<Self>) -> Retained<Self>;
502 );
503}
504
505#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
507impl UISegmentedControl {
508 extern_methods!(
509 #[unsafe(method(new))]
510 #[unsafe(method_family = new)]
511 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
512 );
513}
514
515#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
517impl UISegmentedControl {
518 extern_methods!();
519}
520
521#[cfg(all(
522 feature = "UIControl",
523 feature = "UIResponder",
524 feature = "UISpringLoadedInteractionSupporting",
525 feature = "UIView"
526))]
527extern_conformance!(
528 unsafe impl UISpringLoadedInteractionSupporting for UISegmentedControl {}
529);