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::*;
pub const NSAttachmentCharacter: c_uint = 0xFFFC;
extern_protocol!(
pub unsafe trait NSTextAttachmentLayout: NSObjectProtocol {
#[cfg(all(
feature = "NSImage",
feature = "NSTextContainer",
feature = "NSTextRange",
feature = "objc2-core-foundation"
))]
#[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<NSImage>>;
#[cfg(all(
feature = "NSTextContainer",
feature = "NSTextRange",
feature = "objc2-core-foundation"
))]
#[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 = "NSResponder",
feature = "NSTextContainer",
feature = "NSTextRange",
feature = "NSView"
))]
#[unsafe(method(viewProviderForParentView:location:textContainer:))]
#[unsafe(method_family = none)]
fn viewProviderForParentView_location_textContainer(
&self,
parent_view: Option<&NSView>,
location: &ProtocolObject<dyn NSTextLocation>,
text_container: Option<&NSTextContainer>,
) -> Option<Retained<NSTextAttachmentViewProvider>>;
}
);
extern_class!(
#[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!(
#[unsafe(method(initWithData:ofType:))]
#[unsafe(method_family = init)]
pub fn initWithData_ofType(
this: Allocated<Self>,
content_data: Option<&NSData>,
uti: Option<&NSString>,
) -> Retained<Self>;
#[unsafe(method(initWithFileWrapper:))]
#[unsafe(method_family = init)]
pub fn initWithFileWrapper(
this: Allocated<Self>,
file_wrapper: Option<&NSFileWrapper>,
) -> Retained<Self>;
#[unsafe(method(contents))]
#[unsafe(method_family = none)]
pub fn contents(&self) -> Option<Retained<NSData>>;
#[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>>;
#[unsafe(method(setFileType:))]
#[unsafe(method_family = none)]
pub fn setFileType(&self, file_type: Option<&NSString>);
#[cfg(feature = "NSImage")]
#[unsafe(method(image))]
#[unsafe(method_family = none)]
pub fn image(&self) -> Option<Retained<NSImage>>;
#[cfg(feature = "NSImage")]
#[unsafe(method(setImage:))]
#[unsafe(method_family = none)]
pub fn setImage(&self, image: Option<&NSImage>);
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(bounds))]
#[unsafe(method_family = none)]
pub fn bounds(&self) -> CGRect;
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(setBounds:))]
#[unsafe(method_family = none)]
pub fn setBounds(&self, bounds: CGRect);
#[unsafe(method(fileWrapper))]
#[unsafe(method_family = none)]
pub fn fileWrapper(&self) -> Option<Retained<NSFileWrapper>>;
#[unsafe(method(setFileWrapper:))]
#[unsafe(method_family = none)]
pub fn setFileWrapper(&self, file_wrapper: Option<&NSFileWrapper>);
#[cfg(feature = "NSTextAttachmentCell")]
#[unsafe(method(attachmentCell))]
#[unsafe(method_family = none)]
pub fn attachmentCell(
&self,
) -> Option<Retained<ProtocolObject<dyn NSTextAttachmentCellProtocol>>>;
#[cfg(feature = "NSTextAttachmentCell")]
#[unsafe(method(setAttachmentCell:))]
#[unsafe(method_family = none)]
pub fn setAttachmentCell(
&self,
attachment_cell: Option<&ProtocolObject<dyn NSTextAttachmentCellProtocol>>,
);
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(lineLayoutPadding))]
#[unsafe(method_family = none)]
pub fn lineLayoutPadding(&self) -> CGFloat;
#[cfg(feature = "objc2-core-foundation")]
#[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>;
#[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;
#[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;
);
}
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 {}
}
pub unsafe trait NSAttributedStringAttachmentConveniences:
ClassType + Sized + private_NSAttributedStringAttachmentConveniences::Sealed
{
extern_methods!(
#[unsafe(method(attributedStringWithAttachment:))]
#[unsafe(method_family = none)]
fn attributedStringWithAttachment(
attachment: &NSTextAttachment,
) -> Retained<NSAttributedString>;
#[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!(
#[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 = "NSResponder",
feature = "NSTextLayoutManager",
feature = "NSTextRange",
feature = "NSView"
))]
#[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<&NSView>,
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 = "NSResponder", feature = "NSView"))]
#[unsafe(method(view))]
#[unsafe(method_family = none)]
pub fn view(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
#[unsafe(method(setView:))]
#[unsafe(method_family = none)]
pub fn setView(&self, view: Option<&NSView>);
#[unsafe(method(loadView))]
#[unsafe(method_family = none)]
pub fn loadView(&self);
#[unsafe(method(tracksTextAttachmentViewBounds))]
#[unsafe(method_family = none)]
pub fn tracksTextAttachmentViewBounds(&self) -> bool;
#[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"
))]
#[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;
);
}
mod private_NSMutableAttributedStringAttachmentConveniences {
pub trait Sealed {}
}
pub unsafe trait NSMutableAttributedStringAttachmentConveniences:
ClassType + Sized + private_NSMutableAttributedStringAttachmentConveniences::Sealed
{
extern_methods!(
#[unsafe(method(updateAttachmentsFromPath:))]
#[unsafe(method_family = none)]
fn updateAttachmentsFromPath(&self, path: &NSString);
);
}
impl private_NSMutableAttributedStringAttachmentConveniences::Sealed for NSMutableAttributedString {}
unsafe impl NSMutableAttributedStringAttachmentConveniences for NSMutableAttributedString {}
extern_protocol!(
pub unsafe trait NSTextAttachmentContainer: NSObjectProtocol {
#[cfg(all(
feature = "NSImage",
feature = "NSTextContainer",
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<NSImage>>;
#[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;
}
);
impl NSTextAttachment {
extern_methods!();
}
extern_conformance!(
unsafe impl NSTextAttachmentContainer for NSTextAttachment {}
);