1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11 #[unsafe(super(NSButton, NSControl, NSView, NSResponder, NSObject))]
13 #[derive(Debug, PartialEq, Eq, Hash)]
14 #[cfg(all(
15 feature = "NSButton",
16 feature = "NSControl",
17 feature = "NSResponder",
18 feature = "NSView"
19 ))]
20 pub struct NSPopUpButton;
21);
22
23#[cfg(all(
24 feature = "NSAccessibilityProtocols",
25 feature = "NSButton",
26 feature = "NSControl",
27 feature = "NSResponder",
28 feature = "NSView"
29))]
30extern_conformance!(
31 unsafe impl NSAccessibility for NSPopUpButton {}
32);
33
34#[cfg(all(
35 feature = "NSAccessibilityProtocols",
36 feature = "NSButton",
37 feature = "NSControl",
38 feature = "NSResponder",
39 feature = "NSView"
40))]
41extern_conformance!(
42 unsafe impl NSAccessibilityButton for NSPopUpButton {}
43);
44
45#[cfg(all(
46 feature = "NSAccessibilityProtocols",
47 feature = "NSButton",
48 feature = "NSControl",
49 feature = "NSResponder",
50 feature = "NSView"
51))]
52extern_conformance!(
53 unsafe impl NSAccessibilityElementProtocol for NSPopUpButton {}
54);
55
56#[cfg(all(
57 feature = "NSAnimation",
58 feature = "NSButton",
59 feature = "NSControl",
60 feature = "NSResponder",
61 feature = "NSView"
62))]
63extern_conformance!(
64 unsafe impl NSAnimatablePropertyContainer for NSPopUpButton {}
65);
66
67#[cfg(all(
68 feature = "NSAppearance",
69 feature = "NSButton",
70 feature = "NSControl",
71 feature = "NSResponder",
72 feature = "NSView"
73))]
74extern_conformance!(
75 unsafe impl NSAppearanceCustomization for NSPopUpButton {}
76);
77
78#[cfg(all(
79 feature = "NSButton",
80 feature = "NSControl",
81 feature = "NSResponder",
82 feature = "NSView"
83))]
84extern_conformance!(
85 unsafe impl NSCoding for NSPopUpButton {}
86);
87
88#[cfg(all(
89 feature = "NSButton",
90 feature = "NSControl",
91 feature = "NSDragging",
92 feature = "NSResponder",
93 feature = "NSView"
94))]
95extern_conformance!(
96 unsafe impl NSDraggingDestination for NSPopUpButton {}
97);
98
99#[cfg(all(
100 feature = "NSButton",
101 feature = "NSControl",
102 feature = "NSResponder",
103 feature = "NSView"
104))]
105extern_conformance!(
106 unsafe impl NSObjectProtocol for NSPopUpButton {}
107);
108
109#[cfg(all(
110 feature = "NSButton",
111 feature = "NSControl",
112 feature = "NSResponder",
113 feature = "NSUserInterfaceCompression",
114 feature = "NSView"
115))]
116extern_conformance!(
117 unsafe impl NSUserInterfaceCompression for NSPopUpButton {}
118);
119
120#[cfg(all(
121 feature = "NSButton",
122 feature = "NSControl",
123 feature = "NSResponder",
124 feature = "NSUserInterfaceItemIdentification",
125 feature = "NSView"
126))]
127extern_conformance!(
128 unsafe impl NSUserInterfaceItemIdentification for NSPopUpButton {}
129);
130
131#[cfg(all(
132 feature = "NSButton",
133 feature = "NSControl",
134 feature = "NSResponder",
135 feature = "NSUserInterfaceValidation",
136 feature = "NSView"
137))]
138extern_conformance!(
139 unsafe impl NSUserInterfaceValidations for NSPopUpButton {}
140);
141
142#[cfg(all(
143 feature = "NSButton",
144 feature = "NSControl",
145 feature = "NSResponder",
146 feature = "NSView"
147))]
148impl NSPopUpButton {
149 extern_methods!(
150 #[cfg(feature = "NSMenu")]
151 #[unsafe(method(popUpButtonWithMenu:target:action:))]
168 #[unsafe(method_family = none)]
169 pub unsafe fn popUpButtonWithMenu_target_action(
170 menu: &NSMenu,
171 target: Option<&AnyObject>,
172 action: Option<Sel>,
173 ) -> Retained<Self>;
174
175 #[cfg(feature = "NSMenu")]
176 #[unsafe(method(pullDownButtonWithTitle:menu:))]
186 #[unsafe(method_family = none)]
187 pub fn pullDownButtonWithTitle_menu(title: &NSString, menu: &NSMenu) -> Retained<Self>;
188
189 #[cfg(all(feature = "NSImage", feature = "NSMenu"))]
190 #[unsafe(method(pullDownButtonWithImage:menu:))]
200 #[unsafe(method_family = none)]
201 pub fn pullDownButtonWithImage_menu(image: &NSImage, menu: &NSMenu) -> Retained<Self>;
202
203 #[cfg(all(feature = "NSImage", feature = "NSMenu"))]
204 #[unsafe(method(pullDownButtonWithTitle:image:menu:))]
216 #[unsafe(method_family = none)]
217 pub fn pullDownButtonWithTitle_image_menu(
218 title: &NSString,
219 image: &NSImage,
220 menu: &NSMenu,
221 ) -> Retained<Self>;
222
223 #[unsafe(method(initWithFrame:pullsDown:))]
224 #[unsafe(method_family = init)]
225 pub fn initWithFrame_pullsDown(
226 this: Allocated<Self>,
227 button_frame: NSRect,
228 flag: bool,
229 ) -> Retained<Self>;
230
231 #[cfg(feature = "NSMenu")]
232 #[unsafe(method(menu))]
234 #[unsafe(method_family = none)]
235 pub fn menu(&self) -> Option<Retained<NSMenu>>;
236
237 #[cfg(feature = "NSMenu")]
238 #[unsafe(method(setMenu:))]
240 #[unsafe(method_family = none)]
241 pub fn setMenu(&self, menu: Option<&NSMenu>);
242
243 #[unsafe(method(pullsDown))]
245 #[unsafe(method_family = none)]
246 pub fn pullsDown(&self) -> bool;
247
248 #[unsafe(method(setPullsDown:))]
250 #[unsafe(method_family = none)]
251 pub fn setPullsDown(&self, pulls_down: bool);
252
253 #[unsafe(method(autoenablesItems))]
255 #[unsafe(method_family = none)]
256 pub fn autoenablesItems(&self) -> bool;
257
258 #[unsafe(method(setAutoenablesItems:))]
260 #[unsafe(method_family = none)]
261 pub fn setAutoenablesItems(&self, autoenables_items: bool);
262
263 #[unsafe(method(preferredEdge))]
265 #[unsafe(method_family = none)]
266 pub fn preferredEdge(&self) -> NSRectEdge;
267
268 #[unsafe(method(setPreferredEdge:))]
270 #[unsafe(method_family = none)]
271 pub fn setPreferredEdge(&self, preferred_edge: NSRectEdge);
272
273 #[unsafe(method(usesItemFromMenu))]
275 #[unsafe(method_family = none)]
276 pub fn usesItemFromMenu(&self) -> bool;
277
278 #[unsafe(method(setUsesItemFromMenu:))]
280 #[unsafe(method_family = none)]
281 pub fn setUsesItemFromMenu(&self, uses_item_from_menu: bool);
282
283 #[unsafe(method(altersStateOfSelectedItem))]
285 #[unsafe(method_family = none)]
286 pub fn altersStateOfSelectedItem(&self) -> bool;
287
288 #[unsafe(method(setAltersStateOfSelectedItem:))]
290 #[unsafe(method_family = none)]
291 pub fn setAltersStateOfSelectedItem(&self, alters_state_of_selected_item: bool);
292
293 #[unsafe(method(addItemWithTitle:))]
294 #[unsafe(method_family = none)]
295 pub fn addItemWithTitle(&self, title: &NSString);
296
297 #[unsafe(method(addItemsWithTitles:))]
298 #[unsafe(method_family = none)]
299 pub fn addItemsWithTitles(&self, item_titles: &NSArray<NSString>);
300
301 #[unsafe(method(insertItemWithTitle:atIndex:))]
302 #[unsafe(method_family = none)]
303 pub fn insertItemWithTitle_atIndex(&self, title: &NSString, index: NSInteger);
304
305 #[unsafe(method(removeItemWithTitle:))]
306 #[unsafe(method_family = none)]
307 pub fn removeItemWithTitle(&self, title: &NSString);
308
309 #[unsafe(method(removeItemAtIndex:))]
310 #[unsafe(method_family = none)]
311 pub fn removeItemAtIndex(&self, index: NSInteger);
312
313 #[unsafe(method(removeAllItems))]
314 #[unsafe(method_family = none)]
315 pub fn removeAllItems(&self);
316
317 #[cfg(feature = "NSMenuItem")]
318 #[unsafe(method(itemArray))]
319 #[unsafe(method_family = none)]
320 pub fn itemArray(&self) -> Retained<NSArray<NSMenuItem>>;
321
322 #[unsafe(method(numberOfItems))]
323 #[unsafe(method_family = none)]
324 pub fn numberOfItems(&self) -> NSInteger;
325
326 #[cfg(feature = "NSMenuItem")]
327 #[unsafe(method(indexOfItem:))]
328 #[unsafe(method_family = none)]
329 pub fn indexOfItem(&self, item: &NSMenuItem) -> NSInteger;
330
331 #[unsafe(method(indexOfItemWithTitle:))]
332 #[unsafe(method_family = none)]
333 pub fn indexOfItemWithTitle(&self, title: &NSString) -> NSInteger;
334
335 #[unsafe(method(indexOfItemWithTag:))]
336 #[unsafe(method_family = none)]
337 pub fn indexOfItemWithTag(&self, tag: NSInteger) -> NSInteger;
338
339 #[unsafe(method(indexOfItemWithRepresentedObject:))]
343 #[unsafe(method_family = none)]
344 pub unsafe fn indexOfItemWithRepresentedObject(&self, obj: Option<&AnyObject>)
345 -> NSInteger;
346
347 #[unsafe(method(indexOfItemWithTarget:andAction:))]
352 #[unsafe(method_family = none)]
353 pub unsafe fn indexOfItemWithTarget_andAction(
354 &self,
355 target: Option<&AnyObject>,
356 action_selector: Option<Sel>,
357 ) -> NSInteger;
358
359 #[cfg(feature = "NSMenuItem")]
360 #[unsafe(method(itemAtIndex:))]
361 #[unsafe(method_family = none)]
362 pub fn itemAtIndex(&self, index: NSInteger) -> Option<Retained<NSMenuItem>>;
363
364 #[cfg(feature = "NSMenuItem")]
365 #[unsafe(method(itemWithTitle:))]
366 #[unsafe(method_family = none)]
367 pub fn itemWithTitle(&self, title: &NSString) -> Option<Retained<NSMenuItem>>;
368
369 #[cfg(feature = "NSMenuItem")]
370 #[unsafe(method(lastItem))]
371 #[unsafe(method_family = none)]
372 pub fn lastItem(&self) -> Option<Retained<NSMenuItem>>;
373
374 #[cfg(feature = "NSMenuItem")]
375 #[unsafe(method(selectItem:))]
376 #[unsafe(method_family = none)]
377 pub fn selectItem(&self, item: Option<&NSMenuItem>);
378
379 #[unsafe(method(selectItemAtIndex:))]
380 #[unsafe(method_family = none)]
381 pub fn selectItemAtIndex(&self, index: NSInteger);
382
383 #[unsafe(method(selectItemWithTitle:))]
384 #[unsafe(method_family = none)]
385 pub fn selectItemWithTitle(&self, title: &NSString);
386
387 #[unsafe(method(selectItemWithTag:))]
388 #[unsafe(method_family = none)]
389 pub fn selectItemWithTag(&self, tag: NSInteger) -> bool;
390
391 #[unsafe(method(setTitle:))]
392 #[unsafe(method_family = none)]
393 pub fn setTitle(&self, string: &NSString);
394
395 #[cfg(feature = "NSMenuItem")]
396 #[unsafe(method(selectedItem))]
397 #[unsafe(method_family = none)]
398 pub fn selectedItem(&self) -> Option<Retained<NSMenuItem>>;
399
400 #[unsafe(method(indexOfSelectedItem))]
401 #[unsafe(method_family = none)]
402 pub fn indexOfSelectedItem(&self) -> NSInteger;
403
404 #[unsafe(method(selectedTag))]
405 #[unsafe(method_family = none)]
406 pub fn selectedTag(&self) -> NSInteger;
407
408 #[unsafe(method(synchronizeTitleAndSelectedItem))]
409 #[unsafe(method_family = none)]
410 pub fn synchronizeTitleAndSelectedItem(&self);
411
412 #[unsafe(method(itemTitleAtIndex:))]
413 #[unsafe(method_family = none)]
414 pub fn itemTitleAtIndex(&self, index: NSInteger) -> Retained<NSString>;
415
416 #[unsafe(method(itemTitles))]
417 #[unsafe(method_family = none)]
418 pub fn itemTitles(&self) -> Retained<NSArray<NSString>>;
419
420 #[unsafe(method(titleOfSelectedItem))]
421 #[unsafe(method_family = none)]
422 pub fn titleOfSelectedItem(&self) -> Option<Retained<NSString>>;
423 );
424}
425
426#[cfg(all(
428 feature = "NSButton",
429 feature = "NSControl",
430 feature = "NSResponder",
431 feature = "NSView"
432))]
433impl NSPopUpButton {
434 extern_methods!(
435 #[cfg(feature = "NSImage")]
436 #[unsafe(method(buttonWithTitle:image:target:action:))]
453 #[unsafe(method_family = none)]
454 pub unsafe fn buttonWithTitle_image_target_action(
455 title: &NSString,
456 image: &NSImage,
457 target: Option<&AnyObject>,
458 action: Option<Sel>,
459 mtm: MainThreadMarker,
460 ) -> Retained<Self>;
461
462 #[unsafe(method(buttonWithTitle:target:action:))]
477 #[unsafe(method_family = none)]
478 pub unsafe fn buttonWithTitle_target_action(
479 title: &NSString,
480 target: Option<&AnyObject>,
481 action: Option<Sel>,
482 mtm: MainThreadMarker,
483 ) -> Retained<Self>;
484
485 #[cfg(feature = "NSImage")]
486 #[unsafe(method(buttonWithImage:target:action:))]
501 #[unsafe(method_family = none)]
502 pub unsafe fn buttonWithImage_target_action(
503 image: &NSImage,
504 target: Option<&AnyObject>,
505 action: Option<Sel>,
506 mtm: MainThreadMarker,
507 ) -> Retained<Self>;
508
509 #[unsafe(method(checkboxWithTitle:target:action:))]
524 #[unsafe(method_family = none)]
525 pub unsafe fn checkboxWithTitle_target_action(
526 title: &NSString,
527 target: Option<&AnyObject>,
528 action: Option<Sel>,
529 mtm: MainThreadMarker,
530 ) -> Retained<Self>;
531
532 #[unsafe(method(radioButtonWithTitle:target:action:))]
547 #[unsafe(method_family = none)]
548 pub unsafe fn radioButtonWithTitle_target_action(
549 title: &NSString,
550 target: Option<&AnyObject>,
551 action: Option<Sel>,
552 mtm: MainThreadMarker,
553 ) -> Retained<Self>;
554 );
555}
556
557#[cfg(all(
559 feature = "NSButton",
560 feature = "NSControl",
561 feature = "NSResponder",
562 feature = "NSView"
563))]
564impl NSPopUpButton {
565 extern_methods!(
566 #[unsafe(method(initWithFrame:))]
567 #[unsafe(method_family = init)]
568 pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
569
570 #[unsafe(method(initWithCoder:))]
574 #[unsafe(method_family = init)]
575 pub unsafe fn initWithCoder(
576 this: Allocated<Self>,
577 coder: &NSCoder,
578 ) -> Option<Retained<Self>>;
579 );
580}
581
582#[cfg(all(
584 feature = "NSButton",
585 feature = "NSControl",
586 feature = "NSResponder",
587 feature = "NSView"
588))]
589impl NSPopUpButton {
590 extern_methods!(
591 #[unsafe(method(init))]
592 #[unsafe(method_family = init)]
593 pub fn init(this: Allocated<Self>) -> Retained<Self>;
594 );
595}
596
597#[cfg(all(
599 feature = "NSButton",
600 feature = "NSControl",
601 feature = "NSResponder",
602 feature = "NSView"
603))]
604impl NSPopUpButton {
605 extern_methods!(
606 #[unsafe(method(new))]
607 #[unsafe(method_family = new)]
608 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
609 );
610}
611
612extern "C" {
613 pub static NSPopUpButtonWillPopUpNotification: &'static NSNotificationName;
615}