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