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 unsafe fn initWithTextElement_range(
91            this: Allocated<Self>,
92            text_element: &NSTextElement,
93            range_in_element: Option<&NSTextRange>,
94        ) -> Retained<Self>;
95
96        #[unsafe(method(initWithCoder:))]
97        #[unsafe(method_family = init)]
98        pub unsafe fn initWithCoder(
99            this: Allocated<Self>,
100            coder: &NSCoder,
101        ) -> Option<Retained<Self>>;
102
103        #[unsafe(method(init))]
104        #[unsafe(method_family = init)]
105        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
106
107        #[cfg(feature = "NSTextLayoutManager")]
108        #[unsafe(method(textLayoutManager))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn textLayoutManager(&self) -> Option<Retained<NSTextLayoutManager>>;
111
112        #[cfg(feature = "NSTextElement")]
113        #[unsafe(method(textElement))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn textElement(&self) -> Option<Retained<NSTextElement>>;
116
117        #[cfg(feature = "NSTextRange")]
118        #[unsafe(method(rangeInElement))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn rangeInElement(&self) -> Retained<NSTextRange>;
121
122        #[cfg(feature = "NSTextLineFragment")]
123        #[unsafe(method(textLineFragments))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn textLineFragments(&self) -> Retained<NSArray<NSTextLineFragment>>;
126
127        #[cfg(all(feature = "NSTextLineFragment", feature = "objc2-core-foundation"))]
128        #[unsafe(method(textLineFragmentForVerticalOffset:requiresExactMatch:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn textLineFragmentForVerticalOffset_requiresExactMatch(
131            &self,
132            vertical_offset: CGFloat,
133            requires_exact_match: bool,
134        ) -> Option<Retained<NSTextLineFragment>>;
135
136        #[cfg(all(feature = "NSTextLineFragment", feature = "NSTextRange"))]
137        #[unsafe(method(textLineFragmentForTextLocation:isUpstreamAffinity:))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn textLineFragmentForTextLocation_isUpstreamAffinity(
140            &self,
141            text_location: &ProtocolObject<dyn NSTextLocation>,
142            is_upstream_affinity: bool,
143        ) -> Option<Retained<NSTextLineFragment>>;
144
145        #[unsafe(method(layoutQueue))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn layoutQueue(&self) -> Option<Retained<NSOperationQueue>>;
148
149        /// Setter for [`layoutQueue`][Self::layoutQueue].
150        #[unsafe(method(setLayoutQueue:))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn setLayoutQueue(&self, layout_queue: Option<&NSOperationQueue>);
153
154        #[unsafe(method(state))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn state(&self) -> NSTextLayoutFragmentState;
157
158        #[unsafe(method(invalidateLayout))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn invalidateLayout(&self);
161
162        #[cfg(feature = "objc2-core-foundation")]
163        #[unsafe(method(layoutFragmentFrame))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn layoutFragmentFrame(&self) -> CGRect;
166
167        #[cfg(feature = "objc2-core-foundation")]
168        #[unsafe(method(renderingSurfaceBounds))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn renderingSurfaceBounds(&self) -> CGRect;
171
172        #[cfg(feature = "objc2-core-foundation")]
173        #[unsafe(method(leadingPadding))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn leadingPadding(&self) -> CGFloat;
176
177        #[cfg(feature = "objc2-core-foundation")]
178        #[unsafe(method(trailingPadding))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn trailingPadding(&self) -> CGFloat;
181
182        #[cfg(feature = "objc2-core-foundation")]
183        #[unsafe(method(topMargin))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn topMargin(&self) -> CGFloat;
186
187        #[cfg(feature = "objc2-core-foundation")]
188        #[unsafe(method(bottomMargin))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn bottomMargin(&self) -> CGFloat;
191
192        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
193        #[unsafe(method(drawAtPoint:inContext:))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn drawAtPoint_inContext(&self, point: CGPoint, context: &CGContext);
196
197        #[cfg(feature = "NSTextAttachment")]
198        #[unsafe(method(textAttachmentViewProviders))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn textAttachmentViewProviders(
201            &self,
202        ) -> Retained<NSArray<NSTextAttachmentViewProvider>>;
203
204        #[cfg(all(feature = "NSTextRange", feature = "objc2-core-foundation"))]
205        #[unsafe(method(frameForTextAttachmentAtLocation:))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn frameForTextAttachmentAtLocation(
208            &self,
209            location: &ProtocolObject<dyn NSTextLocation>,
210        ) -> CGRect;
211    );
212}
213
214/// Methods declared on superclass `NSObject`.
215impl NSTextLayoutFragment {
216    extern_methods!(
217        #[unsafe(method(new))]
218        #[unsafe(method_family = new)]
219        pub unsafe fn new() -> Retained<Self>;
220    );
221}