objc2_ui_kit/generated/
NSStringDrawing.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::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nsstringdrawingcontext?language=objc)
14    #[unsafe(super(NSObject))]
15    #[derive(Debug, PartialEq, Eq, Hash)]
16    pub struct NSStringDrawingContext;
17);
18
19extern_conformance!(
20    unsafe impl NSObjectProtocol for NSStringDrawingContext {}
21);
22
23impl NSStringDrawingContext {
24    extern_methods!(
25        #[cfg(feature = "objc2-core-foundation")]
26        #[unsafe(method(minimumScaleFactor))]
27        #[unsafe(method_family = none)]
28        pub fn minimumScaleFactor(&self) -> CGFloat;
29
30        #[cfg(feature = "objc2-core-foundation")]
31        /// Setter for [`minimumScaleFactor`][Self::minimumScaleFactor].
32        #[unsafe(method(setMinimumScaleFactor:))]
33        #[unsafe(method_family = none)]
34        pub fn setMinimumScaleFactor(&self, minimum_scale_factor: CGFloat);
35
36        #[cfg(feature = "objc2-core-foundation")]
37        #[unsafe(method(actualScaleFactor))]
38        #[unsafe(method_family = none)]
39        pub fn actualScaleFactor(&self) -> CGFloat;
40
41        #[cfg(feature = "objc2-core-foundation")]
42        #[unsafe(method(totalBounds))]
43        #[unsafe(method_family = none)]
44        pub fn totalBounds(&self) -> CGRect;
45    );
46}
47
48/// Methods declared on superclass `NSObject`.
49impl NSStringDrawingContext {
50    extern_methods!(
51        #[unsafe(method(init))]
52        #[unsafe(method_family = init)]
53        pub fn init(this: Allocated<Self>) -> Retained<Self>;
54
55        #[unsafe(method(new))]
56        #[unsafe(method_family = new)]
57        pub fn new() -> Retained<Self>;
58    );
59}
60
61impl DefaultRetained for NSStringDrawingContext {
62    #[inline]
63    fn default_retained() -> Retained<Self> {
64        Self::new()
65    }
66}
67
68mod private_NSStringDrawing {
69    pub trait Sealed {}
70}
71
72/// Category on [`NSString`].
73pub unsafe trait NSStringDrawing:
74    ClassType + Sized + private_NSStringDrawing::Sealed
75{
76    extern_methods!(
77        #[cfg(feature = "objc2-core-foundation")]
78        /// # Safety
79        ///
80        /// `attrs` generic should be of the correct type.
81        #[unsafe(method(sizeWithAttributes:))]
82        #[unsafe(method_family = none)]
83        unsafe fn sizeWithAttributes(
84            &self,
85            attrs: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
86        ) -> CGSize;
87
88        #[cfg(feature = "objc2-core-foundation")]
89        /// # Safety
90        ///
91        /// `attrs` generic should be of the correct type.
92        #[unsafe(method(drawAtPoint:withAttributes:))]
93        #[unsafe(method_family = none)]
94        unsafe fn drawAtPoint_withAttributes(
95            &self,
96            point: CGPoint,
97            attrs: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
98        );
99
100        #[cfg(feature = "objc2-core-foundation")]
101        /// # Safety
102        ///
103        /// `attrs` generic should be of the correct type.
104        #[unsafe(method(drawInRect:withAttributes:))]
105        #[unsafe(method_family = none)]
106        unsafe fn drawInRect_withAttributes(
107            &self,
108            rect: CGRect,
109            attrs: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
110        );
111    );
112}
113
114impl private_NSStringDrawing::Sealed for NSString {}
115unsafe impl NSStringDrawing for NSString {}
116
117mod private_NSAttributedStringNSStringDrawing {
118    pub trait Sealed {}
119}
120
121/// Category "NSStringDrawing" on [`NSAttributedString`].
122#[doc(alias = "NSStringDrawing")]
123pub unsafe trait NSAttributedStringNSStringDrawing:
124    ClassType + Sized + private_NSAttributedStringNSStringDrawing::Sealed
125{
126    extern_methods!(
127        #[cfg(feature = "objc2-core-foundation")]
128        #[unsafe(method(size))]
129        #[unsafe(method_family = none)]
130        fn size(&self) -> CGSize;
131
132        #[cfg(feature = "objc2-core-foundation")]
133        #[unsafe(method(drawAtPoint:))]
134        #[unsafe(method_family = none)]
135        fn drawAtPoint(&self, point: CGPoint);
136
137        #[cfg(feature = "objc2-core-foundation")]
138        #[unsafe(method(drawInRect:))]
139        #[unsafe(method_family = none)]
140        fn drawInRect(&self, rect: CGRect);
141    );
142}
143
144impl private_NSAttributedStringNSStringDrawing::Sealed for NSAttributedString {}
145unsafe impl NSAttributedStringNSStringDrawing for NSAttributedString {}
146
147/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nsstringdrawingoptions?language=objc)
148// NS_OPTIONS
149#[repr(transparent)]
150#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
151pub struct NSStringDrawingOptions(pub NSInteger);
152bitflags::bitflags! {
153    impl NSStringDrawingOptions: NSInteger {
154        #[doc(alias = "NSStringDrawingUsesLineFragmentOrigin")]
155        const UsesLineFragmentOrigin = 1<<0;
156        #[doc(alias = "NSStringDrawingUsesFontLeading")]
157        const UsesFontLeading = 1<<1;
158        #[doc(alias = "NSStringDrawingUsesDeviceMetrics")]
159        const UsesDeviceMetrics = 1<<3;
160        #[doc(alias = "NSStringDrawingTruncatesLastVisibleLine")]
161        const TruncatesLastVisibleLine = 1<<5;
162/// Specifies the behavior for resolving ``NSTextAlignment.natural`` to the visual alignment.
163///
164/// When set, the resolved visual alignment is determined by the resolved base writing direction; otherwise, it is using the user’s preferred language.
165        #[doc(alias = "NSStringDrawingOptionsResolvesNaturalAlignmentWithBaseWritingDirection")]
166        const OptionsResolvesNaturalAlignmentWithBaseWritingDirection = 1<<9;
167    }
168}
169
170unsafe impl Encode for NSStringDrawingOptions {
171    const ENCODING: Encoding = NSInteger::ENCODING;
172}
173
174unsafe impl RefEncode for NSStringDrawingOptions {
175    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
176}
177
178mod private_NSStringNSExtendedStringDrawing {
179    pub trait Sealed {}
180}
181
182/// Category "NSExtendedStringDrawing" on [`NSString`].
183#[doc(alias = "NSExtendedStringDrawing")]
184pub unsafe trait NSStringNSExtendedStringDrawing:
185    ClassType + Sized + private_NSStringNSExtendedStringDrawing::Sealed
186{
187    extern_methods!(
188        #[cfg(feature = "objc2-core-foundation")]
189        /// # Safety
190        ///
191        /// `attributes` generic should be of the correct type.
192        #[unsafe(method(drawWithRect:options:attributes:context:))]
193        #[unsafe(method_family = none)]
194        unsafe fn drawWithRect_options_attributes_context(
195            &self,
196            rect: CGRect,
197            options: NSStringDrawingOptions,
198            attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
199            context: Option<&NSStringDrawingContext>,
200        );
201
202        #[cfg(feature = "objc2-core-foundation")]
203        /// # Safety
204        ///
205        /// `attributes` generic should be of the correct type.
206        #[unsafe(method(boundingRectWithSize:options:attributes:context:))]
207        #[unsafe(method_family = none)]
208        unsafe fn boundingRectWithSize_options_attributes_context(
209            &self,
210            size: CGSize,
211            options: NSStringDrawingOptions,
212            attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
213            context: Option<&NSStringDrawingContext>,
214        ) -> CGRect;
215    );
216}
217
218impl private_NSStringNSExtendedStringDrawing::Sealed for NSString {}
219unsafe impl NSStringNSExtendedStringDrawing for NSString {}
220
221mod private_NSAttributedStringNSExtendedStringDrawing {
222    pub trait Sealed {}
223}
224
225/// Category "NSExtendedStringDrawing" on [`NSAttributedString`].
226#[doc(alias = "NSExtendedStringDrawing")]
227pub unsafe trait NSAttributedStringNSExtendedStringDrawing:
228    ClassType + Sized + private_NSAttributedStringNSExtendedStringDrawing::Sealed
229{
230    extern_methods!(
231        #[cfg(feature = "objc2-core-foundation")]
232        #[unsafe(method(drawWithRect:options:context:))]
233        #[unsafe(method_family = none)]
234        fn drawWithRect_options_context(
235            &self,
236            rect: CGRect,
237            options: NSStringDrawingOptions,
238            context: Option<&NSStringDrawingContext>,
239        );
240
241        #[cfg(feature = "objc2-core-foundation")]
242        #[unsafe(method(boundingRectWithSize:options:context:))]
243        #[unsafe(method_family = none)]
244        fn boundingRectWithSize_options_context(
245            &self,
246            size: CGSize,
247            options: NSStringDrawingOptions,
248            context: Option<&NSStringDrawingContext>,
249        ) -> CGRect;
250    );
251}
252
253impl private_NSAttributedStringNSExtendedStringDrawing::Sealed for NSAttributedString {}
254unsafe impl NSAttributedStringNSExtendedStringDrawing for NSAttributedString {}
255
256/// NSStringDrawingContextDeprecated.
257///
258/// ********************** Deprecated ***********************
259impl NSStringDrawingContext {
260    extern_methods!(
261        #[cfg(feature = "objc2-core-foundation")]
262        #[deprecated]
263        #[unsafe(method(minimumTrackingAdjustment))]
264        #[unsafe(method_family = none)]
265        pub fn minimumTrackingAdjustment(&self) -> CGFloat;
266
267        #[cfg(feature = "objc2-core-foundation")]
268        /// Setter for [`minimumTrackingAdjustment`][Self::minimumTrackingAdjustment].
269        #[deprecated]
270        #[unsafe(method(setMinimumTrackingAdjustment:))]
271        #[unsafe(method_family = none)]
272        pub fn setMinimumTrackingAdjustment(&self, minimum_tracking_adjustment: CGFloat);
273
274        #[cfg(feature = "objc2-core-foundation")]
275        #[deprecated]
276        #[unsafe(method(actualTrackingAdjustment))]
277        #[unsafe(method_family = none)]
278        pub fn actualTrackingAdjustment(&self) -> CGFloat;
279    );
280}