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))]
24extern_conformance!(
25 unsafe impl NSAccessibility for NSButton {}
26);
27
28#[cfg(all(
29 feature = "NSAccessibilityProtocols",
30 feature = "NSControl",
31 feature = "NSResponder",
32 feature = "NSView"
33))]
34extern_conformance!(
35 unsafe impl NSAccessibilityButton for NSButton {}
36);
37
38#[cfg(all(
39 feature = "NSAccessibilityProtocols",
40 feature = "NSControl",
41 feature = "NSResponder",
42 feature = "NSView"
43))]
44extern_conformance!(
45 unsafe impl NSAccessibilityElementProtocol for NSButton {}
46);
47
48#[cfg(all(
49 feature = "NSAnimation",
50 feature = "NSControl",
51 feature = "NSResponder",
52 feature = "NSView"
53))]
54extern_conformance!(
55 unsafe impl NSAnimatablePropertyContainer for NSButton {}
56);
57
58#[cfg(all(
59 feature = "NSAppearance",
60 feature = "NSControl",
61 feature = "NSResponder",
62 feature = "NSView"
63))]
64extern_conformance!(
65 unsafe impl NSAppearanceCustomization for NSButton {}
66);
67
68#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
69extern_conformance!(
70 unsafe impl NSCoding for NSButton {}
71);
72
73#[cfg(all(
74 feature = "NSControl",
75 feature = "NSDragging",
76 feature = "NSResponder",
77 feature = "NSView"
78))]
79extern_conformance!(
80 unsafe impl NSDraggingDestination for NSButton {}
81);
82
83#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
84extern_conformance!(
85 unsafe impl NSObjectProtocol for NSButton {}
86);
87
88#[cfg(all(
89 feature = "NSControl",
90 feature = "NSResponder",
91 feature = "NSUserInterfaceCompression",
92 feature = "NSView"
93))]
94extern_conformance!(
95 unsafe impl NSUserInterfaceCompression for NSButton {}
96);
97
98#[cfg(all(
99 feature = "NSControl",
100 feature = "NSResponder",
101 feature = "NSUserInterfaceItemIdentification",
102 feature = "NSView"
103))]
104extern_conformance!(
105 unsafe impl NSUserInterfaceItemIdentification for NSButton {}
106);
107
108#[cfg(all(
109 feature = "NSControl",
110 feature = "NSResponder",
111 feature = "NSUserInterfaceValidation",
112 feature = "NSView"
113))]
114extern_conformance!(
115 unsafe impl NSUserInterfaceValidations for NSButton {}
116);
117
118#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
119impl NSButton {
120 extern_methods!(
121 #[cfg(feature = "NSImage")]
122 #[unsafe(method(buttonWithTitle:image:target:action:))]
139 #[unsafe(method_family = none)]
140 pub unsafe fn buttonWithTitle_image_target_action(
141 title: &NSString,
142 image: &NSImage,
143 target: Option<&AnyObject>,
144 action: Option<Sel>,
145 mtm: MainThreadMarker,
146 ) -> Retained<Self>;
147
148 #[unsafe(method(buttonWithTitle:target:action:))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn buttonWithTitle_target_action(
165 title: &NSString,
166 target: Option<&AnyObject>,
167 action: Option<Sel>,
168 mtm: MainThreadMarker,
169 ) -> Retained<Self>;
170
171 #[cfg(feature = "NSImage")]
172 #[unsafe(method(buttonWithImage:target:action:))]
187 #[unsafe(method_family = none)]
188 pub unsafe fn buttonWithImage_target_action(
189 image: &NSImage,
190 target: Option<&AnyObject>,
191 action: Option<Sel>,
192 mtm: MainThreadMarker,
193 ) -> Retained<Self>;
194
195 #[unsafe(method(checkboxWithTitle:target:action:))]
210 #[unsafe(method_family = none)]
211 pub unsafe fn checkboxWithTitle_target_action(
212 title: &NSString,
213 target: Option<&AnyObject>,
214 action: Option<Sel>,
215 mtm: MainThreadMarker,
216 ) -> Retained<Self>;
217
218 #[unsafe(method(radioButtonWithTitle:target:action:))]
233 #[unsafe(method_family = none)]
234 pub unsafe fn radioButtonWithTitle_target_action(
235 title: &NSString,
236 target: Option<&AnyObject>,
237 action: Option<Sel>,
238 mtm: MainThreadMarker,
239 ) -> Retained<Self>;
240
241 #[cfg(feature = "NSButtonCell")]
242 #[unsafe(method(setButtonType:))]
244 #[unsafe(method_family = none)]
245 pub fn setButtonType(&self, r#type: NSButtonType);
246
247 #[unsafe(method(title))]
249 #[unsafe(method_family = none)]
250 pub fn title(&self) -> Retained<NSString>;
251
252 #[unsafe(method(setTitle:))]
256 #[unsafe(method_family = none)]
257 pub fn setTitle(&self, title: &NSString);
258
259 #[unsafe(method(attributedTitle))]
261 #[unsafe(method_family = none)]
262 pub fn attributedTitle(&self) -> Retained<NSAttributedString>;
263
264 #[unsafe(method(setAttributedTitle:))]
268 #[unsafe(method_family = none)]
269 pub fn setAttributedTitle(&self, attributed_title: &NSAttributedString);
270
271 #[unsafe(method(alternateTitle))]
273 #[unsafe(method_family = none)]
274 pub fn alternateTitle(&self) -> Retained<NSString>;
275
276 #[unsafe(method(setAlternateTitle:))]
280 #[unsafe(method_family = none)]
281 pub fn setAlternateTitle(&self, alternate_title: &NSString);
282
283 #[unsafe(method(attributedAlternateTitle))]
285 #[unsafe(method_family = none)]
286 pub fn attributedAlternateTitle(&self) -> Retained<NSAttributedString>;
287
288 #[unsafe(method(setAttributedAlternateTitle:))]
292 #[unsafe(method_family = none)]
293 pub fn setAttributedAlternateTitle(&self, attributed_alternate_title: &NSAttributedString);
294
295 #[unsafe(method(hasDestructiveAction))]
297 #[unsafe(method_family = none)]
298 pub fn hasDestructiveAction(&self) -> bool;
299
300 #[unsafe(method(setHasDestructiveAction:))]
302 #[unsafe(method_family = none)]
303 pub fn setHasDestructiveAction(&self, has_destructive_action: bool);
304
305 #[cfg(feature = "NSSound")]
306 #[unsafe(method(sound))]
308 #[unsafe(method_family = none)]
309 pub fn sound(&self) -> Option<Retained<NSSound>>;
310
311 #[cfg(feature = "NSSound")]
312 #[unsafe(method(setSound:))]
314 #[unsafe(method_family = none)]
315 pub fn setSound(&self, sound: Option<&NSSound>);
316
317 #[unsafe(method(isSpringLoaded))]
319 #[unsafe(method_family = none)]
320 pub fn isSpringLoaded(&self) -> bool;
321
322 #[unsafe(method(setSpringLoaded:))]
324 #[unsafe(method_family = none)]
325 pub fn setSpringLoaded(&self, spring_loaded: bool);
326
327 #[unsafe(method(maxAcceleratorLevel))]
329 #[unsafe(method_family = none)]
330 pub fn maxAcceleratorLevel(&self) -> NSInteger;
331
332 #[unsafe(method(setMaxAcceleratorLevel:))]
334 #[unsafe(method_family = none)]
335 pub fn setMaxAcceleratorLevel(&self, max_accelerator_level: NSInteger);
336
337 #[unsafe(method(setPeriodicDelay:interval:))]
339 #[unsafe(method_family = none)]
340 pub fn setPeriodicDelay_interval(&self, delay: c_float, interval: c_float);
341
342 #[unsafe(method(getPeriodicDelay:interval:))]
349 #[unsafe(method_family = none)]
350 pub unsafe fn getPeriodicDelay_interval(
351 &self,
352 delay: NonNull<c_float>,
353 interval: NonNull<c_float>,
354 );
355
356 #[cfg(feature = "NSButtonCell")]
357 #[unsafe(method(bezelStyle))]
359 #[unsafe(method_family = none)]
360 pub fn bezelStyle(&self) -> NSBezelStyle;
361
362 #[cfg(feature = "NSButtonCell")]
363 #[unsafe(method(setBezelStyle:))]
365 #[unsafe(method_family = none)]
366 pub fn setBezelStyle(&self, bezel_style: NSBezelStyle);
367
368 #[unsafe(method(isBordered))]
370 #[unsafe(method_family = none)]
371 pub fn isBordered(&self) -> bool;
372
373 #[unsafe(method(setBordered:))]
375 #[unsafe(method_family = none)]
376 pub fn setBordered(&self, bordered: bool);
377
378 #[unsafe(method(isTransparent))]
380 #[unsafe(method_family = none)]
381 pub fn isTransparent(&self) -> bool;
382
383 #[unsafe(method(setTransparent:))]
385 #[unsafe(method_family = none)]
386 pub fn setTransparent(&self, transparent: bool);
387
388 #[unsafe(method(showsBorderOnlyWhileMouseInside))]
389 #[unsafe(method_family = none)]
390 pub fn showsBorderOnlyWhileMouseInside(&self) -> bool;
391
392 #[unsafe(method(setShowsBorderOnlyWhileMouseInside:))]
394 #[unsafe(method_family = none)]
395 pub fn setShowsBorderOnlyWhileMouseInside(
396 &self,
397 shows_border_only_while_mouse_inside: bool,
398 );
399
400 #[cfg(feature = "NSColor")]
401 #[unsafe(method(bezelColor))]
403 #[unsafe(method_family = none)]
404 pub fn bezelColor(&self) -> Option<Retained<NSColor>>;
405
406 #[cfg(feature = "NSColor")]
407 #[unsafe(method(setBezelColor:))]
411 #[unsafe(method_family = none)]
412 pub fn setBezelColor(&self, bezel_color: Option<&NSColor>);
413
414 #[cfg(feature = "NSColor")]
415 #[unsafe(method(contentTintColor))]
417 #[unsafe(method_family = none)]
418 pub fn contentTintColor(&self) -> Option<Retained<NSColor>>;
419
420 #[cfg(feature = "NSColor")]
421 #[unsafe(method(setContentTintColor:))]
425 #[unsafe(method_family = none)]
426 pub fn setContentTintColor(&self, content_tint_color: Option<&NSColor>);
427
428 #[cfg(feature = "NSTintProminence")]
429 #[unsafe(method(tintProminence))]
431 #[unsafe(method_family = none)]
432 pub fn tintProminence(&self) -> NSTintProminence;
433
434 #[cfg(feature = "NSTintProminence")]
435 #[unsafe(method(setTintProminence:))]
437 #[unsafe(method_family = none)]
438 pub fn setTintProminence(&self, tint_prominence: NSTintProminence);
439
440 #[cfg(feature = "NSImage")]
441 #[unsafe(method(image))]
443 #[unsafe(method_family = none)]
444 pub fn image(&self) -> Option<Retained<NSImage>>;
445
446 #[cfg(feature = "NSImage")]
447 #[unsafe(method(setImage:))]
449 #[unsafe(method_family = none)]
450 pub fn setImage(&self, image: Option<&NSImage>);
451
452 #[cfg(feature = "NSImage")]
453 #[unsafe(method(alternateImage))]
455 #[unsafe(method_family = none)]
456 pub fn alternateImage(&self) -> Option<Retained<NSImage>>;
457
458 #[cfg(feature = "NSImage")]
459 #[unsafe(method(setAlternateImage:))]
461 #[unsafe(method_family = none)]
462 pub fn setAlternateImage(&self, alternate_image: Option<&NSImage>);
463
464 #[cfg(feature = "NSCell")]
465 #[unsafe(method(imagePosition))]
467 #[unsafe(method_family = none)]
468 pub fn imagePosition(&self) -> NSCellImagePosition;
469
470 #[cfg(feature = "NSCell")]
471 #[unsafe(method(setImagePosition:))]
473 #[unsafe(method_family = none)]
474 pub fn setImagePosition(&self, image_position: NSCellImagePosition);
475
476 #[cfg(feature = "NSCell")]
477 #[unsafe(method(imageScaling))]
479 #[unsafe(method_family = none)]
480 pub fn imageScaling(&self) -> NSImageScaling;
481
482 #[cfg(feature = "NSCell")]
483 #[unsafe(method(setImageScaling:))]
485 #[unsafe(method_family = none)]
486 pub fn setImageScaling(&self, image_scaling: NSImageScaling);
487
488 #[unsafe(method(imageHugsTitle))]
490 #[unsafe(method_family = none)]
491 pub fn imageHugsTitle(&self) -> bool;
492
493 #[unsafe(method(setImageHugsTitle:))]
495 #[unsafe(method_family = none)]
496 pub fn setImageHugsTitle(&self, image_hugs_title: bool);
497
498 #[cfg(feature = "NSImage")]
499 #[unsafe(method(symbolConfiguration))]
501 #[unsafe(method_family = none)]
502 pub fn symbolConfiguration(&self) -> Option<Retained<NSImageSymbolConfiguration>>;
503
504 #[cfg(feature = "NSImage")]
505 #[unsafe(method(setSymbolConfiguration:))]
509 #[unsafe(method_family = none)]
510 pub fn setSymbolConfiguration(
511 &self,
512 symbol_configuration: Option<&NSImageSymbolConfiguration>,
513 );
514
515 #[cfg(feature = "NSCell")]
516 #[unsafe(method(state))]
518 #[unsafe(method_family = none)]
519 pub fn state(&self) -> NSControlStateValue;
520
521 #[cfg(feature = "NSCell")]
522 #[unsafe(method(setState:))]
524 #[unsafe(method_family = none)]
525 pub fn setState(&self, state: NSControlStateValue);
526
527 #[unsafe(method(allowsMixedState))]
529 #[unsafe(method_family = none)]
530 pub fn allowsMixedState(&self) -> bool;
531
532 #[unsafe(method(setAllowsMixedState:))]
534 #[unsafe(method_family = none)]
535 pub fn setAllowsMixedState(&self, allows_mixed_state: bool);
536
537 #[unsafe(method(setNextState))]
539 #[unsafe(method_family = none)]
540 pub fn setNextState(&self);
541
542 #[unsafe(method(highlight:))]
544 #[unsafe(method_family = none)]
545 pub fn highlight(&self, flag: bool);
546
547 #[unsafe(method(keyEquivalent))]
549 #[unsafe(method_family = none)]
550 pub fn keyEquivalent(&self) -> Retained<NSString>;
551
552 #[unsafe(method(setKeyEquivalent:))]
556 #[unsafe(method_family = none)]
557 pub fn setKeyEquivalent(&self, key_equivalent: &NSString);
558
559 #[cfg(feature = "NSEvent")]
560 #[unsafe(method(keyEquivalentModifierMask))]
562 #[unsafe(method_family = none)]
563 pub fn keyEquivalentModifierMask(&self) -> NSEventModifierFlags;
564
565 #[cfg(feature = "NSEvent")]
566 #[unsafe(method(setKeyEquivalentModifierMask:))]
568 #[unsafe(method_family = none)]
569 pub fn setKeyEquivalentModifierMask(
570 &self,
571 key_equivalent_modifier_mask: NSEventModifierFlags,
572 );
573
574 #[cfg(feature = "NSEvent")]
575 #[unsafe(method(performKeyEquivalent:))]
577 #[unsafe(method_family = none)]
578 pub fn performKeyEquivalent(&self, key: &NSEvent) -> bool;
579
580 #[cfg(feature = "NSUserInterfaceCompression")]
581 #[unsafe(method(compressWithPrioritizedCompressionOptions:))]
582 #[unsafe(method_family = none)]
583 pub fn compressWithPrioritizedCompressionOptions(
584 &self,
585 prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
586 );
587
588 #[cfg(feature = "NSUserInterfaceCompression")]
589 #[unsafe(method(minimumSizeWithPrioritizedCompressionOptions:))]
590 #[unsafe(method_family = none)]
591 pub fn minimumSizeWithPrioritizedCompressionOptions(
592 &self,
593 prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
594 ) -> NSSize;
595
596 #[cfg(feature = "NSUserInterfaceCompression")]
597 #[unsafe(method(activeCompressionOptions))]
598 #[unsafe(method_family = none)]
599 pub fn activeCompressionOptions(&self) -> Retained<NSUserInterfaceCompressionOptions>;
600
601 #[unsafe(method(borderShape))]
602 #[unsafe(method_family = none)]
603 pub fn borderShape(&self) -> NSControlBorderShape;
604
605 #[unsafe(method(setBorderShape:))]
607 #[unsafe(method_family = none)]
608 pub fn setBorderShape(&self, border_shape: NSControlBorderShape);
609 );
610}
611
612#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
614impl NSButton {
615 extern_methods!(
616 #[unsafe(method(initWithFrame:))]
617 #[unsafe(method_family = init)]
618 pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
619
620 #[unsafe(method(initWithCoder:))]
624 #[unsafe(method_family = init)]
625 pub unsafe fn initWithCoder(
626 this: Allocated<Self>,
627 coder: &NSCoder,
628 ) -> Option<Retained<Self>>;
629 );
630}
631
632#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
634impl NSButton {
635 extern_methods!(
636 #[unsafe(method(init))]
637 #[unsafe(method_family = init)]
638 pub fn init(this: Allocated<Self>) -> Retained<Self>;
639 );
640}
641
642#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
644impl NSButton {
645 extern_methods!(
646 #[unsafe(method(new))]
647 #[unsafe(method_family = new)]
648 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
649 );
650}
651
652#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
654impl NSButton {
655 extern_methods!(
656 #[deprecated = "Mnemonics are not used on macOS. Set the title property directly instead."]
660 #[unsafe(method(setTitleWithMnemonic:))]
661 #[unsafe(method_family = none)]
662 pub unsafe fn setTitleWithMnemonic(&self, string_with_ampersand: Option<&NSString>);
663 );
664}