use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTextLayoutFragmentEnumerationOptions(pub NSUInteger);
impl NSTextLayoutFragmentEnumerationOptions {
#[doc(alias = "NSTextLayoutFragmentEnumerationOptionsNone")]
pub const None: Self = Self(0);
#[doc(alias = "NSTextLayoutFragmentEnumerationOptionsReverse")]
pub const Reverse: Self = Self(1 << 0);
#[doc(alias = "NSTextLayoutFragmentEnumerationOptionsEstimatesSize")]
pub const EstimatesSize: Self = Self(1 << 1);
#[doc(alias = "NSTextLayoutFragmentEnumerationOptionsEnsuresLayout")]
pub const EnsuresLayout: Self = Self(1 << 2);
#[doc(alias = "NSTextLayoutFragmentEnumerationOptionsEnsuresExtraLineFragment")]
pub const EnsuresExtraLineFragment: Self = Self(1 << 3);
}
unsafe impl Encode for NSTextLayoutFragmentEnumerationOptions {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSTextLayoutFragmentEnumerationOptions {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTextLayoutFragmentState(pub NSUInteger);
impl NSTextLayoutFragmentState {
#[doc(alias = "NSTextLayoutFragmentStateNone")]
pub const None: Self = Self(0);
#[doc(alias = "NSTextLayoutFragmentStateEstimatedUsageBounds")]
pub const EstimatedUsageBounds: Self = Self(1);
#[doc(alias = "NSTextLayoutFragmentStateCalculatedUsageBounds")]
pub const CalculatedUsageBounds: Self = Self(2);
#[doc(alias = "NSTextLayoutFragmentStateLayoutAvailable")]
pub const LayoutAvailable: Self = Self(3);
}
unsafe impl Encode for NSTextLayoutFragmentState {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSTextLayoutFragmentState {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSTextLayoutFragment;
unsafe impl ClassType for NSTextLayoutFragment {
type Super = NSObject;
type Mutability = InteriorMutable;
}
);
unsafe impl NSCoding for NSTextLayoutFragment {}
unsafe impl NSObjectProtocol for NSTextLayoutFragment {}
unsafe impl NSSecureCoding for NSTextLayoutFragment {}
extern_methods!(
unsafe impl NSTextLayoutFragment {
#[cfg(all(feature = "NSTextElement", feature = "NSTextRange"))]
#[method_id(@__retain_semantics Init initWithTextElement:range:)]
pub unsafe fn initWithTextElement_range(
this: Allocated<Self>,
text_element: &NSTextElement,
range_in_element: Option<&NSTextRange>,
) -> Id<Self>;
#[method_id(@__retain_semantics Init initWithCoder:)]
pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Option<Id<Self>>;
#[method_id(@__retain_semantics Init init)]
pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
#[cfg(feature = "NSTextLayoutManager")]
#[method_id(@__retain_semantics Other textLayoutManager)]
pub unsafe fn textLayoutManager(&self) -> Option<Id<NSTextLayoutManager>>;
#[cfg(feature = "NSTextElement")]
#[method_id(@__retain_semantics Other textElement)]
pub unsafe fn textElement(&self) -> Option<Id<NSTextElement>>;
#[cfg(feature = "NSTextRange")]
#[method_id(@__retain_semantics Other rangeInElement)]
pub unsafe fn rangeInElement(&self) -> Id<NSTextRange>;
#[cfg(feature = "NSTextLineFragment")]
#[method_id(@__retain_semantics Other textLineFragments)]
pub unsafe fn textLineFragments(&self) -> Id<NSArray<NSTextLineFragment>>;
#[cfg(feature = "NSTextLineFragment")]
#[method_id(@__retain_semantics Other textLineFragmentForVerticalOffset:requiresExactMatch:)]
pub unsafe fn textLineFragmentForVerticalOffset_requiresExactMatch(
&self,
vertical_offset: CGFloat,
requires_exact_match: bool,
) -> Option<Id<NSTextLineFragment>>;
#[cfg(all(feature = "NSTextLineFragment", feature = "NSTextRange"))]
#[method_id(@__retain_semantics Other textLineFragmentForTextLocation:isUpstreamAffinity:)]
pub unsafe fn textLineFragmentForTextLocation_isUpstreamAffinity(
&self,
text_location: &ProtocolObject<dyn NSTextLocation>,
is_upstream_affinity: bool,
) -> Option<Id<NSTextLineFragment>>;
#[method_id(@__retain_semantics Other layoutQueue)]
pub unsafe fn layoutQueue(&self) -> Option<Id<NSOperationQueue>>;
#[method(setLayoutQueue:)]
pub unsafe fn setLayoutQueue(&self, layout_queue: Option<&NSOperationQueue>);
#[method(state)]
pub unsafe fn state(&self) -> NSTextLayoutFragmentState;
#[method(invalidateLayout)]
pub unsafe fn invalidateLayout(&self);
#[method(layoutFragmentFrame)]
pub unsafe fn layoutFragmentFrame(&self) -> CGRect;
#[method(renderingSurfaceBounds)]
pub unsafe fn renderingSurfaceBounds(&self) -> CGRect;
#[method(leadingPadding)]
pub unsafe fn leadingPadding(&self) -> CGFloat;
#[method(trailingPadding)]
pub unsafe fn trailingPadding(&self) -> CGFloat;
#[method(topMargin)]
pub unsafe fn topMargin(&self) -> CGFloat;
#[method(bottomMargin)]
pub unsafe fn bottomMargin(&self) -> CGFloat;
#[cfg(feature = "NSTextAttachment")]
#[method_id(@__retain_semantics Other textAttachmentViewProviders)]
pub unsafe fn textAttachmentViewProviders(
&self,
) -> Id<NSArray<NSTextAttachmentViewProvider>>;
#[cfg(feature = "NSTextRange")]
#[method(frameForTextAttachmentAtLocation:)]
pub unsafe fn frameForTextAttachmentAtLocation(
&self,
location: &ProtocolObject<dyn NSTextLocation>,
) -> CGRect;
}
);
extern_methods!(
unsafe impl NSTextLayoutFragment {
#[method_id(@__retain_semantics New new)]
pub unsafe fn new() -> Id<Self>;
}
);