objc2-app-kit 0.3.2

Bindings to the AppKit 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::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/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 = "NSBezierPath")]
        #[unsafe(method(exclusionPaths))]
        #[unsafe(method_family = none)]
        pub fn exclusionPaths(&self) -> Retained<NSArray<NSBezierPath>>;

        #[cfg(feature = "NSBezierPath")]
        /// 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<NSBezierPath>);

        #[cfg(all(
            feature = "NSResponder",
            feature = "NSText",
            feature = "NSTextView",
            feature = "NSView"
        ))]
        #[unsafe(method(textView))]
        #[unsafe(method_family = none)]
        pub fn textView(&self, mtm: MainThreadMarker) -> Option<Retained<NSTextView>>;

        #[cfg(all(
            feature = "NSResponder",
            feature = "NSText",
            feature = "NSTextView",
            feature = "NSView"
        ))]
        /// Setter for [`textView`][Self::textView].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setTextView:))]
        #[unsafe(method_family = none)]
        pub fn setTextView(&self, text_view: Option<&NSTextView>);
    );
}

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

/// ************************** Deprecated ***************************
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nslinesweepdirection?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSLineSweepDirection(pub NSUInteger);
impl NSLineSweepDirection {
    #[doc(alias = "NSLineSweepLeft")]
    pub const Left: Self = Self(0);
    #[doc(alias = "NSLineSweepRight")]
    pub const Right: Self = Self(1);
    #[doc(alias = "NSLineSweepDown")]
    pub const Down: Self = Self(2);
    #[doc(alias = "NSLineSweepUp")]
    pub const Up: Self = Self(3);
}

unsafe impl Encode for NSLineSweepDirection {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nslinemovementdirection?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSLineMovementDirection(pub NSUInteger);
impl NSLineMovementDirection {
    #[doc(alias = "NSLineDoesntMove")]
    pub const DoesntMove: Self = Self(0);
    #[doc(alias = "NSLineMovesLeft")]
    pub const MovesLeft: Self = Self(1);
    #[doc(alias = "NSLineMovesRight")]
    pub const MovesRight: Self = Self(2);
    #[doc(alias = "NSLineMovesDown")]
    pub const MovesDown: Self = Self(3);
    #[doc(alias = "NSLineMovesUp")]
    pub const MovesUp: Self = Self(4);
}

unsafe impl Encode for NSLineMovementDirection {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

/// NSTextContainerDeprecated.
impl NSTextContainer {
    extern_methods!(
        #[unsafe(method(initWithContainerSize:))]
        #[unsafe(method_family = init)]
        pub fn initWithContainerSize(
            this: Allocated<Self>,
            a_container_size: NSSize,
        ) -> Retained<Self>;

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

        /// Setter for [`containerSize`][Self::containerSize].
        #[unsafe(method(setContainerSize:))]
        #[unsafe(method_family = none)]
        pub fn setContainerSize(&self, container_size: NSSize);

        /// # Safety
        ///
        /// `remaining_rect` must be a valid pointer or null.
        #[unsafe(method(lineFragmentRectForProposedRect:sweepDirection:movementDirection:remainingRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn lineFragmentRectForProposedRect_sweepDirection_movementDirection_remainingRect(
            &self,
            proposed_rect: NSRect,
            sweep_direction: NSLineSweepDirection,
            movement_direction: NSLineMovementDirection,
            remaining_rect: NSRectPointer,
        ) -> NSRect;

        #[deprecated]
        #[unsafe(method(containsPoint:))]
        #[unsafe(method_family = none)]
        pub fn containsPoint(&self, point: NSPoint) -> bool;
    );
}