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/uialertviewstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIAlertViewStyle(pub NSInteger);
impl UIAlertViewStyle {
    #[doc(alias = "UIAlertViewStyleDefault")]
    pub const Default: Self = Self(0);
    #[doc(alias = "UIAlertViewStyleSecureTextInput")]
    pub const SecureTextInput: Self = Self(1);
    #[doc(alias = "UIAlertViewStylePlainTextInput")]
    pub const PlainTextInput: Self = Self(2);
    #[doc(alias = "UIAlertViewStyleLoginAndPasswordInput")]
    pub const LoginAndPasswordInput: Self = Self(3);
}

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

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uialertview?language=objc)
    #[unsafe(super(UIView, UIResponder, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "UIResponder", feature = "UIView"))]
    #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
    pub struct UIAlertView;
);

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

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

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

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

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

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

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

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

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

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

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

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

#[cfg(all(feature = "UIResponder", feature = "UIView"))]
impl UIAlertView {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub fn delegate(&self) -> Option<Retained<AnyObject>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        ///
        /// # Safety
        ///
        /// `delegate` should be of the correct type.
        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(&self, delegate: Option<&AnyObject>);

        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(title))]
        #[unsafe(method_family = none)]
        pub fn title(&self) -> Retained<NSString>;

        /// Setter for [`title`][Self::title].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(setTitle:))]
        #[unsafe(method_family = none)]
        pub fn setTitle(&self, title: &NSString);

        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(message))]
        #[unsafe(method_family = none)]
        pub fn message(&self) -> Option<Retained<NSString>>;

        /// Setter for [`message`][Self::message].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(setMessage:))]
        #[unsafe(method_family = none)]
        pub fn setMessage(&self, message: Option<&NSString>);

        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(addButtonWithTitle:))]
        #[unsafe(method_family = none)]
        pub fn addButtonWithTitle(&self, title: Option<&NSString>) -> NSInteger;

        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(buttonTitleAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn buttonTitleAtIndex(&self, button_index: NSInteger) -> Option<Retained<NSString>>;

        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(numberOfButtons))]
        #[unsafe(method_family = none)]
        pub fn numberOfButtons(&self) -> NSInteger;

        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(cancelButtonIndex))]
        #[unsafe(method_family = none)]
        pub fn cancelButtonIndex(&self) -> NSInteger;

        /// Setter for [`cancelButtonIndex`][Self::cancelButtonIndex].
        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(setCancelButtonIndex:))]
        #[unsafe(method_family = none)]
        pub fn setCancelButtonIndex(&self, cancel_button_index: NSInteger);

        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(firstOtherButtonIndex))]
        #[unsafe(method_family = none)]
        pub fn firstOtherButtonIndex(&self) -> NSInteger;

        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(isVisible))]
        #[unsafe(method_family = none)]
        pub fn isVisible(&self) -> bool;

        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(show))]
        #[unsafe(method_family = none)]
        pub fn show(&self);

        #[deprecated = "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"]
        #[unsafe(method(dismissWithClickedButtonIndex:animated:))]
        #[unsafe(method_family = none)]
        pub fn dismissWithClickedButtonIndex_animated(
            &self,
            button_index: NSInteger,
            animated: bool,
        );

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

        /// Setter for [`alertViewStyle`][Self::alertViewStyle].
        #[unsafe(method(setAlertViewStyle:))]
        #[unsafe(method_family = none)]
        pub fn setAlertViewStyle(&self, alert_view_style: UIAlertViewStyle);

        #[cfg(all(feature = "UIControl", feature = "UITextField"))]
        #[unsafe(method(textFieldAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn textFieldAtIndex(
            &self,
            text_field_index: NSInteger,
        ) -> Option<Retained<UITextField>>;
    );
}

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

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uialertviewdelegate?language=objc)
    pub unsafe trait UIAlertViewDelegate: NSObjectProtocol + MainThreadOnly {
        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[deprecated = "Use UIAlertController instead."]
        #[optional]
        #[unsafe(method(alertView:clickedButtonAtIndex:))]
        #[unsafe(method_family = none)]
        fn alertView_clickedButtonAtIndex(&self, alert_view: &UIAlertView, button_index: NSInteger);

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[deprecated = "Use UIAlertController instead."]
        #[optional]
        #[unsafe(method(alertViewCancel:))]
        #[unsafe(method_family = none)]
        fn alertViewCancel(&self, alert_view: &UIAlertView);

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[deprecated = "Use UIAlertController instead."]
        #[optional]
        #[unsafe(method(willPresentAlertView:))]
        #[unsafe(method_family = none)]
        fn willPresentAlertView(&self, alert_view: &UIAlertView);

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[deprecated = "Use UIAlertController instead."]
        #[optional]
        #[unsafe(method(didPresentAlertView:))]
        #[unsafe(method_family = none)]
        fn didPresentAlertView(&self, alert_view: &UIAlertView);

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[deprecated = "Use UIAlertController instead."]
        #[optional]
        #[unsafe(method(alertView:willDismissWithButtonIndex:))]
        #[unsafe(method_family = none)]
        fn alertView_willDismissWithButtonIndex(
            &self,
            alert_view: &UIAlertView,
            button_index: NSInteger,
        );

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[deprecated = "Use UIAlertController instead."]
        #[optional]
        #[unsafe(method(alertView:didDismissWithButtonIndex:))]
        #[unsafe(method_family = none)]
        fn alertView_didDismissWithButtonIndex(
            &self,
            alert_view: &UIAlertView,
            button_index: NSInteger,
        );

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[deprecated = "Use UIAlertController instead."]
        #[optional]
        #[unsafe(method(alertViewShouldEnableFirstOtherButton:))]
        #[unsafe(method_family = none)]
        fn alertViewShouldEnableFirstOtherButton(&self, alert_view: &UIAlertView) -> bool;
    }
);