1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct NSPopUpArrowPosition(pub NSUInteger);
15impl NSPopUpArrowPosition {
16 #[doc(alias = "NSPopUpNoArrow")]
17 pub const NoArrow: Self = Self(0);
18 #[doc(alias = "NSPopUpArrowAtCenter")]
19 pub const ArrowAtCenter: Self = Self(1);
20 #[doc(alias = "NSPopUpArrowAtBottom")]
21 pub const ArrowAtBottom: Self = Self(2);
22}
23
24unsafe impl Encode for NSPopUpArrowPosition {
25 const ENCODING: Encoding = NSUInteger::ENCODING;
26}
27
28unsafe impl RefEncode for NSPopUpArrowPosition {
29 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32extern_class!(
33 #[unsafe(super(NSMenuItemCell, NSButtonCell, NSActionCell, NSCell, NSObject))]
35 #[derive(Debug, PartialEq, Eq, Hash)]
36 #[cfg(all(
37 feature = "NSActionCell",
38 feature = "NSButtonCell",
39 feature = "NSCell",
40 feature = "NSMenuItemCell"
41 ))]
42 pub struct NSPopUpButtonCell;
43);
44
45#[cfg(all(
46 feature = "NSAccessibilityProtocols",
47 feature = "NSActionCell",
48 feature = "NSButtonCell",
49 feature = "NSCell",
50 feature = "NSMenuItemCell"
51))]
52unsafe impl NSAccessibility for NSPopUpButtonCell {}
53
54#[cfg(all(
55 feature = "NSAccessibilityProtocols",
56 feature = "NSActionCell",
57 feature = "NSButtonCell",
58 feature = "NSCell",
59 feature = "NSMenuItemCell"
60))]
61unsafe impl NSAccessibilityElementProtocol for NSPopUpButtonCell {}
62
63#[cfg(all(
64 feature = "NSActionCell",
65 feature = "NSButtonCell",
66 feature = "NSCell",
67 feature = "NSMenuItemCell"
68))]
69unsafe impl NSCoding for NSPopUpButtonCell {}
70
71#[cfg(all(
72 feature = "NSActionCell",
73 feature = "NSButtonCell",
74 feature = "NSCell",
75 feature = "NSMenuItemCell"
76))]
77unsafe impl NSCopying for NSPopUpButtonCell {}
78
79#[cfg(all(
80 feature = "NSActionCell",
81 feature = "NSButtonCell",
82 feature = "NSCell",
83 feature = "NSMenuItemCell"
84))]
85unsafe impl CopyingHelper for NSPopUpButtonCell {
86 type Result = Self;
87}
88
89#[cfg(all(
90 feature = "NSActionCell",
91 feature = "NSButtonCell",
92 feature = "NSCell",
93 feature = "NSMenu",
94 feature = "NSMenuItemCell"
95))]
96unsafe impl NSMenuItemValidation for NSPopUpButtonCell {}
97
98#[cfg(all(
99 feature = "NSActionCell",
100 feature = "NSButtonCell",
101 feature = "NSCell",
102 feature = "NSMenuItemCell"
103))]
104unsafe impl NSObjectProtocol for NSPopUpButtonCell {}
105
106#[cfg(all(
107 feature = "NSActionCell",
108 feature = "NSButtonCell",
109 feature = "NSCell",
110 feature = "NSMenuItemCell",
111 feature = "NSUserInterfaceItemIdentification"
112))]
113unsafe impl NSUserInterfaceItemIdentification for NSPopUpButtonCell {}
114
115#[cfg(all(
116 feature = "NSActionCell",
117 feature = "NSButtonCell",
118 feature = "NSCell",
119 feature = "NSMenuItemCell"
120))]
121impl NSPopUpButtonCell {
122 extern_methods!(
123 #[unsafe(method(initTextCell:pullsDown:))]
124 #[unsafe(method_family = init)]
125 pub unsafe fn initTextCell_pullsDown(
126 this: Allocated<Self>,
127 string_value: &NSString,
128 pull_down: bool,
129 ) -> Retained<Self>;
130
131 #[unsafe(method(initWithCoder:))]
132 #[unsafe(method_family = init)]
133 pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
134
135 #[cfg(feature = "NSMenu")]
136 #[unsafe(method(menu))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn menu(&self) -> Option<Retained<NSMenu>>;
139
140 #[cfg(feature = "NSMenu")]
141 #[unsafe(method(setMenu:))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn setMenu(&self, menu: Option<&NSMenu>);
145
146 #[unsafe(method(pullsDown))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn pullsDown(&self) -> bool;
149
150 #[unsafe(method(setPullsDown:))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn setPullsDown(&self, pulls_down: bool);
154
155 #[unsafe(method(autoenablesItems))]
156 #[unsafe(method_family = none)]
157 pub unsafe fn autoenablesItems(&self) -> bool;
158
159 #[unsafe(method(setAutoenablesItems:))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn setAutoenablesItems(&self, autoenables_items: bool);
163
164 #[unsafe(method(preferredEdge))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn preferredEdge(&self) -> NSRectEdge;
167
168 #[unsafe(method(setPreferredEdge:))]
170 #[unsafe(method_family = none)]
171 pub unsafe fn setPreferredEdge(&self, preferred_edge: NSRectEdge);
172
173 #[unsafe(method(usesItemFromMenu))]
174 #[unsafe(method_family = none)]
175 pub unsafe fn usesItemFromMenu(&self) -> bool;
176
177 #[unsafe(method(setUsesItemFromMenu:))]
179 #[unsafe(method_family = none)]
180 pub unsafe fn setUsesItemFromMenu(&self, uses_item_from_menu: bool);
181
182 #[unsafe(method(altersStateOfSelectedItem))]
183 #[unsafe(method_family = none)]
184 pub unsafe fn altersStateOfSelectedItem(&self) -> bool;
185
186 #[unsafe(method(setAltersStateOfSelectedItem:))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn setAltersStateOfSelectedItem(&self, alters_state_of_selected_item: bool);
190
191 #[unsafe(method(addItemWithTitle:))]
192 #[unsafe(method_family = none)]
193 pub unsafe fn addItemWithTitle(&self, title: &NSString);
194
195 #[unsafe(method(addItemsWithTitles:))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn addItemsWithTitles(&self, item_titles: &NSArray<NSString>);
198
199 #[unsafe(method(insertItemWithTitle:atIndex:))]
200 #[unsafe(method_family = none)]
201 pub unsafe fn insertItemWithTitle_atIndex(&self, title: &NSString, index: NSInteger);
202
203 #[unsafe(method(removeItemWithTitle:))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn removeItemWithTitle(&self, title: &NSString);
206
207 #[unsafe(method(removeItemAtIndex:))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn removeItemAtIndex(&self, index: NSInteger);
210
211 #[unsafe(method(removeAllItems))]
212 #[unsafe(method_family = none)]
213 pub unsafe fn removeAllItems(&self);
214
215 #[cfg(feature = "NSMenuItem")]
216 #[unsafe(method(itemArray))]
217 #[unsafe(method_family = none)]
218 pub unsafe fn itemArray(&self) -> Retained<NSArray<NSMenuItem>>;
219
220 #[unsafe(method(numberOfItems))]
221 #[unsafe(method_family = none)]
222 pub unsafe fn numberOfItems(&self) -> NSInteger;
223
224 #[cfg(feature = "NSMenuItem")]
225 #[unsafe(method(indexOfItem:))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn indexOfItem(&self, item: &NSMenuItem) -> NSInteger;
228
229 #[unsafe(method(indexOfItemWithTitle:))]
230 #[unsafe(method_family = none)]
231 pub unsafe fn indexOfItemWithTitle(&self, title: &NSString) -> NSInteger;
232
233 #[unsafe(method(indexOfItemWithTag:))]
234 #[unsafe(method_family = none)]
235 pub unsafe fn indexOfItemWithTag(&self, tag: NSInteger) -> NSInteger;
236
237 #[unsafe(method(indexOfItemWithRepresentedObject:))]
238 #[unsafe(method_family = none)]
239 pub unsafe fn indexOfItemWithRepresentedObject(&self, obj: Option<&AnyObject>)
240 -> NSInteger;
241
242 #[unsafe(method(indexOfItemWithTarget:andAction:))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn indexOfItemWithTarget_andAction(
245 &self,
246 target: Option<&AnyObject>,
247 action_selector: Option<Sel>,
248 ) -> NSInteger;
249
250 #[cfg(feature = "NSMenuItem")]
251 #[unsafe(method(itemAtIndex:))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn itemAtIndex(&self, index: NSInteger) -> Option<Retained<NSMenuItem>>;
254
255 #[cfg(feature = "NSMenuItem")]
256 #[unsafe(method(itemWithTitle:))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn itemWithTitle(&self, title: &NSString) -> Option<Retained<NSMenuItem>>;
259
260 #[cfg(feature = "NSMenuItem")]
261 #[unsafe(method(lastItem))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn lastItem(&self) -> Option<Retained<NSMenuItem>>;
264
265 #[cfg(feature = "NSMenuItem")]
266 #[unsafe(method(selectItem:))]
267 #[unsafe(method_family = none)]
268 pub unsafe fn selectItem(&self, item: Option<&NSMenuItem>);
269
270 #[unsafe(method(selectItemAtIndex:))]
271 #[unsafe(method_family = none)]
272 pub unsafe fn selectItemAtIndex(&self, index: NSInteger);
273
274 #[unsafe(method(selectItemWithTitle:))]
275 #[unsafe(method_family = none)]
276 pub unsafe fn selectItemWithTitle(&self, title: &NSString);
277
278 #[unsafe(method(selectItemWithTag:))]
279 #[unsafe(method_family = none)]
280 pub unsafe fn selectItemWithTag(&self, tag: NSInteger) -> bool;
281
282 #[unsafe(method(setTitle:))]
283 #[unsafe(method_family = none)]
284 pub unsafe fn setTitle(&self, string: Option<&NSString>);
285
286 #[cfg(feature = "NSMenuItem")]
287 #[unsafe(method(selectedItem))]
288 #[unsafe(method_family = none)]
289 pub unsafe fn selectedItem(&self) -> Option<Retained<NSMenuItem>>;
290
291 #[unsafe(method(indexOfSelectedItem))]
292 #[unsafe(method_family = none)]
293 pub unsafe fn indexOfSelectedItem(&self) -> NSInteger;
294
295 #[unsafe(method(synchronizeTitleAndSelectedItem))]
296 #[unsafe(method_family = none)]
297 pub unsafe fn synchronizeTitleAndSelectedItem(&self);
298
299 #[unsafe(method(itemTitleAtIndex:))]
300 #[unsafe(method_family = none)]
301 pub unsafe fn itemTitleAtIndex(&self, index: NSInteger) -> Retained<NSString>;
302
303 #[unsafe(method(itemTitles))]
304 #[unsafe(method_family = none)]
305 pub unsafe fn itemTitles(&self) -> Retained<NSArray<NSString>>;
306
307 #[unsafe(method(titleOfSelectedItem))]
308 #[unsafe(method_family = none)]
309 pub unsafe fn titleOfSelectedItem(&self) -> Option<Retained<NSString>>;
310
311 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
312 #[unsafe(method(attachPopUpWithFrame:inView:))]
313 #[unsafe(method_family = none)]
314 pub unsafe fn attachPopUpWithFrame_inView(&self, cell_frame: NSRect, control_view: &NSView);
315
316 #[unsafe(method(dismissPopUp))]
317 #[unsafe(method_family = none)]
318 pub unsafe fn dismissPopUp(&self);
319
320 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
321 #[unsafe(method(performClickWithFrame:inView:))]
322 #[unsafe(method_family = none)]
323 pub unsafe fn performClickWithFrame_inView(&self, frame: NSRect, control_view: &NSView);
324
325 #[unsafe(method(arrowPosition))]
326 #[unsafe(method_family = none)]
327 pub unsafe fn arrowPosition(&self) -> NSPopUpArrowPosition;
328
329 #[unsafe(method(setArrowPosition:))]
331 #[unsafe(method_family = none)]
332 pub unsafe fn setArrowPosition(&self, arrow_position: NSPopUpArrowPosition);
333 );
334}
335
336#[cfg(all(
338 feature = "NSActionCell",
339 feature = "NSButtonCell",
340 feature = "NSCell",
341 feature = "NSMenuItemCell"
342))]
343impl NSPopUpButtonCell {
344 extern_methods!(
345 #[unsafe(method(initTextCell:))]
346 #[unsafe(method_family = init)]
347 pub unsafe fn initTextCell(this: Allocated<Self>, string: &NSString) -> Retained<Self>;
348 );
349}
350
351#[cfg(all(
353 feature = "NSActionCell",
354 feature = "NSButtonCell",
355 feature = "NSCell",
356 feature = "NSMenuItemCell"
357))]
358impl NSPopUpButtonCell {
359 extern_methods!(
360 #[cfg(feature = "NSImage")]
361 #[unsafe(method(initImageCell:))]
362 #[unsafe(method_family = init)]
363 pub unsafe fn initImageCell(
364 this: Allocated<Self>,
365 image: Option<&NSImage>,
366 ) -> Retained<Self>;
367 );
368}
369
370#[cfg(all(
372 feature = "NSActionCell",
373 feature = "NSButtonCell",
374 feature = "NSCell",
375 feature = "NSMenuItemCell"
376))]
377impl NSPopUpButtonCell {
378 extern_methods!(
379 #[unsafe(method(init))]
380 #[unsafe(method_family = init)]
381 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
382 );
383}
384
385#[cfg(all(
387 feature = "NSActionCell",
388 feature = "NSButtonCell",
389 feature = "NSCell",
390 feature = "NSMenuItemCell"
391))]
392impl NSPopUpButtonCell {
393 extern_methods!(
394 #[unsafe(method(new))]
395 #[unsafe(method_family = new)]
396 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
397 );
398}
399
400extern "C" {
401 pub static NSPopUpButtonCellWillPopUpNotification: &'static NSNotificationName;
403}