//! 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/nsattachmentcharacter?language=objc)
pub const NSAttachmentCharacter: c_uint = 0xFFFC;

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextattachmentlayout?language=objc)
    pub unsafe trait NSTextAttachmentLayout: NSObjectProtocol {
        #[cfg(all(
            feature = "NSTextContainer",
            feature = "NSTextRange",
            feature = "UIImage",
            feature = "objc2-core-foundation"
        ))]
        /// # Safety
        ///
        /// `attributes` generic should be of the correct type.
        #[unsafe(method(imageForBounds:attributes:location:textContainer:))]
        #[unsafe(method_family = none)]
        unsafe fn imageForBounds_attributes_location_textContainer(
            &self,
            bounds: CGRect,
            attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
            location: &ProtocolObject<dyn NSTextLocation>,
            text_container: Option<&NSTextContainer>,
        ) -> Option<Retained<UIImage>>;

        #[cfg(all(
            feature = "NSTextContainer",
            feature = "NSTextRange",
            feature = "objc2-core-foundation"
        ))]
        /// # Safety
        ///
        /// `attributes` generic should be of the correct type.
        #[unsafe(method(attachmentBoundsForAttributes:location:textContainer:proposedLineFragment:position:))]
        #[unsafe(method_family = none)]
        unsafe fn attachmentBoundsForAttributes_location_textContainer_proposedLineFragment_position(
            &self,
            attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
            location: &ProtocolObject<dyn NSTextLocation>,
            text_container: Option<&NSTextContainer>,
            proposed_line_fragment: CGRect,
            position: CGPoint,
        ) -> CGRect;

        #[cfg(all(
            feature = "NSTextContainer",
            feature = "NSTextRange",
            feature = "UIResponder",
            feature = "UIView"
        ))]
        #[unsafe(method(viewProviderForParentView:location:textContainer:))]
        #[unsafe(method_family = none)]
        fn viewProviderForParentView_location_textContainer(
            &self,
            parent_view: Option<&UIView>,
            location: &ProtocolObject<dyn NSTextLocation>,
            text_container: Option<&NSTextContainer>,
        ) -> Option<Retained<NSTextAttachmentViewProvider>>;
    }
);

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

extern_conformance!(
    unsafe impl NSCoding for NSTextAttachment {}
);

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

extern_conformance!(
    unsafe impl NSSecureCoding for NSTextAttachment {}
);

extern_conformance!(
    unsafe impl NSTextAttachmentLayout for NSTextAttachment {}
);

impl NSTextAttachment {
    extern_methods!(
        /// ************************** Initialization ***************************
        #[unsafe(method(initWithData:ofType:))]
        #[unsafe(method_family = init)]
        pub fn initWithData_ofType(
            this: Allocated<Self>,
            content_data: Option<&NSData>,
            uti: Option<&NSString>,
        ) -> Retained<Self>;

        /// ************************** Content properties ***************************
        #[unsafe(method(contents))]
        #[unsafe(method_family = none)]
        pub fn contents(&self) -> Option<Retained<NSData>>;

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

        #[unsafe(method(fileType))]
        #[unsafe(method_family = none)]
        pub fn fileType(&self) -> Option<Retained<NSString>>;

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

        #[cfg(feature = "UIImage")]
        /// ************************** Rendering/layout properties ***************************
        #[unsafe(method(image))]
        #[unsafe(method_family = none)]
        pub fn image(&self) -> Option<Retained<UIImage>>;

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

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(bounds))]
        #[unsafe(method_family = none)]
        pub fn bounds(&self) -> CGRect;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`bounds`][Self::bounds].
        #[unsafe(method(setBounds:))]
        #[unsafe(method_family = none)]
        pub fn setBounds(&self, bounds: CGRect);

        /// ************************** Non-image contents properties ***************************
        #[unsafe(method(fileWrapper))]
        #[unsafe(method_family = none)]
        pub fn fileWrapper(&self) -> Option<Retained<NSFileWrapper>>;

        /// Setter for [`fileWrapper`][Self::fileWrapper].
        #[unsafe(method(setFileWrapper:))]
        #[unsafe(method_family = none)]
        pub fn setFileWrapper(&self, file_wrapper: Option<&NSFileWrapper>);

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

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`lineLayoutPadding`][Self::lineLayoutPadding].
        #[unsafe(method(setLineLayoutPadding:))]
        #[unsafe(method_family = none)]
        pub fn setLineLayoutPadding(&self, line_layout_padding: CGFloat);

        #[unsafe(method(textAttachmentViewProviderClassForFileType:))]
        #[unsafe(method_family = none)]
        pub fn textAttachmentViewProviderClassForFileType(
            file_type: &NSString,
        ) -> Option<&'static AnyClass>;

        /// # Safety
        ///
        /// `text_attachment_view_provider_class` probably has further requirements.
        #[unsafe(method(registerTextAttachmentViewProviderClass:forFileType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn registerTextAttachmentViewProviderClass_forFileType(
            text_attachment_view_provider_class: &AnyClass,
            file_type: &NSString,
        );

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

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

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

/// Methods declared on superclass `NSObject`.
impl NSTextAttachment {
    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() -> Retained<Self>;
    );
}

impl DefaultRetained for NSTextAttachment {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

mod private_NSAttributedStringAttachmentConveniences {
    pub trait Sealed {}
}

/// Category on [`NSAttributedString`].
pub unsafe trait NSAttributedStringAttachmentConveniences:
    ClassType + Sized + private_NSAttributedStringAttachmentConveniences::Sealed
{
    extern_methods!(
        #[unsafe(method(attributedStringWithAttachment:))]
        #[unsafe(method_family = none)]
        fn attributedStringWithAttachment(
            attachment: &NSTextAttachment,
        ) -> Retained<NSAttributedString>;

        /// # Safety
        ///
        /// `attributes` generic should be of the correct type.
        #[unsafe(method(attributedStringWithAttachment:attributes:))]
        #[unsafe(method_family = none)]
        unsafe fn attributedStringWithAttachment_attributes(
            attachment: &NSTextAttachment,
            attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
        ) -> Retained<Self>;
    );
}

impl private_NSAttributedStringAttachmentConveniences::Sealed for NSAttributedString {}
unsafe impl NSAttributedStringAttachmentConveniences for NSAttributedString {}

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

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

impl NSTextAttachmentViewProvider {
    extern_methods!(
        #[cfg(all(
            feature = "NSTextLayoutManager",
            feature = "NSTextRange",
            feature = "UIResponder",
            feature = "UIView"
        ))]
        #[unsafe(method(initWithTextAttachment:parentView:textLayoutManager:location:))]
        #[unsafe(method_family = init)]
        pub fn initWithTextAttachment_parentView_textLayoutManager_location(
            this: Allocated<Self>,
            text_attachment: &NSTextAttachment,
            parent_view: Option<&UIView>,
            text_layout_manager: Option<&NSTextLayoutManager>,
            location: &ProtocolObject<dyn NSTextLocation>,
        ) -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

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

        #[unsafe(method(textAttachment))]
        #[unsafe(method_family = none)]
        pub fn textAttachment(&self) -> Option<Retained<NSTextAttachment>>;

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

        #[cfg(feature = "NSTextRange")]
        #[unsafe(method(location))]
        #[unsafe(method_family = none)]
        pub fn location(&self) -> Retained<ProtocolObject<dyn NSTextLocation>>;

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[unsafe(method(view))]
        #[unsafe(method_family = none)]
        pub fn view(&self, mtm: MainThreadMarker) -> Option<Retained<UIView>>;

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        /// Setter for [`view`][Self::view].
        #[unsafe(method(setView:))]
        #[unsafe(method_family = none)]
        pub fn setView(&self, view: Option<&UIView>);

        #[unsafe(method(loadView))]
        #[unsafe(method_family = none)]
        pub fn loadView(&self);

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

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

        #[cfg(all(
            feature = "NSTextContainer",
            feature = "NSTextRange",
            feature = "objc2-core-foundation"
        ))]
        /// # Safety
        ///
        /// `attributes` generic should be of the correct type.
        #[unsafe(method(attachmentBoundsForAttributes:location:textContainer:proposedLineFragment:position:))]
        #[unsafe(method_family = none)]
        pub unsafe fn attachmentBoundsForAttributes_location_textContainer_proposedLineFragment_position(
            &self,
            attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
            location: &ProtocolObject<dyn NSTextLocation>,
            text_container: Option<&NSTextContainer>,
            proposed_line_fragment: CGRect,
            position: CGPoint,
        ) -> CGRect;
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextattachmentcontainer?language=objc)
    pub unsafe trait NSTextAttachmentContainer: NSObjectProtocol {
        #[cfg(all(
            feature = "NSTextContainer",
            feature = "UIImage",
            feature = "objc2-core-foundation"
        ))]
        #[unsafe(method(imageForBounds:textContainer:characterIndex:))]
        #[unsafe(method_family = none)]
        fn imageForBounds_textContainer_characterIndex(
            &self,
            image_bounds: CGRect,
            text_container: Option<&NSTextContainer>,
            char_index: NSUInteger,
        ) -> Option<Retained<UIImage>>;

        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
        #[unsafe(method(attachmentBoundsForTextContainer:proposedLineFragment:glyphPosition:characterIndex:))]
        #[unsafe(method_family = none)]
        fn attachmentBoundsForTextContainer_proposedLineFragment_glyphPosition_characterIndex(
            &self,
            text_container: Option<&NSTextContainer>,
            line_frag: CGRect,
            position: CGPoint,
            char_index: NSUInteger,
        ) -> CGRect;
    }
);

/// NSTextAttachment_Deprecation.
impl NSTextAttachment {
    extern_methods!();
}

extern_conformance!(
    unsafe impl NSTextAttachmentContainer for NSTextAttachment {}
);
