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))]
30unsafe impl NSAccessibility for NSPopUpButton {}
31
32#[cfg(all(
33 feature = "NSAccessibilityProtocols",
34 feature = "NSButton",
35 feature = "NSControl",
36 feature = "NSResponder",
37 feature = "NSView"
38))]
39unsafe impl NSAccessibilityButton for NSPopUpButton {}
40
41#[cfg(all(
42 feature = "NSAccessibilityProtocols",
43 feature = "NSButton",
44 feature = "NSControl",
45 feature = "NSResponder",
46 feature = "NSView"
47))]
48unsafe impl NSAccessibilityElementProtocol for NSPopUpButton {}
49
50#[cfg(all(
51 feature = "NSAnimation",
52 feature = "NSButton",
53 feature = "NSControl",
54 feature = "NSResponder",
55 feature = "NSView"
56))]
57unsafe impl NSAnimatablePropertyContainer for NSPopUpButton {}
58
59#[cfg(all(
60 feature = "NSAppearance",
61 feature = "NSButton",
62 feature = "NSControl",
63 feature = "NSResponder",
64 feature = "NSView"
65))]
66unsafe impl NSAppearanceCustomization for NSPopUpButton {}
67
68#[cfg(all(
69 feature = "NSButton",
70 feature = "NSControl",
71 feature = "NSResponder",
72 feature = "NSView"
73))]
74unsafe impl NSCoding for NSPopUpButton {}
75
76#[cfg(all(
77 feature = "NSButton",
78 feature = "NSControl",
79 feature = "NSDragging",
80 feature = "NSResponder",
81 feature = "NSView"
82))]
83unsafe impl NSDraggingDestination for NSPopUpButton {}
84
85#[cfg(all(
86 feature = "NSButton",
87 feature = "NSControl",
88 feature = "NSResponder",
89 feature = "NSView"
90))]
91unsafe impl NSObjectProtocol for NSPopUpButton {}
92
93#[cfg(all(
94 feature = "NSButton",
95 feature = "NSControl",
96 feature = "NSResponder",
97 feature = "NSUserInterfaceCompression",
98 feature = "NSView"
99))]
100unsafe impl NSUserInterfaceCompression for NSPopUpButton {}
101
102#[cfg(all(
103 feature = "NSButton",
104 feature = "NSControl",
105 feature = "NSResponder",
106 feature = "NSUserInterfaceItemIdentification",
107 feature = "NSView"
108))]
109unsafe impl NSUserInterfaceItemIdentification for NSPopUpButton {}
110
111#[cfg(all(
112 feature = "NSButton",
113 feature = "NSControl",
114 feature = "NSResponder",
115 feature = "NSUserInterfaceValidation",
116 feature = "NSView"
117))]
118unsafe impl NSUserInterfaceValidations for NSPopUpButton {}
119
120#[cfg(all(
121 feature = "NSButton",
122 feature = "NSControl",
123 feature = "NSResponder",
124 feature = "NSView"
125))]
126impl NSPopUpButton {
127 extern_methods!(
128 #[cfg(feature = "NSMenu")]
129 #[unsafe(method(popUpButtonWithMenu:target:action:))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn popUpButtonWithMenu_target_action(
143 menu: &NSMenu,
144 target: Option<&AnyObject>,
145 action: Option<Sel>,
146 ) -> Retained<Self>;
147
148 #[cfg(feature = "NSMenu")]
149 #[unsafe(method(pullDownButtonWithTitle:menu:))]
159 #[unsafe(method_family = none)]
160 pub unsafe fn pullDownButtonWithTitle_menu(
161 title: &NSString,
162 menu: &NSMenu,
163 ) -> Retained<Self>;
164
165 #[cfg(all(feature = "NSImage", feature = "NSMenu"))]
166 #[unsafe(method(pullDownButtonWithImage:menu:))]
176 #[unsafe(method_family = none)]
177 pub unsafe fn pullDownButtonWithImage_menu(
178 image: &NSImage,
179 menu: &NSMenu,
180 ) -> Retained<Self>;
181
182 #[cfg(all(feature = "NSImage", feature = "NSMenu"))]
183 #[unsafe(method(pullDownButtonWithTitle:image:menu:))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn pullDownButtonWithTitle_image_menu(
197 title: &NSString,
198 image: &NSImage,
199 menu: &NSMenu,
200 ) -> Retained<Self>;
201
202 #[unsafe(method(initWithFrame:pullsDown:))]
203 #[unsafe(method_family = init)]
204 pub unsafe fn initWithFrame_pullsDown(
205 this: Allocated<Self>,
206 button_frame: NSRect,
207 flag: bool,
208 ) -> Retained<Self>;
209
210 #[cfg(feature = "NSMenu")]
211 #[unsafe(method(menu))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn menu(&self) -> Option<Retained<NSMenu>>;
215
216 #[cfg(feature = "NSMenu")]
217 #[unsafe(method(setMenu:))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn setMenu(&self, menu: Option<&NSMenu>);
221
222 #[unsafe(method(pullsDown))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn pullsDown(&self) -> bool;
226
227 #[unsafe(method(setPullsDown:))]
229 #[unsafe(method_family = none)]
230 pub unsafe fn setPullsDown(&self, pulls_down: bool);
231
232 #[unsafe(method(autoenablesItems))]
234 #[unsafe(method_family = none)]
235 pub unsafe fn autoenablesItems(&self) -> bool;
236
237 #[unsafe(method(setAutoenablesItems:))]
239 #[unsafe(method_family = none)]
240 pub unsafe fn setAutoenablesItems(&self, autoenables_items: bool);
241
242 #[unsafe(method(preferredEdge))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn preferredEdge(&self) -> NSRectEdge;
246
247 #[unsafe(method(setPreferredEdge:))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn setPreferredEdge(&self, preferred_edge: NSRectEdge);
251
252 #[unsafe(method(usesItemFromMenu))]
254 #[unsafe(method_family = none)]
255 pub unsafe fn usesItemFromMenu(&self) -> bool;
256
257 #[unsafe(method(setUsesItemFromMenu:))]
259 #[unsafe(method_family = none)]
260 pub unsafe fn setUsesItemFromMenu(&self, uses_item_from_menu: bool);
261
262 #[unsafe(method(altersStateOfSelectedItem))]
264 #[unsafe(method_family = none)]
265 pub unsafe fn altersStateOfSelectedItem(&self) -> bool;
266
267 #[unsafe(method(setAltersStateOfSelectedItem:))]
269 #[unsafe(method_family = none)]
270 pub unsafe fn setAltersStateOfSelectedItem(&self, alters_state_of_selected_item: bool);
271
272 #[unsafe(method(addItemWithTitle:))]
273 #[unsafe(method_family = none)]
274 pub unsafe fn addItemWithTitle(&self, title: &NSString);
275
276 #[unsafe(method(addItemsWithTitles:))]
277 #[unsafe(method_family = none)]
278 pub unsafe fn addItemsWithTitles(&self, item_titles: &NSArray<NSString>);
279
280 #[unsafe(method(insertItemWithTitle:atIndex:))]
281 #[unsafe(method_family = none)]
282 pub unsafe fn insertItemWithTitle_atIndex(&self, title: &NSString, index: NSInteger);
283
284 #[unsafe(method(removeItemWithTitle:))]
285 #[unsafe(method_family = none)]
286 pub unsafe fn removeItemWithTitle(&self, title: &NSString);
287
288 #[unsafe(method(removeItemAtIndex:))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn removeItemAtIndex(&self, index: NSInteger);
291
292 #[unsafe(method(removeAllItems))]
293 #[unsafe(method_family = none)]
294 pub unsafe fn removeAllItems(&self);
295
296 #[cfg(feature = "NSMenuItem")]
297 #[unsafe(method(itemArray))]
298 #[unsafe(method_family = none)]
299 pub unsafe fn itemArray(&self) -> Retained<NSArray<NSMenuItem>>;
300
301 #[unsafe(method(numberOfItems))]
302 #[unsafe(method_family = none)]
303 pub unsafe fn numberOfItems(&self) -> NSInteger;
304
305 #[cfg(feature = "NSMenuItem")]
306 #[unsafe(method(indexOfItem:))]
307 #[unsafe(method_family = none)]
308 pub unsafe fn indexOfItem(&self, item: &NSMenuItem) -> NSInteger;
309
310 #[unsafe(method(indexOfItemWithTitle:))]
311 #[unsafe(method_family = none)]
312 pub unsafe fn indexOfItemWithTitle(&self, title: &NSString) -> NSInteger;
313
314 #[unsafe(method(indexOfItemWithTag:))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn indexOfItemWithTag(&self, tag: NSInteger) -> NSInteger;
317
318 #[unsafe(method(indexOfItemWithRepresentedObject:))]
319 #[unsafe(method_family = none)]
320 pub unsafe fn indexOfItemWithRepresentedObject(&self, obj: Option<&AnyObject>)
321 -> NSInteger;
322
323 #[unsafe(method(indexOfItemWithTarget:andAction:))]
324 #[unsafe(method_family = none)]
325 pub unsafe fn indexOfItemWithTarget_andAction(
326 &self,
327 target: Option<&AnyObject>,
328 action_selector: Option<Sel>,
329 ) -> NSInteger;
330
331 #[cfg(feature = "NSMenuItem")]
332 #[unsafe(method(itemAtIndex:))]
333 #[unsafe(method_family = none)]
334 pub unsafe fn itemAtIndex(&self, index: NSInteger) -> Option<Retained<NSMenuItem>>;
335
336 #[cfg(feature = "NSMenuItem")]
337 #[unsafe(method(itemWithTitle:))]
338 #[unsafe(method_family = none)]
339 pub unsafe fn itemWithTitle(&self, title: &NSString) -> Option<Retained<NSMenuItem>>;
340
341 #[cfg(feature = "NSMenuItem")]
342 #[unsafe(method(lastItem))]
343 #[unsafe(method_family = none)]
344 pub unsafe fn lastItem(&self) -> Option<Retained<NSMenuItem>>;
345
346 #[cfg(feature = "NSMenuItem")]
347 #[unsafe(method(selectItem:))]
348 #[unsafe(method_family = none)]
349 pub unsafe fn selectItem(&self, item: Option<&NSMenuItem>);
350
351 #[unsafe(method(selectItemAtIndex:))]
352 #[unsafe(method_family = none)]
353 pub unsafe fn selectItemAtIndex(&self, index: NSInteger);
354
355 #[unsafe(method(selectItemWithTitle:))]
356 #[unsafe(method_family = none)]
357 pub unsafe fn selectItemWithTitle(&self, title: &NSString);
358
359 #[unsafe(method(selectItemWithTag:))]
360 #[unsafe(method_family = none)]
361 pub unsafe fn selectItemWithTag(&self, tag: NSInteger) -> bool;
362
363 #[unsafe(method(setTitle:))]
364 #[unsafe(method_family = none)]
365 pub unsafe fn setTitle(&self, string: &NSString);
366
367 #[cfg(feature = "NSMenuItem")]
368 #[unsafe(method(selectedItem))]
369 #[unsafe(method_family = none)]
370 pub unsafe fn selectedItem(&self) -> Option<Retained<NSMenuItem>>;
371
372 #[unsafe(method(indexOfSelectedItem))]
373 #[unsafe(method_family = none)]
374 pub unsafe fn indexOfSelectedItem(&self) -> NSInteger;
375
376 #[unsafe(method(selectedTag))]
377 #[unsafe(method_family = none)]
378 pub unsafe fn selectedTag(&self) -> NSInteger;
379
380 #[unsafe(method(synchronizeTitleAndSelectedItem))]
381 #[unsafe(method_family = none)]
382 pub unsafe fn synchronizeTitleAndSelectedItem(&self);
383
384 #[unsafe(method(itemTitleAtIndex:))]
385 #[unsafe(method_family = none)]
386 pub unsafe fn itemTitleAtIndex(&self, index: NSInteger) -> Retained<NSString>;
387
388 #[unsafe(method(itemTitles))]
389 #[unsafe(method_family = none)]
390 pub unsafe fn itemTitles(&self) -> Retained<NSArray<NSString>>;
391
392 #[unsafe(method(titleOfSelectedItem))]
393 #[unsafe(method_family = none)]
394 pub unsafe fn titleOfSelectedItem(&self) -> Option<Retained<NSString>>;
395 );
396}
397
398#[cfg(all(
400 feature = "NSButton",
401 feature = "NSControl",
402 feature = "NSResponder",
403 feature = "NSView"
404))]
405impl NSPopUpButton {
406 extern_methods!(
407 #[cfg(feature = "NSImage")]
408 #[unsafe(method(buttonWithTitle:image:target:action:))]
420 #[unsafe(method_family = none)]
421 pub unsafe fn buttonWithTitle_image_target_action(
422 title: &NSString,
423 image: &NSImage,
424 target: Option<&AnyObject>,
425 action: Option<Sel>,
426 mtm: MainThreadMarker,
427 ) -> Retained<Self>;
428
429 #[unsafe(method(buttonWithTitle:target:action:))]
439 #[unsafe(method_family = none)]
440 pub unsafe fn buttonWithTitle_target_action(
441 title: &NSString,
442 target: Option<&AnyObject>,
443 action: Option<Sel>,
444 mtm: MainThreadMarker,
445 ) -> Retained<Self>;
446
447 #[cfg(feature = "NSImage")]
448 #[unsafe(method(buttonWithImage:target:action:))]
458 #[unsafe(method_family = none)]
459 pub unsafe fn buttonWithImage_target_action(
460 image: &NSImage,
461 target: Option<&AnyObject>,
462 action: Option<Sel>,
463 mtm: MainThreadMarker,
464 ) -> Retained<Self>;
465
466 #[unsafe(method(checkboxWithTitle:target:action:))]
476 #[unsafe(method_family = none)]
477 pub unsafe fn checkboxWithTitle_target_action(
478 title: &NSString,
479 target: Option<&AnyObject>,
480 action: Option<Sel>,
481 mtm: MainThreadMarker,
482 ) -> Retained<Self>;
483
484 #[unsafe(method(radioButtonWithTitle:target:action:))]
494 #[unsafe(method_family = none)]
495 pub unsafe fn radioButtonWithTitle_target_action(
496 title: &NSString,
497 target: Option<&AnyObject>,
498 action: Option<Sel>,
499 mtm: MainThreadMarker,
500 ) -> Retained<Self>;
501 );
502}
503
504#[cfg(all(
506 feature = "NSButton",
507 feature = "NSControl",
508 feature = "NSResponder",
509 feature = "NSView"
510))]
511impl NSPopUpButton {
512 extern_methods!(
513 #[unsafe(method(initWithFrame:))]
514 #[unsafe(method_family = init)]
515 pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
516
517 #[unsafe(method(initWithCoder:))]
518 #[unsafe(method_family = init)]
519 pub unsafe fn initWithCoder(
520 this: Allocated<Self>,
521 coder: &NSCoder,
522 ) -> Option<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(init))]
536 #[unsafe(method_family = init)]
537 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
538 );
539}
540
541#[cfg(all(
543 feature = "NSButton",
544 feature = "NSControl",
545 feature = "NSResponder",
546 feature = "NSView"
547))]
548impl NSPopUpButton {
549 extern_methods!(
550 #[unsafe(method(new))]
551 #[unsafe(method_family = new)]
552 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
553 );
554}
555
556extern "C" {
557 pub static NSPopUpButtonWillPopUpNotification: &'static NSNotificationName;
559}