1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11 #[unsafe(super(NSControl, NSView, NSResponder, NSObject))]
13 #[derive(Debug, PartialEq, Eq, Hash)]
14 #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
15 pub struct NSButton;
16);
17
18#[cfg(all(
19 feature = "NSAccessibilityProtocols",
20 feature = "NSControl",
21 feature = "NSResponder",
22 feature = "NSView"
23))]
24unsafe impl NSAccessibility for NSButton {}
25
26#[cfg(all(
27 feature = "NSAccessibilityProtocols",
28 feature = "NSControl",
29 feature = "NSResponder",
30 feature = "NSView"
31))]
32unsafe impl NSAccessibilityButton for NSButton {}
33
34#[cfg(all(
35 feature = "NSAccessibilityProtocols",
36 feature = "NSControl",
37 feature = "NSResponder",
38 feature = "NSView"
39))]
40unsafe impl NSAccessibilityElementProtocol for NSButton {}
41
42#[cfg(all(
43 feature = "NSAnimation",
44 feature = "NSControl",
45 feature = "NSResponder",
46 feature = "NSView"
47))]
48unsafe impl NSAnimatablePropertyContainer for NSButton {}
49
50#[cfg(all(
51 feature = "NSAppearance",
52 feature = "NSControl",
53 feature = "NSResponder",
54 feature = "NSView"
55))]
56unsafe impl NSAppearanceCustomization for NSButton {}
57
58#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
59unsafe impl NSCoding for NSButton {}
60
61#[cfg(all(
62 feature = "NSControl",
63 feature = "NSDragging",
64 feature = "NSResponder",
65 feature = "NSView"
66))]
67unsafe impl NSDraggingDestination for NSButton {}
68
69#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
70unsafe impl NSObjectProtocol for NSButton {}
71
72#[cfg(all(
73 feature = "NSControl",
74 feature = "NSResponder",
75 feature = "NSUserInterfaceCompression",
76 feature = "NSView"
77))]
78unsafe impl NSUserInterfaceCompression for NSButton {}
79
80#[cfg(all(
81 feature = "NSControl",
82 feature = "NSResponder",
83 feature = "NSUserInterfaceItemIdentification",
84 feature = "NSView"
85))]
86unsafe impl NSUserInterfaceItemIdentification for NSButton {}
87
88#[cfg(all(
89 feature = "NSControl",
90 feature = "NSResponder",
91 feature = "NSUserInterfaceValidation",
92 feature = "NSView"
93))]
94unsafe impl NSUserInterfaceValidations for NSButton {}
95
96#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
97impl NSButton {
98 extern_methods!(
99 #[cfg(feature = "NSImage")]
100 #[unsafe(method(buttonWithTitle:image:target:action:))]
112 #[unsafe(method_family = none)]
113 pub unsafe fn buttonWithTitle_image_target_action(
114 title: &NSString,
115 image: &NSImage,
116 target: Option<&AnyObject>,
117 action: Option<Sel>,
118 mtm: MainThreadMarker,
119 ) -> Retained<Self>;
120
121 #[unsafe(method(buttonWithTitle:target:action:))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn buttonWithTitle_target_action(
133 title: &NSString,
134 target: Option<&AnyObject>,
135 action: Option<Sel>,
136 mtm: MainThreadMarker,
137 ) -> Retained<Self>;
138
139 #[cfg(feature = "NSImage")]
140 #[unsafe(method(buttonWithImage:target:action:))]
150 #[unsafe(method_family = none)]
151 pub unsafe fn buttonWithImage_target_action(
152 image: &NSImage,
153 target: Option<&AnyObject>,
154 action: Option<Sel>,
155 mtm: MainThreadMarker,
156 ) -> Retained<Self>;
157
158 #[unsafe(method(checkboxWithTitle:target:action:))]
168 #[unsafe(method_family = none)]
169 pub unsafe fn checkboxWithTitle_target_action(
170 title: &NSString,
171 target: Option<&AnyObject>,
172 action: Option<Sel>,
173 mtm: MainThreadMarker,
174 ) -> Retained<Self>;
175
176 #[unsafe(method(radioButtonWithTitle:target:action:))]
186 #[unsafe(method_family = none)]
187 pub unsafe fn radioButtonWithTitle_target_action(
188 title: &NSString,
189 target: Option<&AnyObject>,
190 action: Option<Sel>,
191 mtm: MainThreadMarker,
192 ) -> Retained<Self>;
193
194 #[cfg(feature = "NSButtonCell")]
195 #[unsafe(method(setButtonType:))]
197 #[unsafe(method_family = none)]
198 pub unsafe fn setButtonType(&self, r#type: NSButtonType);
199
200 #[unsafe(method(title))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn title(&self) -> Retained<NSString>;
204
205 #[unsafe(method(setTitle:))]
207 #[unsafe(method_family = none)]
208 pub unsafe fn setTitle(&self, title: &NSString);
209
210 #[unsafe(method(attributedTitle))]
212 #[unsafe(method_family = none)]
213 pub unsafe fn attributedTitle(&self) -> Retained<NSAttributedString>;
214
215 #[unsafe(method(setAttributedTitle:))]
217 #[unsafe(method_family = none)]
218 pub unsafe fn setAttributedTitle(&self, attributed_title: &NSAttributedString);
219
220 #[unsafe(method(alternateTitle))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn alternateTitle(&self) -> Retained<NSString>;
224
225 #[unsafe(method(setAlternateTitle:))]
227 #[unsafe(method_family = none)]
228 pub unsafe fn setAlternateTitle(&self, alternate_title: &NSString);
229
230 #[unsafe(method(attributedAlternateTitle))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn attributedAlternateTitle(&self) -> Retained<NSAttributedString>;
234
235 #[unsafe(method(setAttributedAlternateTitle:))]
237 #[unsafe(method_family = none)]
238 pub unsafe fn setAttributedAlternateTitle(
239 &self,
240 attributed_alternate_title: &NSAttributedString,
241 );
242
243 #[unsafe(method(hasDestructiveAction))]
245 #[unsafe(method_family = none)]
246 pub unsafe fn hasDestructiveAction(&self) -> bool;
247
248 #[unsafe(method(setHasDestructiveAction:))]
250 #[unsafe(method_family = none)]
251 pub unsafe fn setHasDestructiveAction(&self, has_destructive_action: bool);
252
253 #[cfg(feature = "NSSound")]
254 #[unsafe(method(sound))]
256 #[unsafe(method_family = none)]
257 pub unsafe fn sound(&self) -> Option<Retained<NSSound>>;
258
259 #[cfg(feature = "NSSound")]
260 #[unsafe(method(setSound:))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn setSound(&self, sound: Option<&NSSound>);
264
265 #[unsafe(method(isSpringLoaded))]
267 #[unsafe(method_family = none)]
268 pub unsafe fn isSpringLoaded(&self) -> bool;
269
270 #[unsafe(method(setSpringLoaded:))]
272 #[unsafe(method_family = none)]
273 pub unsafe fn setSpringLoaded(&self, spring_loaded: bool);
274
275 #[unsafe(method(maxAcceleratorLevel))]
277 #[unsafe(method_family = none)]
278 pub unsafe fn maxAcceleratorLevel(&self) -> NSInteger;
279
280 #[unsafe(method(setMaxAcceleratorLevel:))]
282 #[unsafe(method_family = none)]
283 pub unsafe fn setMaxAcceleratorLevel(&self, max_accelerator_level: NSInteger);
284
285 #[unsafe(method(setPeriodicDelay:interval:))]
287 #[unsafe(method_family = none)]
288 pub unsafe fn setPeriodicDelay_interval(&self, delay: c_float, interval: c_float);
289
290 #[unsafe(method(getPeriodicDelay:interval:))]
292 #[unsafe(method_family = none)]
293 pub unsafe fn getPeriodicDelay_interval(
294 &self,
295 delay: NonNull<c_float>,
296 interval: NonNull<c_float>,
297 );
298
299 #[cfg(feature = "NSButtonCell")]
300 #[unsafe(method(bezelStyle))]
302 #[unsafe(method_family = none)]
303 pub unsafe fn bezelStyle(&self) -> NSBezelStyle;
304
305 #[cfg(feature = "NSButtonCell")]
306 #[unsafe(method(setBezelStyle:))]
308 #[unsafe(method_family = none)]
309 pub unsafe fn setBezelStyle(&self, bezel_style: NSBezelStyle);
310
311 #[unsafe(method(isBordered))]
313 #[unsafe(method_family = none)]
314 pub unsafe fn isBordered(&self) -> bool;
315
316 #[unsafe(method(setBordered:))]
318 #[unsafe(method_family = none)]
319 pub unsafe fn setBordered(&self, bordered: bool);
320
321 #[unsafe(method(isTransparent))]
323 #[unsafe(method_family = none)]
324 pub unsafe fn isTransparent(&self) -> bool;
325
326 #[unsafe(method(setTransparent:))]
328 #[unsafe(method_family = none)]
329 pub unsafe fn setTransparent(&self, transparent: bool);
330
331 #[unsafe(method(showsBorderOnlyWhileMouseInside))]
332 #[unsafe(method_family = none)]
333 pub unsafe fn showsBorderOnlyWhileMouseInside(&self) -> bool;
334
335 #[unsafe(method(setShowsBorderOnlyWhileMouseInside:))]
337 #[unsafe(method_family = none)]
338 pub unsafe fn setShowsBorderOnlyWhileMouseInside(
339 &self,
340 shows_border_only_while_mouse_inside: bool,
341 );
342
343 #[cfg(feature = "NSColor")]
344 #[unsafe(method(bezelColor))]
346 #[unsafe(method_family = none)]
347 pub unsafe fn bezelColor(&self) -> Option<Retained<NSColor>>;
348
349 #[cfg(feature = "NSColor")]
350 #[unsafe(method(setBezelColor:))]
352 #[unsafe(method_family = none)]
353 pub unsafe fn setBezelColor(&self, bezel_color: Option<&NSColor>);
354
355 #[cfg(feature = "NSColor")]
356 #[unsafe(method(contentTintColor))]
358 #[unsafe(method_family = none)]
359 pub unsafe fn contentTintColor(&self) -> Option<Retained<NSColor>>;
360
361 #[cfg(feature = "NSColor")]
362 #[unsafe(method(setContentTintColor:))]
364 #[unsafe(method_family = none)]
365 pub unsafe fn setContentTintColor(&self, content_tint_color: Option<&NSColor>);
366
367 #[cfg(feature = "NSImage")]
368 #[unsafe(method(image))]
370 #[unsafe(method_family = none)]
371 pub unsafe fn image(&self) -> Option<Retained<NSImage>>;
372
373 #[cfg(feature = "NSImage")]
374 #[unsafe(method(setImage:))]
376 #[unsafe(method_family = none)]
377 pub unsafe fn setImage(&self, image: Option<&NSImage>);
378
379 #[cfg(feature = "NSImage")]
380 #[unsafe(method(alternateImage))]
382 #[unsafe(method_family = none)]
383 pub unsafe fn alternateImage(&self) -> Option<Retained<NSImage>>;
384
385 #[cfg(feature = "NSImage")]
386 #[unsafe(method(setAlternateImage:))]
388 #[unsafe(method_family = none)]
389 pub unsafe fn setAlternateImage(&self, alternate_image: Option<&NSImage>);
390
391 #[cfg(feature = "NSCell")]
392 #[unsafe(method(imagePosition))]
394 #[unsafe(method_family = none)]
395 pub unsafe fn imagePosition(&self) -> NSCellImagePosition;
396
397 #[cfg(feature = "NSCell")]
398 #[unsafe(method(setImagePosition:))]
400 #[unsafe(method_family = none)]
401 pub unsafe fn setImagePosition(&self, image_position: NSCellImagePosition);
402
403 #[cfg(feature = "NSCell")]
404 #[unsafe(method(imageScaling))]
406 #[unsafe(method_family = none)]
407 pub unsafe fn imageScaling(&self) -> NSImageScaling;
408
409 #[cfg(feature = "NSCell")]
410 #[unsafe(method(setImageScaling:))]
412 #[unsafe(method_family = none)]
413 pub unsafe fn setImageScaling(&self, image_scaling: NSImageScaling);
414
415 #[unsafe(method(imageHugsTitle))]
417 #[unsafe(method_family = none)]
418 pub unsafe fn imageHugsTitle(&self) -> bool;
419
420 #[unsafe(method(setImageHugsTitle:))]
422 #[unsafe(method_family = none)]
423 pub unsafe fn setImageHugsTitle(&self, image_hugs_title: bool);
424
425 #[cfg(feature = "NSImage")]
426 #[unsafe(method(symbolConfiguration))]
428 #[unsafe(method_family = none)]
429 pub unsafe fn symbolConfiguration(&self) -> Option<Retained<NSImageSymbolConfiguration>>;
430
431 #[cfg(feature = "NSImage")]
432 #[unsafe(method(setSymbolConfiguration:))]
434 #[unsafe(method_family = none)]
435 pub unsafe fn setSymbolConfiguration(
436 &self,
437 symbol_configuration: Option<&NSImageSymbolConfiguration>,
438 );
439
440 #[cfg(feature = "NSCell")]
441 #[unsafe(method(state))]
443 #[unsafe(method_family = none)]
444 pub unsafe fn state(&self) -> NSControlStateValue;
445
446 #[cfg(feature = "NSCell")]
447 #[unsafe(method(setState:))]
449 #[unsafe(method_family = none)]
450 pub unsafe fn setState(&self, state: NSControlStateValue);
451
452 #[unsafe(method(allowsMixedState))]
454 #[unsafe(method_family = none)]
455 pub unsafe fn allowsMixedState(&self) -> bool;
456
457 #[unsafe(method(setAllowsMixedState:))]
459 #[unsafe(method_family = none)]
460 pub unsafe fn setAllowsMixedState(&self, allows_mixed_state: bool);
461
462 #[unsafe(method(setNextState))]
464 #[unsafe(method_family = none)]
465 pub unsafe fn setNextState(&self);
466
467 #[unsafe(method(highlight:))]
469 #[unsafe(method_family = none)]
470 pub unsafe fn highlight(&self, flag: bool);
471
472 #[unsafe(method(keyEquivalent))]
474 #[unsafe(method_family = none)]
475 pub unsafe fn keyEquivalent(&self) -> Retained<NSString>;
476
477 #[unsafe(method(setKeyEquivalent:))]
479 #[unsafe(method_family = none)]
480 pub unsafe fn setKeyEquivalent(&self, key_equivalent: &NSString);
481
482 #[cfg(feature = "NSEvent")]
483 #[unsafe(method(keyEquivalentModifierMask))]
485 #[unsafe(method_family = none)]
486 pub unsafe fn keyEquivalentModifierMask(&self) -> NSEventModifierFlags;
487
488 #[cfg(feature = "NSEvent")]
489 #[unsafe(method(setKeyEquivalentModifierMask:))]
491 #[unsafe(method_family = none)]
492 pub unsafe fn setKeyEquivalentModifierMask(
493 &self,
494 key_equivalent_modifier_mask: NSEventModifierFlags,
495 );
496
497 #[cfg(feature = "NSEvent")]
498 #[unsafe(method(performKeyEquivalent:))]
500 #[unsafe(method_family = none)]
501 pub unsafe fn performKeyEquivalent(&self, key: &NSEvent) -> bool;
502
503 #[cfg(feature = "NSUserInterfaceCompression")]
504 #[unsafe(method(compressWithPrioritizedCompressionOptions:))]
505 #[unsafe(method_family = none)]
506 pub unsafe fn compressWithPrioritizedCompressionOptions(
507 &self,
508 prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
509 );
510
511 #[cfg(feature = "NSUserInterfaceCompression")]
512 #[unsafe(method(minimumSizeWithPrioritizedCompressionOptions:))]
513 #[unsafe(method_family = none)]
514 pub unsafe fn minimumSizeWithPrioritizedCompressionOptions(
515 &self,
516 prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
517 ) -> NSSize;
518
519 #[cfg(feature = "NSUserInterfaceCompression")]
520 #[unsafe(method(activeCompressionOptions))]
521 #[unsafe(method_family = none)]
522 pub unsafe fn activeCompressionOptions(
523 &self,
524 ) -> Retained<NSUserInterfaceCompressionOptions>;
525 );
526}
527
528#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
530impl NSButton {
531 extern_methods!(
532 #[unsafe(method(initWithFrame:))]
533 #[unsafe(method_family = init)]
534 pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
535
536 #[unsafe(method(initWithCoder:))]
537 #[unsafe(method_family = init)]
538 pub unsafe fn initWithCoder(
539 this: Allocated<Self>,
540 coder: &NSCoder,
541 ) -> Option<Retained<Self>>;
542 );
543}
544
545#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
547impl NSButton {
548 extern_methods!(
549 #[unsafe(method(init))]
550 #[unsafe(method_family = init)]
551 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
552 );
553}
554
555#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
557impl NSButton {
558 extern_methods!(
559 #[unsafe(method(new))]
560 #[unsafe(method_family = new)]
561 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
562 );
563}
564
565#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
567impl NSButton {
568 extern_methods!(
569 #[deprecated = "Mnemonics are not used on macOS. Set the title property directly instead."]
570 #[unsafe(method(setTitleWithMnemonic:))]
571 #[unsafe(method_family = none)]
572 pub unsafe fn setTitleWithMnemonic(&self, string_with_ampersand: Option<&NSString>);
573 );
574}