objc2-ui-kit 0.3.2

Bindings to the UIKit framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
use objc2_quartz_core::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uilabelvibrancy?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UILabelVibrancy(pub NSInteger);
impl UILabelVibrancy {
    #[doc(alias = "UILabelVibrancyNone")]
    pub const None: Self = Self(0);
    #[doc(alias = "UILabelVibrancyAutomatic")]
    pub const Automatic: Self = Self(1);
}

unsafe impl Encode for UILabelVibrancy {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UILabelVibrancy {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uilabel?language=objc)
    #[unsafe(super(UIView, UIResponder, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "UIResponder", feature = "UIView"))]
    pub struct UILabel;
);

#[cfg(all(
    feature = "UIResponder",
    feature = "UIView",
    feature = "objc2-quartz-core"
))]
#[cfg(not(target_os = "watchos"))]
extern_conformance!(
    unsafe impl CALayerDelegate for UILabel {}
);

#[cfg(all(feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl NSCoding for UILabel {}
);

#[cfg(all(feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for UILabel {}
);

#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl UIAppearance for UILabel {}
);

#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl UIAppearanceContainer for UILabel {}
);

#[cfg(all(
    feature = "UIContentSizeCategoryAdjusting",
    feature = "UIResponder",
    feature = "UIView"
))]
extern_conformance!(
    unsafe impl UIContentSizeCategoryAdjusting for UILabel {}
);

#[cfg(all(feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl UICoordinateSpace for UILabel {}
);

#[cfg(all(
    feature = "UIDynamicBehavior",
    feature = "UIResponder",
    feature = "UIView"
))]
extern_conformance!(
    unsafe impl UIDynamicItem for UILabel {}
);

#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl UIFocusEnvironment for UILabel {}
);

#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl UIFocusItem for UILabel {}
);

#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl UIFocusItemContainer for UILabel {}
);

#[cfg(all(
    feature = "UILetterformAwareAdjusting",
    feature = "UIResponder",
    feature = "UIView"
))]
extern_conformance!(
    unsafe impl UILetterformAwareAdjusting for UILabel {}
);

#[cfg(all(feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl UIResponderStandardEditActions for UILabel {}
);

#[cfg(all(
    feature = "UIResponder",
    feature = "UITraitCollection",
    feature = "UIView"
))]
extern_conformance!(
    unsafe impl UITraitEnvironment for UILabel {}
);

#[cfg(all(feature = "UIResponder", feature = "UIView"))]
impl UILabel {
    extern_methods!(
        #[unsafe(method(text))]
        #[unsafe(method_family = none)]
        pub fn text(&self) -> Option<Retained<NSString>>;

        /// Setter for [`text`][Self::text].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setText:))]
        #[unsafe(method_family = none)]
        pub fn setText(&self, text: Option<&NSString>);

        #[cfg(feature = "UIFont")]
        #[unsafe(method(font))]
        #[unsafe(method_family = none)]
        pub fn font(&self) -> Option<Retained<UIFont>>;

        #[cfg(feature = "UIFont")]
        /// Setter for [`font`][Self::font].
        ///
        /// # Safety
        ///
        /// `font` might not allow `None`.
        #[unsafe(method(setFont:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFont(&self, font: Option<&UIFont>);

        #[cfg(feature = "UIColor")]
        #[unsafe(method(textColor))]
        #[unsafe(method_family = none)]
        pub fn textColor(&self) -> Option<Retained<UIColor>>;

        #[cfg(feature = "UIColor")]
        /// Setter for [`textColor`][Self::textColor].
        ///
        /// # Safety
        ///
        /// `text_color` might not allow `None`.
        #[unsafe(method(setTextColor:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTextColor(&self, text_color: Option<&UIColor>);

        #[unsafe(method(preferredVibrancy))]
        #[unsafe(method_family = none)]
        pub fn preferredVibrancy(&self) -> UILabelVibrancy;

        /// Setter for [`preferredVibrancy`][Self::preferredVibrancy].
        #[unsafe(method(setPreferredVibrancy:))]
        #[unsafe(method_family = none)]
        pub fn setPreferredVibrancy(&self, preferred_vibrancy: UILabelVibrancy);

        #[cfg(feature = "UIColor")]
        #[unsafe(method(shadowColor))]
        #[unsafe(method_family = none)]
        pub fn shadowColor(&self) -> Option<Retained<UIColor>>;

        #[cfg(feature = "UIColor")]
        /// Setter for [`shadowColor`][Self::shadowColor].
        #[unsafe(method(setShadowColor:))]
        #[unsafe(method_family = none)]
        pub fn setShadowColor(&self, shadow_color: Option<&UIColor>);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(shadowOffset))]
        #[unsafe(method_family = none)]
        pub fn shadowOffset(&self) -> CGSize;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`shadowOffset`][Self::shadowOffset].
        #[unsafe(method(setShadowOffset:))]
        #[unsafe(method_family = none)]
        pub fn setShadowOffset(&self, shadow_offset: CGSize);

        #[cfg(feature = "NSText")]
        #[unsafe(method(textAlignment))]
        #[unsafe(method_family = none)]
        pub fn textAlignment(&self) -> NSTextAlignment;

        #[cfg(feature = "NSText")]
        /// Setter for [`textAlignment`][Self::textAlignment].
        #[unsafe(method(setTextAlignment:))]
        #[unsafe(method_family = none)]
        pub fn setTextAlignment(&self, text_alignment: NSTextAlignment);

        #[cfg(feature = "NSParagraphStyle")]
        #[unsafe(method(lineBreakMode))]
        #[unsafe(method_family = none)]
        pub fn lineBreakMode(&self) -> NSLineBreakMode;

        #[cfg(feature = "NSParagraphStyle")]
        /// Setter for [`lineBreakMode`][Self::lineBreakMode].
        #[unsafe(method(setLineBreakMode:))]
        #[unsafe(method_family = none)]
        pub fn setLineBreakMode(&self, line_break_mode: NSLineBreakMode);

        #[unsafe(method(attributedText))]
        #[unsafe(method_family = none)]
        pub fn attributedText(&self) -> Option<Retained<NSAttributedString>>;

        /// Setter for [`attributedText`][Self::attributedText].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setAttributedText:))]
        #[unsafe(method_family = none)]
        pub fn setAttributedText(&self, attributed_text: Option<&NSAttributedString>);

        #[cfg(feature = "UIColor")]
        #[unsafe(method(highlightedTextColor))]
        #[unsafe(method_family = none)]
        pub fn highlightedTextColor(&self) -> Option<Retained<UIColor>>;

        #[cfg(feature = "UIColor")]
        /// Setter for [`highlightedTextColor`][Self::highlightedTextColor].
        #[unsafe(method(setHighlightedTextColor:))]
        #[unsafe(method_family = none)]
        pub fn setHighlightedTextColor(&self, highlighted_text_color: Option<&UIColor>);

        #[unsafe(method(isHighlighted))]
        #[unsafe(method_family = none)]
        pub fn isHighlighted(&self) -> bool;

        /// Setter for [`isHighlighted`][Self::isHighlighted].
        #[unsafe(method(setHighlighted:))]
        #[unsafe(method_family = none)]
        pub fn setHighlighted(&self, highlighted: bool);

        #[unsafe(method(isUserInteractionEnabled))]
        #[unsafe(method_family = none)]
        pub fn isUserInteractionEnabled(&self) -> bool;

        /// Setter for [`isUserInteractionEnabled`][Self::isUserInteractionEnabled].
        #[unsafe(method(setUserInteractionEnabled:))]
        #[unsafe(method_family = none)]
        pub fn setUserInteractionEnabled(&self, user_interaction_enabled: bool);

        #[unsafe(method(isEnabled))]
        #[unsafe(method_family = none)]
        pub fn isEnabled(&self) -> bool;

        /// Setter for [`isEnabled`][Self::isEnabled].
        #[unsafe(method(setEnabled:))]
        #[unsafe(method_family = none)]
        pub fn setEnabled(&self, enabled: bool);

        #[unsafe(method(numberOfLines))]
        #[unsafe(method_family = none)]
        pub fn numberOfLines(&self) -> NSInteger;

        /// Setter for [`numberOfLines`][Self::numberOfLines].
        #[unsafe(method(setNumberOfLines:))]
        #[unsafe(method_family = none)]
        pub fn setNumberOfLines(&self, number_of_lines: NSInteger);

        #[unsafe(method(adjustsFontSizeToFitWidth))]
        #[unsafe(method_family = none)]
        pub fn adjustsFontSizeToFitWidth(&self) -> bool;

        /// Setter for [`adjustsFontSizeToFitWidth`][Self::adjustsFontSizeToFitWidth].
        #[unsafe(method(setAdjustsFontSizeToFitWidth:))]
        #[unsafe(method_family = none)]
        pub fn setAdjustsFontSizeToFitWidth(&self, adjusts_font_size_to_fit_width: bool);

        #[cfg(feature = "UIStringDrawing")]
        #[unsafe(method(baselineAdjustment))]
        #[unsafe(method_family = none)]
        pub fn baselineAdjustment(&self) -> UIBaselineAdjustment;

        #[cfg(feature = "UIStringDrawing")]
        /// Setter for [`baselineAdjustment`][Self::baselineAdjustment].
        #[unsafe(method(setBaselineAdjustment:))]
        #[unsafe(method_family = none)]
        pub fn setBaselineAdjustment(&self, baseline_adjustment: UIBaselineAdjustment);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(minimumScaleFactor))]
        #[unsafe(method_family = none)]
        pub fn minimumScaleFactor(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`minimumScaleFactor`][Self::minimumScaleFactor].
        #[unsafe(method(setMinimumScaleFactor:))]
        #[unsafe(method_family = none)]
        pub fn setMinimumScaleFactor(&self, minimum_scale_factor: CGFloat);

        #[unsafe(method(allowsDefaultTighteningForTruncation))]
        #[unsafe(method_family = none)]
        pub fn allowsDefaultTighteningForTruncation(&self) -> bool;

        /// Setter for [`allowsDefaultTighteningForTruncation`][Self::allowsDefaultTighteningForTruncation].
        #[unsafe(method(setAllowsDefaultTighteningForTruncation:))]
        #[unsafe(method_family = none)]
        pub fn setAllowsDefaultTighteningForTruncation(
            &self,
            allows_default_tightening_for_truncation: bool,
        );

        #[cfg(feature = "NSParagraphStyle")]
        #[unsafe(method(lineBreakStrategy))]
        #[unsafe(method_family = none)]
        pub fn lineBreakStrategy(&self) -> NSLineBreakStrategy;

        #[cfg(feature = "NSParagraphStyle")]
        /// Setter for [`lineBreakStrategy`][Self::lineBreakStrategy].
        #[unsafe(method(setLineBreakStrategy:))]
        #[unsafe(method_family = none)]
        pub fn setLineBreakStrategy(&self, line_break_strategy: NSLineBreakStrategy);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(textRectForBounds:limitedToNumberOfLines:))]
        #[unsafe(method_family = none)]
        pub fn textRectForBounds_limitedToNumberOfLines(
            &self,
            bounds: CGRect,
            number_of_lines: NSInteger,
        ) -> CGRect;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(drawTextInRect:))]
        #[unsafe(method_family = none)]
        pub fn drawTextInRect(&self, rect: CGRect);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(preferredMaxLayoutWidth))]
        #[unsafe(method_family = none)]
        pub fn preferredMaxLayoutWidth(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`preferredMaxLayoutWidth`][Self::preferredMaxLayoutWidth].
        #[unsafe(method(setPreferredMaxLayoutWidth:))]
        #[unsafe(method_family = none)]
        pub fn setPreferredMaxLayoutWidth(&self, preferred_max_layout_width: CGFloat);

        #[unsafe(method(enablesMarqueeWhenAncestorFocused))]
        #[unsafe(method_family = none)]
        pub fn enablesMarqueeWhenAncestorFocused(&self) -> bool;

        /// Setter for [`enablesMarqueeWhenAncestorFocused`][Self::enablesMarqueeWhenAncestorFocused].
        #[unsafe(method(setEnablesMarqueeWhenAncestorFocused:))]
        #[unsafe(method_family = none)]
        pub fn setEnablesMarqueeWhenAncestorFocused(
            &self,
            enables_marquee_when_ancestor_focused: bool,
        );

        /// Indicates whether expansion text will be shown when the view is too small to show all the contents. Defaults to NO.
        #[unsafe(method(showsExpansionTextWhenTruncated))]
        #[unsafe(method_family = none)]
        pub fn showsExpansionTextWhenTruncated(&self) -> bool;

        /// Setter for [`showsExpansionTextWhenTruncated`][Self::showsExpansionTextWhenTruncated].
        #[unsafe(method(setShowsExpansionTextWhenTruncated:))]
        #[unsafe(method_family = none)]
        pub fn setShowsExpansionTextWhenTruncated(&self, shows_expansion_text_when_truncated: bool);

        #[cfg(feature = "objc2-core-foundation")]
        #[deprecated]
        #[unsafe(method(minimumFontSize))]
        #[unsafe(method_family = none)]
        pub fn minimumFontSize(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`minimumFontSize`][Self::minimumFontSize].
        #[deprecated]
        #[unsafe(method(setMinimumFontSize:))]
        #[unsafe(method_family = none)]
        pub fn setMinimumFontSize(&self, minimum_font_size: CGFloat);

        #[deprecated]
        #[unsafe(method(adjustsLetterSpacingToFitWidth))]
        #[unsafe(method_family = none)]
        pub fn adjustsLetterSpacingToFitWidth(&self) -> bool;

        /// Setter for [`adjustsLetterSpacingToFitWidth`][Self::adjustsLetterSpacingToFitWidth].
        #[deprecated]
        #[unsafe(method(setAdjustsLetterSpacingToFitWidth:))]
        #[unsafe(method_family = none)]
        pub fn setAdjustsLetterSpacingToFitWidth(&self, adjusts_letter_spacing_to_fit_width: bool);
    );
}

/// Methods declared on superclass `UIView`.
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
impl UILabel {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
impl UILabel {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}