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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
//! 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::*;
#[cfg(feature = "objc2-ui-kit")]
use objc2_ui_kit::*;
use crate::*;
/// Specifies the style used to display a
/// `CPBarButton.`
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpbarbuttonstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CPBarButtonStyle(pub NSInteger);
impl CPBarButtonStyle {
#[doc(alias = "CPBarButtonStyleNone")]
pub const None: Self = Self(0);
#[doc(alias = "CPBarButtonStyleRounded")]
pub const Rounded: Self = Self(1);
}
unsafe impl Encode for CPBarButtonStyle {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for CPBarButtonStyle {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// Specifies the type of a
/// `CPBarButton.`
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpbarbuttontype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CPBarButtonType(pub NSUInteger);
impl CPBarButtonType {
#[doc(alias = "CPBarButtonTypeText")]
pub const Text: Self = Self(0);
#[doc(alias = "CPBarButtonTypeImage")]
pub const Image: Self = Self(1);
}
unsafe impl Encode for CPBarButtonType {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for CPBarButtonType {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpbarbuttonhandler?language=objc)
#[cfg(feature = "block2")]
pub type CPBarButtonHandler = *mut block2::DynBlock<dyn Fn(NonNull<CPBarButton>)>;
extern_class!(
/// A button for placement in a navigation bar.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpbarbutton?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct CPBarButton;
);
extern_conformance!(
unsafe impl NSCoding for CPBarButton {}
);
extern_conformance!(
unsafe impl NSObjectProtocol for CPBarButton {}
);
extern_conformance!(
unsafe impl NSSecureCoding for CPBarButton {}
);
impl CPBarButton {
extern_methods!(
#[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>;
#[cfg(all(feature = "block2", feature = "objc2-ui-kit"))]
/// Convenience initializer that creates a bar button that renders with an image.
///
/// # Safety
///
/// `handler` must be a valid pointer or null.
#[unsafe(method(initWithImage:handler:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithImage_handler(
this: Allocated<Self>,
image: &UIImage,
handler: CPBarButtonHandler,
) -> Retained<Self>;
#[cfg(feature = "block2")]
/// Convenience initializer that creates a bar button that displays a text label.
///
/// # Safety
///
/// `handler` must be a valid pointer or null.
#[unsafe(method(initWithTitle:handler:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithTitle_handler(
this: Allocated<Self>,
title: &NSString,
handler: CPBarButtonHandler,
) -> Retained<Self>;
/// A Boolean value indicating whether the button is enabled.
///
///
/// Set the value of this property to
/// `YES`to enable the button or
/// `NO`to disable it. The default value of this property is
/// `YES.`
#[unsafe(method(isEnabled))]
#[unsafe(method_family = none)]
pub unsafe fn isEnabled(&self) -> bool;
/// Setter for [`isEnabled`][Self::isEnabled].
#[unsafe(method(setEnabled:))]
#[unsafe(method_family = none)]
pub unsafe fn setEnabled(&self, enabled: bool);
/// The style used to display this button.
///
/// Defaults to
/// `CPBarButtonStyleNone.`
#[unsafe(method(buttonStyle))]
#[unsafe(method_family = none)]
pub unsafe fn buttonStyle(&self) -> CPBarButtonStyle;
/// Setter for [`buttonStyle`][Self::buttonStyle].
#[unsafe(method(setButtonStyle:))]
#[unsafe(method_family = none)]
pub unsafe fn setButtonStyle(&self, button_style: CPBarButtonStyle);
#[cfg(feature = "objc2-ui-kit")]
/// The image displayed on the button.
///
///
/// Animated images are not supported. If an animated image is assigned, only the first image will be used.
///
///
/// Note: If both an image and title are specified, the title will take precedence.
/// To use an image, ensure that the button's title is nil.
#[unsafe(method(image))]
#[unsafe(method_family = none)]
pub unsafe fn image(&self) -> Option<Retained<UIImage>>;
#[cfg(feature = "objc2-ui-kit")]
/// Setter for [`image`][Self::image].
#[unsafe(method(setImage:))]
#[unsafe(method_family = none)]
pub unsafe fn setImage(&self, image: Option<&UIImage>);
/// The title displayed on the button.
///
///
/// Note: If both an image and title are specified, the title will take precedence.
/// To use an image, ensure that the button's title is nil.
#[unsafe(method(title))]
#[unsafe(method_family = none)]
pub unsafe fn title(&self) -> Option<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: Option<&NSString>);
#[cfg(feature = "block2")]
/// # Safety
///
/// `handler` must be a valid pointer or null.
#[deprecated]
#[unsafe(method(initWithType:handler:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithType_handler(
this: Allocated<Self>,
r#type: CPBarButtonType,
handler: CPBarButtonHandler,
) -> Retained<Self>;
#[deprecated]
#[unsafe(method(buttonType))]
#[unsafe(method_family = none)]
pub unsafe fn buttonType(&self) -> CPBarButtonType;
);
}