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/nsatstypesetter?language=objc)
    #[unsafe(super(NSTypesetter, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSTypesetter")]
    pub struct NSATSTypesetter;
);

#[cfg(feature = "NSTypesetter")]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSATSTypesetter {}
);

#[cfg(feature = "NSTypesetter")]
impl NSATSTypesetter {
    extern_methods!(
        #[unsafe(method(sharedTypesetter))]
        #[unsafe(method_family = none)]
        pub fn sharedTypesetter() -> Retained<NSATSTypesetter>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSTypesetter")]
impl NSATSTypesetter {
    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>;
    );
}

#[cfg(feature = "NSTypesetter")]
impl DefaultRetained for NSATSTypesetter {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

/// NSPantherCompatibility.
#[cfg(feature = "NSTypesetter")]
impl NSATSTypesetter {
    extern_methods!(
        /// # Safety
        ///
        /// `remaining_rect` must be a valid pointer.
        #[deprecated]
        #[unsafe(method(lineFragmentRectForProposedRect:remainingRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn lineFragmentRectForProposedRect_remainingRect(
            &self,
            proposed_rect: NSRect,
            remaining_rect: NSRectPointer,
        ) -> NSRect;
    );
}

/// NSPrimitiveInterface.
#[cfg(feature = "NSTypesetter")]
impl NSATSTypesetter {
    extern_methods!(
        #[unsafe(method(usesFontLeading))]
        #[unsafe(method_family = none)]
        pub fn usesFontLeading(&self) -> bool;

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

        #[cfg(feature = "NSLayoutManager")]
        #[unsafe(method(typesetterBehavior))]
        #[unsafe(method_family = none)]
        pub fn typesetterBehavior(&self) -> NSTypesetterBehavior;

        #[cfg(feature = "NSLayoutManager")]
        /// Setter for [`typesetterBehavior`][Self::typesetterBehavior].
        #[unsafe(method(setTypesetterBehavior:))]
        #[unsafe(method_family = none)]
        pub fn setTypesetterBehavior(&self, typesetter_behavior: NSTypesetterBehavior);

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

        /// Setter for [`hyphenationFactor`][Self::hyphenationFactor].
        #[unsafe(method(setHyphenationFactor:))]
        #[unsafe(method_family = none)]
        pub fn setHyphenationFactor(&self, hyphenation_factor: c_float);

        #[cfg(feature = "objc2-core-foundation")]
        #[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);

        #[cfg(feature = "NSFont")]
        #[unsafe(method(substituteFontForFont:))]
        #[unsafe(method_family = none)]
        pub fn substituteFontForFont(&self, original_font: &NSFont) -> Retained<NSFont>;

        #[cfg(all(
            feature = "NSParagraphStyle",
            feature = "NSText",
            feature = "objc2-core-foundation"
        ))]
        #[unsafe(method(textTabForGlyphLocation:writingDirection:maxLocation:))]
        #[unsafe(method_family = none)]
        pub fn textTabForGlyphLocation_writingDirection_maxLocation(
            &self,
            glyph_location: CGFloat,
            direction: NSWritingDirection,
            max_location: CGFloat,
        ) -> Option<Retained<NSTextTab>>;

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

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

        /// # Safety
        ///
        /// This is not retained internally, you must ensure the object is still alive.
        #[unsafe(method(attributedString))]
        #[unsafe(method_family = none)]
        pub unsafe fn attributedString(&self) -> Option<Retained<NSAttributedString>>;

        /// Setter for [`attributedString`][Self::attributedString].
        ///
        /// # Safety
        ///
        /// This is unretained, you must ensure the object is kept alive while in use.
        #[unsafe(method(setAttributedString:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAttributedString(&self, attributed_string: Option<&NSAttributedString>);

        #[unsafe(method(setParagraphGlyphRange:separatorGlyphRange:))]
        #[unsafe(method_family = none)]
        pub fn setParagraphGlyphRange_separatorGlyphRange(
            &self,
            paragraph_range: NSRange,
            paragraph_separator_range: NSRange,
        );

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

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

        /// # Safety
        ///
        /// `line_fragment_origin` must be a valid pointer.
        #[unsafe(method(layoutParagraphAtPoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn layoutParagraphAtPoint(
            &self,
            line_fragment_origin: NonNull<NSPoint>,
        ) -> NSUInteger;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(lineSpacingAfterGlyphAtIndex:withProposedLineFragmentRect:))]
        #[unsafe(method_family = none)]
        pub fn lineSpacingAfterGlyphAtIndex_withProposedLineFragmentRect(
            &self,
            glyph_index: NSUInteger,
            rect: NSRect,
        ) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(paragraphSpacingBeforeGlyphAtIndex:withProposedLineFragmentRect:))]
        #[unsafe(method_family = none)]
        pub fn paragraphSpacingBeforeGlyphAtIndex_withProposedLineFragmentRect(
            &self,
            glyph_index: NSUInteger,
            rect: NSRect,
        ) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(paragraphSpacingAfterGlyphAtIndex:withProposedLineFragmentRect:))]
        #[unsafe(method_family = none)]
        pub fn paragraphSpacingAfterGlyphAtIndex_withProposedLineFragmentRect(
            &self,
            glyph_index: NSUInteger,
            rect: NSRect,
        ) -> CGFloat;

        #[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 = "NSTextContainer")]
        /// # Safety
        ///
        /// This is not retained internally, you must ensure the object is still alive.
        #[unsafe(method(currentTextContainer))]
        #[unsafe(method_family = none)]
        pub unsafe fn currentTextContainer(&self) -> Option<Retained<NSTextContainer>>;

        #[unsafe(method(setHardInvalidation:forGlyphRange:))]
        #[unsafe(method_family = none)]
        pub fn setHardInvalidation_forGlyphRange(&self, flag: bool, glyph_range: NSRange);

        /// # Safety
        ///
        /// - `line_fragment_rect` must be a valid pointer.
        /// - `line_fragment_used_rect` must be a valid pointer.
        #[unsafe(method(getLineFragmentRect:usedRect:forParagraphSeparatorGlyphRange:atProposedOrigin:))]
        #[unsafe(method_family = none)]
        pub unsafe fn getLineFragmentRect_usedRect_forParagraphSeparatorGlyphRange_atProposedOrigin(
            &self,
            line_fragment_rect: NonNull<NSRect>,
            line_fragment_used_rect: NonNull<NSRect>,
            paragraph_separator_glyph_range: NSRange,
            line_origin: NSPoint,
        );
    );
}

/// NSLayoutPhaseInterface.
#[cfg(feature = "NSTypesetter")]
impl NSATSTypesetter {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        /// # Safety
        ///
        /// - `line_rect` must be a valid pointer.
        /// - `used_rect` must be a valid pointer.
        /// - `baseline_offset` must be a valid pointer.
        #[unsafe(method(willSetLineFragmentRect:forGlyphRange:usedRect:baselineOffset:))]
        #[unsafe(method_family = none)]
        pub unsafe fn willSetLineFragmentRect_forGlyphRange_usedRect_baselineOffset(
            &self,
            line_rect: NonNull<NSRect>,
            glyph_range: NSRange,
            used_rect: NonNull<NSRect>,
            baseline_offset: NonNull<CGFloat>,
        );

        #[unsafe(method(shouldBreakLineByWordBeforeCharacterAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn shouldBreakLineByWordBeforeCharacterAtIndex(&self, char_index: NSUInteger) -> bool;

        #[unsafe(method(shouldBreakLineByHyphenatingBeforeCharacterAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn shouldBreakLineByHyphenatingBeforeCharacterAtIndex(
            &self,
            char_index: NSUInteger,
        ) -> bool;

        #[unsafe(method(hyphenationFactorForGlyphAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn hyphenationFactorForGlyphAtIndex(&self, glyph_index: NSUInteger) -> c_float;

        #[unsafe(method(hyphenCharacterForGlyphAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn hyphenCharacterForGlyphAtIndex(&self, glyph_index: NSUInteger) -> UTF32Char;

        #[cfg(feature = "NSTextContainer")]
        #[unsafe(method(boundingBoxForControlGlyphAtIndex:forTextContainer:proposedLineFragment:glyphPosition:characterIndex:))]
        #[unsafe(method_family = none)]
        pub fn boundingBoxForControlGlyphAtIndex_forTextContainer_proposedLineFragment_glyphPosition_characterIndex(
            &self,
            glyph_index: NSUInteger,
            text_container: &NSTextContainer,
            proposed_rect: NSRect,
            glyph_position: NSPoint,
            char_index: NSUInteger,
        ) -> NSRect;
    );
}

/// NSGlyphStorageInterface.
#[cfg(feature = "NSTypesetter")]
impl NSATSTypesetter {
    extern_methods!(
        #[cfg(all(feature = "NSFont", feature = "NSLayoutManager"))]
        /// # Safety
        ///
        /// - `glyph_buffer` must be a valid pointer.
        /// - `char_index_buffer` must be a valid pointer.
        /// - `inscribe_buffer` must be a valid pointer.
        /// - `elastic_buffer` must be a valid pointer.
        #[deprecated]
        #[unsafe(method(getGlyphsInRange:glyphs:characterIndexes:glyphInscriptions:elasticBits:))]
        #[unsafe(method_family = none)]
        pub unsafe fn getGlyphsInRange_glyphs_characterIndexes_glyphInscriptions_elasticBits(
            &self,
            glyphs_range: NSRange,
            glyph_buffer: *mut NSGlyph,
            char_index_buffer: *mut NSUInteger,
            inscribe_buffer: *mut NSGlyphInscription,
            elastic_buffer: *mut Bool,
        ) -> NSUInteger;
    );
}