//! 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/uikit/uitextinteractionmode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UITextInteractionMode(pub NSInteger);
impl UITextInteractionMode {
    #[doc(alias = "UITextInteractionModeEditable")]
    pub const Editable: Self = Self(0);
    #[doc(alias = "UITextInteractionModeNonEditable")]
    pub const NonEditable: Self = Self(1);
}

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

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

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextinteractiondelegate?language=objc)
    pub unsafe trait UITextInteractionDelegate: NSObjectProtocol + MainThreadOnly {
        #[cfg(feature = "objc2-core-foundation")]
        #[optional]
        #[unsafe(method(interactionShouldBegin:atPoint:))]
        #[unsafe(method_family = none)]
        fn interactionShouldBegin_atPoint(
            &self,
            interaction: &UITextInteraction,
            point: CGPoint,
        ) -> bool;

        #[optional]
        #[unsafe(method(interactionWillBegin:))]
        #[unsafe(method_family = none)]
        fn interactionWillBegin(&self, interaction: &UITextInteraction);

        #[optional]
        #[unsafe(method(interactionDidEnd:))]
        #[unsafe(method_family = none)]
        fn interactionDidEnd(&self, interaction: &UITextInteraction);
    }
);

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextinteraction?language=objc)
    #[unsafe(super(NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct UITextInteraction;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for UITextInteraction {}
);

#[cfg(feature = "UIInteraction")]
extern_conformance!(
    unsafe impl UIInteraction for UITextInteraction {}
);

impl UITextInteraction {
    extern_methods!(
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn UITextInteractionDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn UITextInteractionDelegate>>);

        #[cfg(all(
            feature = "UIResponder",
            feature = "UITextInput",
            feature = "UITextInputTraits"
        ))]
        #[unsafe(method(textInput))]
        #[unsafe(method_family = none)]
        pub fn textInput(&self) -> Option<Retained<UIResponder>>;

        #[cfg(all(
            feature = "UIResponder",
            feature = "UITextInput",
            feature = "UITextInputTraits"
        ))]
        /// Setter for [`textInput`][Self::textInput].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        ///
        /// # Safety
        ///
        /// `text_input` must implement UITextInput.
        #[unsafe(method(setTextInput:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTextInput(&self, text_input: Option<&UIResponder>);

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

        #[cfg(feature = "UIGestureRecognizer")]
        #[unsafe(method(gesturesForFailureRequirements))]
        #[unsafe(method_family = none)]
        pub fn gesturesForFailureRequirements(&self) -> Retained<NSArray<UIGestureRecognizer>>;

        #[unsafe(method(textInteractionForMode:))]
        #[unsafe(method_family = none)]
        pub fn textInteractionForMode(
            mode: UITextInteractionMode,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
impl UITextInteraction {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}
