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