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"))]
115extern_conformance!(
116    unsafe impl CALayerDelegate for UIPageControl {}
117);
118
119#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
120extern_conformance!(
121    unsafe impl NSCoding for UIPageControl {}
122);
123
124#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
125extern_conformance!(
126    unsafe impl NSObjectProtocol for UIPageControl {}
127);
128
129#[cfg(all(
130    feature = "UIAppearance",
131    feature = "UIControl",
132    feature = "UIResponder",
133    feature = "UIView"
134))]
135extern_conformance!(
136    unsafe impl UIAppearance for UIPageControl {}
137);
138
139#[cfg(all(
140    feature = "UIAppearance",
141    feature = "UIControl",
142    feature = "UIResponder",
143    feature = "UIView"
144))]
145extern_conformance!(
146    unsafe impl UIAppearanceContainer for UIPageControl {}
147);
148
149#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
150extern_conformance!(
151    unsafe impl UICoordinateSpace for UIPageControl {}
152);
153
154#[cfg(all(
155    feature = "UIControl",
156    feature = "UIDynamicBehavior",
157    feature = "UIResponder",
158    feature = "UIView"
159))]
160extern_conformance!(
161    unsafe impl UIDynamicItem for UIPageControl {}
162);
163
164#[cfg(all(
165    feature = "UIControl",
166    feature = "UIFocus",
167    feature = "UIResponder",
168    feature = "UIView"
169))]
170extern_conformance!(
171    unsafe impl UIFocusEnvironment for UIPageControl {}
172);
173
174#[cfg(all(
175    feature = "UIControl",
176    feature = "UIFocus",
177    feature = "UIResponder",
178    feature = "UIView"
179))]
180extern_conformance!(
181    unsafe impl UIFocusItem for UIPageControl {}
182);
183
184#[cfg(all(
185    feature = "UIControl",
186    feature = "UIFocus",
187    feature = "UIResponder",
188    feature = "UIView"
189))]
190extern_conformance!(
191    unsafe impl UIFocusItemContainer for UIPageControl {}
192);
193
194#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
195extern_conformance!(
196    unsafe impl UIResponderStandardEditActions for UIPageControl {}
197);
198
199#[cfg(all(
200    feature = "UIControl",
201    feature = "UIResponder",
202    feature = "UITraitCollection",
203    feature = "UIView"
204))]
205extern_conformance!(
206    unsafe impl UITraitEnvironment for UIPageControl {}
207);
208
209#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
210impl UIPageControl {
211    extern_methods!(
212        /// default is 0
213        #[unsafe(method(numberOfPages))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn numberOfPages(&self) -> NSInteger;
216
217        /// Setter for [`numberOfPages`][Self::numberOfPages].
218        #[unsafe(method(setNumberOfPages:))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn setNumberOfPages(&self, number_of_pages: NSInteger);
221
222        /// default is 0. Value is pinned to 0..numberOfPages-1
223        #[unsafe(method(currentPage))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn currentPage(&self) -> NSInteger;
226
227        /// Setter for [`currentPage`][Self::currentPage].
228        #[unsafe(method(setCurrentPage:))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn setCurrentPage(&self, current_page: NSInteger);
231
232        /// hides the indicator if there is only one page, default is NO
233        #[unsafe(method(hidesForSinglePage))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn hidesForSinglePage(&self) -> bool;
236
237        /// Setter for [`hidesForSinglePage`][Self::hidesForSinglePage].
238        #[unsafe(method(setHidesForSinglePage:))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn setHidesForSinglePage(&self, hides_for_single_page: bool);
241
242        #[cfg(feature = "UIPageControlProgress")]
243        /// An object that defines the progress of the page control. Default is nil.
244        #[unsafe(method(progress))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn progress(&self) -> Option<Retained<UIPageControlProgress>>;
247
248        #[cfg(feature = "UIPageControlProgress")]
249        /// Setter for [`progress`][Self::progress].
250        #[unsafe(method(setProgress:))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn setProgress(&self, progress: Option<&UIPageControlProgress>);
253
254        #[cfg(feature = "UIColor")]
255        /// The tint color for non-selected indicators. Default is nil.
256        #[unsafe(method(pageIndicatorTintColor))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn pageIndicatorTintColor(&self) -> Option<Retained<UIColor>>;
259
260        #[cfg(feature = "UIColor")]
261        /// Setter for [`pageIndicatorTintColor`][Self::pageIndicatorTintColor].
262        #[unsafe(method(setPageIndicatorTintColor:))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn setPageIndicatorTintColor(&self, page_indicator_tint_color: Option<&UIColor>);
265
266        #[cfg(feature = "UIColor")]
267        /// The tint color for the currently-selected indicators. Default is nil.
268        #[unsafe(method(currentPageIndicatorTintColor))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn currentPageIndicatorTintColor(&self) -> Option<Retained<UIColor>>;
271
272        #[cfg(feature = "UIColor")]
273        /// Setter for [`currentPageIndicatorTintColor`][Self::currentPageIndicatorTintColor].
274        #[unsafe(method(setCurrentPageIndicatorTintColor:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn setCurrentPageIndicatorTintColor(
277            &self,
278            current_page_indicator_tint_color: Option<&UIColor>,
279        );
280
281        /// The preferred background style. Default is UIPageControlBackgroundStyleAutomatic on iOS, and UIPageControlBackgroundStyleProminent on tvOS.
282        #[unsafe(method(backgroundStyle))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn backgroundStyle(&self) -> UIPageControlBackgroundStyle;
285
286        /// Setter for [`backgroundStyle`][Self::backgroundStyle].
287        #[unsafe(method(setBackgroundStyle:))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn setBackgroundStyle(&self, background_style: UIPageControlBackgroundStyle);
290
291        /// The layout direction of the page indicators. The default value is
292        /// `UIPageControlDirectionNatural.`
293        #[unsafe(method(direction))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn direction(&self) -> UIPageControlDirection;
296
297        /// Setter for [`direction`][Self::direction].
298        #[unsafe(method(setDirection:))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn setDirection(&self, direction: UIPageControlDirection);
301
302        /// The current interaction state for when the current page changes. Default is UIPageControlInteractionStateNone
303        #[unsafe(method(interactionState))]
304        #[unsafe(method_family = none)]
305        pub unsafe fn interactionState(&self) -> UIPageControlInteractionState;
306
307        /// Returns YES if continuous interaction is supported and enabled, NO otherwise. Default is YES for platforms that support it.
308        #[unsafe(method(allowsContinuousInteraction))]
309        #[unsafe(method_family = none)]
310        pub unsafe fn allowsContinuousInteraction(&self) -> bool;
311
312        /// Setter for [`allowsContinuousInteraction`][Self::allowsContinuousInteraction].
313        #[unsafe(method(setAllowsContinuousInteraction:))]
314        #[unsafe(method_family = none)]
315        pub unsafe fn setAllowsContinuousInteraction(&self, allows_continuous_interaction: bool);
316
317        #[cfg(feature = "UIImage")]
318        /// The preferred image for indicators. Symbol images are recommended. Default is nil.
319        #[unsafe(method(preferredIndicatorImage))]
320        #[unsafe(method_family = none)]
321        pub unsafe fn preferredIndicatorImage(&self) -> Option<Retained<UIImage>>;
322
323        #[cfg(feature = "UIImage")]
324        /// Setter for [`preferredIndicatorImage`][Self::preferredIndicatorImage].
325        #[unsafe(method(setPreferredIndicatorImage:))]
326        #[unsafe(method_family = none)]
327        pub unsafe fn setPreferredIndicatorImage(
328            &self,
329            preferred_indicator_image: Option<&UIImage>,
330        );
331
332        #[cfg(feature = "UIImage")]
333        /// Returns the override indicator image for the specific page, nil if no override image was set.
334        ///
335        /// Parameter `page`: Must be in the range of 0..numberOfPages
336        #[unsafe(method(indicatorImageForPage:))]
337        #[unsafe(method_family = none)]
338        pub unsafe fn indicatorImageForPage(&self, page: NSInteger) -> Option<Retained<UIImage>>;
339
340        #[cfg(feature = "UIImage")]
341        /// Override the indicator image for a specific page. Symbol images are recommended.
342        ///
343        /// Parameter `image`: The image for the indicator. Resets to the default if image is nil.
344        ///
345        /// Parameter `page`: Must be in the range of 0..numberOfPages
346        #[unsafe(method(setIndicatorImage:forPage:))]
347        #[unsafe(method_family = none)]
348        pub unsafe fn setIndicatorImage_forPage(&self, image: Option<&UIImage>, page: NSInteger);
349
350        #[cfg(feature = "UIImage")]
351        /// The preferred image for the current page indicator. Symbol images are recommended. Default is nil.
352        /// If this value is nil, then UIPageControl will use
353        /// `preferredPageIndicatorImage`(or its per-page variant) as
354        /// the indicator image.
355        #[unsafe(method(preferredCurrentPageIndicatorImage))]
356        #[unsafe(method_family = none)]
357        pub unsafe fn preferredCurrentPageIndicatorImage(&self) -> Option<Retained<UIImage>>;
358
359        #[cfg(feature = "UIImage")]
360        /// Setter for [`preferredCurrentPageIndicatorImage`][Self::preferredCurrentPageIndicatorImage].
361        #[unsafe(method(setPreferredCurrentPageIndicatorImage:))]
362        #[unsafe(method_family = none)]
363        pub unsafe fn setPreferredCurrentPageIndicatorImage(
364            &self,
365            preferred_current_page_indicator_image: Option<&UIImage>,
366        );
367
368        #[cfg(feature = "UIImage")]
369        /// Returns the override current page indicator image for the specific page, nil if no override image was set.
370        ///
371        /// Parameter `page`: Must be in the range of 0..numberOfPages
372        #[unsafe(method(currentPageIndicatorImageForPage:))]
373        #[unsafe(method_family = none)]
374        pub unsafe fn currentPageIndicatorImageForPage(
375            &self,
376            page: NSInteger,
377        ) -> Option<Retained<UIImage>>;
378
379        #[cfg(feature = "UIImage")]
380        /// Override the current page indicator image for a specific page. Symbol images are recommended.
381        ///
382        /// Parameter `image`: The image for the indicator. Resets to the default if image is nil.
383        ///
384        /// Parameter `page`: Must be in the range of 0..numberOfPages
385        #[unsafe(method(setCurrentPageIndicatorImage:forPage:))]
386        #[unsafe(method_family = none)]
387        pub unsafe fn setCurrentPageIndicatorImage_forPage(
388            &self,
389            image: Option<&UIImage>,
390            page: NSInteger,
391        );
392
393        #[cfg(feature = "objc2-core-foundation")]
394        /// 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.
395        #[unsafe(method(sizeForNumberOfPages:))]
396        #[unsafe(method_family = none)]
397        pub unsafe fn sizeForNumberOfPages(&self, page_count: NSInteger) -> CGSize;
398
399        /// if set, tapping to a new page won't update the currently displayed page until -updateCurrentPageDisplay is called. default is NO
400        #[deprecated = "defersCurrentPageDisplay no longer does anything reasonable with the new interaction mode."]
401        #[unsafe(method(defersCurrentPageDisplay))]
402        #[unsafe(method_family = none)]
403        pub unsafe fn defersCurrentPageDisplay(&self) -> bool;
404
405        /// Setter for [`defersCurrentPageDisplay`][Self::defersCurrentPageDisplay].
406        #[deprecated = "defersCurrentPageDisplay no longer does anything reasonable with the new interaction mode."]
407        #[unsafe(method(setDefersCurrentPageDisplay:))]
408        #[unsafe(method_family = none)]
409        pub unsafe fn setDefersCurrentPageDisplay(&self, defers_current_page_display: bool);
410
411        /// update page display to match the currentPage. ignored if defersCurrentPageDisplay is NO. setting the page value directly will update immediately
412        #[deprecated = "updateCurrentPageDisplay no longer does anything reasonable with the new interaction mode."]
413        #[unsafe(method(updateCurrentPageDisplay))]
414        #[unsafe(method_family = none)]
415        pub unsafe fn updateCurrentPageDisplay(&self);
416    );
417}
418
419/// Methods declared on superclass `UIControl`.
420#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
421impl UIPageControl {
422    extern_methods!(
423        #[cfg(feature = "objc2-core-foundation")]
424        #[unsafe(method(initWithFrame:))]
425        #[unsafe(method_family = init)]
426        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
427
428        #[unsafe(method(initWithCoder:))]
429        #[unsafe(method_family = init)]
430        pub unsafe fn initWithCoder(
431            this: Allocated<Self>,
432            coder: &NSCoder,
433        ) -> Option<Retained<Self>>;
434
435        #[cfg(all(
436            feature = "UIAction",
437            feature = "UIMenuElement",
438            feature = "objc2-core-foundation"
439        ))]
440        /// 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.
441        #[unsafe(method(initWithFrame:primaryAction:))]
442        #[unsafe(method_family = init)]
443        pub unsafe fn initWithFrame_primaryAction(
444            this: Allocated<Self>,
445            frame: CGRect,
446            primary_action: Option<&UIAction>,
447        ) -> Retained<Self>;
448    );
449}
450
451/// Methods declared on superclass `NSObject`.
452#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
453impl UIPageControl {
454    extern_methods!(
455        #[unsafe(method(init))]
456        #[unsafe(method_family = init)]
457        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
458
459        #[unsafe(method(new))]
460        #[unsafe(method_family = new)]
461        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
462    );
463}