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 unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
190
191 #[unsafe(method(initWithCoder:))]
192 #[unsafe(method_family = init)]
193 pub unsafe fn initWithCoder(
194 this: Allocated<Self>,
195 coder: &NSCoder,
196 ) -> Option<Retained<Self>>;
197
198 #[unsafe(method(initWithItems:))]
200 #[unsafe(method_family = init)]
201 pub unsafe fn initWithItems(
202 this: Allocated<Self>,
203 items: Option<&NSArray>,
204 ) -> Retained<Self>;
205
206 #[cfg(all(
207 feature = "UIAction",
208 feature = "UIMenuElement",
209 feature = "objc2-core-foundation"
210 ))]
211 #[unsafe(method(initWithFrame:actions:))]
213 #[unsafe(method_family = init)]
214 pub unsafe fn initWithFrame_actions(
215 this: Allocated<Self>,
216 frame: CGRect,
217 actions: &NSArray<UIAction>,
218 ) -> Retained<Self>;
219
220 #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
221 #[unsafe(method(insertSegmentWithAction:atIndex:animated:))]
223 #[unsafe(method_family = none)]
224 pub unsafe fn insertSegmentWithAction_atIndex_animated(
225 &self,
226 action: &UIAction,
227 segment: NSUInteger,
228 animated: bool,
229 );
230
231 #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
232 #[unsafe(method(setAction:forSegmentAtIndex:))]
234 #[unsafe(method_family = none)]
235 pub unsafe fn setAction_forSegmentAtIndex(&self, action: &UIAction, segment: NSUInteger);
236
237 #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
238 #[unsafe(method(actionForSegmentAtIndex:))]
240 #[unsafe(method_family = none)]
241 pub unsafe fn actionForSegmentAtIndex(
242 &self,
243 segment: NSUInteger,
244 ) -> Option<Retained<UIAction>>;
245
246 #[cfg(feature = "UIAction")]
247 #[unsafe(method(segmentIndexForActionIdentifier:))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn segmentIndexForActionIdentifier(
251 &self,
252 action_identifier: &UIActionIdentifier,
253 ) -> NSInteger;
254
255 #[deprecated = "The segmentedControlStyle property no longer has any effect"]
256 #[unsafe(method(segmentedControlStyle))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn segmentedControlStyle(&self) -> UISegmentedControlStyle;
259
260 #[deprecated = "The segmentedControlStyle property no longer has any effect"]
262 #[unsafe(method(setSegmentedControlStyle:))]
263 #[unsafe(method_family = none)]
264 pub unsafe fn setSegmentedControlStyle(
265 &self,
266 segmented_control_style: UISegmentedControlStyle,
267 );
268
269 #[unsafe(method(isMomentary))]
270 #[unsafe(method_family = none)]
271 pub unsafe fn isMomentary(&self) -> bool;
272
273 #[unsafe(method(setMomentary:))]
275 #[unsafe(method_family = none)]
276 pub unsafe fn setMomentary(&self, momentary: bool);
277
278 #[unsafe(method(numberOfSegments))]
279 #[unsafe(method_family = none)]
280 pub unsafe fn numberOfSegments(&self) -> NSUInteger;
281
282 #[unsafe(method(apportionsSegmentWidthsByContent))]
283 #[unsafe(method_family = none)]
284 pub unsafe fn apportionsSegmentWidthsByContent(&self) -> bool;
285
286 #[unsafe(method(setApportionsSegmentWidthsByContent:))]
288 #[unsafe(method_family = none)]
289 pub unsafe fn setApportionsSegmentWidthsByContent(
290 &self,
291 apportions_segment_widths_by_content: bool,
292 );
293
294 #[unsafe(method(insertSegmentWithTitle:atIndex:animated:))]
295 #[unsafe(method_family = none)]
296 pub unsafe fn insertSegmentWithTitle_atIndex_animated(
297 &self,
298 title: Option<&NSString>,
299 segment: NSUInteger,
300 animated: bool,
301 );
302
303 #[cfg(feature = "UIImage")]
304 #[unsafe(method(insertSegmentWithImage:atIndex:animated:))]
305 #[unsafe(method_family = none)]
306 pub unsafe fn insertSegmentWithImage_atIndex_animated(
307 &self,
308 image: Option<&UIImage>,
309 segment: NSUInteger,
310 animated: bool,
311 );
312
313 #[unsafe(method(removeSegmentAtIndex:animated:))]
314 #[unsafe(method_family = none)]
315 pub unsafe fn removeSegmentAtIndex_animated(&self, segment: NSUInteger, animated: bool);
316
317 #[unsafe(method(removeAllSegments))]
318 #[unsafe(method_family = none)]
319 pub unsafe fn removeAllSegments(&self);
320
321 #[unsafe(method(setTitle:forSegmentAtIndex:))]
322 #[unsafe(method_family = none)]
323 pub unsafe fn setTitle_forSegmentAtIndex(
324 &self,
325 title: Option<&NSString>,
326 segment: NSUInteger,
327 );
328
329 #[unsafe(method(titleForSegmentAtIndex:))]
330 #[unsafe(method_family = none)]
331 pub unsafe fn titleForSegmentAtIndex(
332 &self,
333 segment: NSUInteger,
334 ) -> Option<Retained<NSString>>;
335
336 #[cfg(feature = "UIImage")]
337 #[unsafe(method(setImage:forSegmentAtIndex:))]
338 #[unsafe(method_family = none)]
339 pub unsafe fn setImage_forSegmentAtIndex(
340 &self,
341 image: Option<&UIImage>,
342 segment: NSUInteger,
343 );
344
345 #[cfg(feature = "UIImage")]
346 #[unsafe(method(imageForSegmentAtIndex:))]
347 #[unsafe(method_family = none)]
348 pub unsafe fn imageForSegmentAtIndex(
349 &self,
350 segment: NSUInteger,
351 ) -> Option<Retained<UIImage>>;
352
353 #[cfg(feature = "objc2-core-foundation")]
354 #[unsafe(method(setWidth:forSegmentAtIndex:))]
355 #[unsafe(method_family = none)]
356 pub unsafe fn setWidth_forSegmentAtIndex(&self, width: CGFloat, segment: NSUInteger);
357
358 #[cfg(feature = "objc2-core-foundation")]
359 #[unsafe(method(widthForSegmentAtIndex:))]
360 #[unsafe(method_family = none)]
361 pub unsafe fn widthForSegmentAtIndex(&self, segment: NSUInteger) -> CGFloat;
362
363 #[cfg(feature = "objc2-core-foundation")]
364 #[unsafe(method(setContentOffset:forSegmentAtIndex:))]
365 #[unsafe(method_family = none)]
366 pub unsafe fn setContentOffset_forSegmentAtIndex(
367 &self,
368 offset: CGSize,
369 segment: NSUInteger,
370 );
371
372 #[cfg(feature = "objc2-core-foundation")]
373 #[unsafe(method(contentOffsetForSegmentAtIndex:))]
374 #[unsafe(method_family = none)]
375 pub unsafe fn contentOffsetForSegmentAtIndex(&self, segment: NSUInteger) -> CGSize;
376
377 #[unsafe(method(setEnabled:forSegmentAtIndex:))]
378 #[unsafe(method_family = none)]
379 pub unsafe fn setEnabled_forSegmentAtIndex(&self, enabled: bool, segment: NSUInteger);
380
381 #[unsafe(method(isEnabledForSegmentAtIndex:))]
382 #[unsafe(method_family = none)]
383 pub unsafe fn isEnabledForSegmentAtIndex(&self, segment: NSUInteger) -> bool;
384
385 #[unsafe(method(selectedSegmentIndex))]
386 #[unsafe(method_family = none)]
387 pub unsafe fn selectedSegmentIndex(&self) -> NSInteger;
388
389 #[unsafe(method(setSelectedSegmentIndex:))]
391 #[unsafe(method_family = none)]
392 pub unsafe fn setSelectedSegmentIndex(&self, selected_segment_index: NSInteger);
393
394 #[cfg(feature = "UIColor")]
395 #[unsafe(method(selectedSegmentTintColor))]
396 #[unsafe(method_family = none)]
397 pub unsafe fn selectedSegmentTintColor(&self) -> Option<Retained<UIColor>>;
398
399 #[cfg(feature = "UIColor")]
400 #[unsafe(method(setSelectedSegmentTintColor:))]
402 #[unsafe(method_family = none)]
403 pub unsafe fn setSelectedSegmentTintColor(
404 &self,
405 selected_segment_tint_color: Option<&UIColor>,
406 );
407
408 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
409 #[unsafe(method(setBackgroundImage:forState:barMetrics:))]
410 #[unsafe(method_family = none)]
411 pub unsafe fn setBackgroundImage_forState_barMetrics(
412 &self,
413 background_image: Option<&UIImage>,
414 state: UIControlState,
415 bar_metrics: UIBarMetrics,
416 );
417
418 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
419 #[unsafe(method(backgroundImageForState:barMetrics:))]
420 #[unsafe(method_family = none)]
421 pub unsafe fn backgroundImageForState_barMetrics(
422 &self,
423 state: UIControlState,
424 bar_metrics: UIBarMetrics,
425 ) -> Option<Retained<UIImage>>;
426
427 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
428 #[unsafe(method(setDividerImage:forLeftSegmentState:rightSegmentState:barMetrics:))]
429 #[unsafe(method_family = none)]
430 pub unsafe fn setDividerImage_forLeftSegmentState_rightSegmentState_barMetrics(
431 &self,
432 divider_image: Option<&UIImage>,
433 left_state: UIControlState,
434 right_state: UIControlState,
435 bar_metrics: UIBarMetrics,
436 );
437
438 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
439 #[unsafe(method(dividerImageForLeftSegmentState:rightSegmentState:barMetrics:))]
440 #[unsafe(method_family = none)]
441 pub unsafe fn dividerImageForLeftSegmentState_rightSegmentState_barMetrics(
442 &self,
443 left_state: UIControlState,
444 right_state: UIControlState,
445 bar_metrics: UIBarMetrics,
446 ) -> Option<Retained<UIImage>>;
447
448 #[unsafe(method(setTitleTextAttributes:forState:))]
449 #[unsafe(method_family = none)]
450 pub unsafe fn setTitleTextAttributes_forState(
451 &self,
452 attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
453 state: UIControlState,
454 );
455
456 #[unsafe(method(titleTextAttributesForState:))]
457 #[unsafe(method_family = none)]
458 pub unsafe fn titleTextAttributesForState(
459 &self,
460 state: UIControlState,
461 ) -> Option<Retained<NSDictionary<NSAttributedStringKey, AnyObject>>>;
462
463 #[cfg(all(
464 feature = "UIBarCommon",
465 feature = "UIGeometry",
466 feature = "objc2-core-foundation"
467 ))]
468 #[unsafe(method(setContentPositionAdjustment:forSegmentType:barMetrics:))]
469 #[unsafe(method_family = none)]
470 pub unsafe fn setContentPositionAdjustment_forSegmentType_barMetrics(
471 &self,
472 adjustment: UIOffset,
473 left_center_right_or_alone: UISegmentedControlSegment,
474 bar_metrics: UIBarMetrics,
475 );
476
477 #[cfg(all(
478 feature = "UIBarCommon",
479 feature = "UIGeometry",
480 feature = "objc2-core-foundation"
481 ))]
482 #[unsafe(method(contentPositionAdjustmentForSegmentType:barMetrics:))]
483 #[unsafe(method_family = none)]
484 pub unsafe fn contentPositionAdjustmentForSegmentType_barMetrics(
485 &self,
486 left_center_right_or_alone: UISegmentedControlSegment,
487 bar_metrics: UIBarMetrics,
488 ) -> UIOffset;
489 );
490}
491
492#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
494impl UISegmentedControl {
495 extern_methods!(
496 #[cfg(all(
497 feature = "UIAction",
498 feature = "UIMenuElement",
499 feature = "objc2-core-foundation"
500 ))]
501 #[unsafe(method(initWithFrame:primaryAction:))]
503 #[unsafe(method_family = init)]
504 pub unsafe fn initWithFrame_primaryAction(
505 this: Allocated<Self>,
506 frame: CGRect,
507 primary_action: Option<&UIAction>,
508 ) -> Retained<Self>;
509 );
510}
511
512#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
514impl UISegmentedControl {
515 extern_methods!(
516 #[unsafe(method(init))]
517 #[unsafe(method_family = init)]
518 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
519
520 #[unsafe(method(new))]
521 #[unsafe(method_family = new)]
522 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
523 );
524}
525
526#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
528impl UISegmentedControl {
529 extern_methods!();
530}
531
532#[cfg(all(
533 feature = "UIControl",
534 feature = "UIResponder",
535 feature = "UISpringLoadedInteractionSupporting",
536 feature = "UIView"
537))]
538extern_conformance!(
539 unsafe impl UISpringLoadedInteractionSupporting for UISegmentedControl {}
540);