objc2-app-kit 0.2.2

Bindings to the AppKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

pub const NSAttachmentCharacter: c_uint = 0xFFFC;

extern_protocol!(
    pub unsafe trait NSTextAttachmentContainer: NSObjectProtocol {
        #[cfg(all(feature = "NSImage", feature = "NSTextContainer"))]
        #[method_id(@__retain_semantics Other imageForBounds:textContainer:characterIndex:)]
        unsafe fn imageForBounds_textContainer_characterIndex(
            &self,
            image_bounds: CGRect,
            text_container: Option<&NSTextContainer>,
            char_index: NSUInteger,
        ) -> Option<Retained<NSImage>>;

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

    unsafe impl ProtocolType for dyn NSTextAttachmentContainer {}
);

extern_protocol!(
    pub unsafe trait NSTextAttachmentLayout: NSObjectProtocol {
        #[cfg(all(
            feature = "NSImage",
            feature = "NSTextContainer",
            feature = "NSTextRange"
        ))]
        #[method_id(@__retain_semantics Other imageForBounds:attributes:location:textContainer:)]
        unsafe fn imageForBounds_attributes_location_textContainer(
            &self,
            bounds: CGRect,
            attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
            location: &ProtocolObject<dyn NSTextLocation>,
            text_container: Option<&NSTextContainer>,
        ) -> Option<Retained<NSImage>>;

        #[cfg(all(feature = "NSTextContainer", feature = "NSTextRange"))]
        #[method(attachmentBoundsForAttributes:location:textContainer:proposedLineFragment:position:)]
        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 = "NSResponder",
            feature = "NSTextContainer",
            feature = "NSTextRange",
            feature = "NSView"
        ))]
        #[method_id(@__retain_semantics Other viewProviderForParentView:location:textContainer:)]
        unsafe fn viewProviderForParentView_location_textContainer(
            &self,
            parent_view: Option<&NSView>,
            location: &ProtocolObject<dyn NSTextLocation>,
            text_container: Option<&NSTextContainer>,
        ) -> Option<Retained<NSTextAttachmentViewProvider>>;
    }

    unsafe impl ProtocolType for dyn NSTextAttachmentLayout {}
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSTextAttachment;

    unsafe impl ClassType for NSTextAttachment {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSCoding for NSTextAttachment {}

unsafe impl NSObjectProtocol for NSTextAttachment {}

unsafe impl NSSecureCoding for NSTextAttachment {}

unsafe impl NSTextAttachmentContainer for NSTextAttachment {}

unsafe impl NSTextAttachmentLayout for NSTextAttachment {}

extern_methods!(
    unsafe impl NSTextAttachment {
        #[method_id(@__retain_semantics Init initWithData:ofType:)]
        pub unsafe fn initWithData_ofType(
            this: Allocated<Self>,
            content_data: Option<&NSData>,
            uti: Option<&NSString>,
        ) -> Retained<Self>;

        #[method_id(@__retain_semantics Init initWithFileWrapper:)]
        pub unsafe fn initWithFileWrapper(
            this: Allocated<Self>,
            file_wrapper: Option<&NSFileWrapper>,
        ) -> Retained<Self>;

        #[method_id(@__retain_semantics Other contents)]
        pub unsafe fn contents(&self) -> Option<Retained<NSData>>;

        #[method(setContents:)]
        pub unsafe fn setContents(&self, contents: Option<&NSData>);

        #[method_id(@__retain_semantics Other fileType)]
        pub unsafe fn fileType(&self) -> Option<Retained<NSString>>;

        #[method(setFileType:)]
        pub unsafe fn setFileType(&self, file_type: Option<&NSString>);

        #[cfg(feature = "NSImage")]
        #[method_id(@__retain_semantics Other image)]
        pub unsafe fn image(&self) -> Option<Retained<NSImage>>;

        #[cfg(feature = "NSImage")]
        #[method(setImage:)]
        pub unsafe fn setImage(&self, image: Option<&NSImage>);

        #[method(bounds)]
        pub unsafe fn bounds(&self) -> CGRect;

        #[method(setBounds:)]
        pub unsafe fn setBounds(&self, bounds: CGRect);

        #[method_id(@__retain_semantics Other fileWrapper)]
        pub unsafe fn fileWrapper(&self) -> Option<Retained<NSFileWrapper>>;

        #[method(setFileWrapper:)]
        pub unsafe fn setFileWrapper(&self, file_wrapper: Option<&NSFileWrapper>);

        #[cfg(feature = "NSTextAttachmentCell")]
        #[method_id(@__retain_semantics Other attachmentCell)]
        pub unsafe fn attachmentCell(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn NSTextAttachmentCellProtocol>>>;

        #[cfg(feature = "NSTextAttachmentCell")]
        #[method(setAttachmentCell:)]
        pub unsafe fn setAttachmentCell(
            &self,
            attachment_cell: Option<&ProtocolObject<dyn NSTextAttachmentCellProtocol>>,
        );

        #[method(lineLayoutPadding)]
        pub unsafe fn lineLayoutPadding(&self) -> CGFloat;

        #[method(setLineLayoutPadding:)]
        pub unsafe fn setLineLayoutPadding(&self, line_layout_padding: CGFloat);

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

        #[method(registerTextAttachmentViewProviderClass:forFileType:)]
        pub unsafe fn registerTextAttachmentViewProviderClass_forFileType(
            text_attachment_view_provider_class: &AnyClass,
            file_type: &NSString,
        );

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

        #[method(setAllowsTextAttachmentView:)]
        pub unsafe fn setAllowsTextAttachmentView(&self, allows_text_attachment_view: bool);

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

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSTextAttachment {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);

extern_category!(
    /// Category on [`NSAttributedString`].
    pub unsafe trait NSAttributedStringAttachmentConveniences {
        #[method_id(@__retain_semantics Other attributedStringWithAttachment:)]
        unsafe fn attributedStringWithAttachment(
            attachment: &NSTextAttachment,
        ) -> Retained<NSAttributedString>;
    }

    unsafe impl NSAttributedStringAttachmentConveniences for NSAttributedString {}
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSTextAttachmentViewProvider;

    unsafe impl ClassType for NSTextAttachmentViewProvider {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for NSTextAttachmentViewProvider {}

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

        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;

        #[method_id(@__retain_semantics Other textAttachment)]
        pub unsafe fn textAttachment(&self) -> Option<Retained<NSTextAttachment>>;

        #[cfg(feature = "NSTextLayoutManager")]
        #[method_id(@__retain_semantics Other textLayoutManager)]
        pub unsafe fn textLayoutManager(&self) -> Option<Retained<NSTextLayoutManager>>;

        #[cfg(feature = "NSTextRange")]
        #[method_id(@__retain_semantics Other location)]
        pub unsafe fn location(&self) -> Retained<ProtocolObject<dyn NSTextLocation>>;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[method_id(@__retain_semantics Other view)]
        pub unsafe fn view(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[method(setView:)]
        pub unsafe fn setView(&self, view: Option<&NSView>);

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

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

        #[method(setTracksTextAttachmentViewBounds:)]
        pub unsafe fn setTracksTextAttachmentViewBounds(
            &self,
            tracks_text_attachment_view_bounds: bool,
        );

        #[cfg(all(feature = "NSTextContainer", feature = "NSTextRange"))]
        #[method(attachmentBoundsForAttributes:location:textContainer:proposedLineFragment:position:)]
        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_category!(
    /// Category on [`NSMutableAttributedString`].
    pub unsafe trait NSMutableAttributedStringAttachmentConveniences {
        #[method(updateAttachmentsFromPath:)]
        unsafe fn updateAttachmentsFromPath(&self, path: &NSString);
    }

    unsafe impl NSMutableAttributedStringAttachmentConveniences for NSMutableAttributedString {}
);