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
10use crate::*;
11
12extern "C" {
13 pub static NSComboBoxWillPopUpNotification: &'static NSNotificationName;
15}
16
17extern "C" {
18 pub static NSComboBoxWillDismissNotification: &'static NSNotificationName;
20}
21
22extern "C" {
23 pub static NSComboBoxSelectionDidChangeNotification: &'static NSNotificationName;
25}
26
27extern "C" {
28 pub static NSComboBoxSelectionIsChangingNotification: &'static NSNotificationName;
30}
31
32extern_protocol!(
33 pub unsafe trait NSComboBoxDataSource: NSObjectProtocol + MainThreadOnly {
35 #[cfg(all(
36 feature = "NSControl",
37 feature = "NSResponder",
38 feature = "NSTextField",
39 feature = "NSView"
40 ))]
41 #[optional]
42 #[unsafe(method(numberOfItemsInComboBox:))]
43 #[unsafe(method_family = none)]
44 fn numberOfItemsInComboBox(&self, combo_box: &NSComboBox) -> NSInteger;
45
46 #[cfg(all(
47 feature = "NSControl",
48 feature = "NSResponder",
49 feature = "NSTextField",
50 feature = "NSView"
51 ))]
52 #[optional]
53 #[unsafe(method(comboBox:objectValueForItemAtIndex:))]
54 #[unsafe(method_family = none)]
55 fn comboBox_objectValueForItemAtIndex(
56 &self,
57 combo_box: &NSComboBox,
58 index: NSInteger,
59 ) -> Option<Retained<AnyObject>>;
60
61 #[cfg(all(
62 feature = "NSControl",
63 feature = "NSResponder",
64 feature = "NSTextField",
65 feature = "NSView"
66 ))]
67 #[optional]
68 #[unsafe(method(comboBox:indexOfItemWithStringValue:))]
69 #[unsafe(method_family = none)]
70 fn comboBox_indexOfItemWithStringValue(
71 &self,
72 combo_box: &NSComboBox,
73 string: &NSString,
74 ) -> NSUInteger;
75
76 #[cfg(all(
77 feature = "NSControl",
78 feature = "NSResponder",
79 feature = "NSTextField",
80 feature = "NSView"
81 ))]
82 #[optional]
83 #[unsafe(method(comboBox:completedString:))]
84 #[unsafe(method_family = none)]
85 fn comboBox_completedString(
86 &self,
87 combo_box: &NSComboBox,
88 string: &NSString,
89 ) -> Option<Retained<NSString>>;
90 }
91);
92
93extern_protocol!(
94 #[cfg(all(feature = "NSControl", feature = "NSTextField"))]
96 pub unsafe trait NSComboBoxDelegate: NSTextFieldDelegate + MainThreadOnly {
97 #[optional]
98 #[unsafe(method(comboBoxWillPopUp:))]
99 #[unsafe(method_family = none)]
100 fn comboBoxWillPopUp(&self, notification: &NSNotification);
101
102 #[optional]
103 #[unsafe(method(comboBoxWillDismiss:))]
104 #[unsafe(method_family = none)]
105 fn comboBoxWillDismiss(&self, notification: &NSNotification);
106
107 #[optional]
108 #[unsafe(method(comboBoxSelectionDidChange:))]
109 #[unsafe(method_family = none)]
110 fn comboBoxSelectionDidChange(&self, notification: &NSNotification);
111
112 #[optional]
113 #[unsafe(method(comboBoxSelectionIsChanging:))]
114 #[unsafe(method_family = none)]
115 fn comboBoxSelectionIsChanging(&self, notification: &NSNotification);
116 }
117);
118
119extern_class!(
120 #[unsafe(super(NSTextField, NSControl, NSView, NSResponder, NSObject))]
122 #[derive(Debug, PartialEq, Eq, Hash)]
123 #[cfg(all(
124 feature = "NSControl",
125 feature = "NSResponder",
126 feature = "NSTextField",
127 feature = "NSView"
128 ))]
129 pub struct NSComboBox;
130);
131
132#[cfg(all(
133 feature = "NSAccessibilityProtocols",
134 feature = "NSControl",
135 feature = "NSResponder",
136 feature = "NSTextField",
137 feature = "NSView"
138))]
139extern_conformance!(
140 unsafe impl NSAccessibility for NSComboBox {}
141);
142
143#[cfg(all(
144 feature = "NSAccessibilityProtocols",
145 feature = "NSControl",
146 feature = "NSResponder",
147 feature = "NSTextField",
148 feature = "NSView"
149))]
150extern_conformance!(
151 unsafe impl NSAccessibilityElementProtocol for NSComboBox {}
152);
153
154#[cfg(all(
155 feature = "NSAccessibilityProtocols",
156 feature = "NSControl",
157 feature = "NSResponder",
158 feature = "NSTextField",
159 feature = "NSView"
160))]
161extern_conformance!(
162 unsafe impl NSAccessibilityNavigableStaticText for NSComboBox {}
163);
164
165#[cfg(all(
166 feature = "NSAccessibilityProtocols",
167 feature = "NSControl",
168 feature = "NSResponder",
169 feature = "NSTextField",
170 feature = "NSView"
171))]
172extern_conformance!(
173 unsafe impl NSAccessibilityStaticText for NSComboBox {}
174);
175
176#[cfg(all(
177 feature = "NSAnimation",
178 feature = "NSControl",
179 feature = "NSResponder",
180 feature = "NSTextField",
181 feature = "NSView"
182))]
183extern_conformance!(
184 unsafe impl NSAnimatablePropertyContainer for NSComboBox {}
185);
186
187#[cfg(all(
188 feature = "NSAppearance",
189 feature = "NSControl",
190 feature = "NSResponder",
191 feature = "NSTextField",
192 feature = "NSView"
193))]
194extern_conformance!(
195 unsafe impl NSAppearanceCustomization for NSComboBox {}
196);
197
198#[cfg(all(
199 feature = "NSControl",
200 feature = "NSResponder",
201 feature = "NSTextField",
202 feature = "NSView"
203))]
204extern_conformance!(
205 unsafe impl NSCoding for NSComboBox {}
206);
207
208#[cfg(all(
209 feature = "NSControl",
210 feature = "NSDragging",
211 feature = "NSResponder",
212 feature = "NSTextField",
213 feature = "NSView"
214))]
215extern_conformance!(
216 unsafe impl NSDraggingDestination for NSComboBox {}
217);
218
219#[cfg(all(
220 feature = "NSControl",
221 feature = "NSResponder",
222 feature = "NSTextField",
223 feature = "NSView"
224))]
225extern_conformance!(
226 unsafe impl NSObjectProtocol for NSComboBox {}
227);
228
229#[cfg(all(
230 feature = "NSControl",
231 feature = "NSResponder",
232 feature = "NSTextContent",
233 feature = "NSTextField",
234 feature = "NSView"
235))]
236extern_conformance!(
237 unsafe impl NSTextContent for NSComboBox {}
238);
239
240#[cfg(all(
241 feature = "NSControl",
242 feature = "NSResponder",
243 feature = "NSTextField",
244 feature = "NSUserInterfaceItemIdentification",
245 feature = "NSView"
246))]
247extern_conformance!(
248 unsafe impl NSUserInterfaceItemIdentification for NSComboBox {}
249);
250
251#[cfg(all(
252 feature = "NSControl",
253 feature = "NSResponder",
254 feature = "NSTextField",
255 feature = "NSUserInterfaceValidation",
256 feature = "NSView"
257))]
258extern_conformance!(
259 unsafe impl NSUserInterfaceValidations for NSComboBox {}
260);
261
262#[cfg(all(
263 feature = "NSControl",
264 feature = "NSResponder",
265 feature = "NSTextField",
266 feature = "NSView"
267))]
268impl NSComboBox {
269 extern_methods!(
270 #[unsafe(method(hasVerticalScroller))]
271 #[unsafe(method_family = none)]
272 pub fn hasVerticalScroller(&self) -> bool;
273
274 #[unsafe(method(setHasVerticalScroller:))]
276 #[unsafe(method_family = none)]
277 pub fn setHasVerticalScroller(&self, has_vertical_scroller: bool);
278
279 #[unsafe(method(intercellSpacing))]
280 #[unsafe(method_family = none)]
281 pub fn intercellSpacing(&self) -> NSSize;
282
283 #[unsafe(method(setIntercellSpacing:))]
285 #[unsafe(method_family = none)]
286 pub fn setIntercellSpacing(&self, intercell_spacing: NSSize);
287
288 #[cfg(feature = "objc2-core-foundation")]
289 #[unsafe(method(itemHeight))]
290 #[unsafe(method_family = none)]
291 pub fn itemHeight(&self) -> CGFloat;
292
293 #[cfg(feature = "objc2-core-foundation")]
294 #[unsafe(method(setItemHeight:))]
296 #[unsafe(method_family = none)]
297 pub fn setItemHeight(&self, item_height: CGFloat);
298
299 #[unsafe(method(numberOfVisibleItems))]
300 #[unsafe(method_family = none)]
301 pub fn numberOfVisibleItems(&self) -> NSInteger;
302
303 #[unsafe(method(setNumberOfVisibleItems:))]
305 #[unsafe(method_family = none)]
306 pub fn setNumberOfVisibleItems(&self, number_of_visible_items: NSInteger);
307
308 #[unsafe(method(isButtonBordered))]
309 #[unsafe(method_family = none)]
310 pub fn isButtonBordered(&self) -> bool;
311
312 #[unsafe(method(setButtonBordered:))]
314 #[unsafe(method_family = none)]
315 pub fn setButtonBordered(&self, button_bordered: bool);
316
317 #[unsafe(method(reloadData))]
318 #[unsafe(method_family = none)]
319 pub fn reloadData(&self);
320
321 #[unsafe(method(noteNumberOfItemsChanged))]
322 #[unsafe(method_family = none)]
323 pub fn noteNumberOfItemsChanged(&self);
324
325 #[unsafe(method(usesDataSource))]
326 #[unsafe(method_family = none)]
327 pub fn usesDataSource(&self) -> bool;
328
329 #[unsafe(method(setUsesDataSource:))]
331 #[unsafe(method_family = none)]
332 pub fn setUsesDataSource(&self, uses_data_source: bool);
333
334 #[unsafe(method(scrollItemAtIndexToTop:))]
335 #[unsafe(method_family = none)]
336 pub fn scrollItemAtIndexToTop(&self, index: NSInteger);
337
338 #[unsafe(method(scrollItemAtIndexToVisible:))]
339 #[unsafe(method_family = none)]
340 pub fn scrollItemAtIndexToVisible(&self, index: NSInteger);
341
342 #[unsafe(method(selectItemAtIndex:))]
343 #[unsafe(method_family = none)]
344 pub fn selectItemAtIndex(&self, index: NSInteger);
345
346 #[unsafe(method(deselectItemAtIndex:))]
347 #[unsafe(method_family = none)]
348 pub fn deselectItemAtIndex(&self, index: NSInteger);
349
350 #[unsafe(method(indexOfSelectedItem))]
351 #[unsafe(method_family = none)]
352 pub fn indexOfSelectedItem(&self) -> NSInteger;
353
354 #[unsafe(method(numberOfItems))]
355 #[unsafe(method_family = none)]
356 pub fn numberOfItems(&self) -> NSInteger;
357
358 #[unsafe(method(completes))]
359 #[unsafe(method_family = none)]
360 pub fn completes(&self) -> bool;
361
362 #[unsafe(method(setCompletes:))]
364 #[unsafe(method_family = none)]
365 pub fn setCompletes(&self, completes: bool);
366
367 #[unsafe(method(delegate))]
368 #[unsafe(method_family = none)]
369 pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSComboBoxDelegate>>>;
370
371 #[unsafe(method(setDelegate:))]
375 #[unsafe(method_family = none)]
376 pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSComboBoxDelegate>>);
377
378 #[unsafe(method(dataSource))]
382 #[unsafe(method_family = none)]
383 pub unsafe fn dataSource(
384 &self,
385 ) -> Option<Retained<ProtocolObject<dyn NSComboBoxDataSource>>>;
386
387 #[unsafe(method(setDataSource:))]
393 #[unsafe(method_family = none)]
394 pub unsafe fn setDataSource(
395 &self,
396 data_source: Option<&ProtocolObject<dyn NSComboBoxDataSource>>,
397 );
398
399 #[unsafe(method(addItemWithObjectValue:))]
403 #[unsafe(method_family = none)]
404 pub unsafe fn addItemWithObjectValue(&self, object: &AnyObject);
405
406 #[unsafe(method(addItemsWithObjectValues:))]
410 #[unsafe(method_family = none)]
411 pub unsafe fn addItemsWithObjectValues(&self, objects: &NSArray);
412
413 #[unsafe(method(insertItemWithObjectValue:atIndex:))]
417 #[unsafe(method_family = none)]
418 pub unsafe fn insertItemWithObjectValue_atIndex(
419 &self,
420 object: &AnyObject,
421 index: NSInteger,
422 );
423
424 #[unsafe(method(removeItemWithObjectValue:))]
428 #[unsafe(method_family = none)]
429 pub unsafe fn removeItemWithObjectValue(&self, object: &AnyObject);
430
431 #[unsafe(method(removeItemAtIndex:))]
432 #[unsafe(method_family = none)]
433 pub fn removeItemAtIndex(&self, index: NSInteger);
434
435 #[unsafe(method(removeAllItems))]
436 #[unsafe(method_family = none)]
437 pub fn removeAllItems(&self);
438
439 #[unsafe(method(selectItemWithObjectValue:))]
443 #[unsafe(method_family = none)]
444 pub unsafe fn selectItemWithObjectValue(&self, object: Option<&AnyObject>);
445
446 #[unsafe(method(itemObjectValueAtIndex:))]
447 #[unsafe(method_family = none)]
448 pub fn itemObjectValueAtIndex(&self, index: NSInteger) -> Retained<AnyObject>;
449
450 #[unsafe(method(objectValueOfSelectedItem))]
451 #[unsafe(method_family = none)]
452 pub fn objectValueOfSelectedItem(&self) -> Option<Retained<AnyObject>>;
453
454 #[unsafe(method(indexOfItemWithObjectValue:))]
458 #[unsafe(method_family = none)]
459 pub unsafe fn indexOfItemWithObjectValue(&self, object: &AnyObject) -> NSInteger;
460
461 #[unsafe(method(objectValues))]
462 #[unsafe(method_family = none)]
463 pub fn objectValues(&self) -> Retained<NSArray>;
464 );
465}
466
467#[cfg(all(
469 feature = "NSControl",
470 feature = "NSResponder",
471 feature = "NSTextField",
472 feature = "NSView"
473))]
474impl NSComboBox {
475 extern_methods!(
476 #[unsafe(method(initWithFrame:))]
477 #[unsafe(method_family = init)]
478 pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
479
480 #[unsafe(method(initWithCoder:))]
484 #[unsafe(method_family = init)]
485 pub unsafe fn initWithCoder(
486 this: Allocated<Self>,
487 coder: &NSCoder,
488 ) -> Option<Retained<Self>>;
489 );
490}
491
492#[cfg(all(
494 feature = "NSControl",
495 feature = "NSResponder",
496 feature = "NSTextField",
497 feature = "NSView"
498))]
499impl NSComboBox {
500 extern_methods!(
501 #[unsafe(method(init))]
502 #[unsafe(method_family = init)]
503 pub fn init(this: Allocated<Self>) -> Retained<Self>;
504 );
505}
506
507#[cfg(all(
509 feature = "NSControl",
510 feature = "NSResponder",
511 feature = "NSTextField",
512 feature = "NSView"
513))]
514impl NSComboBox {
515 extern_methods!(
516 #[unsafe(method(new))]
517 #[unsafe(method_family = new)]
518 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
519 );
520}