objc2_car_play/generated/
CPButton.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-ui-kit")]
10use objc2_ui_kit::*;
11
12use crate::*;
13
14extern "C" {
15    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpbuttonmaximumimagesize?language=objc)
16    #[cfg(feature = "objc2-core-foundation")]
17    pub static CPButtonMaximumImageSize: CGSize;
18}
19
20extern_class!(
21    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpbutton?language=objc)
22    #[unsafe(super(NSObject))]
23    #[derive(Debug, PartialEq, Eq, Hash)]
24    pub struct CPButton;
25);
26
27extern_conformance!(
28    unsafe impl NSObjectProtocol for CPButton {}
29);
30
31impl CPButton {
32    extern_methods!(
33        #[cfg(all(feature = "block2", feature = "objc2-ui-kit"))]
34        /// Initialize a button for the Contact, POI, or Information templates with a custom image and a handler, called when
35        /// the user taps this button.
36        ///
37        ///
38        /// Parameter `image`: An image to be displayed in this button. The maximum image size is given by
39        /// `CPButtonMaximumImageSize.`
40        /// Parameter `handler`: A block that will be called when the user taps this button.
41        ///
42        ///
43        /// Note: This class is only available in templates that support buttons with custom images, like the Contact template.
44        ///
45        ///
46        /// When providing an image, your app should provide a
47        /// `UIImage`that is display-ready. If necessary for the image, provide
48        /// light and dark styles by using an asset from your asset catalog, prepared with light and dark styles
49        /// or by using
50        /// `UIImageAsset`to combine two
51        /// `UIImage`instances into a single image with
52        /// both styles.
53        ///
54        /// UIImageAsset is used to combine multiple UIImages with different trait collections into a single UIImage.
55        #[unsafe(method(initWithImage:handler:))]
56        #[unsafe(method_family = init)]
57        pub unsafe fn initWithImage_handler(
58            this: Allocated<Self>,
59            image: &UIImage,
60            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPButton>)>>,
61        ) -> Retained<Self>;
62
63        #[cfg(feature = "objc2-ui-kit")]
64        /// An optional image, displayed only in templates that support custom images, like the Contact template.
65        ///
66        ///
67        /// When providing an image, your app should provide a
68        /// `UIImage`that is display-ready. If necessary for the image, provide
69        /// light and dark styles by using an asset from your asset catalog, prepared with light and dark styles
70        /// or by using
71        /// `UIImageAsset`to combine two
72        /// `UIImage`instances into a single image with
73        /// both styles.
74        ///
75        /// UIImageAsset is used to combine multiple UIImages with different trait collections into a single UIImage.
76        #[unsafe(method(image))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn image(&self) -> Option<Retained<UIImage>>;
79
80        /// A custom title to display for this button, displayed only in templates that allow for custom titles.
81        #[unsafe(method(title))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn title(&self) -> Option<Retained<NSString>>;
84
85        /// Setter for [`title`][Self::title].
86        ///
87        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
88        #[unsafe(method(setTitle:))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn setTitle(&self, title: Option<&NSString>);
91
92        /// A Boolean value indicating whether the button is enabled.
93        ///
94        ///
95        /// Set the value of this property to
96        /// `YES`to enable the button or
97        /// `NO`to disable it. The default value of this property is
98        /// `YES.`
99        #[unsafe(method(isEnabled))]
100        #[unsafe(method_family = none)]
101        pub unsafe fn isEnabled(&self) -> bool;
102
103        /// Setter for [`isEnabled`][Self::isEnabled].
104        #[unsafe(method(setEnabled:))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn setEnabled(&self, enabled: bool);
107
108        #[unsafe(method(new))]
109        #[unsafe(method_family = new)]
110        pub unsafe fn new() -> Retained<Self>;
111
112        #[unsafe(method(init))]
113        #[unsafe(method_family = init)]
114        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
115    );
116}