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