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:))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn popUpButtonWithMenu_target_action(
165 menu: &NSMenu,
166 target: Option<&AnyObject>,
167 action: Option<Sel>,
168 ) -> Retained<Self>;
169
170 #[cfg(feature = "NSMenu")]
171 #[unsafe(method(pullDownButtonWithTitle:menu:))]
181 #[unsafe(method_family = none)]
182 pub unsafe fn pullDownButtonWithTitle_menu(
183 title: &NSString,
184 menu: &NSMenu,
185 ) -> Retained<Self>;
186
187 #[cfg(all(feature = "NSImage", feature = "NSMenu"))]
188 #[unsafe(method(pullDownButtonWithImage:menu:))]
198 #[unsafe(method_family = none)]
199 pub unsafe fn pullDownButtonWithImage_menu(
200 image: &NSImage,
201 menu: &NSMenu,
202 ) -> Retained<Self>;
203
204 #[cfg(all(feature = "NSImage", feature = "NSMenu"))]
205 #[unsafe(method(pullDownButtonWithTitle:image:menu:))]
217 #[unsafe(method_family = none)]
218 pub unsafe fn pullDownButtonWithTitle_image_menu(
219 title: &NSString,
220 image: &NSImage,
221 menu: &NSMenu,
222 ) -> Retained<Self>;
223
224 #[unsafe(method(initWithFrame:pullsDown:))]
225 #[unsafe(method_family = init)]
226 pub unsafe fn initWithFrame_pullsDown(
227 this: Allocated<Self>,
228 button_frame: NSRect,
229 flag: bool,
230 ) -> Retained<Self>;
231
232 #[cfg(feature = "NSMenu")]
233 #[unsafe(method(menu))]
235 #[unsafe(method_family = none)]
236 pub unsafe fn menu(&self) -> Option<Retained<NSMenu>>;
237
238 #[cfg(feature = "NSMenu")]
239 #[unsafe(method(setMenu:))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn setMenu(&self, menu: Option<&NSMenu>);
243
244 #[unsafe(method(pullsDown))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn pullsDown(&self) -> bool;
248
249 #[unsafe(method(setPullsDown:))]
251 #[unsafe(method_family = none)]
252 pub unsafe fn setPullsDown(&self, pulls_down: bool);
253
254 #[unsafe(method(autoenablesItems))]
256 #[unsafe(method_family = none)]
257 pub unsafe fn autoenablesItems(&self) -> bool;
258
259 #[unsafe(method(setAutoenablesItems:))]
261 #[unsafe(method_family = none)]
262 pub unsafe fn setAutoenablesItems(&self, autoenables_items: bool);
263
264 #[unsafe(method(preferredEdge))]
266 #[unsafe(method_family = none)]
267 pub unsafe fn preferredEdge(&self) -> NSRectEdge;
268
269 #[unsafe(method(setPreferredEdge:))]
271 #[unsafe(method_family = none)]
272 pub unsafe fn setPreferredEdge(&self, preferred_edge: NSRectEdge);
273
274 #[unsafe(method(usesItemFromMenu))]
276 #[unsafe(method_family = none)]
277 pub unsafe fn usesItemFromMenu(&self) -> bool;
278
279 #[unsafe(method(setUsesItemFromMenu:))]
281 #[unsafe(method_family = none)]
282 pub unsafe fn setUsesItemFromMenu(&self, uses_item_from_menu: bool);
283
284 #[unsafe(method(altersStateOfSelectedItem))]
286 #[unsafe(method_family = none)]
287 pub unsafe fn altersStateOfSelectedItem(&self) -> bool;
288
289 #[unsafe(method(setAltersStateOfSelectedItem:))]
291 #[unsafe(method_family = none)]
292 pub unsafe fn setAltersStateOfSelectedItem(&self, alters_state_of_selected_item: bool);
293
294 #[unsafe(method(addItemWithTitle:))]
295 #[unsafe(method_family = none)]
296 pub unsafe fn addItemWithTitle(&self, title: &NSString);
297
298 #[unsafe(method(addItemsWithTitles:))]
299 #[unsafe(method_family = none)]
300 pub unsafe fn addItemsWithTitles(&self, item_titles: &NSArray<NSString>);
301
302 #[unsafe(method(insertItemWithTitle:atIndex:))]
303 #[unsafe(method_family = none)]
304 pub unsafe fn insertItemWithTitle_atIndex(&self, title: &NSString, index: NSInteger);
305
306 #[unsafe(method(removeItemWithTitle:))]
307 #[unsafe(method_family = none)]
308 pub unsafe fn removeItemWithTitle(&self, title: &NSString);
309
310 #[unsafe(method(removeItemAtIndex:))]
311 #[unsafe(method_family = none)]
312 pub unsafe fn removeItemAtIndex(&self, index: NSInteger);
313
314 #[unsafe(method(removeAllItems))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn removeAllItems(&self);
317
318 #[cfg(feature = "NSMenuItem")]
319 #[unsafe(method(itemArray))]
320 #[unsafe(method_family = none)]
321 pub unsafe fn itemArray(&self) -> Retained<NSArray<NSMenuItem>>;
322
323 #[unsafe(method(numberOfItems))]
324 #[unsafe(method_family = none)]
325 pub unsafe fn numberOfItems(&self) -> NSInteger;
326
327 #[cfg(feature = "NSMenuItem")]
328 #[unsafe(method(indexOfItem:))]
329 #[unsafe(method_family = none)]
330 pub unsafe fn indexOfItem(&self, item: &NSMenuItem) -> NSInteger;
331
332 #[unsafe(method(indexOfItemWithTitle:))]
333 #[unsafe(method_family = none)]
334 pub unsafe fn indexOfItemWithTitle(&self, title: &NSString) -> NSInteger;
335
336 #[unsafe(method(indexOfItemWithTag:))]
337 #[unsafe(method_family = none)]
338 pub unsafe fn indexOfItemWithTag(&self, tag: NSInteger) -> NSInteger;
339
340 #[unsafe(method(indexOfItemWithRepresentedObject:))]
341 #[unsafe(method_family = none)]
342 pub unsafe fn indexOfItemWithRepresentedObject(&self, obj: Option<&AnyObject>)
343 -> NSInteger;
344
345 #[unsafe(method(indexOfItemWithTarget:andAction:))]
346 #[unsafe(method_family = none)]
347 pub unsafe fn indexOfItemWithTarget_andAction(
348 &self,
349 target: Option<&AnyObject>,
350 action_selector: Option<Sel>,
351 ) -> NSInteger;
352
353 #[cfg(feature = "NSMenuItem")]
354 #[unsafe(method(itemAtIndex:))]
355 #[unsafe(method_family = none)]
356 pub unsafe fn itemAtIndex(&self, index: NSInteger) -> Option<Retained<NSMenuItem>>;
357
358 #[cfg(feature = "NSMenuItem")]
359 #[unsafe(method(itemWithTitle:))]
360 #[unsafe(method_family = none)]
361 pub unsafe fn itemWithTitle(&self, title: &NSString) -> Option<Retained<NSMenuItem>>;
362
363 #[cfg(feature = "NSMenuItem")]
364 #[unsafe(method(lastItem))]
365 #[unsafe(method_family = none)]
366 pub unsafe fn lastItem(&self) -> Option<Retained<NSMenuItem>>;
367
368 #[cfg(feature = "NSMenuItem")]
369 #[unsafe(method(selectItem:))]
370 #[unsafe(method_family = none)]
371 pub unsafe fn selectItem(&self, item: Option<&NSMenuItem>);
372
373 #[unsafe(method(selectItemAtIndex:))]
374 #[unsafe(method_family = none)]
375 pub unsafe fn selectItemAtIndex(&self, index: NSInteger);
376
377 #[unsafe(method(selectItemWithTitle:))]
378 #[unsafe(method_family = none)]
379 pub unsafe fn selectItemWithTitle(&self, title: &NSString);
380
381 #[unsafe(method(selectItemWithTag:))]
382 #[unsafe(method_family = none)]
383 pub unsafe fn selectItemWithTag(&self, tag: NSInteger) -> bool;
384
385 #[unsafe(method(setTitle:))]
386 #[unsafe(method_family = none)]
387 pub unsafe fn setTitle(&self, string: &NSString);
388
389 #[cfg(feature = "NSMenuItem")]
390 #[unsafe(method(selectedItem))]
391 #[unsafe(method_family = none)]
392 pub unsafe fn selectedItem(&self) -> Option<Retained<NSMenuItem>>;
393
394 #[unsafe(method(indexOfSelectedItem))]
395 #[unsafe(method_family = none)]
396 pub unsafe fn indexOfSelectedItem(&self) -> NSInteger;
397
398 #[unsafe(method(selectedTag))]
399 #[unsafe(method_family = none)]
400 pub unsafe fn selectedTag(&self) -> NSInteger;
401
402 #[unsafe(method(synchronizeTitleAndSelectedItem))]
403 #[unsafe(method_family = none)]
404 pub unsafe fn synchronizeTitleAndSelectedItem(&self);
405
406 #[unsafe(method(itemTitleAtIndex:))]
407 #[unsafe(method_family = none)]
408 pub unsafe fn itemTitleAtIndex(&self, index: NSInteger) -> Retained<NSString>;
409
410 #[unsafe(method(itemTitles))]
411 #[unsafe(method_family = none)]
412 pub unsafe fn itemTitles(&self) -> Retained<NSArray<NSString>>;
413
414 #[unsafe(method(titleOfSelectedItem))]
415 #[unsafe(method_family = none)]
416 pub unsafe fn titleOfSelectedItem(&self) -> Option<Retained<NSString>>;
417 );
418}
419
420#[cfg(all(
422 feature = "NSButton",
423 feature = "NSControl",
424 feature = "NSResponder",
425 feature = "NSView"
426))]
427impl NSPopUpButton {
428 extern_methods!(
429 #[cfg(feature = "NSImage")]
430 #[unsafe(method(buttonWithTitle:image:target:action:))]
442 #[unsafe(method_family = none)]
443 pub unsafe fn buttonWithTitle_image_target_action(
444 title: &NSString,
445 image: &NSImage,
446 target: Option<&AnyObject>,
447 action: Option<Sel>,
448 mtm: MainThreadMarker,
449 ) -> Retained<Self>;
450
451 #[unsafe(method(buttonWithTitle:target:action:))]
461 #[unsafe(method_family = none)]
462 pub unsafe fn buttonWithTitle_target_action(
463 title: &NSString,
464 target: Option<&AnyObject>,
465 action: Option<Sel>,
466 mtm: MainThreadMarker,
467 ) -> Retained<Self>;
468
469 #[cfg(feature = "NSImage")]
470 #[unsafe(method(buttonWithImage:target:action:))]
480 #[unsafe(method_family = none)]
481 pub unsafe fn buttonWithImage_target_action(
482 image: &NSImage,
483 target: Option<&AnyObject>,
484 action: Option<Sel>,
485 mtm: MainThreadMarker,
486 ) -> Retained<Self>;
487
488 #[unsafe(method(checkboxWithTitle:target:action:))]
498 #[unsafe(method_family = none)]
499 pub unsafe fn checkboxWithTitle_target_action(
500 title: &NSString,
501 target: Option<&AnyObject>,
502 action: Option<Sel>,
503 mtm: MainThreadMarker,
504 ) -> Retained<Self>;
505
506 #[unsafe(method(radioButtonWithTitle:target:action:))]
516 #[unsafe(method_family = none)]
517 pub unsafe fn radioButtonWithTitle_target_action(
518 title: &NSString,
519 target: Option<&AnyObject>,
520 action: Option<Sel>,
521 mtm: MainThreadMarker,
522 ) -> Retained<Self>;
523 );
524}
525
526#[cfg(all(
528 feature = "NSButton",
529 feature = "NSControl",
530 feature = "NSResponder",
531 feature = "NSView"
532))]
533impl NSPopUpButton {
534 extern_methods!(
535 #[unsafe(method(initWithFrame:))]
536 #[unsafe(method_family = init)]
537 pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
538
539 #[unsafe(method(initWithCoder:))]
540 #[unsafe(method_family = init)]
541 pub unsafe fn initWithCoder(
542 this: Allocated<Self>,
543 coder: &NSCoder,
544 ) -> Option<Retained<Self>>;
545 );
546}
547
548#[cfg(all(
550 feature = "NSButton",
551 feature = "NSControl",
552 feature = "NSResponder",
553 feature = "NSView"
554))]
555impl NSPopUpButton {
556 extern_methods!(
557 #[unsafe(method(init))]
558 #[unsafe(method_family = init)]
559 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
560 );
561}
562
563#[cfg(all(
565 feature = "NSButton",
566 feature = "NSControl",
567 feature = "NSResponder",
568 feature = "NSView"
569))]
570impl NSPopUpButton {
571 extern_methods!(
572 #[unsafe(method(new))]
573 #[unsafe(method_family = new)]
574 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
575 );
576}
577
578extern "C" {
579 pub static NSPopUpButtonWillPopUpNotification: &'static NSNotificationName;
581}