//! 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::*;

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

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

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

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

impl NSTextContainer {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        /// ************************** Initialization ***************************
        #[unsafe(method(initWithSize:))]
        #[unsafe(method_family = init)]
        pub fn initWithSize(this: Allocated<Self>, size: CGSize) -> Retained<Self>;

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

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

        #[cfg(feature = "objc2-core-foundation")]
        /// *********************** Container shape properties ************************
        #[unsafe(method(size))]
        #[unsafe(method_family = none)]
        pub fn size(&self) -> CGSize;

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

        #[cfg(feature = "NSParagraphStyle")]
        #[unsafe(method(lineBreakMode))]
        #[unsafe(method_family = none)]
        pub fn lineBreakMode(&self) -> NSLineBreakMode;

        #[cfg(feature = "NSParagraphStyle")]
        /// Setter for [`lineBreakMode`][Self::lineBreakMode].
        #[unsafe(method(setLineBreakMode:))]
        #[unsafe(method_family = none)]
        pub fn setLineBreakMode(&self, line_break_mode: NSLineBreakMode);

        #[cfg(feature = "objc2-core-foundation")]
        /// *********************** Layout constraint properties ************************
        #[unsafe(method(lineFragmentPadding))]
        #[unsafe(method_family = none)]
        pub fn lineFragmentPadding(&self) -> CGFloat;

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

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

        /// Setter for [`maximumNumberOfLines`][Self::maximumNumberOfLines].
        #[unsafe(method(setMaximumNumberOfLines:))]
        #[unsafe(method_family = none)]
        pub fn setMaximumNumberOfLines(&self, maximum_number_of_lines: NSUInteger);

        #[cfg(all(feature = "NSText", feature = "objc2-core-foundation"))]
        /// ************************** Line fragments ***************************
        ///
        /// # Safety
        ///
        /// `remaining_rect` must be a valid pointer or null.
        #[unsafe(method(lineFragmentRectForProposedRect:atIndex:writingDirection:remainingRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn lineFragmentRectForProposedRect_atIndex_writingDirection_remainingRect(
            &self,
            proposed_rect: CGRect,
            character_index: NSUInteger,
            base_writing_direction: NSWritingDirection,
            remaining_rect: *mut CGRect,
        ) -> CGRect;

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

        /// ************************** View synchronization ***************************
        #[unsafe(method(widthTracksTextView))]
        #[unsafe(method_family = none)]
        pub fn widthTracksTextView(&self) -> bool;

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

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

        /// Setter for [`heightTracksTextView`][Self::heightTracksTextView].
        #[unsafe(method(setHeightTracksTextView:))]
        #[unsafe(method_family = none)]
        pub fn setHeightTracksTextView(&self, height_tracks_text_view: bool);
    );
}

/// Methods declared on superclass `NSObject`.
impl NSTextContainer {
    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 NSTextContainer {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

impl NSTextContainer {
    extern_methods!(
        #[cfg(feature = "NSLayoutManager")]
        /// # Safety
        ///
        /// This is not retained internally, you must ensure the object is still alive.
        #[unsafe(method(layoutManager))]
        #[unsafe(method_family = none)]
        pub unsafe fn layoutManager(&self) -> Option<Retained<NSLayoutManager>>;

        #[cfg(feature = "NSLayoutManager")]
        /// Setter for [`layoutManager`][Self::layoutManager].
        ///
        /// # Safety
        ///
        /// This is unretained, you must ensure the object is kept alive while in use.
        #[unsafe(method(setLayoutManager:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLayoutManager(&self, layout_manager: Option<&NSLayoutManager>);

        #[cfg(feature = "NSLayoutManager")]
        #[unsafe(method(replaceLayoutManager:))]
        #[unsafe(method_family = none)]
        pub fn replaceLayoutManager(&self, new_layout_manager: &NSLayoutManager);

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

        #[cfg(feature = "UIBezierPath")]
        /// Setter for [`exclusionPaths`][Self::exclusionPaths].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setExclusionPaths:))]
        #[unsafe(method_family = none)]
        pub fn setExclusionPaths(&self, exclusion_paths: &NSArray<UIBezierPath>);
    );
}

#[cfg(feature = "NSLayoutManager")]
extern_conformance!(
    unsafe impl NSTextLayoutOrientationProvider for NSTextContainer {}
);
