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
10use crate::*;
11
12#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct NSSegmentSwitchTracking(pub NSUInteger);
17impl NSSegmentSwitchTracking {
18    #[doc(alias = "NSSegmentSwitchTrackingSelectOne")]
19    pub const SelectOne: Self = Self(0);
20    #[doc(alias = "NSSegmentSwitchTrackingSelectAny")]
21    pub const SelectAny: Self = Self(1);
22    #[doc(alias = "NSSegmentSwitchTrackingMomentary")]
23    pub const Momentary: Self = Self(2);
24    #[doc(alias = "NSSegmentSwitchTrackingMomentaryAccelerator")]
25    pub const MomentaryAccelerator: Self = Self(3);
26}
27
28unsafe impl Encode for NSSegmentSwitchTracking {
29    const ENCODING: Encoding = NSUInteger::ENCODING;
30}
31
32unsafe impl RefEncode for NSSegmentSwitchTracking {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36#[repr(transparent)]
39#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
40pub struct NSSegmentStyle(pub NSInteger);
41impl NSSegmentStyle {
42    #[doc(alias = "NSSegmentStyleAutomatic")]
43    pub const Automatic: Self = Self(0);
44    #[doc(alias = "NSSegmentStyleRounded")]
45    pub const Rounded: Self = Self(1);
46    #[doc(alias = "NSSegmentStyleRoundRect")]
47    pub const RoundRect: Self = Self(3);
48    #[doc(alias = "NSSegmentStyleTexturedSquare")]
49    pub const TexturedSquare: Self = Self(4);
50    #[doc(alias = "NSSegmentStyleSmallSquare")]
51    pub const SmallSquare: Self = Self(6);
52    #[doc(alias = "NSSegmentStyleSeparated")]
53    pub const Separated: Self = Self(8);
54    #[doc(alias = "NSSegmentStyleTexturedRounded")]
55    pub const TexturedRounded: Self = Self(2);
56    #[doc(alias = "NSSegmentStyleCapsule")]
57    pub const Capsule: Self = Self(5);
58}
59
60unsafe impl Encode for NSSegmentStyle {
61    const ENCODING: Encoding = NSInteger::ENCODING;
62}
63
64unsafe impl RefEncode for NSSegmentStyle {
65    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
66}
67
68#[repr(transparent)]
71#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
72pub struct NSSegmentDistribution(pub NSInteger);
73impl NSSegmentDistribution {
74    #[doc(alias = "NSSegmentDistributionFit")]
76    pub const Fit: Self = Self(0);
77    #[doc(alias = "NSSegmentDistributionFill")]
79    pub const Fill: Self = Self(1);
80    #[doc(alias = "NSSegmentDistributionFillEqually")]
82    pub const FillEqually: Self = Self(2);
83    #[doc(alias = "NSSegmentDistributionFillProportionally")]
85    pub const FillProportionally: Self = Self(3);
86}
87
88unsafe impl Encode for NSSegmentDistribution {
89    const ENCODING: Encoding = NSInteger::ENCODING;
90}
91
92unsafe impl RefEncode for NSSegmentDistribution {
93    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
94}
95
96extern_class!(
97    #[unsafe(super(NSControl, NSView, NSResponder, NSObject))]
99    #[derive(Debug, PartialEq, Eq, Hash)]
100    #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
101    pub struct NSSegmentedControl;
102);
103
104#[cfg(all(
105    feature = "NSAccessibilityProtocols",
106    feature = "NSControl",
107    feature = "NSResponder",
108    feature = "NSView"
109))]
110extern_conformance!(
111    unsafe impl NSAccessibility for NSSegmentedControl {}
112);
113
114#[cfg(all(
115    feature = "NSAccessibilityProtocols",
116    feature = "NSControl",
117    feature = "NSResponder",
118    feature = "NSView"
119))]
120extern_conformance!(
121    unsafe impl NSAccessibilityElementProtocol for NSSegmentedControl {}
122);
123
124#[cfg(all(
125    feature = "NSAnimation",
126    feature = "NSControl",
127    feature = "NSResponder",
128    feature = "NSView"
129))]
130extern_conformance!(
131    unsafe impl NSAnimatablePropertyContainer for NSSegmentedControl {}
132);
133
134#[cfg(all(
135    feature = "NSAppearance",
136    feature = "NSControl",
137    feature = "NSResponder",
138    feature = "NSView"
139))]
140extern_conformance!(
141    unsafe impl NSAppearanceCustomization for NSSegmentedControl {}
142);
143
144#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
145extern_conformance!(
146    unsafe impl NSCoding for NSSegmentedControl {}
147);
148
149#[cfg(all(
150    feature = "NSControl",
151    feature = "NSDragging",
152    feature = "NSResponder",
153    feature = "NSView"
154))]
155extern_conformance!(
156    unsafe impl NSDraggingDestination for NSSegmentedControl {}
157);
158
159#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
160extern_conformance!(
161    unsafe impl NSObjectProtocol for NSSegmentedControl {}
162);
163
164#[cfg(all(
165    feature = "NSControl",
166    feature = "NSResponder",
167    feature = "NSUserInterfaceCompression",
168    feature = "NSView"
169))]
170extern_conformance!(
171    unsafe impl NSUserInterfaceCompression for NSSegmentedControl {}
172);
173
174#[cfg(all(
175    feature = "NSControl",
176    feature = "NSResponder",
177    feature = "NSUserInterfaceItemIdentification",
178    feature = "NSView"
179))]
180extern_conformance!(
181    unsafe impl NSUserInterfaceItemIdentification for NSSegmentedControl {}
182);
183
184#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
185impl NSSegmentedControl {
186    extern_methods!(
187        #[unsafe(method(segmentCount))]
188        #[unsafe(method_family = none)]
189        pub fn segmentCount(&self) -> NSInteger;
190
191        #[unsafe(method(setSegmentCount:))]
193        #[unsafe(method_family = none)]
194        pub fn setSegmentCount(&self, segment_count: NSInteger);
195
196        #[unsafe(method(selectedSegment))]
197        #[unsafe(method_family = none)]
198        pub fn selectedSegment(&self) -> NSInteger;
199
200        #[unsafe(method(setSelectedSegment:))]
202        #[unsafe(method_family = none)]
203        pub fn setSelectedSegment(&self, selected_segment: NSInteger);
204
205        #[unsafe(method(selectSegmentWithTag:))]
206        #[unsafe(method_family = none)]
207        pub fn selectSegmentWithTag(&self, tag: NSInteger) -> bool;
208
209        #[cfg(feature = "objc2-core-foundation")]
210        #[unsafe(method(setWidth:forSegment:))]
211        #[unsafe(method_family = none)]
212        pub fn setWidth_forSegment(&self, width: CGFloat, segment: NSInteger);
213
214        #[cfg(feature = "objc2-core-foundation")]
215        #[unsafe(method(widthForSegment:))]
216        #[unsafe(method_family = none)]
217        pub fn widthForSegment(&self, segment: NSInteger) -> CGFloat;
218
219        #[cfg(feature = "NSImage")]
220        #[unsafe(method(setImage:forSegment:))]
221        #[unsafe(method_family = none)]
222        pub fn setImage_forSegment(&self, image: Option<&NSImage>, segment: NSInteger);
223
224        #[cfg(feature = "NSImage")]
225        #[unsafe(method(imageForSegment:))]
226        #[unsafe(method_family = none)]
227        pub fn imageForSegment(&self, segment: NSInteger) -> Option<Retained<NSImage>>;
228
229        #[cfg(feature = "NSCell")]
230        #[unsafe(method(setImageScaling:forSegment:))]
231        #[unsafe(method_family = none)]
232        pub fn setImageScaling_forSegment(&self, scaling: NSImageScaling, segment: NSInteger);
233
234        #[cfg(feature = "NSCell")]
235        #[unsafe(method(imageScalingForSegment:))]
236        #[unsafe(method_family = none)]
237        pub fn imageScalingForSegment(&self, segment: NSInteger) -> NSImageScaling;
238
239        #[unsafe(method(setLabel:forSegment:))]
240        #[unsafe(method_family = none)]
241        pub fn setLabel_forSegment(&self, label: &NSString, segment: NSInteger);
242
243        #[unsafe(method(labelForSegment:))]
244        #[unsafe(method_family = none)]
245        pub fn labelForSegment(&self, segment: NSInteger) -> Option<Retained<NSString>>;
246
247        #[cfg(feature = "NSMenu")]
248        #[unsafe(method(setMenu:forSegment:))]
249        #[unsafe(method_family = none)]
250        pub fn setMenu_forSegment(&self, menu: Option<&NSMenu>, segment: NSInteger);
251
252        #[cfg(feature = "NSMenu")]
253        #[unsafe(method(menuForSegment:))]
254        #[unsafe(method_family = none)]
255        pub fn menuForSegment(&self, segment: NSInteger) -> Option<Retained<NSMenu>>;
256
257        #[unsafe(method(setSelected:forSegment:))]
258        #[unsafe(method_family = none)]
259        pub fn setSelected_forSegment(&self, selected: bool, segment: NSInteger);
260
261        #[unsafe(method(isSelectedForSegment:))]
262        #[unsafe(method_family = none)]
263        pub fn isSelectedForSegment(&self, segment: NSInteger) -> bool;
264
265        #[unsafe(method(setEnabled:forSegment:))]
266        #[unsafe(method_family = none)]
267        pub fn setEnabled_forSegment(&self, enabled: bool, segment: NSInteger);
268
269        #[unsafe(method(isEnabledForSegment:))]
270        #[unsafe(method_family = none)]
271        pub fn isEnabledForSegment(&self, segment: NSInteger) -> bool;
272
273        #[unsafe(method(setToolTip:forSegment:))]
274        #[unsafe(method_family = none)]
275        pub fn setToolTip_forSegment(&self, tool_tip: Option<&NSString>, segment: NSInteger);
276
277        #[unsafe(method(toolTipForSegment:))]
278        #[unsafe(method_family = none)]
279        pub fn toolTipForSegment(&self, segment: NSInteger) -> Option<Retained<NSString>>;
280
281        #[unsafe(method(setTag:forSegment:))]
282        #[unsafe(method_family = none)]
283        pub fn setTag_forSegment(&self, tag: NSInteger, segment: NSInteger);
284
285        #[unsafe(method(tagForSegment:))]
286        #[unsafe(method_family = none)]
287        pub fn tagForSegment(&self, segment: NSInteger) -> NSInteger;
288
289        #[unsafe(method(setShowsMenuIndicator:forSegment:))]
290        #[unsafe(method_family = none)]
291        pub fn setShowsMenuIndicator_forSegment(
292            &self,
293            shows_menu_indicator: bool,
294            segment: NSInteger,
295        );
296
297        #[unsafe(method(showsMenuIndicatorForSegment:))]
298        #[unsafe(method_family = none)]
299        pub fn showsMenuIndicatorForSegment(&self, segment: NSInteger) -> bool;
300
301        #[unsafe(method(segmentStyle))]
302        #[unsafe(method_family = none)]
303        pub fn segmentStyle(&self) -> NSSegmentStyle;
304
305        #[unsafe(method(setSegmentStyle:))]
307        #[unsafe(method_family = none)]
308        pub fn setSegmentStyle(&self, segment_style: NSSegmentStyle);
309
310        #[unsafe(method(isSpringLoaded))]
311        #[unsafe(method_family = none)]
312        pub fn isSpringLoaded(&self) -> bool;
313
314        #[unsafe(method(setSpringLoaded:))]
316        #[unsafe(method_family = none)]
317        pub fn setSpringLoaded(&self, spring_loaded: bool);
318
319        #[unsafe(method(trackingMode))]
320        #[unsafe(method_family = none)]
321        pub fn trackingMode(&self) -> NSSegmentSwitchTracking;
322
323        #[unsafe(method(setTrackingMode:))]
325        #[unsafe(method_family = none)]
326        pub fn setTrackingMode(&self, tracking_mode: NSSegmentSwitchTracking);
327
328        #[unsafe(method(doubleValueForSelectedSegment))]
329        #[unsafe(method_family = none)]
330        pub fn doubleValueForSelectedSegment(&self) -> c_double;
331
332        #[cfg(feature = "NSColor")]
333        #[unsafe(method(selectedSegmentBezelColor))]
334        #[unsafe(method_family = none)]
335        pub fn selectedSegmentBezelColor(&self) -> Option<Retained<NSColor>>;
336
337        #[cfg(feature = "NSColor")]
338        #[unsafe(method(setSelectedSegmentBezelColor:))]
342        #[unsafe(method_family = none)]
343        pub fn setSelectedSegmentBezelColor(&self, selected_segment_bezel_color: Option<&NSColor>);
344
345        #[unsafe(method(indexOfSelectedItem))]
346        #[unsafe(method_family = none)]
347        pub fn indexOfSelectedItem(&self) -> NSInteger;
348
349        #[cfg(feature = "NSText")]
350        #[unsafe(method(setAlignment:forSegment:))]
351        #[unsafe(method_family = none)]
352        pub fn setAlignment_forSegment(&self, alignment: NSTextAlignment, segment: NSInteger);
353
354        #[cfg(feature = "NSText")]
355        #[unsafe(method(alignmentForSegment:))]
356        #[unsafe(method_family = none)]
357        pub fn alignmentForSegment(&self, segment: NSInteger) -> NSTextAlignment;
358
359        #[unsafe(method(segmentDistribution))]
360        #[unsafe(method_family = none)]
361        pub fn segmentDistribution(&self) -> NSSegmentDistribution;
362
363        #[unsafe(method(setSegmentDistribution:))]
365        #[unsafe(method_family = none)]
366        pub fn setSegmentDistribution(&self, segment_distribution: NSSegmentDistribution);
367
368        #[cfg(feature = "NSUserInterfaceCompression")]
369        #[unsafe(method(compressWithPrioritizedCompressionOptions:))]
370        #[unsafe(method_family = none)]
371        pub fn compressWithPrioritizedCompressionOptions(
372            &self,
373            prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
374        );
375
376        #[cfg(feature = "NSUserInterfaceCompression")]
377        #[unsafe(method(minimumSizeWithPrioritizedCompressionOptions:))]
378        #[unsafe(method_family = none)]
379        pub fn minimumSizeWithPrioritizedCompressionOptions(
380            &self,
381            prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
382        ) -> NSSize;
383
384        #[cfg(feature = "NSUserInterfaceCompression")]
385        #[unsafe(method(activeCompressionOptions))]
386        #[unsafe(method_family = none)]
387        pub fn activeCompressionOptions(&self) -> Retained<NSUserInterfaceCompressionOptions>;
388
389        #[unsafe(method(borderShape))]
390        #[unsafe(method_family = none)]
391        pub fn borderShape(&self) -> NSControlBorderShape;
392
393        #[unsafe(method(setBorderShape:))]
395        #[unsafe(method_family = none)]
396        pub fn setBorderShape(&self, border_shape: NSControlBorderShape);
397    );
398}
399
400#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
402impl NSSegmentedControl {
403    extern_methods!(
404        #[unsafe(method(initWithFrame:))]
405        #[unsafe(method_family = init)]
406        pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
407
408        #[unsafe(method(initWithCoder:))]
412        #[unsafe(method_family = init)]
413        pub unsafe fn initWithCoder(
414            this: Allocated<Self>,
415            coder: &NSCoder,
416        ) -> Option<Retained<Self>>;
417    );
418}
419
420#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
422impl NSSegmentedControl {
423    extern_methods!(
424        #[unsafe(method(init))]
425        #[unsafe(method_family = init)]
426        pub fn init(this: Allocated<Self>) -> Retained<Self>;
427    );
428}
429
430#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
432impl NSSegmentedControl {
433    extern_methods!(
434        #[unsafe(method(new))]
435        #[unsafe(method_family = new)]
436        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
437    );
438}
439
440#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
442impl NSSegmentedControl {
443    extern_methods!(
444        #[unsafe(method(segmentedControlWithLabels:trackingMode:target:action:))]
461        #[unsafe(method_family = none)]
462        pub unsafe fn segmentedControlWithLabels_trackingMode_target_action(
463            labels: &NSArray<NSString>,
464            tracking_mode: NSSegmentSwitchTracking,
465            target: Option<&AnyObject>,
466            action: Option<Sel>,
467            mtm: MainThreadMarker,
468        ) -> Retained<Self>;
469
470        #[cfg(feature = "NSImage")]
471        #[unsafe(method(segmentedControlWithImages:trackingMode:target:action:))]
488        #[unsafe(method_family = none)]
489        pub unsafe fn segmentedControlWithImages_trackingMode_target_action(
490            images: &NSArray<NSImage>,
491            tracking_mode: NSSegmentSwitchTracking,
492            target: Option<&AnyObject>,
493            action: Option<Sel>,
494            mtm: MainThreadMarker,
495        ) -> Retained<Self>;
496    );
497}