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 fn numberOfPages(&self) -> NSInteger;
216
217        /// Setter for [`numberOfPages`][Self::numberOfPages].
218        #[unsafe(method(setNumberOfPages:))]
219        #[unsafe(method_family = none)]
220        pub 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 fn currentPage(&self) -> NSInteger;
226
227        /// Setter for [`currentPage`][Self::currentPage].
228        #[unsafe(method(setCurrentPage:))]
229        #[unsafe(method_family = none)]
230        pub 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 fn hidesForSinglePage(&self) -> bool;
236
237        /// Setter for [`hidesForSinglePage`][Self::hidesForSinglePage].
238        #[unsafe(method(setHidesForSinglePage:))]
239        #[unsafe(method_family = none)]
240        pub 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 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 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 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 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 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 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 fn backgroundStyle(&self) -> UIPageControlBackgroundStyle;
285
286        /// Setter for [`backgroundStyle`][Self::backgroundStyle].
287        #[unsafe(method(setBackgroundStyle:))]
288        #[unsafe(method_family = none)]
289        pub 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 fn direction(&self) -> UIPageControlDirection;
296
297        /// Setter for [`direction`][Self::direction].
298        #[unsafe(method(setDirection:))]
299        #[unsafe(method_family = none)]
300        pub 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 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 fn allowsContinuousInteraction(&self) -> bool;
311
312        /// Setter for [`allowsContinuousInteraction`][Self::allowsContinuousInteraction].
313        #[unsafe(method(setAllowsContinuousInteraction:))]
314        #[unsafe(method_family = none)]
315        pub 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 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 fn setPreferredIndicatorImage(&self, preferred_indicator_image: Option<&UIImage>);
328
329        #[cfg(feature = "UIImage")]
330        /// Returns the override indicator image for the specific page, nil if no override image was set.
331        ///
332        /// Parameter `page`: Must be in the range of 0..numberOfPages
333        #[unsafe(method(indicatorImageForPage:))]
334        #[unsafe(method_family = none)]
335        pub fn indicatorImageForPage(&self, page: NSInteger) -> Option<Retained<UIImage>>;
336
337        #[cfg(feature = "UIImage")]
338        /// Override the indicator image for a specific page. Symbol images are recommended.
339        ///
340        /// Parameter `image`: The image for the indicator. Resets to the default if image is nil.
341        ///
342        /// Parameter `page`: Must be in the range of 0..numberOfPages
343        #[unsafe(method(setIndicatorImage:forPage:))]
344        #[unsafe(method_family = none)]
345        pub fn setIndicatorImage_forPage(&self, image: Option<&UIImage>, page: NSInteger);
346
347        #[cfg(feature = "UIImage")]
348        /// The preferred image for the current page indicator. Symbol images are recommended. Default is nil.
349        /// If this value is nil, then UIPageControl will use
350        /// `preferredPageIndicatorImage`(or its per-page variant) as
351        /// the indicator image.
352        #[unsafe(method(preferredCurrentPageIndicatorImage))]
353        #[unsafe(method_family = none)]
354        pub fn preferredCurrentPageIndicatorImage(&self) -> Option<Retained<UIImage>>;
355
356        #[cfg(feature = "UIImage")]
357        /// Setter for [`preferredCurrentPageIndicatorImage`][Self::preferredCurrentPageIndicatorImage].
358        #[unsafe(method(setPreferredCurrentPageIndicatorImage:))]
359        #[unsafe(method_family = none)]
360        pub fn setPreferredCurrentPageIndicatorImage(
361            &self,
362            preferred_current_page_indicator_image: Option<&UIImage>,
363        );
364
365        #[cfg(feature = "UIImage")]
366        /// Returns the override current page indicator image for the specific page, nil if no override image was set.
367        ///
368        /// Parameter `page`: Must be in the range of 0..numberOfPages
369        #[unsafe(method(currentPageIndicatorImageForPage:))]
370        #[unsafe(method_family = none)]
371        pub fn currentPageIndicatorImageForPage(
372            &self,
373            page: NSInteger,
374        ) -> Option<Retained<UIImage>>;
375
376        #[cfg(feature = "UIImage")]
377        /// Override the current page indicator image for a specific page. Symbol images are recommended.
378        ///
379        /// Parameter `image`: The image for the indicator. Resets to the default if image is nil.
380        ///
381        /// Parameter `page`: Must be in the range of 0..numberOfPages
382        #[unsafe(method(setCurrentPageIndicatorImage:forPage:))]
383        #[unsafe(method_family = none)]
384        pub fn setCurrentPageIndicatorImage_forPage(
385            &self,
386            image: Option<&UIImage>,
387            page: NSInteger,
388        );
389
390        #[cfg(feature = "objc2-core-foundation")]
391        /// 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.
392        #[unsafe(method(sizeForNumberOfPages:))]
393        #[unsafe(method_family = none)]
394        pub fn sizeForNumberOfPages(&self, page_count: NSInteger) -> CGSize;
395
396        /// if set, tapping to a new page won't update the currently displayed page until -updateCurrentPageDisplay is called. default is NO
397        #[deprecated = "defersCurrentPageDisplay no longer does anything reasonable with the new interaction mode."]
398        #[unsafe(method(defersCurrentPageDisplay))]
399        #[unsafe(method_family = none)]
400        pub fn defersCurrentPageDisplay(&self) -> bool;
401
402        /// Setter for [`defersCurrentPageDisplay`][Self::defersCurrentPageDisplay].
403        #[deprecated = "defersCurrentPageDisplay no longer does anything reasonable with the new interaction mode."]
404        #[unsafe(method(setDefersCurrentPageDisplay:))]
405        #[unsafe(method_family = none)]
406        pub fn setDefersCurrentPageDisplay(&self, defers_current_page_display: bool);
407
408        /// update page display to match the currentPage. ignored if defersCurrentPageDisplay is NO. setting the page value directly will update immediately
409        #[deprecated = "updateCurrentPageDisplay no longer does anything reasonable with the new interaction mode."]
410        #[unsafe(method(updateCurrentPageDisplay))]
411        #[unsafe(method_family = none)]
412        pub fn updateCurrentPageDisplay(&self);
413    );
414}
415
416/// Methods declared on superclass `UIControl`.
417#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
418impl UIPageControl {
419    extern_methods!(
420        #[cfg(feature = "objc2-core-foundation")]
421        #[unsafe(method(initWithFrame:))]
422        #[unsafe(method_family = init)]
423        pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
424
425        /// # Safety
426        ///
427        /// `coder` possibly has further requirements.
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 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 `UIView`.
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 fn init(this: Allocated<Self>) -> Retained<Self>;
458    );
459}
460
461/// Methods declared on superclass `NSObject`.
462#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
463impl UIPageControl {
464    extern_methods!(
465        #[unsafe(method(new))]
466        #[unsafe(method_family = new)]
467        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
468    );
469}