objc2-ui-kit 0.3.2

Bindings to the UIKit framework
Documentation
//! 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::*;
#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
use objc2_quartz_core::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiswitchstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UISwitchStyle(pub NSInteger);
impl UISwitchStyle {
    #[doc(alias = "UISwitchStyleAutomatic")]
    pub const Automatic: Self = Self(0);
    #[doc(alias = "UISwitchStyleCheckbox")]
    pub const Checkbox: Self = Self(1);
    #[doc(alias = "UISwitchStyleSliding")]
    pub const Sliding: Self = Self(2);
}

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

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiswitch?language=objc)
    #[unsafe(super(UIControl, UIView, UIResponder, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
    pub struct UISwitch;
);

#[cfg(all(
    feature = "UIControl",
    feature = "UIResponder",
    feature = "UIView",
    feature = "objc2-quartz-core"
))]
#[cfg(not(target_os = "watchos"))]
extern_conformance!(
    unsafe impl CALayerDelegate for UISwitch {}
);

#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl NSCoding for UISwitch {}
);

#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for UISwitch {}
);

#[cfg(all(
    feature = "UIAppearance",
    feature = "UIControl",
    feature = "UIResponder",
    feature = "UIView"
))]
extern_conformance!(
    unsafe impl UIAppearance for UISwitch {}
);

#[cfg(all(
    feature = "UIAppearance",
    feature = "UIControl",
    feature = "UIResponder",
    feature = "UIView"
))]
extern_conformance!(
    unsafe impl UIAppearanceContainer for UISwitch {}
);

#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl UICoordinateSpace for UISwitch {}
);

#[cfg(all(
    feature = "UIControl",
    feature = "UIDynamicBehavior",
    feature = "UIResponder",
    feature = "UIView"
))]
extern_conformance!(
    unsafe impl UIDynamicItem for UISwitch {}
);

#[cfg(all(
    feature = "UIControl",
    feature = "UIFocus",
    feature = "UIResponder",
    feature = "UIView"
))]
extern_conformance!(
    unsafe impl UIFocusEnvironment for UISwitch {}
);

#[cfg(all(
    feature = "UIControl",
    feature = "UIFocus",
    feature = "UIResponder",
    feature = "UIView"
))]
extern_conformance!(
    unsafe impl UIFocusItem for UISwitch {}
);

#[cfg(all(
    feature = "UIControl",
    feature = "UIFocus",
    feature = "UIResponder",
    feature = "UIView"
))]
extern_conformance!(
    unsafe impl UIFocusItemContainer for UISwitch {}
);

#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl UIResponderStandardEditActions for UISwitch {}
);

#[cfg(all(
    feature = "UIControl",
    feature = "UIResponder",
    feature = "UITraitCollection",
    feature = "UIView"
))]
extern_conformance!(
    unsafe impl UITraitEnvironment for UISwitch {}
);

#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
impl UISwitch {
    extern_methods!(
        #[cfg(feature = "UIColor")]
        #[unsafe(method(onTintColor))]
        #[unsafe(method_family = none)]
        pub fn onTintColor(&self) -> Option<Retained<UIColor>>;

        #[cfg(feature = "UIColor")]
        /// Setter for [`onTintColor`][Self::onTintColor].
        #[unsafe(method(setOnTintColor:))]
        #[unsafe(method_family = none)]
        pub fn setOnTintColor(&self, on_tint_color: Option<&UIColor>);

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

        #[cfg(feature = "UIColor")]
        /// Setter for [`thumbTintColor`][Self::thumbTintColor].
        #[unsafe(method(setThumbTintColor:))]
        #[unsafe(method_family = none)]
        pub fn setThumbTintColor(&self, thumb_tint_color: Option<&UIColor>);

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

        #[cfg(feature = "UIImage")]
        /// Setter for [`onImage`][Self::onImage].
        #[unsafe(method(setOnImage:))]
        #[unsafe(method_family = none)]
        pub fn setOnImage(&self, on_image: Option<&UIImage>);

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

        #[cfg(feature = "UIImage")]
        /// Setter for [`offImage`][Self::offImage].
        #[unsafe(method(setOffImage:))]
        #[unsafe(method_family = none)]
        pub fn setOffImage(&self, off_image: Option<&UIImage>);

        /// The title displayed alongside the switch, positioned appropriately for the
        /// `UIUserInterfaceIdiom.`
        /// Note: This property is only supported for Catalyst in the Mac idiom.
        #[unsafe(method(title))]
        #[unsafe(method_family = none)]
        pub fn title(&self) -> Option<Retained<NSString>>;

        /// Setter for [`title`][Self::title].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setTitle:))]
        #[unsafe(method_family = none)]
        pub fn setTitle(&self, title: Option<&NSString>);

        /// The switch's display style. This property always returns a concrete, resolved style (never UISwitchStyleAutomatic).
        #[unsafe(method(style))]
        #[unsafe(method_family = none)]
        pub fn style(&self) -> UISwitchStyle;

        /// Request a style for the switch. If the style changed, then the switch may resize.
        #[unsafe(method(preferredStyle))]
        #[unsafe(method_family = none)]
        pub fn preferredStyle(&self) -> UISwitchStyle;

        /// Setter for [`preferredStyle`][Self::preferredStyle].
        #[unsafe(method(setPreferredStyle:))]
        #[unsafe(method_family = none)]
        pub fn setPreferredStyle(&self, preferred_style: UISwitchStyle);

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

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

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> 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>>;

        #[unsafe(method(setOn:animated:))]
        #[unsafe(method_family = none)]
        pub fn setOn_animated(&self, on: bool, animated: bool);
    );
}

/// Methods declared on superclass `UIControl`.
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
impl UISwitch {
    extern_methods!(
        #[cfg(all(
            feature = "UIAction",
            feature = "UIMenuElement",
            feature = "objc2-core-foundation"
        ))]
        /// Initializes the control and adds primaryAction for the UIControlEventPrimaryActionTriggered control event. Subclasses of UIControl may alter or add behaviors around the usage of primaryAction, see subclass documentation of this initializer for additional information.
        #[unsafe(method(initWithFrame:primaryAction:))]
        #[unsafe(method_family = init)]
        pub fn initWithFrame_primaryAction(
            this: Allocated<Self>,
            frame: CGRect,
            primary_action: Option<&UIAction>,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `UIView`.
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
impl UISwitch {
    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 = "UIControl", feature = "UIResponder", feature = "UIView"))]
impl UISwitch {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}