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 unsafe fn initTextCell_pullsDown(
140 this: Allocated<Self>,
141 string_value: &NSString,
142 pull_down: bool,
143 ) -> Retained<Self>;
144
145 #[unsafe(method(initWithCoder:))]
146 #[unsafe(method_family = init)]
147 pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
148
149 #[cfg(feature = "NSMenu")]
150 #[unsafe(method(menu))]
151 #[unsafe(method_family = none)]
152 pub unsafe fn menu(&self) -> Option<Retained<NSMenu>>;
153
154 #[cfg(feature = "NSMenu")]
155 #[unsafe(method(setMenu:))]
157 #[unsafe(method_family = none)]
158 pub unsafe fn setMenu(&self, menu: Option<&NSMenu>);
159
160 #[unsafe(method(pullsDown))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn pullsDown(&self) -> bool;
163
164 #[unsafe(method(setPullsDown:))]
166 #[unsafe(method_family = none)]
167 pub unsafe fn setPullsDown(&self, pulls_down: bool);
168
169 #[unsafe(method(autoenablesItems))]
170 #[unsafe(method_family = none)]
171 pub unsafe fn autoenablesItems(&self) -> bool;
172
173 #[unsafe(method(setAutoenablesItems:))]
175 #[unsafe(method_family = none)]
176 pub unsafe fn setAutoenablesItems(&self, autoenables_items: bool);
177
178 #[unsafe(method(preferredEdge))]
179 #[unsafe(method_family = none)]
180 pub unsafe fn preferredEdge(&self) -> NSRectEdge;
181
182 #[unsafe(method(setPreferredEdge:))]
184 #[unsafe(method_family = none)]
185 pub unsafe fn setPreferredEdge(&self, preferred_edge: NSRectEdge);
186
187 #[unsafe(method(usesItemFromMenu))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn usesItemFromMenu(&self) -> bool;
190
191 #[unsafe(method(setUsesItemFromMenu:))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn setUsesItemFromMenu(&self, uses_item_from_menu: bool);
195
196 #[unsafe(method(altersStateOfSelectedItem))]
197 #[unsafe(method_family = none)]
198 pub unsafe fn altersStateOfSelectedItem(&self) -> bool;
199
200 #[unsafe(method(setAltersStateOfSelectedItem:))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn setAltersStateOfSelectedItem(&self, alters_state_of_selected_item: bool);
204
205 #[unsafe(method(addItemWithTitle:))]
206 #[unsafe(method_family = none)]
207 pub unsafe fn addItemWithTitle(&self, title: &NSString);
208
209 #[unsafe(method(addItemsWithTitles:))]
210 #[unsafe(method_family = none)]
211 pub unsafe fn addItemsWithTitles(&self, item_titles: &NSArray<NSString>);
212
213 #[unsafe(method(insertItemWithTitle:atIndex:))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn insertItemWithTitle_atIndex(&self, title: &NSString, index: NSInteger);
216
217 #[unsafe(method(removeItemWithTitle:))]
218 #[unsafe(method_family = none)]
219 pub unsafe fn removeItemWithTitle(&self, title: &NSString);
220
221 #[unsafe(method(removeItemAtIndex:))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn removeItemAtIndex(&self, index: NSInteger);
224
225 #[unsafe(method(removeAllItems))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn removeAllItems(&self);
228
229 #[cfg(feature = "NSMenuItem")]
230 #[unsafe(method(itemArray))]
231 #[unsafe(method_family = none)]
232 pub unsafe fn itemArray(&self) -> Retained<NSArray<NSMenuItem>>;
233
234 #[unsafe(method(numberOfItems))]
235 #[unsafe(method_family = none)]
236 pub unsafe fn numberOfItems(&self) -> NSInteger;
237
238 #[cfg(feature = "NSMenuItem")]
239 #[unsafe(method(indexOfItem:))]
240 #[unsafe(method_family = none)]
241 pub unsafe fn indexOfItem(&self, item: &NSMenuItem) -> NSInteger;
242
243 #[unsafe(method(indexOfItemWithTitle:))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn indexOfItemWithTitle(&self, title: &NSString) -> NSInteger;
246
247 #[unsafe(method(indexOfItemWithTag:))]
248 #[unsafe(method_family = none)]
249 pub unsafe fn indexOfItemWithTag(&self, tag: NSInteger) -> NSInteger;
250
251 #[unsafe(method(indexOfItemWithRepresentedObject:))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn indexOfItemWithRepresentedObject(&self, obj: Option<&AnyObject>)
254 -> NSInteger;
255
256 #[unsafe(method(indexOfItemWithTarget:andAction:))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn indexOfItemWithTarget_andAction(
259 &self,
260 target: Option<&AnyObject>,
261 action_selector: Option<Sel>,
262 ) -> NSInteger;
263
264 #[cfg(feature = "NSMenuItem")]
265 #[unsafe(method(itemAtIndex:))]
266 #[unsafe(method_family = none)]
267 pub unsafe fn itemAtIndex(&self, index: NSInteger) -> Option<Retained<NSMenuItem>>;
268
269 #[cfg(feature = "NSMenuItem")]
270 #[unsafe(method(itemWithTitle:))]
271 #[unsafe(method_family = none)]
272 pub unsafe fn itemWithTitle(&self, title: &NSString) -> Option<Retained<NSMenuItem>>;
273
274 #[cfg(feature = "NSMenuItem")]
275 #[unsafe(method(lastItem))]
276 #[unsafe(method_family = none)]
277 pub unsafe fn lastItem(&self) -> Option<Retained<NSMenuItem>>;
278
279 #[cfg(feature = "NSMenuItem")]
280 #[unsafe(method(selectItem:))]
281 #[unsafe(method_family = none)]
282 pub unsafe fn selectItem(&self, item: Option<&NSMenuItem>);
283
284 #[unsafe(method(selectItemAtIndex:))]
285 #[unsafe(method_family = none)]
286 pub unsafe fn selectItemAtIndex(&self, index: NSInteger);
287
288 #[unsafe(method(selectItemWithTitle:))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn selectItemWithTitle(&self, title: &NSString);
291
292 #[unsafe(method(selectItemWithTag:))]
293 #[unsafe(method_family = none)]
294 pub unsafe fn selectItemWithTag(&self, tag: NSInteger) -> bool;
295
296 #[unsafe(method(setTitle:))]
297 #[unsafe(method_family = none)]
298 pub unsafe fn setTitle(&self, string: Option<&NSString>);
299
300 #[cfg(feature = "NSMenuItem")]
301 #[unsafe(method(selectedItem))]
302 #[unsafe(method_family = none)]
303 pub unsafe fn selectedItem(&self) -> Option<Retained<NSMenuItem>>;
304
305 #[unsafe(method(indexOfSelectedItem))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn indexOfSelectedItem(&self) -> NSInteger;
308
309 #[unsafe(method(synchronizeTitleAndSelectedItem))]
310 #[unsafe(method_family = none)]
311 pub unsafe fn synchronizeTitleAndSelectedItem(&self);
312
313 #[unsafe(method(itemTitleAtIndex:))]
314 #[unsafe(method_family = none)]
315 pub unsafe fn itemTitleAtIndex(&self, index: NSInteger) -> Retained<NSString>;
316
317 #[unsafe(method(itemTitles))]
318 #[unsafe(method_family = none)]
319 pub unsafe fn itemTitles(&self) -> Retained<NSArray<NSString>>;
320
321 #[unsafe(method(titleOfSelectedItem))]
322 #[unsafe(method_family = none)]
323 pub unsafe fn titleOfSelectedItem(&self) -> Option<Retained<NSString>>;
324
325 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
326 #[unsafe(method(attachPopUpWithFrame:inView:))]
327 #[unsafe(method_family = none)]
328 pub unsafe fn attachPopUpWithFrame_inView(&self, cell_frame: NSRect, control_view: &NSView);
329
330 #[unsafe(method(dismissPopUp))]
331 #[unsafe(method_family = none)]
332 pub unsafe fn dismissPopUp(&self);
333
334 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
335 #[unsafe(method(performClickWithFrame:inView:))]
336 #[unsafe(method_family = none)]
337 pub unsafe fn performClickWithFrame_inView(&self, frame: NSRect, control_view: &NSView);
338
339 #[unsafe(method(arrowPosition))]
340 #[unsafe(method_family = none)]
341 pub unsafe fn arrowPosition(&self) -> NSPopUpArrowPosition;
342
343 #[unsafe(method(setArrowPosition:))]
345 #[unsafe(method_family = none)]
346 pub unsafe fn setArrowPosition(&self, arrow_position: NSPopUpArrowPosition);
347 );
348}
349
350#[cfg(all(
352 feature = "NSActionCell",
353 feature = "NSButtonCell",
354 feature = "NSCell",
355 feature = "NSMenuItemCell"
356))]
357impl NSPopUpButtonCell {
358 extern_methods!(
359 #[unsafe(method(initTextCell:))]
360 #[unsafe(method_family = init)]
361 pub unsafe fn initTextCell(this: Allocated<Self>, string: &NSString) -> Retained<Self>;
362 );
363}
364
365#[cfg(all(
367 feature = "NSActionCell",
368 feature = "NSButtonCell",
369 feature = "NSCell",
370 feature = "NSMenuItemCell"
371))]
372impl NSPopUpButtonCell {
373 extern_methods!(
374 #[cfg(feature = "NSImage")]
375 #[unsafe(method(initImageCell:))]
376 #[unsafe(method_family = init)]
377 pub unsafe fn initImageCell(
378 this: Allocated<Self>,
379 image: Option<&NSImage>,
380 ) -> Retained<Self>;
381 );
382}
383
384#[cfg(all(
386 feature = "NSActionCell",
387 feature = "NSButtonCell",
388 feature = "NSCell",
389 feature = "NSMenuItemCell"
390))]
391impl NSPopUpButtonCell {
392 extern_methods!(
393 #[unsafe(method(init))]
394 #[unsafe(method_family = init)]
395 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
396 );
397}
398
399#[cfg(all(
401 feature = "NSActionCell",
402 feature = "NSButtonCell",
403 feature = "NSCell",
404 feature = "NSMenuItemCell"
405))]
406impl NSPopUpButtonCell {
407 extern_methods!(
408 #[unsafe(method(new))]
409 #[unsafe(method_family = new)]
410 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
411 );
412}
413
414extern "C" {
415 pub static NSPopUpButtonCellWillPopUpNotification: &'static NSNotificationName;
417}