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 #[deprecated = "The segmentedControlStyle property no longer has any effect"]
23 #[doc(alias = "UISegmentedControlStylePlain")]
24 pub const Plain: Self = Self(0);
25 #[deprecated = "The segmentedControlStyle property no longer has any effect"]
26 #[doc(alias = "UISegmentedControlStyleBordered")]
27 pub const Bordered: Self = Self(1);
28 #[deprecated = "The segmentedControlStyle property no longer has any effect"]
29 #[doc(alias = "UISegmentedControlStyleBar")]
30 pub const Bar: Self = Self(2);
31 #[deprecated = "The segmentedControlStyle property no longer has any effect"]
32 #[doc(alias = "UISegmentedControlStyleBezeled")]
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"))]
89unsafe impl CALayerDelegate for UISegmentedControl {}
90
91#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
92unsafe impl NSCoding for UISegmentedControl {}
93
94#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
95unsafe impl NSObjectProtocol for UISegmentedControl {}
96
97#[cfg(all(
98 feature = "UIAppearance",
99 feature = "UIControl",
100 feature = "UIResponder",
101 feature = "UIView"
102))]
103unsafe impl UIAppearance for UISegmentedControl {}
104
105#[cfg(all(
106 feature = "UIAppearance",
107 feature = "UIControl",
108 feature = "UIResponder",
109 feature = "UIView"
110))]
111unsafe impl UIAppearanceContainer for UISegmentedControl {}
112
113#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
114unsafe impl UICoordinateSpace for UISegmentedControl {}
115
116#[cfg(all(
117 feature = "UIControl",
118 feature = "UIDynamicBehavior",
119 feature = "UIResponder",
120 feature = "UIView"
121))]
122unsafe impl UIDynamicItem for UISegmentedControl {}
123
124#[cfg(all(
125 feature = "UIControl",
126 feature = "UIFocus",
127 feature = "UIResponder",
128 feature = "UIView"
129))]
130unsafe impl UIFocusEnvironment for UISegmentedControl {}
131
132#[cfg(all(
133 feature = "UIControl",
134 feature = "UIFocus",
135 feature = "UIResponder",
136 feature = "UIView"
137))]
138unsafe impl UIFocusItem for UISegmentedControl {}
139
140#[cfg(all(
141 feature = "UIControl",
142 feature = "UIFocus",
143 feature = "UIResponder",
144 feature = "UIView"
145))]
146unsafe impl UIFocusItemContainer for UISegmentedControl {}
147
148#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
149unsafe impl UIResponderStandardEditActions for UISegmentedControl {}
150
151#[cfg(all(
152 feature = "UIControl",
153 feature = "UIResponder",
154 feature = "UITraitCollection",
155 feature = "UIView"
156))]
157unsafe impl UITraitEnvironment for UISegmentedControl {}
158
159#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
160impl UISegmentedControl {
161 extern_methods!(
162 #[cfg(feature = "objc2-core-foundation")]
163 #[unsafe(method(initWithFrame:))]
164 #[unsafe(method_family = init)]
165 pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
166
167 #[unsafe(method(initWithCoder:))]
168 #[unsafe(method_family = init)]
169 pub unsafe fn initWithCoder(
170 this: Allocated<Self>,
171 coder: &NSCoder,
172 ) -> Option<Retained<Self>>;
173
174 #[unsafe(method(initWithItems:))]
176 #[unsafe(method_family = init)]
177 pub unsafe fn initWithItems(
178 this: Allocated<Self>,
179 items: Option<&NSArray>,
180 ) -> Retained<Self>;
181
182 #[cfg(all(
183 feature = "UIAction",
184 feature = "UIMenuElement",
185 feature = "objc2-core-foundation"
186 ))]
187 #[unsafe(method(initWithFrame:actions:))]
189 #[unsafe(method_family = init)]
190 pub unsafe fn initWithFrame_actions(
191 this: Allocated<Self>,
192 frame: CGRect,
193 actions: &NSArray<UIAction>,
194 ) -> Retained<Self>;
195
196 #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
197 #[unsafe(method(insertSegmentWithAction:atIndex:animated:))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn insertSegmentWithAction_atIndex_animated(
201 &self,
202 action: &UIAction,
203 segment: NSUInteger,
204 animated: bool,
205 );
206
207 #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
208 #[unsafe(method(setAction:forSegmentAtIndex:))]
210 #[unsafe(method_family = none)]
211 pub unsafe fn setAction_forSegmentAtIndex(&self, action: &UIAction, segment: NSUInteger);
212
213 #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
214 #[unsafe(method(actionForSegmentAtIndex:))]
216 #[unsafe(method_family = none)]
217 pub unsafe fn actionForSegmentAtIndex(
218 &self,
219 segment: NSUInteger,
220 ) -> Option<Retained<UIAction>>;
221
222 #[cfg(feature = "UIAction")]
223 #[unsafe(method(segmentIndexForActionIdentifier:))]
225 #[unsafe(method_family = none)]
226 pub unsafe fn segmentIndexForActionIdentifier(
227 &self,
228 action_identifier: &UIActionIdentifier,
229 ) -> NSInteger;
230
231 #[deprecated = "The segmentedControlStyle property no longer has any effect"]
232 #[unsafe(method(segmentedControlStyle))]
233 #[unsafe(method_family = none)]
234 pub unsafe fn segmentedControlStyle(&self) -> UISegmentedControlStyle;
235
236 #[deprecated = "The segmentedControlStyle property no longer has any effect"]
238 #[unsafe(method(setSegmentedControlStyle:))]
239 #[unsafe(method_family = none)]
240 pub unsafe fn setSegmentedControlStyle(
241 &self,
242 segmented_control_style: UISegmentedControlStyle,
243 );
244
245 #[unsafe(method(isMomentary))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn isMomentary(&self) -> bool;
248
249 #[unsafe(method(setMomentary:))]
251 #[unsafe(method_family = none)]
252 pub unsafe fn setMomentary(&self, momentary: bool);
253
254 #[unsafe(method(numberOfSegments))]
255 #[unsafe(method_family = none)]
256 pub unsafe fn numberOfSegments(&self) -> NSUInteger;
257
258 #[unsafe(method(apportionsSegmentWidthsByContent))]
259 #[unsafe(method_family = none)]
260 pub unsafe fn apportionsSegmentWidthsByContent(&self) -> bool;
261
262 #[unsafe(method(setApportionsSegmentWidthsByContent:))]
264 #[unsafe(method_family = none)]
265 pub unsafe fn setApportionsSegmentWidthsByContent(
266 &self,
267 apportions_segment_widths_by_content: bool,
268 );
269
270 #[unsafe(method(insertSegmentWithTitle:atIndex:animated:))]
271 #[unsafe(method_family = none)]
272 pub unsafe fn insertSegmentWithTitle_atIndex_animated(
273 &self,
274 title: Option<&NSString>,
275 segment: NSUInteger,
276 animated: bool,
277 );
278
279 #[cfg(feature = "UIImage")]
280 #[unsafe(method(insertSegmentWithImage:atIndex:animated:))]
281 #[unsafe(method_family = none)]
282 pub unsafe fn insertSegmentWithImage_atIndex_animated(
283 &self,
284 image: Option<&UIImage>,
285 segment: NSUInteger,
286 animated: bool,
287 );
288
289 #[unsafe(method(removeSegmentAtIndex:animated:))]
290 #[unsafe(method_family = none)]
291 pub unsafe fn removeSegmentAtIndex_animated(&self, segment: NSUInteger, animated: bool);
292
293 #[unsafe(method(removeAllSegments))]
294 #[unsafe(method_family = none)]
295 pub unsafe fn removeAllSegments(&self);
296
297 #[unsafe(method(setTitle:forSegmentAtIndex:))]
298 #[unsafe(method_family = none)]
299 pub unsafe fn setTitle_forSegmentAtIndex(
300 &self,
301 title: Option<&NSString>,
302 segment: NSUInteger,
303 );
304
305 #[unsafe(method(titleForSegmentAtIndex:))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn titleForSegmentAtIndex(
308 &self,
309 segment: NSUInteger,
310 ) -> Option<Retained<NSString>>;
311
312 #[cfg(feature = "UIImage")]
313 #[unsafe(method(setImage:forSegmentAtIndex:))]
314 #[unsafe(method_family = none)]
315 pub unsafe fn setImage_forSegmentAtIndex(
316 &self,
317 image: Option<&UIImage>,
318 segment: NSUInteger,
319 );
320
321 #[cfg(feature = "UIImage")]
322 #[unsafe(method(imageForSegmentAtIndex:))]
323 #[unsafe(method_family = none)]
324 pub unsafe fn imageForSegmentAtIndex(
325 &self,
326 segment: NSUInteger,
327 ) -> Option<Retained<UIImage>>;
328
329 #[cfg(feature = "objc2-core-foundation")]
330 #[unsafe(method(setWidth:forSegmentAtIndex:))]
331 #[unsafe(method_family = none)]
332 pub unsafe fn setWidth_forSegmentAtIndex(&self, width: CGFloat, segment: NSUInteger);
333
334 #[cfg(feature = "objc2-core-foundation")]
335 #[unsafe(method(widthForSegmentAtIndex:))]
336 #[unsafe(method_family = none)]
337 pub unsafe fn widthForSegmentAtIndex(&self, segment: NSUInteger) -> CGFloat;
338
339 #[cfg(feature = "objc2-core-foundation")]
340 #[unsafe(method(setContentOffset:forSegmentAtIndex:))]
341 #[unsafe(method_family = none)]
342 pub unsafe fn setContentOffset_forSegmentAtIndex(
343 &self,
344 offset: CGSize,
345 segment: NSUInteger,
346 );
347
348 #[cfg(feature = "objc2-core-foundation")]
349 #[unsafe(method(contentOffsetForSegmentAtIndex:))]
350 #[unsafe(method_family = none)]
351 pub unsafe fn contentOffsetForSegmentAtIndex(&self, segment: NSUInteger) -> CGSize;
352
353 #[unsafe(method(setEnabled:forSegmentAtIndex:))]
354 #[unsafe(method_family = none)]
355 pub unsafe fn setEnabled_forSegmentAtIndex(&self, enabled: bool, segment: NSUInteger);
356
357 #[unsafe(method(isEnabledForSegmentAtIndex:))]
358 #[unsafe(method_family = none)]
359 pub unsafe fn isEnabledForSegmentAtIndex(&self, segment: NSUInteger) -> bool;
360
361 #[unsafe(method(selectedSegmentIndex))]
362 #[unsafe(method_family = none)]
363 pub unsafe fn selectedSegmentIndex(&self) -> NSInteger;
364
365 #[unsafe(method(setSelectedSegmentIndex:))]
367 #[unsafe(method_family = none)]
368 pub unsafe fn setSelectedSegmentIndex(&self, selected_segment_index: NSInteger);
369
370 #[cfg(feature = "UIColor")]
371 #[unsafe(method(selectedSegmentTintColor))]
372 #[unsafe(method_family = none)]
373 pub unsafe fn selectedSegmentTintColor(&self) -> Option<Retained<UIColor>>;
374
375 #[cfg(feature = "UIColor")]
376 #[unsafe(method(setSelectedSegmentTintColor:))]
378 #[unsafe(method_family = none)]
379 pub unsafe fn setSelectedSegmentTintColor(
380 &self,
381 selected_segment_tint_color: Option<&UIColor>,
382 );
383
384 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
385 #[unsafe(method(setBackgroundImage:forState:barMetrics:))]
386 #[unsafe(method_family = none)]
387 pub unsafe fn setBackgroundImage_forState_barMetrics(
388 &self,
389 background_image: Option<&UIImage>,
390 state: UIControlState,
391 bar_metrics: UIBarMetrics,
392 );
393
394 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
395 #[unsafe(method(backgroundImageForState:barMetrics:))]
396 #[unsafe(method_family = none)]
397 pub unsafe fn backgroundImageForState_barMetrics(
398 &self,
399 state: UIControlState,
400 bar_metrics: UIBarMetrics,
401 ) -> Option<Retained<UIImage>>;
402
403 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
404 #[unsafe(method(setDividerImage:forLeftSegmentState:rightSegmentState:barMetrics:))]
405 #[unsafe(method_family = none)]
406 pub unsafe fn setDividerImage_forLeftSegmentState_rightSegmentState_barMetrics(
407 &self,
408 divider_image: Option<&UIImage>,
409 left_state: UIControlState,
410 right_state: UIControlState,
411 bar_metrics: UIBarMetrics,
412 );
413
414 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
415 #[unsafe(method(dividerImageForLeftSegmentState:rightSegmentState:barMetrics:))]
416 #[unsafe(method_family = none)]
417 pub unsafe fn dividerImageForLeftSegmentState_rightSegmentState_barMetrics(
418 &self,
419 left_state: UIControlState,
420 right_state: UIControlState,
421 bar_metrics: UIBarMetrics,
422 ) -> Option<Retained<UIImage>>;
423
424 #[unsafe(method(setTitleTextAttributes:forState:))]
425 #[unsafe(method_family = none)]
426 pub unsafe fn setTitleTextAttributes_forState(
427 &self,
428 attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
429 state: UIControlState,
430 );
431
432 #[unsafe(method(titleTextAttributesForState:))]
433 #[unsafe(method_family = none)]
434 pub unsafe fn titleTextAttributesForState(
435 &self,
436 state: UIControlState,
437 ) -> Option<Retained<NSDictionary<NSAttributedStringKey, AnyObject>>>;
438
439 #[cfg(all(
440 feature = "UIBarCommon",
441 feature = "UIGeometry",
442 feature = "objc2-core-foundation"
443 ))]
444 #[unsafe(method(setContentPositionAdjustment:forSegmentType:barMetrics:))]
445 #[unsafe(method_family = none)]
446 pub unsafe fn setContentPositionAdjustment_forSegmentType_barMetrics(
447 &self,
448 adjustment: UIOffset,
449 left_center_right_or_alone: UISegmentedControlSegment,
450 bar_metrics: UIBarMetrics,
451 );
452
453 #[cfg(all(
454 feature = "UIBarCommon",
455 feature = "UIGeometry",
456 feature = "objc2-core-foundation"
457 ))]
458 #[unsafe(method(contentPositionAdjustmentForSegmentType:barMetrics:))]
459 #[unsafe(method_family = none)]
460 pub unsafe fn contentPositionAdjustmentForSegmentType_barMetrics(
461 &self,
462 left_center_right_or_alone: UISegmentedControlSegment,
463 bar_metrics: UIBarMetrics,
464 ) -> UIOffset;
465 );
466}
467
468#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
470impl UISegmentedControl {
471 extern_methods!(
472 #[cfg(all(
473 feature = "UIAction",
474 feature = "UIMenuElement",
475 feature = "objc2-core-foundation"
476 ))]
477 #[unsafe(method(initWithFrame:primaryAction:))]
479 #[unsafe(method_family = init)]
480 pub unsafe fn initWithFrame_primaryAction(
481 this: Allocated<Self>,
482 frame: CGRect,
483 primary_action: Option<&UIAction>,
484 ) -> Retained<Self>;
485 );
486}
487
488#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
490impl UISegmentedControl {
491 extern_methods!(
492 #[unsafe(method(init))]
493 #[unsafe(method_family = init)]
494 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
495
496 #[unsafe(method(new))]
497 #[unsafe(method_family = new)]
498 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
499 );
500}
501
502#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
504impl UISegmentedControl {
505 extern_methods!();
506}
507
508#[cfg(all(
509 feature = "UIControl",
510 feature = "UIResponder",
511 feature = "UISpringLoadedInteractionSupporting",
512 feature = "UIView"
513))]
514unsafe impl UISpringLoadedInteractionSupporting for UISegmentedControl {}