1use 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
15extern_class!(
16 #[unsafe(super(UIView, UIResponder, NSObject))]
18 #[thread_kind = MainThreadOnly]
19 #[derive(Debug, PartialEq, Eq, Hash)]
20 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
21 pub struct UIPickerView;
22);
23
24#[cfg(all(
25 feature = "UIResponder",
26 feature = "UIView",
27 feature = "objc2-quartz-core"
28))]
29#[cfg(not(target_os = "watchos"))]
30extern_conformance!(
31 unsafe impl CALayerDelegate for UIPickerView {}
32);
33
34#[cfg(all(feature = "UIResponder", feature = "UIView"))]
35extern_conformance!(
36 unsafe impl NSCoding for UIPickerView {}
37);
38
39#[cfg(all(feature = "UIResponder", feature = "UIView"))]
40extern_conformance!(
41 unsafe impl NSObjectProtocol for UIPickerView {}
42);
43
44#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
45extern_conformance!(
46 unsafe impl UIAppearance for UIPickerView {}
47);
48
49#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
50extern_conformance!(
51 unsafe impl UIAppearanceContainer for UIPickerView {}
52);
53
54#[cfg(all(feature = "UIResponder", feature = "UIView"))]
55extern_conformance!(
56 unsafe impl UICoordinateSpace for UIPickerView {}
57);
58
59#[cfg(all(
60 feature = "UIDynamicBehavior",
61 feature = "UIResponder",
62 feature = "UIView"
63))]
64extern_conformance!(
65 unsafe impl UIDynamicItem for UIPickerView {}
66);
67
68#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
69extern_conformance!(
70 unsafe impl UIFocusEnvironment for UIPickerView {}
71);
72
73#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
74extern_conformance!(
75 unsafe impl UIFocusItem for UIPickerView {}
76);
77
78#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
79extern_conformance!(
80 unsafe impl UIFocusItemContainer for UIPickerView {}
81);
82
83#[cfg(all(feature = "UIResponder", feature = "UIView"))]
84extern_conformance!(
85 unsafe impl UIResponderStandardEditActions for UIPickerView {}
86);
87
88#[cfg(all(
89 feature = "UIResponder",
90 feature = "UITraitCollection",
91 feature = "UIView"
92))]
93extern_conformance!(
94 unsafe impl UITraitEnvironment for UIPickerView {}
95);
96
97#[cfg(all(feature = "UIResponder", feature = "UIView"))]
98impl UIPickerView {
99 extern_methods!(
100 #[unsafe(method(dataSource))]
101 #[unsafe(method_family = none)]
102 pub unsafe fn dataSource(
103 &self,
104 ) -> Option<Retained<ProtocolObject<dyn UIPickerViewDataSource>>>;
105
106 #[unsafe(method(setDataSource:))]
109 #[unsafe(method_family = none)]
110 pub unsafe fn setDataSource(
111 &self,
112 data_source: Option<&ProtocolObject<dyn UIPickerViewDataSource>>,
113 );
114
115 #[unsafe(method(delegate))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn delegate(&self)
118 -> Option<Retained<ProtocolObject<dyn UIPickerViewDelegate>>>;
119
120 #[unsafe(method(setDelegate:))]
123 #[unsafe(method_family = none)]
124 pub unsafe fn setDelegate(
125 &self,
126 delegate: Option<&ProtocolObject<dyn UIPickerViewDelegate>>,
127 );
128
129 #[deprecated = "This property has no effect on iOS 7 and later."]
130 #[unsafe(method(showsSelectionIndicator))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn showsSelectionIndicator(&self) -> bool;
133
134 #[deprecated = "This property has no effect on iOS 7 and later."]
136 #[unsafe(method(setShowsSelectionIndicator:))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn setShowsSelectionIndicator(&self, shows_selection_indicator: bool);
139
140 #[unsafe(method(numberOfComponents))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn numberOfComponents(&self) -> NSInteger;
143
144 #[unsafe(method(numberOfRowsInComponent:))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn numberOfRowsInComponent(&self, component: NSInteger) -> NSInteger;
147
148 #[cfg(feature = "objc2-core-foundation")]
149 #[unsafe(method(rowSizeForComponent:))]
150 #[unsafe(method_family = none)]
151 pub unsafe fn rowSizeForComponent(&self, component: NSInteger) -> CGSize;
152
153 #[unsafe(method(viewForRow:forComponent:))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn viewForRow_forComponent(
156 &self,
157 row: NSInteger,
158 component: NSInteger,
159 ) -> Option<Retained<UIView>>;
160
161 #[unsafe(method(reloadAllComponents))]
162 #[unsafe(method_family = none)]
163 pub unsafe fn reloadAllComponents(&self);
164
165 #[unsafe(method(reloadComponent:))]
166 #[unsafe(method_family = none)]
167 pub unsafe fn reloadComponent(&self, component: NSInteger);
168
169 #[unsafe(method(selectRow:inComponent:animated:))]
170 #[unsafe(method_family = none)]
171 pub unsafe fn selectRow_inComponent_animated(
172 &self,
173 row: NSInteger,
174 component: NSInteger,
175 animated: bool,
176 );
177
178 #[unsafe(method(selectedRowInComponent:))]
179 #[unsafe(method_family = none)]
180 pub unsafe fn selectedRowInComponent(&self, component: NSInteger) -> NSInteger;
181 );
182}
183
184#[cfg(all(feature = "UIResponder", feature = "UIView"))]
186impl UIPickerView {
187 extern_methods!(
188 #[cfg(feature = "objc2-core-foundation")]
189 #[unsafe(method(initWithFrame:))]
190 #[unsafe(method_family = init)]
191 pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
192
193 #[unsafe(method(initWithCoder:))]
194 #[unsafe(method_family = init)]
195 pub unsafe fn initWithCoder(
196 this: Allocated<Self>,
197 coder: &NSCoder,
198 ) -> Option<Retained<Self>>;
199 );
200}
201
202#[cfg(all(feature = "UIResponder", feature = "UIView"))]
204impl UIPickerView {
205 extern_methods!(
206 #[unsafe(method(init))]
207 #[unsafe(method_family = init)]
208 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
209
210 #[unsafe(method(new))]
211 #[unsafe(method_family = new)]
212 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
213 );
214}
215
216extern_protocol!(
217 pub unsafe trait UIPickerViewDataSource: NSObjectProtocol + MainThreadOnly {
219 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
220 #[unsafe(method(numberOfComponentsInPickerView:))]
221 #[unsafe(method_family = none)]
222 unsafe fn numberOfComponentsInPickerView(&self, picker_view: &UIPickerView) -> NSInteger;
223
224 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
225 #[unsafe(method(pickerView:numberOfRowsInComponent:))]
226 #[unsafe(method_family = none)]
227 unsafe fn pickerView_numberOfRowsInComponent(
228 &self,
229 picker_view: &UIPickerView,
230 component: NSInteger,
231 ) -> NSInteger;
232 }
233);
234
235extern_protocol!(
236 pub unsafe trait UIPickerViewDelegate: NSObjectProtocol + MainThreadOnly {
238 #[cfg(all(
239 feature = "UIResponder",
240 feature = "UIView",
241 feature = "objc2-core-foundation"
242 ))]
243 #[optional]
244 #[unsafe(method(pickerView:widthForComponent:))]
245 #[unsafe(method_family = none)]
246 unsafe fn pickerView_widthForComponent(
247 &self,
248 picker_view: &UIPickerView,
249 component: NSInteger,
250 ) -> CGFloat;
251
252 #[cfg(all(
253 feature = "UIResponder",
254 feature = "UIView",
255 feature = "objc2-core-foundation"
256 ))]
257 #[optional]
258 #[unsafe(method(pickerView:rowHeightForComponent:))]
259 #[unsafe(method_family = none)]
260 unsafe fn pickerView_rowHeightForComponent(
261 &self,
262 picker_view: &UIPickerView,
263 component: NSInteger,
264 ) -> CGFloat;
265
266 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
267 #[optional]
268 #[unsafe(method(pickerView:titleForRow:forComponent:))]
269 #[unsafe(method_family = none)]
270 unsafe fn pickerView_titleForRow_forComponent(
271 &self,
272 picker_view: &UIPickerView,
273 row: NSInteger,
274 component: NSInteger,
275 ) -> Option<Retained<NSString>>;
276
277 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
278 #[optional]
279 #[unsafe(method(pickerView:attributedTitleForRow:forComponent:))]
280 #[unsafe(method_family = none)]
281 unsafe fn pickerView_attributedTitleForRow_forComponent(
282 &self,
283 picker_view: &UIPickerView,
284 row: NSInteger,
285 component: NSInteger,
286 ) -> Option<Retained<NSAttributedString>>;
287
288 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
289 #[optional]
290 #[unsafe(method(pickerView:viewForRow:forComponent:reusingView:))]
291 #[unsafe(method_family = none)]
292 unsafe fn pickerView_viewForRow_forComponent_reusingView(
293 &self,
294 picker_view: &UIPickerView,
295 row: NSInteger,
296 component: NSInteger,
297 view: Option<&UIView>,
298 ) -> Retained<UIView>;
299
300 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
301 #[optional]
302 #[unsafe(method(pickerView:didSelectRow:inComponent:))]
303 #[unsafe(method_family = none)]
304 unsafe fn pickerView_didSelectRow_inComponent(
305 &self,
306 picker_view: &UIPickerView,
307 row: NSInteger,
308 component: NSInteger,
309 );
310 }
311);