objc2_ui_kit/generated/
UIPageControl.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/uipagecontrolinteractionstate?language=objc)
16// NS_ENUM
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct UIPageControlInteractionState(pub NSInteger);
20impl UIPageControlInteractionState {
21    /// The default interaction state, where no interaction has occurred.
22    #[doc(alias = "UIPageControlInteractionStateNone")]
23    pub const None: Self = Self(0);
24    /// The interaction state for which the page was changed via a single, discrete interaction.
25    #[doc(alias = "UIPageControlInteractionStateDiscrete")]
26    pub const Discrete: Self = Self(1);
27    /// The interaction state for which the page was changed via a continuous interaction.
28    #[doc(alias = "UIPageControlInteractionStateContinuous")]
29    pub const Continuous: Self = Self(2);
30}
31
32unsafe impl Encode for UIPageControlInteractionState {
33    const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for UIPageControlInteractionState {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipagecontrolbackgroundstyle?language=objc)
41// NS_ENUM
42#[repr(transparent)]
43#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
44pub struct UIPageControlBackgroundStyle(pub NSInteger);
45impl UIPageControlBackgroundStyle {
46    /// The default background style that adapts based on the current interaction state.
47    #[doc(alias = "UIPageControlBackgroundStyleAutomatic")]
48    pub const Automatic: Self = Self(0);
49    /// The background style that shows a full background regardless of the interaction
50    #[doc(alias = "UIPageControlBackgroundStyleProminent")]
51    pub const Prominent: Self = Self(1);
52    /// The background style that shows a minimal background regardless of the interaction
53    #[doc(alias = "UIPageControlBackgroundStyleMinimal")]
54    pub const Minimal: Self = Self(2);
55}
56
57unsafe impl Encode for UIPageControlBackgroundStyle {
58    const ENCODING: Encoding = NSInteger::ENCODING;
59}
60
61unsafe impl RefEncode for UIPageControlBackgroundStyle {
62    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
63}
64
65/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipagecontroldirection?language=objc)
66// NS_ENUM
67#[repr(transparent)]
68#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
69pub struct UIPageControlDirection(pub NSInteger);
70impl UIPageControlDirection {
71    /// Page indicators are laid out in the natural direction of the system locale.
72    /// By default, this is equivalent to
73    /// `UIPageControlDirectionLeftToRight`on LTR locales, and
74    /// `UIPageControlDirectionRightToLeft`on RTL locales.
75    #[doc(alias = "UIPageControlDirectionNatural")]
76    pub const Natural: Self = Self(0);
77    /// Page indicators are laid out from left to right.
78    #[doc(alias = "UIPageControlDirectionLeftToRight")]
79    pub const LeftToRight: Self = Self(1);
80    /// Page indicators are laid out from right to left.
81    #[doc(alias = "UIPageControlDirectionRightToLeft")]
82    pub const RightToLeft: Self = Self(2);
83    /// Page indicators are laid out from top to bottom.
84    #[doc(alias = "UIPageControlDirectionTopToBottom")]
85    pub const TopToBottom: Self = Self(3);
86    /// Page indicators are laid out from bottom to top.
87    #[doc(alias = "UIPageControlDirectionBottomToTop")]
88    pub const BottomToTop: Self = Self(4);
89}
90
91unsafe impl Encode for UIPageControlDirection {
92    const ENCODING: Encoding = NSInteger::ENCODING;
93}
94
95unsafe impl RefEncode for UIPageControlDirection {
96    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
97}
98
99extern_class!(
100    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipagecontrol?language=objc)
101    #[unsafe(super(UIControl, UIView, UIResponder, NSObject))]
102    #[thread_kind = MainThreadOnly]
103    #[derive(Debug, PartialEq, Eq, Hash)]
104    #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
105    pub struct UIPageControl;
106);
107
108#[cfg(all(
109    feature = "UIControl",
110    feature = "UIResponder",
111    feature = "UIView",
112    feature = "objc2-quartz-core"
113))]
114#[cfg(not(target_os = "watchos"))]
115unsafe impl CALayerDelegate for UIPageControl {}
116
117#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
118unsafe impl NSCoding for UIPageControl {}
119
120#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
121unsafe impl NSObjectProtocol for UIPageControl {}
122
123#[cfg(all(
124    feature = "UIAppearance",
125    feature = "UIControl",
126    feature = "UIResponder",
127    feature = "UIView"
128))]
129unsafe impl UIAppearance for UIPageControl {}
130
131#[cfg(all(
132    feature = "UIAppearance",
133    feature = "UIControl",
134    feature = "UIResponder",
135    feature = "UIView"
136))]
137unsafe impl UIAppearanceContainer for UIPageControl {}
138
139#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
140unsafe impl UICoordinateSpace for UIPageControl {}
141
142#[cfg(all(
143    feature = "UIControl",
144    feature = "UIDynamicBehavior",
145    feature = "UIResponder",
146    feature = "UIView"
147))]
148unsafe impl UIDynamicItem for UIPageControl {}
149
150#[cfg(all(
151    feature = "UIControl",
152    feature = "UIFocus",
153    feature = "UIResponder",
154    feature = "UIView"
155))]
156unsafe impl UIFocusEnvironment for UIPageControl {}
157
158#[cfg(all(
159    feature = "UIControl",
160    feature = "UIFocus",
161    feature = "UIResponder",
162    feature = "UIView"
163))]
164unsafe impl UIFocusItem for UIPageControl {}
165
166#[cfg(all(
167    feature = "UIControl",
168    feature = "UIFocus",
169    feature = "UIResponder",
170    feature = "UIView"
171))]
172unsafe impl UIFocusItemContainer for UIPageControl {}
173
174#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
175unsafe impl UIResponderStandardEditActions for UIPageControl {}
176
177#[cfg(all(
178    feature = "UIControl",
179    feature = "UIResponder",
180    feature = "UITraitCollection",
181    feature = "UIView"
182))]
183unsafe impl UITraitEnvironment for UIPageControl {}
184
185#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
186impl UIPageControl {
187    extern_methods!(
188        /// default is 0
189        #[unsafe(method(numberOfPages))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn numberOfPages(&self) -> NSInteger;
192
193        /// Setter for [`numberOfPages`][Self::numberOfPages].
194        #[unsafe(method(setNumberOfPages:))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn setNumberOfPages(&self, number_of_pages: NSInteger);
197
198        /// default is 0. Value is pinned to 0..numberOfPages-1
199        #[unsafe(method(currentPage))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn currentPage(&self) -> NSInteger;
202
203        /// Setter for [`currentPage`][Self::currentPage].
204        #[unsafe(method(setCurrentPage:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn setCurrentPage(&self, current_page: NSInteger);
207
208        /// hides the indicator if there is only one page, default is NO
209        #[unsafe(method(hidesForSinglePage))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn hidesForSinglePage(&self) -> bool;
212
213        /// Setter for [`hidesForSinglePage`][Self::hidesForSinglePage].
214        #[unsafe(method(setHidesForSinglePage:))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn setHidesForSinglePage(&self, hides_for_single_page: bool);
217
218        #[cfg(feature = "UIPageControlProgress")]
219        /// An object that defines the progress of the page control. Default is nil.
220        #[unsafe(method(progress))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn progress(&self) -> Option<Retained<UIPageControlProgress>>;
223
224        #[cfg(feature = "UIPageControlProgress")]
225        /// Setter for [`progress`][Self::progress].
226        #[unsafe(method(setProgress:))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn setProgress(&self, progress: Option<&UIPageControlProgress>);
229
230        #[cfg(feature = "UIColor")]
231        /// The tint color for non-selected indicators. Default is nil.
232        #[unsafe(method(pageIndicatorTintColor))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn pageIndicatorTintColor(&self) -> Option<Retained<UIColor>>;
235
236        #[cfg(feature = "UIColor")]
237        /// Setter for [`pageIndicatorTintColor`][Self::pageIndicatorTintColor].
238        #[unsafe(method(setPageIndicatorTintColor:))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn setPageIndicatorTintColor(&self, page_indicator_tint_color: Option<&UIColor>);
241
242        #[cfg(feature = "UIColor")]
243        /// The tint color for the currently-selected indicators. Default is nil.
244        #[unsafe(method(currentPageIndicatorTintColor))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn currentPageIndicatorTintColor(&self) -> Option<Retained<UIColor>>;
247
248        #[cfg(feature = "UIColor")]
249        /// Setter for [`currentPageIndicatorTintColor`][Self::currentPageIndicatorTintColor].
250        #[unsafe(method(setCurrentPageIndicatorTintColor:))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn setCurrentPageIndicatorTintColor(
253            &self,
254            current_page_indicator_tint_color: Option<&UIColor>,
255        );
256
257        /// The preferred background style. Default is UIPageControlBackgroundStyleAutomatic on iOS, and UIPageControlBackgroundStyleProminent on tvOS.
258        #[unsafe(method(backgroundStyle))]
259        #[unsafe(method_family = none)]
260        pub unsafe fn backgroundStyle(&self) -> UIPageControlBackgroundStyle;
261
262        /// Setter for [`backgroundStyle`][Self::backgroundStyle].
263        #[unsafe(method(setBackgroundStyle:))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn setBackgroundStyle(&self, background_style: UIPageControlBackgroundStyle);
266
267        /// The layout direction of the page indicators. The default value is
268        /// `UIPageControlDirectionNatural.`
269        #[unsafe(method(direction))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn direction(&self) -> UIPageControlDirection;
272
273        /// Setter for [`direction`][Self::direction].
274        #[unsafe(method(setDirection:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn setDirection(&self, direction: UIPageControlDirection);
277
278        /// The current interaction state for when the current page changes. Default is UIPageControlInteractionStateNone
279        #[unsafe(method(interactionState))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn interactionState(&self) -> UIPageControlInteractionState;
282
283        /// Returns YES if continuous interaction is supported and enabled, NO otherwise. Default is YES for platforms that support it.
284        #[unsafe(method(allowsContinuousInteraction))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn allowsContinuousInteraction(&self) -> bool;
287
288        /// Setter for [`allowsContinuousInteraction`][Self::allowsContinuousInteraction].
289        #[unsafe(method(setAllowsContinuousInteraction:))]
290        #[unsafe(method_family = none)]
291        pub unsafe fn setAllowsContinuousInteraction(&self, allows_continuous_interaction: bool);
292
293        #[cfg(feature = "UIImage")]
294        /// The preferred image for indicators. Symbol images are recommended. Default is nil.
295        #[unsafe(method(preferredIndicatorImage))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn preferredIndicatorImage(&self) -> Option<Retained<UIImage>>;
298
299        #[cfg(feature = "UIImage")]
300        /// Setter for [`preferredIndicatorImage`][Self::preferredIndicatorImage].
301        #[unsafe(method(setPreferredIndicatorImage:))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn setPreferredIndicatorImage(
304            &self,
305            preferred_indicator_image: Option<&UIImage>,
306        );
307
308        #[cfg(feature = "UIImage")]
309        /// Returns the override indicator image for the specific page, nil if no override image was set.
310        ///
311        /// Parameter `page`: Must be in the range of 0..numberOfPages
312        #[unsafe(method(indicatorImageForPage:))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn indicatorImageForPage(&self, page: NSInteger) -> Option<Retained<UIImage>>;
315
316        #[cfg(feature = "UIImage")]
317        /// Override the indicator image for a specific page. Symbol images are recommended.
318        ///
319        /// Parameter `image`: The image for the indicator. Resets to the default if image is nil.
320        ///
321        /// Parameter `page`: Must be in the range of 0..numberOfPages
322        #[unsafe(method(setIndicatorImage:forPage:))]
323        #[unsafe(method_family = none)]
324        pub unsafe fn setIndicatorImage_forPage(&self, image: Option<&UIImage>, page: NSInteger);
325
326        #[cfg(feature = "UIImage")]
327        /// The preferred image for the current page indicator. Symbol images are recommended. Default is nil.
328        /// If this value is nil, then UIPageControl will use
329        /// `preferredPageIndicatorImage`(or its per-page variant) as
330        /// the indicator image.
331        #[unsafe(method(preferredCurrentPageIndicatorImage))]
332        #[unsafe(method_family = none)]
333        pub unsafe fn preferredCurrentPageIndicatorImage(&self) -> Option<Retained<UIImage>>;
334
335        #[cfg(feature = "UIImage")]
336        /// Setter for [`preferredCurrentPageIndicatorImage`][Self::preferredCurrentPageIndicatorImage].
337        #[unsafe(method(setPreferredCurrentPageIndicatorImage:))]
338        #[unsafe(method_family = none)]
339        pub unsafe fn setPreferredCurrentPageIndicatorImage(
340            &self,
341            preferred_current_page_indicator_image: Option<&UIImage>,
342        );
343
344        #[cfg(feature = "UIImage")]
345        /// Returns the override current page indicator image for the specific page, nil if no override image was set.
346        ///
347        /// Parameter `page`: Must be in the range of 0..numberOfPages
348        #[unsafe(method(currentPageIndicatorImageForPage:))]
349        #[unsafe(method_family = none)]
350        pub unsafe fn currentPageIndicatorImageForPage(
351            &self,
352            page: NSInteger,
353        ) -> Option<Retained<UIImage>>;
354
355        #[cfg(feature = "UIImage")]
356        /// Override the current page indicator image for a specific page. Symbol images are recommended.
357        ///
358        /// Parameter `image`: The image for the indicator. Resets to the default if image is nil.
359        ///
360        /// Parameter `page`: Must be in the range of 0..numberOfPages
361        #[unsafe(method(setCurrentPageIndicatorImage:forPage:))]
362        #[unsafe(method_family = none)]
363        pub unsafe fn setCurrentPageIndicatorImage_forPage(
364            &self,
365            image: Option<&UIImage>,
366            page: NSInteger,
367        );
368
369        #[cfg(feature = "objc2-core-foundation")]
370        /// Returns the minimum size required to display indicators for the given page count. Can be used to size the control if the page count could change.
371        #[unsafe(method(sizeForNumberOfPages:))]
372        #[unsafe(method_family = none)]
373        pub unsafe fn sizeForNumberOfPages(&self, page_count: NSInteger) -> CGSize;
374
375        /// if set, tapping to a new page won't update the currently displayed page until -updateCurrentPageDisplay is called. default is NO
376        #[deprecated = "defersCurrentPageDisplay no longer does anything reasonable with the new interaction mode."]
377        #[unsafe(method(defersCurrentPageDisplay))]
378        #[unsafe(method_family = none)]
379        pub unsafe fn defersCurrentPageDisplay(&self) -> bool;
380
381        /// Setter for [`defersCurrentPageDisplay`][Self::defersCurrentPageDisplay].
382        #[deprecated = "defersCurrentPageDisplay no longer does anything reasonable with the new interaction mode."]
383        #[unsafe(method(setDefersCurrentPageDisplay:))]
384        #[unsafe(method_family = none)]
385        pub unsafe fn setDefersCurrentPageDisplay(&self, defers_current_page_display: bool);
386
387        /// update page display to match the currentPage. ignored if defersCurrentPageDisplay is NO. setting the page value directly will update immediately
388        #[deprecated = "updateCurrentPageDisplay no longer does anything reasonable with the new interaction mode."]
389        #[unsafe(method(updateCurrentPageDisplay))]
390        #[unsafe(method_family = none)]
391        pub unsafe fn updateCurrentPageDisplay(&self);
392    );
393}
394
395/// Methods declared on superclass `UIControl`.
396#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
397impl UIPageControl {
398    extern_methods!(
399        #[cfg(feature = "objc2-core-foundation")]
400        #[unsafe(method(initWithFrame:))]
401        #[unsafe(method_family = init)]
402        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
403
404        #[unsafe(method(initWithCoder:))]
405        #[unsafe(method_family = init)]
406        pub unsafe fn initWithCoder(
407            this: Allocated<Self>,
408            coder: &NSCoder,
409        ) -> Option<Retained<Self>>;
410
411        #[cfg(all(
412            feature = "UIAction",
413            feature = "UIMenuElement",
414            feature = "objc2-core-foundation"
415        ))]
416        /// Initializes the control and adds primaryAction for the UIControlEventPrimaryActionTriggered control event. Subclasses of UIControl may alter or add behaviors around the usage of primaryAction, see subclass documentation of this initializer for additional information.
417        #[unsafe(method(initWithFrame:primaryAction:))]
418        #[unsafe(method_family = init)]
419        pub unsafe fn initWithFrame_primaryAction(
420            this: Allocated<Self>,
421            frame: CGRect,
422            primary_action: Option<&UIAction>,
423        ) -> Retained<Self>;
424    );
425}
426
427/// Methods declared on superclass `NSObject`.
428#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
429impl UIPageControl {
430    extern_methods!(
431        #[unsafe(method(init))]
432        #[unsafe(method_family = init)]
433        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
434
435        #[unsafe(method(new))]
436        #[unsafe(method_family = new)]
437        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
438    );
439}