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))]
52extern_conformance!(
53 unsafe impl NSAccessibility for NSPopUpButtonCell {}
54);
55
56#[cfg(all(
57 feature = "NSAccessibilityProtocols",
58 feature = "NSActionCell",
59 feature = "NSButtonCell",
60 feature = "NSCell",
61 feature = "NSMenuItemCell"
62))]
63extern_conformance!(
64 unsafe impl NSAccessibilityElementProtocol for NSPopUpButtonCell {}
65);
66
67#[cfg(all(
68 feature = "NSActionCell",
69 feature = "NSButtonCell",
70 feature = "NSCell",
71 feature = "NSMenuItemCell"
72))]
73extern_conformance!(
74 unsafe impl NSCoding for NSPopUpButtonCell {}
75);
76
77#[cfg(all(
78 feature = "NSActionCell",
79 feature = "NSButtonCell",
80 feature = "NSCell",
81 feature = "NSMenuItemCell"
82))]
83extern_conformance!(
84 unsafe impl NSCopying for NSPopUpButtonCell {}
85);
86
87#[cfg(all(
88 feature = "NSActionCell",
89 feature = "NSButtonCell",
90 feature = "NSCell",
91 feature = "NSMenuItemCell"
92))]
93unsafe impl CopyingHelper for NSPopUpButtonCell {
94 type Result = Self;
95}
96
97#[cfg(all(
98 feature = "NSActionCell",
99 feature = "NSButtonCell",
100 feature = "NSCell",
101 feature = "NSMenu",
102 feature = "NSMenuItemCell"
103))]
104extern_conformance!(
105 unsafe impl NSMenuItemValidation for NSPopUpButtonCell {}
106);
107
108#[cfg(all(
109 feature = "NSActionCell",
110 feature = "NSButtonCell",
111 feature = "NSCell",
112 feature = "NSMenuItemCell"
113))]
114extern_conformance!(
115 unsafe impl NSObjectProtocol for NSPopUpButtonCell {}
116);
117
118#[cfg(all(
119 feature = "NSActionCell",
120 feature = "NSButtonCell",
121 feature = "NSCell",
122 feature = "NSMenuItemCell",
123 feature = "NSUserInterfaceItemIdentification"
124))]
125extern_conformance!(
126 unsafe impl NSUserInterfaceItemIdentification for NSPopUpButtonCell {}
127);
128
129#[cfg(all(
130 feature = "NSActionCell",
131 feature = "NSButtonCell",
132 feature = "NSCell",
133 feature = "NSMenuItemCell"
134))]
135impl NSPopUpButtonCell {
136 extern_methods!(
137 #[unsafe(method(initTextCell:pullsDown:))]
138 #[unsafe(method_family = init)]
139 pub fn initTextCell_pullsDown(
140 this: Allocated<Self>,
141 string_value: &NSString,
142 pull_down: bool,
143 ) -> Retained<Self>;
144
145 #[unsafe(method(initWithCoder:))]
149 #[unsafe(method_family = init)]
150 pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
151
152 #[cfg(feature = "NSMenu")]
153 #[unsafe(method(menu))]
154 #[unsafe(method_family = none)]
155 pub fn menu(&self) -> Option<Retained<NSMenu>>;
156
157 #[cfg(feature = "NSMenu")]
158 #[unsafe(method(setMenu:))]
160 #[unsafe(method_family = none)]
161 pub fn setMenu(&self, menu: Option<&NSMenu>);
162
163 #[unsafe(method(pullsDown))]
164 #[unsafe(method_family = none)]
165 pub fn pullsDown(&self) -> bool;
166
167 #[unsafe(method(setPullsDown:))]
169 #[unsafe(method_family = none)]
170 pub fn setPullsDown(&self, pulls_down: bool);
171
172 #[unsafe(method(autoenablesItems))]
173 #[unsafe(method_family = none)]
174 pub fn autoenablesItems(&self) -> bool;
175
176 #[unsafe(method(setAutoenablesItems:))]
178 #[unsafe(method_family = none)]
179 pub fn setAutoenablesItems(&self, autoenables_items: bool);
180
181 #[unsafe(method(preferredEdge))]
182 #[unsafe(method_family = none)]
183 pub fn preferredEdge(&self) -> NSRectEdge;
184
185 #[unsafe(method(setPreferredEdge:))]
187 #[unsafe(method_family = none)]
188 pub fn setPreferredEdge(&self, preferred_edge: NSRectEdge);
189
190 #[unsafe(method(usesItemFromMenu))]
191 #[unsafe(method_family = none)]
192 pub fn usesItemFromMenu(&self) -> bool;
193
194 #[unsafe(method(setUsesItemFromMenu:))]
196 #[unsafe(method_family = none)]
197 pub fn setUsesItemFromMenu(&self, uses_item_from_menu: bool);
198
199 #[unsafe(method(altersStateOfSelectedItem))]
200 #[unsafe(method_family = none)]
201 pub fn altersStateOfSelectedItem(&self) -> bool;
202
203 #[unsafe(method(setAltersStateOfSelectedItem:))]
205 #[unsafe(method_family = none)]
206 pub fn setAltersStateOfSelectedItem(&self, alters_state_of_selected_item: bool);
207
208 #[unsafe(method(addItemWithTitle:))]
209 #[unsafe(method_family = none)]
210 pub fn addItemWithTitle(&self, title: &NSString);
211
212 #[unsafe(method(addItemsWithTitles:))]
213 #[unsafe(method_family = none)]
214 pub fn addItemsWithTitles(&self, item_titles: &NSArray<NSString>);
215
216 #[unsafe(method(insertItemWithTitle:atIndex:))]
217 #[unsafe(method_family = none)]
218 pub fn insertItemWithTitle_atIndex(&self, title: &NSString, index: NSInteger);
219
220 #[unsafe(method(removeItemWithTitle:))]
221 #[unsafe(method_family = none)]
222 pub fn removeItemWithTitle(&self, title: &NSString);
223
224 #[unsafe(method(removeItemAtIndex:))]
225 #[unsafe(method_family = none)]
226 pub fn removeItemAtIndex(&self, index: NSInteger);
227
228 #[unsafe(method(removeAllItems))]
229 #[unsafe(method_family = none)]
230 pub fn removeAllItems(&self);
231
232 #[cfg(feature = "NSMenuItem")]
233 #[unsafe(method(itemArray))]
234 #[unsafe(method_family = none)]
235 pub fn itemArray(&self) -> Retained<NSArray<NSMenuItem>>;
236
237 #[unsafe(method(numberOfItems))]
238 #[unsafe(method_family = none)]
239 pub fn numberOfItems(&self) -> NSInteger;
240
241 #[cfg(feature = "NSMenuItem")]
242 #[unsafe(method(indexOfItem:))]
243 #[unsafe(method_family = none)]
244 pub fn indexOfItem(&self, item: &NSMenuItem) -> NSInteger;
245
246 #[unsafe(method(indexOfItemWithTitle:))]
247 #[unsafe(method_family = none)]
248 pub fn indexOfItemWithTitle(&self, title: &NSString) -> NSInteger;
249
250 #[unsafe(method(indexOfItemWithTag:))]
251 #[unsafe(method_family = none)]
252 pub fn indexOfItemWithTag(&self, tag: NSInteger) -> NSInteger;
253
254 #[unsafe(method(indexOfItemWithRepresentedObject:))]
258 #[unsafe(method_family = none)]
259 pub unsafe fn indexOfItemWithRepresentedObject(&self, obj: Option<&AnyObject>)
260 -> NSInteger;
261
262 #[unsafe(method(indexOfItemWithTarget:andAction:))]
267 #[unsafe(method_family = none)]
268 pub unsafe fn indexOfItemWithTarget_andAction(
269 &self,
270 target: Option<&AnyObject>,
271 action_selector: Option<Sel>,
272 ) -> NSInteger;
273
274 #[cfg(feature = "NSMenuItem")]
275 #[unsafe(method(itemAtIndex:))]
276 #[unsafe(method_family = none)]
277 pub fn itemAtIndex(&self, index: NSInteger) -> Option<Retained<NSMenuItem>>;
278
279 #[cfg(feature = "NSMenuItem")]
280 #[unsafe(method(itemWithTitle:))]
281 #[unsafe(method_family = none)]
282 pub fn itemWithTitle(&self, title: &NSString) -> Option<Retained<NSMenuItem>>;
283
284 #[cfg(feature = "NSMenuItem")]
285 #[unsafe(method(lastItem))]
286 #[unsafe(method_family = none)]
287 pub fn lastItem(&self) -> Option<Retained<NSMenuItem>>;
288
289 #[cfg(feature = "NSMenuItem")]
290 #[unsafe(method(selectItem:))]
291 #[unsafe(method_family = none)]
292 pub fn selectItem(&self, item: Option<&NSMenuItem>);
293
294 #[unsafe(method(selectItemAtIndex:))]
295 #[unsafe(method_family = none)]
296 pub fn selectItemAtIndex(&self, index: NSInteger);
297
298 #[unsafe(method(selectItemWithTitle:))]
299 #[unsafe(method_family = none)]
300 pub fn selectItemWithTitle(&self, title: &NSString);
301
302 #[unsafe(method(selectItemWithTag:))]
303 #[unsafe(method_family = none)]
304 pub fn selectItemWithTag(&self, tag: NSInteger) -> bool;
305
306 #[unsafe(method(setTitle:))]
307 #[unsafe(method_family = none)]
308 pub fn setTitle(&self, string: Option<&NSString>);
309
310 #[cfg(feature = "NSMenuItem")]
311 #[unsafe(method(selectedItem))]
312 #[unsafe(method_family = none)]
313 pub fn selectedItem(&self) -> Option<Retained<NSMenuItem>>;
314
315 #[unsafe(method(indexOfSelectedItem))]
316 #[unsafe(method_family = none)]
317 pub fn indexOfSelectedItem(&self) -> NSInteger;
318
319 #[unsafe(method(synchronizeTitleAndSelectedItem))]
320 #[unsafe(method_family = none)]
321 pub fn synchronizeTitleAndSelectedItem(&self);
322
323 #[unsafe(method(itemTitleAtIndex:))]
324 #[unsafe(method_family = none)]
325 pub fn itemTitleAtIndex(&self, index: NSInteger) -> Retained<NSString>;
326
327 #[unsafe(method(itemTitles))]
328 #[unsafe(method_family = none)]
329 pub fn itemTitles(&self) -> Retained<NSArray<NSString>>;
330
331 #[unsafe(method(titleOfSelectedItem))]
332 #[unsafe(method_family = none)]
333 pub fn titleOfSelectedItem(&self) -> Option<Retained<NSString>>;
334
335 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
336 #[unsafe(method(attachPopUpWithFrame:inView:))]
337 #[unsafe(method_family = none)]
338 pub fn attachPopUpWithFrame_inView(&self, cell_frame: NSRect, control_view: &NSView);
339
340 #[unsafe(method(dismissPopUp))]
341 #[unsafe(method_family = none)]
342 pub fn dismissPopUp(&self);
343
344 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
345 #[unsafe(method(performClickWithFrame:inView:))]
346 #[unsafe(method_family = none)]
347 pub fn performClickWithFrame_inView(&self, frame: NSRect, control_view: &NSView);
348
349 #[unsafe(method(arrowPosition))]
350 #[unsafe(method_family = none)]
351 pub fn arrowPosition(&self) -> NSPopUpArrowPosition;
352
353 #[unsafe(method(setArrowPosition:))]
355 #[unsafe(method_family = none)]
356 pub fn setArrowPosition(&self, arrow_position: NSPopUpArrowPosition);
357 );
358}
359
360#[cfg(all(
362 feature = "NSActionCell",
363 feature = "NSButtonCell",
364 feature = "NSCell",
365 feature = "NSMenuItemCell"
366))]
367impl NSPopUpButtonCell {
368 extern_methods!(
369 #[unsafe(method(initTextCell:))]
370 #[unsafe(method_family = init)]
371 pub fn initTextCell(this: Allocated<Self>, string: &NSString) -> Retained<Self>;
372 );
373}
374
375#[cfg(all(
377 feature = "NSActionCell",
378 feature = "NSButtonCell",
379 feature = "NSCell",
380 feature = "NSMenuItemCell"
381))]
382impl NSPopUpButtonCell {
383 extern_methods!(
384 #[cfg(feature = "NSImage")]
385 #[unsafe(method(initImageCell:))]
386 #[unsafe(method_family = init)]
387 pub fn initImageCell(this: Allocated<Self>, image: Option<&NSImage>) -> Retained<Self>;
388 );
389}
390
391#[cfg(all(
393 feature = "NSActionCell",
394 feature = "NSButtonCell",
395 feature = "NSCell",
396 feature = "NSMenuItemCell"
397))]
398impl NSPopUpButtonCell {
399 extern_methods!(
400 #[unsafe(method(init))]
401 #[unsafe(method_family = init)]
402 pub fn init(this: Allocated<Self>) -> Retained<Self>;
403 );
404}
405
406#[cfg(all(
408 feature = "NSActionCell",
409 feature = "NSButtonCell",
410 feature = "NSCell",
411 feature = "NSMenuItemCell"
412))]
413impl NSPopUpButtonCell {
414 extern_methods!(
415 #[unsafe(method(new))]
416 #[unsafe(method_family = new)]
417 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
418 );
419}
420
421extern "C" {
422 pub static NSPopUpButtonCellWillPopUpNotification: &'static NSNotificationName;
424}