objc2_ui_kit/generated/
UICollectionViewCell.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#[cfg(feature = "objc2-quartz-core")]
10#[cfg(not(target_os = "watchos"))]
11use objc2_quartz_core::*;
12
13use crate::*;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewcelldragstate?language=objc)
16// NS_ENUM
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct UICollectionViewCellDragState(pub NSInteger);
20impl UICollectionViewCellDragState {
21    #[doc(alias = "UICollectionViewCellDragStateNone")]
22    pub const None: Self = Self(0);
23    #[doc(alias = "UICollectionViewCellDragStateLifting")]
24    pub const Lifting: Self = Self(1);
25    #[doc(alias = "UICollectionViewCellDragStateDragging")]
26    pub const Dragging: Self = Self(2);
27}
28
29unsafe impl Encode for UICollectionViewCellDragState {
30    const ENCODING: Encoding = NSInteger::ENCODING;
31}
32
33unsafe impl RefEncode for UICollectionViewCellDragState {
34    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
35}
36
37extern_class!(
38    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionreusableview?language=objc)
39    #[unsafe(super(UIView, UIResponder, NSObject))]
40    #[thread_kind = MainThreadOnly]
41    #[derive(Debug, PartialEq, Eq, Hash)]
42    #[cfg(all(feature = "UIResponder", feature = "UIView"))]
43    pub struct UICollectionReusableView;
44);
45
46#[cfg(all(
47    feature = "UIResponder",
48    feature = "UIView",
49    feature = "objc2-quartz-core"
50))]
51#[cfg(not(target_os = "watchos"))]
52extern_conformance!(
53    unsafe impl CALayerDelegate for UICollectionReusableView {}
54);
55
56#[cfg(all(feature = "UIResponder", feature = "UIView"))]
57extern_conformance!(
58    unsafe impl NSCoding for UICollectionReusableView {}
59);
60
61#[cfg(all(feature = "UIResponder", feature = "UIView"))]
62extern_conformance!(
63    unsafe impl NSObjectProtocol for UICollectionReusableView {}
64);
65
66#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
67extern_conformance!(
68    unsafe impl UIAppearance for UICollectionReusableView {}
69);
70
71#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
72extern_conformance!(
73    unsafe impl UIAppearanceContainer for UICollectionReusableView {}
74);
75
76#[cfg(all(feature = "UIResponder", feature = "UIView"))]
77extern_conformance!(
78    unsafe impl UICoordinateSpace for UICollectionReusableView {}
79);
80
81#[cfg(all(
82    feature = "UIDynamicBehavior",
83    feature = "UIResponder",
84    feature = "UIView"
85))]
86extern_conformance!(
87    unsafe impl UIDynamicItem for UICollectionReusableView {}
88);
89
90#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
91extern_conformance!(
92    unsafe impl UIFocusEnvironment for UICollectionReusableView {}
93);
94
95#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
96extern_conformance!(
97    unsafe impl UIFocusItem for UICollectionReusableView {}
98);
99
100#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
101extern_conformance!(
102    unsafe impl UIFocusItemContainer for UICollectionReusableView {}
103);
104
105#[cfg(all(feature = "UIResponder", feature = "UIView"))]
106extern_conformance!(
107    unsafe impl UIResponderStandardEditActions for UICollectionReusableView {}
108);
109
110#[cfg(all(
111    feature = "UIResponder",
112    feature = "UITraitCollection",
113    feature = "UIView"
114))]
115extern_conformance!(
116    unsafe impl UITraitEnvironment for UICollectionReusableView {}
117);
118
119#[cfg(all(feature = "UIResponder", feature = "UIView"))]
120impl UICollectionReusableView {
121    extern_methods!(
122        #[unsafe(method(reuseIdentifier))]
123        #[unsafe(method_family = none)]
124        pub fn reuseIdentifier(&self) -> Option<Retained<NSString>>;
125
126        #[unsafe(method(prepareForReuse))]
127        #[unsafe(method_family = none)]
128        pub fn prepareForReuse(&self);
129
130        #[cfg(feature = "UICollectionViewLayout")]
131        #[unsafe(method(applyLayoutAttributes:))]
132        #[unsafe(method_family = none)]
133        pub fn applyLayoutAttributes(&self, layout_attributes: &UICollectionViewLayoutAttributes);
134
135        #[cfg(feature = "UICollectionViewLayout")]
136        #[unsafe(method(willTransitionFromLayout:toLayout:))]
137        #[unsafe(method_family = none)]
138        pub fn willTransitionFromLayout_toLayout(
139            &self,
140            old_layout: &UICollectionViewLayout,
141            new_layout: &UICollectionViewLayout,
142        );
143
144        #[cfg(feature = "UICollectionViewLayout")]
145        #[unsafe(method(didTransitionFromLayout:toLayout:))]
146        #[unsafe(method_family = none)]
147        pub fn didTransitionFromLayout_toLayout(
148            &self,
149            old_layout: &UICollectionViewLayout,
150            new_layout: &UICollectionViewLayout,
151        );
152
153        #[cfg(feature = "UICollectionViewLayout")]
154        #[unsafe(method(preferredLayoutAttributesFittingAttributes:))]
155        #[unsafe(method_family = none)]
156        pub fn preferredLayoutAttributesFittingAttributes(
157            &self,
158            layout_attributes: &UICollectionViewLayoutAttributes,
159        ) -> Retained<UICollectionViewLayoutAttributes>;
160    );
161}
162
163/// Methods declared on superclass `UIView`.
164#[cfg(all(feature = "UIResponder", feature = "UIView"))]
165impl UICollectionReusableView {
166    extern_methods!(
167        #[cfg(feature = "objc2-core-foundation")]
168        #[unsafe(method(initWithFrame:))]
169        #[unsafe(method_family = init)]
170        pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
171
172        /// # Safety
173        ///
174        /// `coder` possibly has further requirements.
175        #[unsafe(method(initWithCoder:))]
176        #[unsafe(method_family = init)]
177        pub unsafe fn initWithCoder(
178            this: Allocated<Self>,
179            coder: &NSCoder,
180        ) -> Option<Retained<Self>>;
181
182        #[unsafe(method(init))]
183        #[unsafe(method_family = init)]
184        pub fn init(this: Allocated<Self>) -> Retained<Self>;
185    );
186}
187
188/// Methods declared on superclass `NSObject`.
189#[cfg(all(feature = "UIResponder", feature = "UIView"))]
190impl UICollectionReusableView {
191    extern_methods!(
192        #[unsafe(method(new))]
193        #[unsafe(method_family = new)]
194        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
195    );
196}
197
198/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewcellconfigurationupdatehandler?language=objc)
199#[cfg(all(
200    feature = "UICellConfigurationState",
201    feature = "UIResponder",
202    feature = "UIView",
203    feature = "UIViewConfigurationState",
204    feature = "block2"
205))]
206pub type UICollectionViewCellConfigurationUpdateHandler =
207    *mut block2::DynBlock<dyn Fn(NonNull<UICollectionViewCell>, NonNull<UICellConfigurationState>)>;
208
209extern_class!(
210    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewcell?language=objc)
211    #[unsafe(super(UICollectionReusableView, UIView, UIResponder, NSObject))]
212    #[thread_kind = MainThreadOnly]
213    #[derive(Debug, PartialEq, Eq, Hash)]
214    #[cfg(all(feature = "UIResponder", feature = "UIView"))]
215    pub struct UICollectionViewCell;
216);
217
218#[cfg(all(
219    feature = "UIResponder",
220    feature = "UIView",
221    feature = "objc2-quartz-core"
222))]
223#[cfg(not(target_os = "watchos"))]
224extern_conformance!(
225    unsafe impl CALayerDelegate for UICollectionViewCell {}
226);
227
228#[cfg(all(feature = "UIResponder", feature = "UIView"))]
229extern_conformance!(
230    unsafe impl NSCoding for UICollectionViewCell {}
231);
232
233#[cfg(all(feature = "UIResponder", feature = "UIView"))]
234extern_conformance!(
235    unsafe impl NSObjectProtocol for UICollectionViewCell {}
236);
237
238#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
239extern_conformance!(
240    unsafe impl UIAppearance for UICollectionViewCell {}
241);
242
243#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
244extern_conformance!(
245    unsafe impl UIAppearanceContainer for UICollectionViewCell {}
246);
247
248#[cfg(all(feature = "UIResponder", feature = "UIView"))]
249extern_conformance!(
250    unsafe impl UICoordinateSpace for UICollectionViewCell {}
251);
252
253#[cfg(all(
254    feature = "UIDynamicBehavior",
255    feature = "UIResponder",
256    feature = "UIView"
257))]
258extern_conformance!(
259    unsafe impl UIDynamicItem for UICollectionViewCell {}
260);
261
262#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
263extern_conformance!(
264    unsafe impl UIFocusEnvironment for UICollectionViewCell {}
265);
266
267#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
268extern_conformance!(
269    unsafe impl UIFocusItem for UICollectionViewCell {}
270);
271
272#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
273extern_conformance!(
274    unsafe impl UIFocusItemContainer for UICollectionViewCell {}
275);
276
277#[cfg(all(feature = "UIResponder", feature = "UIView"))]
278extern_conformance!(
279    unsafe impl UIResponderStandardEditActions for UICollectionViewCell {}
280);
281
282#[cfg(all(
283    feature = "UIResponder",
284    feature = "UITraitCollection",
285    feature = "UIView"
286))]
287extern_conformance!(
288    unsafe impl UITraitEnvironment for UICollectionViewCell {}
289);
290
291#[cfg(all(feature = "UIResponder", feature = "UIView"))]
292impl UICollectionViewCell {
293    extern_methods!(
294        #[cfg(all(
295            feature = "UICellConfigurationState",
296            feature = "UIViewConfigurationState"
297        ))]
298        /// Returns the current configuration state for the cell.
299        /// To add your own custom state(s), override the getter and call super to obtain an instance with the
300        /// system properties set, then set your own custom states as desired.
301        #[unsafe(method(configurationState))]
302        #[unsafe(method_family = none)]
303        pub fn configurationState(&self) -> Retained<UICellConfigurationState>;
304
305        /// Requests the cell update its configuration for its current state. This method is called automatically
306        /// when the cell's `configurationState` may have changed, as well as in other circumstances where an
307        /// update may be required. Multiple requests may be coalesced into a single update at the appropriate time.
308        #[unsafe(method(setNeedsUpdateConfiguration))]
309        #[unsafe(method_family = none)]
310        pub fn setNeedsUpdateConfiguration(&self);
311
312        #[cfg(all(
313            feature = "UICellConfigurationState",
314            feature = "UIViewConfigurationState"
315        ))]
316        /// Subclasses should override this method and update the cell's configuration using the state provided.
317        /// This method should not be called directly, use `setNeedsUpdateConfiguration` to request an update.
318        #[unsafe(method(updateConfigurationUsingState:))]
319        #[unsafe(method_family = none)]
320        pub fn updateConfigurationUsingState(&self, state: &UICellConfigurationState);
321
322        #[cfg(all(
323            feature = "UICellConfigurationState",
324            feature = "UIViewConfigurationState",
325            feature = "block2"
326        ))]
327        /// Optional block-based alternative to overriding `-updateConfigurationUsingState:` in a subclass. This handler
328        /// is called after `-updateConfigurationUsingState:`. Setting a new handler triggers `setNeedsUpdateConfiguration`.
329        ///
330        /// # Safety
331        ///
332        /// - The returned block's argument 1 must be a valid pointer.
333        /// - The returned block's argument 2 must be a valid pointer.
334        #[unsafe(method(configurationUpdateHandler))]
335        #[unsafe(method_family = none)]
336        pub unsafe fn configurationUpdateHandler(
337            &self,
338        ) -> UICollectionViewCellConfigurationUpdateHandler;
339
340        #[cfg(all(
341            feature = "UICellConfigurationState",
342            feature = "UIViewConfigurationState",
343            feature = "block2"
344        ))]
345        /// Setter for [`configurationUpdateHandler`][Self::configurationUpdateHandler].
346        ///
347        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
348        ///
349        /// # Safety
350        ///
351        /// `configuration_update_handler` must be a valid pointer or null.
352        #[unsafe(method(setConfigurationUpdateHandler:))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn setConfigurationUpdateHandler(
355            &self,
356            configuration_update_handler: UICollectionViewCellConfigurationUpdateHandler,
357        );
358
359        #[cfg(feature = "UIContentConfiguration")]
360        /// Setting a content configuration replaces the existing contentView of the cell with a new content view instance from the configuration,
361        /// or directly applies the configuration to the existing content view if the configuration is compatible with the existing content view type.
362        /// The default value is nil. After a configuration has been set, setting this property to nil will replace the current content view with a new content view.
363        #[unsafe(method(contentConfiguration))]
364        #[unsafe(method_family = none)]
365        pub fn contentConfiguration(
366            &self,
367        ) -> Option<Retained<ProtocolObject<dyn UIContentConfiguration>>>;
368
369        #[cfg(feature = "UIContentConfiguration")]
370        /// Setter for [`contentConfiguration`][Self::contentConfiguration].
371        ///
372        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
373        #[unsafe(method(setContentConfiguration:))]
374        #[unsafe(method_family = none)]
375        pub fn setContentConfiguration(
376            &self,
377            content_configuration: Option<&ProtocolObject<dyn UIContentConfiguration>>,
378        );
379
380        /// When YES, the cell will automatically call -updatedConfigurationForState: on its `contentConfiguration` when the cell's
381        /// configuration state changes, and apply the updated configuration back to the cell. The default value is YES.
382        #[unsafe(method(automaticallyUpdatesContentConfiguration))]
383        #[unsafe(method_family = none)]
384        pub fn automaticallyUpdatesContentConfiguration(&self) -> bool;
385
386        /// Setter for [`automaticallyUpdatesContentConfiguration`][Self::automaticallyUpdatesContentConfiguration].
387        #[unsafe(method(setAutomaticallyUpdatesContentConfiguration:))]
388        #[unsafe(method_family = none)]
389        pub fn setAutomaticallyUpdatesContentConfiguration(
390            &self,
391            automatically_updates_content_configuration: bool,
392        );
393
394        #[unsafe(method(contentView))]
395        #[unsafe(method_family = none)]
396        pub fn contentView(&self) -> Retained<UIView>;
397
398        #[unsafe(method(isSelected))]
399        #[unsafe(method_family = none)]
400        pub fn isSelected(&self) -> bool;
401
402        /// Setter for [`isSelected`][Self::isSelected].
403        #[unsafe(method(setSelected:))]
404        #[unsafe(method_family = none)]
405        pub fn setSelected(&self, selected: bool);
406
407        #[unsafe(method(isHighlighted))]
408        #[unsafe(method_family = none)]
409        pub fn isHighlighted(&self) -> bool;
410
411        /// Setter for [`isHighlighted`][Self::isHighlighted].
412        #[unsafe(method(setHighlighted:))]
413        #[unsafe(method_family = none)]
414        pub fn setHighlighted(&self, highlighted: bool);
415
416        #[unsafe(method(dragStateDidChange:))]
417        #[unsafe(method_family = none)]
418        pub fn dragStateDidChange(&self, drag_state: UICollectionViewCellDragState);
419
420        #[cfg(feature = "UIBackgroundConfiguration")]
421        /// Returns a default background configuration for the cell's style.
422        /// This background configuration represents the default appearance that the cell will use.
423        #[unsafe(method(defaultBackgroundConfiguration))]
424        #[unsafe(method_family = none)]
425        pub fn defaultBackgroundConfiguration(&self) -> Retained<UIBackgroundConfiguration>;
426
427        #[cfg(feature = "UIBackgroundConfiguration")]
428        /// Setting a background configuration supersedes the cell's backgroundView and selectedBackgroundView. The default value is nil.
429        #[unsafe(method(backgroundConfiguration))]
430        #[unsafe(method_family = none)]
431        pub fn backgroundConfiguration(&self) -> Option<Retained<UIBackgroundConfiguration>>;
432
433        #[cfg(feature = "UIBackgroundConfiguration")]
434        /// Setter for [`backgroundConfiguration`][Self::backgroundConfiguration].
435        ///
436        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
437        #[unsafe(method(setBackgroundConfiguration:))]
438        #[unsafe(method_family = none)]
439        pub fn setBackgroundConfiguration(
440            &self,
441            background_configuration: Option<&UIBackgroundConfiguration>,
442        );
443
444        /// When YES, the cell will automatically call -updatedConfigurationForState: on its `backgroundConfiguration` when the cell's
445        /// configuration state changes, and apply the updated configuration back to the cell. The default value is YES.
446        #[unsafe(method(automaticallyUpdatesBackgroundConfiguration))]
447        #[unsafe(method_family = none)]
448        pub fn automaticallyUpdatesBackgroundConfiguration(&self) -> bool;
449
450        /// Setter for [`automaticallyUpdatesBackgroundConfiguration`][Self::automaticallyUpdatesBackgroundConfiguration].
451        #[unsafe(method(setAutomaticallyUpdatesBackgroundConfiguration:))]
452        #[unsafe(method_family = none)]
453        pub fn setAutomaticallyUpdatesBackgroundConfiguration(
454            &self,
455            automatically_updates_background_configuration: bool,
456        );
457
458        #[unsafe(method(backgroundView))]
459        #[unsafe(method_family = none)]
460        pub fn backgroundView(&self) -> Option<Retained<UIView>>;
461
462        /// Setter for [`backgroundView`][Self::backgroundView].
463        #[unsafe(method(setBackgroundView:))]
464        #[unsafe(method_family = none)]
465        pub fn setBackgroundView(&self, background_view: Option<&UIView>);
466
467        #[unsafe(method(selectedBackgroundView))]
468        #[unsafe(method_family = none)]
469        pub fn selectedBackgroundView(&self) -> Option<Retained<UIView>>;
470
471        /// Setter for [`selectedBackgroundView`][Self::selectedBackgroundView].
472        #[unsafe(method(setSelectedBackgroundView:))]
473        #[unsafe(method_family = none)]
474        pub fn setSelectedBackgroundView(&self, selected_background_view: Option<&UIView>);
475    );
476}
477
478/// Methods declared on superclass `UIView`.
479#[cfg(all(feature = "UIResponder", feature = "UIView"))]
480impl UICollectionViewCell {
481    extern_methods!(
482        #[cfg(feature = "objc2-core-foundation")]
483        #[unsafe(method(initWithFrame:))]
484        #[unsafe(method_family = init)]
485        pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
486
487        /// # Safety
488        ///
489        /// `coder` possibly has further requirements.
490        #[unsafe(method(initWithCoder:))]
491        #[unsafe(method_family = init)]
492        pub unsafe fn initWithCoder(
493            this: Allocated<Self>,
494            coder: &NSCoder,
495        ) -> Option<Retained<Self>>;
496
497        #[unsafe(method(init))]
498        #[unsafe(method_family = init)]
499        pub fn init(this: Allocated<Self>) -> Retained<Self>;
500    );
501}
502
503/// Methods declared on superclass `NSObject`.
504#[cfg(all(feature = "UIResponder", feature = "UIView"))]
505impl UICollectionViewCell {
506    extern_methods!(
507        #[unsafe(method(new))]
508        #[unsafe(method_family = new)]
509        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
510    );
511}