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