//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssegmentswitchtracking?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSSegmentSwitchTracking(pub NSUInteger);
impl NSSegmentSwitchTracking {
    #[doc(alias = "NSSegmentSwitchTrackingSelectOne")]
    pub const SelectOne: Self = Self(0);
    #[doc(alias = "NSSegmentSwitchTrackingSelectAny")]
    pub const SelectAny: Self = Self(1);
    #[doc(alias = "NSSegmentSwitchTrackingMomentary")]
    pub const Momentary: Self = Self(2);
    #[doc(alias = "NSSegmentSwitchTrackingMomentaryAccelerator")]
    pub const MomentaryAccelerator: Self = Self(3);
}

unsafe impl Encode for NSSegmentSwitchTracking {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssegmentstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSSegmentStyle(pub NSInteger);
impl NSSegmentStyle {
    #[doc(alias = "NSSegmentStyleAutomatic")]
    pub const Automatic: Self = Self(0);
    #[doc(alias = "NSSegmentStyleRounded")]
    pub const Rounded: Self = Self(1);
    #[doc(alias = "NSSegmentStyleRoundRect")]
    pub const RoundRect: Self = Self(3);
    #[doc(alias = "NSSegmentStyleTexturedSquare")]
    pub const TexturedSquare: Self = Self(4);
    #[doc(alias = "NSSegmentStyleSmallSquare")]
    pub const SmallSquare: Self = Self(6);
    #[doc(alias = "NSSegmentStyleSeparated")]
    pub const Separated: Self = Self(8);
    #[doc(alias = "NSSegmentStyleTexturedRounded")]
    pub const TexturedRounded: Self = Self(2);
    #[doc(alias = "NSSegmentStyleCapsule")]
    pub const Capsule: Self = Self(5);
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssegmentdistribution?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSSegmentDistribution(pub NSInteger);
impl NSSegmentDistribution {
    /// Dynamically sized segments will be sized to fit their contents, any remaining space will be left blank. This style is equivalent to the way segments were distributed on older systems.
    #[doc(alias = "NSSegmentDistributionFit")]
    pub const Fit: Self = Self(0);
    /// Dynamically sized segments will be sized to fill the available space, with extra space being distributed equally among them. Default value.
    #[doc(alias = "NSSegmentDistributionFill")]
    pub const Fill: Self = Self(1);
    /// Dynamically sized segments will be sized to fill the available space, and kept the same size as each other.
    #[doc(alias = "NSSegmentDistributionFillEqually")]
    pub const FillEqually: Self = Self(2);
    /// Dynamically sized segments will be sized to fill the available space, and kept proportional to their fitting size.
    #[doc(alias = "NSSegmentDistributionFillProportionally")]
    pub const FillProportionally: Self = Self(3);
}

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

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssegmentedcontrol?language=objc)
    #[unsafe(super(NSControl, NSView, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
    pub struct NSSegmentedControl;
);

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSAccessibility for NSSegmentedControl {}
);

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSAccessibilityElementProtocol for NSSegmentedControl {}
);

#[cfg(all(
    feature = "NSAnimation",
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSAnimatablePropertyContainer for NSSegmentedControl {}
);

#[cfg(all(
    feature = "NSAppearance",
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSAppearanceCustomization for NSSegmentedControl {}
);

#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
extern_conformance!(
    unsafe impl NSCoding for NSSegmentedControl {}
);

#[cfg(all(
    feature = "NSControl",
    feature = "NSDragging",
    feature = "NSResponder",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSDraggingDestination for NSSegmentedControl {}
);

#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSSegmentedControl {}
);

#[cfg(all(
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSUserInterfaceCompression",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSUserInterfaceCompression for NSSegmentedControl {}
);

#[cfg(all(
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSUserInterfaceItemIdentification",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSUserInterfaceItemIdentification for NSSegmentedControl {}
);

#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSSegmentedControl {
    extern_methods!(
        #[unsafe(method(segmentCount))]
        #[unsafe(method_family = none)]
        pub fn segmentCount(&self) -> NSInteger;

        /// Setter for [`segmentCount`][Self::segmentCount].
        #[unsafe(method(setSegmentCount:))]
        #[unsafe(method_family = none)]
        pub fn setSegmentCount(&self, segment_count: NSInteger);

        #[unsafe(method(selectedSegment))]
        #[unsafe(method_family = none)]
        pub fn selectedSegment(&self) -> NSInteger;

        /// Setter for [`selectedSegment`][Self::selectedSegment].
        #[unsafe(method(setSelectedSegment:))]
        #[unsafe(method_family = none)]
        pub fn setSelectedSegment(&self, selected_segment: NSInteger);

        #[unsafe(method(selectSegmentWithTag:))]
        #[unsafe(method_family = none)]
        pub fn selectSegmentWithTag(&self, tag: NSInteger) -> bool;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(setWidth:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setWidth_forSegment(&self, width: CGFloat, segment: NSInteger);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(widthForSegment:))]
        #[unsafe(method_family = none)]
        pub fn widthForSegment(&self, segment: NSInteger) -> CGFloat;

        #[cfg(feature = "NSImage")]
        #[unsafe(method(setImage:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setImage_forSegment(&self, image: Option<&NSImage>, segment: NSInteger);

        #[cfg(feature = "NSImage")]
        #[unsafe(method(imageForSegment:))]
        #[unsafe(method_family = none)]
        pub fn imageForSegment(&self, segment: NSInteger) -> Option<Retained<NSImage>>;

        #[cfg(feature = "NSCell")]
        #[unsafe(method(setImageScaling:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setImageScaling_forSegment(&self, scaling: NSImageScaling, segment: NSInteger);

        #[cfg(feature = "NSCell")]
        #[unsafe(method(imageScalingForSegment:))]
        #[unsafe(method_family = none)]
        pub fn imageScalingForSegment(&self, segment: NSInteger) -> NSImageScaling;

        #[unsafe(method(setLabel:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setLabel_forSegment(&self, label: &NSString, segment: NSInteger);

        #[unsafe(method(labelForSegment:))]
        #[unsafe(method_family = none)]
        pub fn labelForSegment(&self, segment: NSInteger) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSMenu")]
        #[unsafe(method(setMenu:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setMenu_forSegment(&self, menu: Option<&NSMenu>, segment: NSInteger);

        #[cfg(feature = "NSMenu")]
        #[unsafe(method(menuForSegment:))]
        #[unsafe(method_family = none)]
        pub fn menuForSegment(&self, segment: NSInteger) -> Option<Retained<NSMenu>>;

        #[unsafe(method(setSelected:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setSelected_forSegment(&self, selected: bool, segment: NSInteger);

        #[unsafe(method(isSelectedForSegment:))]
        #[unsafe(method_family = none)]
        pub fn isSelectedForSegment(&self, segment: NSInteger) -> bool;

        #[unsafe(method(setEnabled:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setEnabled_forSegment(&self, enabled: bool, segment: NSInteger);

        #[unsafe(method(isEnabledForSegment:))]
        #[unsafe(method_family = none)]
        pub fn isEnabledForSegment(&self, segment: NSInteger) -> bool;

        #[unsafe(method(setToolTip:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setToolTip_forSegment(&self, tool_tip: Option<&NSString>, segment: NSInteger);

        #[unsafe(method(toolTipForSegment:))]
        #[unsafe(method_family = none)]
        pub fn toolTipForSegment(&self, segment: NSInteger) -> Option<Retained<NSString>>;

        #[unsafe(method(setTag:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setTag_forSegment(&self, tag: NSInteger, segment: NSInteger);

        #[unsafe(method(tagForSegment:))]
        #[unsafe(method_family = none)]
        pub fn tagForSegment(&self, segment: NSInteger) -> NSInteger;

        #[unsafe(method(setShowsMenuIndicator:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setShowsMenuIndicator_forSegment(
            &self,
            shows_menu_indicator: bool,
            segment: NSInteger,
        );

        #[unsafe(method(showsMenuIndicatorForSegment:))]
        #[unsafe(method_family = none)]
        pub fn showsMenuIndicatorForSegment(&self, segment: NSInteger) -> bool;

        #[unsafe(method(segmentStyle))]
        #[unsafe(method_family = none)]
        pub fn segmentStyle(&self) -> NSSegmentStyle;

        /// Setter for [`segmentStyle`][Self::segmentStyle].
        #[unsafe(method(setSegmentStyle:))]
        #[unsafe(method_family = none)]
        pub fn setSegmentStyle(&self, segment_style: NSSegmentStyle);

        #[unsafe(method(isSpringLoaded))]
        #[unsafe(method_family = none)]
        pub fn isSpringLoaded(&self) -> bool;

        /// Setter for [`isSpringLoaded`][Self::isSpringLoaded].
        #[unsafe(method(setSpringLoaded:))]
        #[unsafe(method_family = none)]
        pub fn setSpringLoaded(&self, spring_loaded: bool);

        #[unsafe(method(trackingMode))]
        #[unsafe(method_family = none)]
        pub fn trackingMode(&self) -> NSSegmentSwitchTracking;

        /// Setter for [`trackingMode`][Self::trackingMode].
        #[unsafe(method(setTrackingMode:))]
        #[unsafe(method_family = none)]
        pub fn setTrackingMode(&self, tracking_mode: NSSegmentSwitchTracking);

        #[unsafe(method(doubleValueForSelectedSegment))]
        #[unsafe(method_family = none)]
        pub fn doubleValueForSelectedSegment(&self) -> c_double;

        #[cfg(feature = "NSColor")]
        #[unsafe(method(selectedSegmentBezelColor))]
        #[unsafe(method_family = none)]
        pub fn selectedSegmentBezelColor(&self) -> Option<Retained<NSColor>>;

        #[cfg(feature = "NSColor")]
        /// Setter for [`selectedSegmentBezelColor`][Self::selectedSegmentBezelColor].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setSelectedSegmentBezelColor:))]
        #[unsafe(method_family = none)]
        pub fn setSelectedSegmentBezelColor(&self, selected_segment_bezel_color: Option<&NSColor>);

        #[unsafe(method(indexOfSelectedItem))]
        #[unsafe(method_family = none)]
        pub fn indexOfSelectedItem(&self) -> NSInteger;

        #[cfg(feature = "NSText")]
        #[unsafe(method(setAlignment:forSegment:))]
        #[unsafe(method_family = none)]
        pub fn setAlignment_forSegment(&self, alignment: NSTextAlignment, segment: NSInteger);

        #[cfg(feature = "NSText")]
        #[unsafe(method(alignmentForSegment:))]
        #[unsafe(method_family = none)]
        pub fn alignmentForSegment(&self, segment: NSInteger) -> NSTextAlignment;

        #[unsafe(method(segmentDistribution))]
        #[unsafe(method_family = none)]
        pub fn segmentDistribution(&self) -> NSSegmentDistribution;

        /// Setter for [`segmentDistribution`][Self::segmentDistribution].
        #[unsafe(method(setSegmentDistribution:))]
        #[unsafe(method_family = none)]
        pub fn setSegmentDistribution(&self, segment_distribution: NSSegmentDistribution);

        #[cfg(feature = "NSUserInterfaceCompression")]
        #[unsafe(method(compressWithPrioritizedCompressionOptions:))]
        #[unsafe(method_family = none)]
        pub fn compressWithPrioritizedCompressionOptions(
            &self,
            prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
        );

        #[cfg(feature = "NSUserInterfaceCompression")]
        #[unsafe(method(minimumSizeWithPrioritizedCompressionOptions:))]
        #[unsafe(method_family = none)]
        pub fn minimumSizeWithPrioritizedCompressionOptions(
            &self,
            prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
        ) -> NSSize;

        #[cfg(feature = "NSUserInterfaceCompression")]
        #[unsafe(method(activeCompressionOptions))]
        #[unsafe(method_family = none)]
        pub fn activeCompressionOptions(&self) -> Retained<NSUserInterfaceCompressionOptions>;

        #[unsafe(method(borderShape))]
        #[unsafe(method_family = none)]
        pub fn borderShape(&self) -> NSControlBorderShape;

        /// Setter for [`borderShape`][Self::borderShape].
        #[unsafe(method(setBorderShape:))]
        #[unsafe(method_family = none)]
        pub fn setBorderShape(&self, border_shape: NSControlBorderShape);
    );
}

/// Methods declared on superclass `NSControl`.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSSegmentedControl {
    extern_methods!(
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;
    );
}

/// Methods declared on superclass `NSResponder`.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSSegmentedControl {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSSegmentedControl {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

/// NSSegmentedControlConvenience.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSSegmentedControl {
    extern_methods!(
        /// Creates a standard segmented control containing one segment for each of the provided labels.
        ///
        /// Parameter `labels`: An array of localized label strings to use for the control's segments.
        ///
        /// Parameter `trackingMode`: The selection mode for the control. The NSSegmentSwitchTracking enum describes the possible values and their effects.
        ///
        /// Parameter `target`: The target object that receives action messages from the control.
        ///
        /// Parameter `action`: The action message sent by the control.
        ///
        /// Returns: An initialized segmented control.
        ///
        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `action` must be a valid selector.
        #[unsafe(method(segmentedControlWithLabels:trackingMode:target:action:))]
        #[unsafe(method_family = none)]
        pub unsafe fn segmentedControlWithLabels_trackingMode_target_action(
            labels: &NSArray<NSString>,
            tracking_mode: NSSegmentSwitchTracking,
            target: Option<&AnyObject>,
            action: Option<Sel>,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[cfg(feature = "NSImage")]
        /// Creates a standard segmented control containing one segment for each of the provided images. To ensure accessibility for this control, set the accessibilityDescription property on each of the provided images.
        ///
        /// Parameter `images`: An array of image objects to use for the control's segments.
        ///
        /// Parameter `trackingMode`: The selection mode for the control. The NSSegmentSwitchTracking enum describes the possible values and their effects.
        ///
        /// Parameter `target`: The target object that receives action messages from the control.
        ///
        /// Parameter `action`: The action message sent by the control.
        ///
        /// Returns: An initialized segmented control.
        ///
        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `action` must be a valid selector.
        #[unsafe(method(segmentedControlWithImages:trackingMode:target:action:))]
        #[unsafe(method_family = none)]
        pub unsafe fn segmentedControlWithImages_trackingMode_target_action(
            images: &NSArray<NSImage>,
            tracking_mode: NSSegmentSwitchTracking,
            target: Option<&AnyObject>,
            action: Option<Sel>,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;
    );
}
