objc2_car_play/generated/
CPTextButton.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/carplay/cptextbuttonstyle?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct CPTextButtonStyle(pub NSInteger);
15impl CPTextButtonStyle {
16    /// A style that indicates a default action.
17    #[doc(alias = "CPTextButtonStyleNormal")]
18    pub const Normal: Self = Self(0);
19    /// A style that indicates the action will cancel and leave data unchanged.
20    #[doc(alias = "CPTextButtonStyleCancel")]
21    pub const Cancel: Self = Self(1);
22    /// A style that indicates the button will confirm an action.
23    #[doc(alias = "CPTextButtonStyleConfirm")]
24    pub const Confirm: Self = Self(2);
25}
26
27unsafe impl Encode for CPTextButtonStyle {
28    const ENCODING: Encoding = NSInteger::ENCODING;
29}
30
31unsafe impl RefEncode for CPTextButtonStyle {
32    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35extern_class!(
36    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cptextbutton?language=objc)
37    #[unsafe(super(NSObject))]
38    #[derive(Debug, PartialEq, Eq, Hash)]
39    pub struct CPTextButton;
40);
41
42extern_conformance!(
43    unsafe impl NSObjectProtocol for CPTextButton {}
44);
45
46impl CPTextButton {
47    extern_methods!(
48        #[cfg(feature = "block2")]
49        /// Create a button with text and a style that, when tapped, calls your custom handler.
50        ///
51        ///
52        /// Parameter `title`: A title that will appear in the button.
53        ///
54        /// Parameter `textStyle`: A style that will be applied by the system for this button.
55        ///
56        /// Parameter `handler`: A block that will be called when the user taps this button.
57        #[unsafe(method(initWithTitle:textStyle:handler:))]
58        #[unsafe(method_family = init)]
59        pub unsafe fn initWithTitle_textStyle_handler(
60            this: Allocated<Self>,
61            title: &NSString,
62            text_style: CPTextButtonStyle,
63            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPTextButton>)>>,
64        ) -> Retained<Self>;
65
66        /// A custom title to display for this button, displayed only in templates that allow for custom titles.
67        #[unsafe(method(title))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn title(&self) -> Retained<NSString>;
70
71        /// Setter for [`title`][Self::title].
72        ///
73        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
74        #[unsafe(method(setTitle:))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn setTitle(&self, title: &NSString);
77
78        /// A
79        /// `CPButtonTextStyle`value indicating the style for this button, when displayed in a template
80        /// that supports button styling, like the Information template.
81        ///
82        ///
83        /// This value defaults to
84        /// `CPTextButtonStyleNormal.`
85        #[unsafe(method(textStyle))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn textStyle(&self) -> CPTextButtonStyle;
88
89        /// Setter for [`textStyle`][Self::textStyle].
90        #[unsafe(method(setTextStyle:))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn setTextStyle(&self, text_style: CPTextButtonStyle);
93
94        #[unsafe(method(new))]
95        #[unsafe(method_family = new)]
96        pub unsafe fn new() -> Retained<Self>;
97
98        #[unsafe(method(init))]
99        #[unsafe(method_family = init)]
100        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
101    );
102}