objc2_ui_kit/generated/
NSTextLayoutFragment.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-graphics")]
9use objc2_core_graphics::*;
10use objc2_foundation::*;
11
12use crate::*;
13
14/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextlayoutfragmentenumerationoptions?language=objc)
15// NS_OPTIONS
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct NSTextLayoutFragmentEnumerationOptions(pub NSUInteger);
19bitflags::bitflags! {
20    impl NSTextLayoutFragmentEnumerationOptions: NSUInteger {
21        #[doc(alias = "NSTextLayoutFragmentEnumerationOptionsNone")]
22        const None = 0;
23        #[doc(alias = "NSTextLayoutFragmentEnumerationOptionsReverse")]
24        const Reverse = 1<<0;
25        #[doc(alias = "NSTextLayoutFragmentEnumerationOptionsEstimatesSize")]
26        const EstimatesSize = 1<<1;
27        #[doc(alias = "NSTextLayoutFragmentEnumerationOptionsEnsuresLayout")]
28        const EnsuresLayout = 1<<2;
29        #[doc(alias = "NSTextLayoutFragmentEnumerationOptionsEnsuresExtraLineFragment")]
30        const EnsuresExtraLineFragment = 1<<3;
31    }
32}
33
34unsafe impl Encode for NSTextLayoutFragmentEnumerationOptions {
35    const ENCODING: Encoding = NSUInteger::ENCODING;
36}
37
38unsafe impl RefEncode for NSTextLayoutFragmentEnumerationOptions {
39    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
40}
41
42/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextlayoutfragmentstate?language=objc)
43// NS_ENUM
44#[repr(transparent)]
45#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
46pub struct NSTextLayoutFragmentState(pub NSUInteger);
47impl NSTextLayoutFragmentState {
48    #[doc(alias = "NSTextLayoutFragmentStateNone")]
49    pub const None: Self = Self(0);
50    #[doc(alias = "NSTextLayoutFragmentStateEstimatedUsageBounds")]
51    pub const EstimatedUsageBounds: Self = Self(1);
52    #[doc(alias = "NSTextLayoutFragmentStateCalculatedUsageBounds")]
53    pub const CalculatedUsageBounds: Self = Self(2);
54    #[doc(alias = "NSTextLayoutFragmentStateLayoutAvailable")]
55    pub const LayoutAvailable: Self = Self(3);
56}
57
58unsafe impl Encode for NSTextLayoutFragmentState {
59    const ENCODING: Encoding = NSUInteger::ENCODING;
60}
61
62unsafe impl RefEncode for NSTextLayoutFragmentState {
63    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
64}
65
66extern_class!(
67    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextlayoutfragment?language=objc)
68    #[unsafe(super(NSObject))]
69    #[derive(Debug, PartialEq, Eq, Hash)]
70    pub struct NSTextLayoutFragment;
71);
72
73extern_conformance!(
74    unsafe impl NSCoding for NSTextLayoutFragment {}
75);
76
77extern_conformance!(
78    unsafe impl NSObjectProtocol for NSTextLayoutFragment {}
79);
80
81extern_conformance!(
82    unsafe impl NSSecureCoding for NSTextLayoutFragment {}
83);
84
85impl NSTextLayoutFragment {
86    extern_methods!(
87        #[cfg(all(feature = "NSTextElement", feature = "NSTextRange"))]
88        #[unsafe(method(initWithTextElement:range:))]
89        #[unsafe(method_family = init)]
90        pub fn initWithTextElement_range(
91            this: Allocated<Self>,
92            text_element: &NSTextElement,
93            range_in_element: Option<&NSTextRange>,
94        ) -> Retained<Self>;
95
96        /// # Safety
97        ///
98        /// `coder` possibly has further requirements.
99        #[unsafe(method(initWithCoder:))]
100        #[unsafe(method_family = init)]
101        pub unsafe fn initWithCoder(
102            this: Allocated<Self>,
103            coder: &NSCoder,
104        ) -> Option<Retained<Self>>;
105
106        #[unsafe(method(init))]
107        #[unsafe(method_family = init)]
108        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
109
110        #[cfg(feature = "NSTextLayoutManager")]
111        #[unsafe(method(textLayoutManager))]
112        #[unsafe(method_family = none)]
113        pub fn textLayoutManager(&self) -> Option<Retained<NSTextLayoutManager>>;
114
115        #[cfg(feature = "NSTextElement")]
116        #[unsafe(method(textElement))]
117        #[unsafe(method_family = none)]
118        pub fn textElement(&self) -> Option<Retained<NSTextElement>>;
119
120        #[cfg(feature = "NSTextRange")]
121        #[unsafe(method(rangeInElement))]
122        #[unsafe(method_family = none)]
123        pub fn rangeInElement(&self) -> Retained<NSTextRange>;
124
125        #[cfg(feature = "NSTextLineFragment")]
126        #[unsafe(method(textLineFragments))]
127        #[unsafe(method_family = none)]
128        pub fn textLineFragments(&self) -> Retained<NSArray<NSTextLineFragment>>;
129
130        #[cfg(all(feature = "NSTextLineFragment", feature = "objc2-core-foundation"))]
131        #[unsafe(method(textLineFragmentForVerticalOffset:requiresExactMatch:))]
132        #[unsafe(method_family = none)]
133        pub fn textLineFragmentForVerticalOffset_requiresExactMatch(
134            &self,
135            vertical_offset: CGFloat,
136            requires_exact_match: bool,
137        ) -> Option<Retained<NSTextLineFragment>>;
138
139        #[cfg(all(feature = "NSTextLineFragment", feature = "NSTextRange"))]
140        #[unsafe(method(textLineFragmentForTextLocation:isUpstreamAffinity:))]
141        #[unsafe(method_family = none)]
142        pub fn textLineFragmentForTextLocation_isUpstreamAffinity(
143            &self,
144            text_location: &ProtocolObject<dyn NSTextLocation>,
145            is_upstream_affinity: bool,
146        ) -> Option<Retained<NSTextLineFragment>>;
147
148        #[unsafe(method(layoutQueue))]
149        #[unsafe(method_family = none)]
150        pub fn layoutQueue(&self) -> Option<Retained<NSOperationQueue>>;
151
152        /// Setter for [`layoutQueue`][Self::layoutQueue].
153        ///
154        /// # Safety
155        ///
156        /// `layout_queue` possibly has additional threading requirements.
157        #[unsafe(method(setLayoutQueue:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn setLayoutQueue(&self, layout_queue: Option<&NSOperationQueue>);
160
161        #[unsafe(method(state))]
162        #[unsafe(method_family = none)]
163        pub fn state(&self) -> NSTextLayoutFragmentState;
164
165        #[unsafe(method(invalidateLayout))]
166        #[unsafe(method_family = none)]
167        pub fn invalidateLayout(&self);
168
169        #[cfg(feature = "objc2-core-foundation")]
170        #[unsafe(method(layoutFragmentFrame))]
171        #[unsafe(method_family = none)]
172        pub fn layoutFragmentFrame(&self) -> CGRect;
173
174        #[cfg(feature = "objc2-core-foundation")]
175        #[unsafe(method(renderingSurfaceBounds))]
176        #[unsafe(method_family = none)]
177        pub fn renderingSurfaceBounds(&self) -> CGRect;
178
179        #[cfg(feature = "objc2-core-foundation")]
180        #[unsafe(method(leadingPadding))]
181        #[unsafe(method_family = none)]
182        pub fn leadingPadding(&self) -> CGFloat;
183
184        #[cfg(feature = "objc2-core-foundation")]
185        #[unsafe(method(trailingPadding))]
186        #[unsafe(method_family = none)]
187        pub fn trailingPadding(&self) -> CGFloat;
188
189        #[cfg(feature = "objc2-core-foundation")]
190        #[unsafe(method(topMargin))]
191        #[unsafe(method_family = none)]
192        pub fn topMargin(&self) -> CGFloat;
193
194        #[cfg(feature = "objc2-core-foundation")]
195        #[unsafe(method(bottomMargin))]
196        #[unsafe(method_family = none)]
197        pub fn bottomMargin(&self) -> CGFloat;
198
199        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
200        #[unsafe(method(drawAtPoint:inContext:))]
201        #[unsafe(method_family = none)]
202        pub fn drawAtPoint_inContext(&self, point: CGPoint, context: &CGContext);
203
204        #[cfg(feature = "NSTextAttachment")]
205        #[unsafe(method(textAttachmentViewProviders))]
206        #[unsafe(method_family = none)]
207        pub fn textAttachmentViewProviders(
208            &self,
209        ) -> Retained<NSArray<NSTextAttachmentViewProvider>>;
210
211        #[cfg(all(feature = "NSTextRange", feature = "objc2-core-foundation"))]
212        #[unsafe(method(frameForTextAttachmentAtLocation:))]
213        #[unsafe(method_family = none)]
214        pub fn frameForTextAttachmentAtLocation(
215            &self,
216            location: &ProtocolObject<dyn NSTextLocation>,
217        ) -> CGRect;
218    );
219}
220
221/// Methods declared on superclass `NSObject`.
222impl NSTextLayoutFragment {
223    extern_methods!(
224        #[unsafe(method(new))]
225        #[unsafe(method_family = new)]
226        pub unsafe fn new() -> Retained<Self>;
227    );
228}