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:))]
134 #[unsafe(method_family = none)]
135 pub unsafe fn buttonWithTitle_image_target_action(
136 title: &NSString,
137 image: &NSImage,
138 target: Option<&AnyObject>,
139 action: Option<Sel>,
140 mtm: MainThreadMarker,
141 ) -> Retained<Self>;
142
143 #[unsafe(method(buttonWithTitle:target:action:))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn buttonWithTitle_target_action(
155 title: &NSString,
156 target: Option<&AnyObject>,
157 action: Option<Sel>,
158 mtm: MainThreadMarker,
159 ) -> Retained<Self>;
160
161 #[cfg(feature = "NSImage")]
162 #[unsafe(method(buttonWithImage:target:action:))]
172 #[unsafe(method_family = none)]
173 pub unsafe fn buttonWithImage_target_action(
174 image: &NSImage,
175 target: Option<&AnyObject>,
176 action: Option<Sel>,
177 mtm: MainThreadMarker,
178 ) -> Retained<Self>;
179
180 #[unsafe(method(checkboxWithTitle:target:action:))]
190 #[unsafe(method_family = none)]
191 pub unsafe fn checkboxWithTitle_target_action(
192 title: &NSString,
193 target: Option<&AnyObject>,
194 action: Option<Sel>,
195 mtm: MainThreadMarker,
196 ) -> Retained<Self>;
197
198 #[unsafe(method(radioButtonWithTitle:target:action:))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn radioButtonWithTitle_target_action(
210 title: &NSString,
211 target: Option<&AnyObject>,
212 action: Option<Sel>,
213 mtm: MainThreadMarker,
214 ) -> Retained<Self>;
215
216 #[cfg(feature = "NSButtonCell")]
217 #[unsafe(method(setButtonType:))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn setButtonType(&self, r#type: NSButtonType);
221
222 #[unsafe(method(title))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn title(&self) -> Retained<NSString>;
226
227 #[unsafe(method(setTitle:))]
229 #[unsafe(method_family = none)]
230 pub unsafe fn setTitle(&self, title: &NSString);
231
232 #[unsafe(method(attributedTitle))]
234 #[unsafe(method_family = none)]
235 pub unsafe fn attributedTitle(&self) -> Retained<NSAttributedString>;
236
237 #[unsafe(method(setAttributedTitle:))]
239 #[unsafe(method_family = none)]
240 pub unsafe fn setAttributedTitle(&self, attributed_title: &NSAttributedString);
241
242 #[unsafe(method(alternateTitle))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn alternateTitle(&self) -> Retained<NSString>;
246
247 #[unsafe(method(setAlternateTitle:))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn setAlternateTitle(&self, alternate_title: &NSString);
251
252 #[unsafe(method(attributedAlternateTitle))]
254 #[unsafe(method_family = none)]
255 pub unsafe fn attributedAlternateTitle(&self) -> Retained<NSAttributedString>;
256
257 #[unsafe(method(setAttributedAlternateTitle:))]
259 #[unsafe(method_family = none)]
260 pub unsafe fn setAttributedAlternateTitle(
261 &self,
262 attributed_alternate_title: &NSAttributedString,
263 );
264
265 #[unsafe(method(hasDestructiveAction))]
267 #[unsafe(method_family = none)]
268 pub unsafe fn hasDestructiveAction(&self) -> bool;
269
270 #[unsafe(method(setHasDestructiveAction:))]
272 #[unsafe(method_family = none)]
273 pub unsafe fn setHasDestructiveAction(&self, has_destructive_action: bool);
274
275 #[cfg(feature = "NSSound")]
276 #[unsafe(method(sound))]
278 #[unsafe(method_family = none)]
279 pub unsafe fn sound(&self) -> Option<Retained<NSSound>>;
280
281 #[cfg(feature = "NSSound")]
282 #[unsafe(method(setSound:))]
284 #[unsafe(method_family = none)]
285 pub unsafe fn setSound(&self, sound: Option<&NSSound>);
286
287 #[unsafe(method(isSpringLoaded))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn isSpringLoaded(&self) -> bool;
291
292 #[unsafe(method(setSpringLoaded:))]
294 #[unsafe(method_family = none)]
295 pub unsafe fn setSpringLoaded(&self, spring_loaded: bool);
296
297 #[unsafe(method(maxAcceleratorLevel))]
299 #[unsafe(method_family = none)]
300 pub unsafe fn maxAcceleratorLevel(&self) -> NSInteger;
301
302 #[unsafe(method(setMaxAcceleratorLevel:))]
304 #[unsafe(method_family = none)]
305 pub unsafe fn setMaxAcceleratorLevel(&self, max_accelerator_level: NSInteger);
306
307 #[unsafe(method(setPeriodicDelay:interval:))]
309 #[unsafe(method_family = none)]
310 pub unsafe fn setPeriodicDelay_interval(&self, delay: c_float, interval: c_float);
311
312 #[unsafe(method(getPeriodicDelay:interval:))]
314 #[unsafe(method_family = none)]
315 pub unsafe fn getPeriodicDelay_interval(
316 &self,
317 delay: NonNull<c_float>,
318 interval: NonNull<c_float>,
319 );
320
321 #[cfg(feature = "NSButtonCell")]
322 #[unsafe(method(bezelStyle))]
324 #[unsafe(method_family = none)]
325 pub unsafe fn bezelStyle(&self) -> NSBezelStyle;
326
327 #[cfg(feature = "NSButtonCell")]
328 #[unsafe(method(setBezelStyle:))]
330 #[unsafe(method_family = none)]
331 pub unsafe fn setBezelStyle(&self, bezel_style: NSBezelStyle);
332
333 #[unsafe(method(isBordered))]
335 #[unsafe(method_family = none)]
336 pub unsafe fn isBordered(&self) -> bool;
337
338 #[unsafe(method(setBordered:))]
340 #[unsafe(method_family = none)]
341 pub unsafe fn setBordered(&self, bordered: bool);
342
343 #[unsafe(method(isTransparent))]
345 #[unsafe(method_family = none)]
346 pub unsafe fn isTransparent(&self) -> bool;
347
348 #[unsafe(method(setTransparent:))]
350 #[unsafe(method_family = none)]
351 pub unsafe fn setTransparent(&self, transparent: bool);
352
353 #[unsafe(method(showsBorderOnlyWhileMouseInside))]
354 #[unsafe(method_family = none)]
355 pub unsafe fn showsBorderOnlyWhileMouseInside(&self) -> bool;
356
357 #[unsafe(method(setShowsBorderOnlyWhileMouseInside:))]
359 #[unsafe(method_family = none)]
360 pub unsafe fn setShowsBorderOnlyWhileMouseInside(
361 &self,
362 shows_border_only_while_mouse_inside: bool,
363 );
364
365 #[cfg(feature = "NSColor")]
366 #[unsafe(method(bezelColor))]
368 #[unsafe(method_family = none)]
369 pub unsafe fn bezelColor(&self) -> Option<Retained<NSColor>>;
370
371 #[cfg(feature = "NSColor")]
372 #[unsafe(method(setBezelColor:))]
374 #[unsafe(method_family = none)]
375 pub unsafe fn setBezelColor(&self, bezel_color: Option<&NSColor>);
376
377 #[cfg(feature = "NSColor")]
378 #[unsafe(method(contentTintColor))]
380 #[unsafe(method_family = none)]
381 pub unsafe fn contentTintColor(&self) -> Option<Retained<NSColor>>;
382
383 #[cfg(feature = "NSColor")]
384 #[unsafe(method(setContentTintColor:))]
386 #[unsafe(method_family = none)]
387 pub unsafe fn setContentTintColor(&self, content_tint_color: Option<&NSColor>);
388
389 #[cfg(feature = "NSImage")]
390 #[unsafe(method(image))]
392 #[unsafe(method_family = none)]
393 pub unsafe fn image(&self) -> Option<Retained<NSImage>>;
394
395 #[cfg(feature = "NSImage")]
396 #[unsafe(method(setImage:))]
398 #[unsafe(method_family = none)]
399 pub unsafe fn setImage(&self, image: Option<&NSImage>);
400
401 #[cfg(feature = "NSImage")]
402 #[unsafe(method(alternateImage))]
404 #[unsafe(method_family = none)]
405 pub unsafe fn alternateImage(&self) -> Option<Retained<NSImage>>;
406
407 #[cfg(feature = "NSImage")]
408 #[unsafe(method(setAlternateImage:))]
410 #[unsafe(method_family = none)]
411 pub unsafe fn setAlternateImage(&self, alternate_image: Option<&NSImage>);
412
413 #[cfg(feature = "NSCell")]
414 #[unsafe(method(imagePosition))]
416 #[unsafe(method_family = none)]
417 pub unsafe fn imagePosition(&self) -> NSCellImagePosition;
418
419 #[cfg(feature = "NSCell")]
420 #[unsafe(method(setImagePosition:))]
422 #[unsafe(method_family = none)]
423 pub unsafe fn setImagePosition(&self, image_position: NSCellImagePosition);
424
425 #[cfg(feature = "NSCell")]
426 #[unsafe(method(imageScaling))]
428 #[unsafe(method_family = none)]
429 pub unsafe fn imageScaling(&self) -> NSImageScaling;
430
431 #[cfg(feature = "NSCell")]
432 #[unsafe(method(setImageScaling:))]
434 #[unsafe(method_family = none)]
435 pub unsafe fn setImageScaling(&self, image_scaling: NSImageScaling);
436
437 #[unsafe(method(imageHugsTitle))]
439 #[unsafe(method_family = none)]
440 pub unsafe fn imageHugsTitle(&self) -> bool;
441
442 #[unsafe(method(setImageHugsTitle:))]
444 #[unsafe(method_family = none)]
445 pub unsafe fn setImageHugsTitle(&self, image_hugs_title: bool);
446
447 #[cfg(feature = "NSImage")]
448 #[unsafe(method(symbolConfiguration))]
450 #[unsafe(method_family = none)]
451 pub unsafe fn symbolConfiguration(&self) -> Option<Retained<NSImageSymbolConfiguration>>;
452
453 #[cfg(feature = "NSImage")]
454 #[unsafe(method(setSymbolConfiguration:))]
456 #[unsafe(method_family = none)]
457 pub unsafe fn setSymbolConfiguration(
458 &self,
459 symbol_configuration: Option<&NSImageSymbolConfiguration>,
460 );
461
462 #[cfg(feature = "NSCell")]
463 #[unsafe(method(state))]
465 #[unsafe(method_family = none)]
466 pub unsafe fn state(&self) -> NSControlStateValue;
467
468 #[cfg(feature = "NSCell")]
469 #[unsafe(method(setState:))]
471 #[unsafe(method_family = none)]
472 pub unsafe fn setState(&self, state: NSControlStateValue);
473
474 #[unsafe(method(allowsMixedState))]
476 #[unsafe(method_family = none)]
477 pub unsafe fn allowsMixedState(&self) -> bool;
478
479 #[unsafe(method(setAllowsMixedState:))]
481 #[unsafe(method_family = none)]
482 pub unsafe fn setAllowsMixedState(&self, allows_mixed_state: bool);
483
484 #[unsafe(method(setNextState))]
486 #[unsafe(method_family = none)]
487 pub unsafe fn setNextState(&self);
488
489 #[unsafe(method(highlight:))]
491 #[unsafe(method_family = none)]
492 pub unsafe fn highlight(&self, flag: bool);
493
494 #[unsafe(method(keyEquivalent))]
496 #[unsafe(method_family = none)]
497 pub unsafe fn keyEquivalent(&self) -> Retained<NSString>;
498
499 #[unsafe(method(setKeyEquivalent:))]
501 #[unsafe(method_family = none)]
502 pub unsafe fn setKeyEquivalent(&self, key_equivalent: &NSString);
503
504 #[cfg(feature = "NSEvent")]
505 #[unsafe(method(keyEquivalentModifierMask))]
507 #[unsafe(method_family = none)]
508 pub unsafe fn keyEquivalentModifierMask(&self) -> NSEventModifierFlags;
509
510 #[cfg(feature = "NSEvent")]
511 #[unsafe(method(setKeyEquivalentModifierMask:))]
513 #[unsafe(method_family = none)]
514 pub unsafe fn setKeyEquivalentModifierMask(
515 &self,
516 key_equivalent_modifier_mask: NSEventModifierFlags,
517 );
518
519 #[cfg(feature = "NSEvent")]
520 #[unsafe(method(performKeyEquivalent:))]
522 #[unsafe(method_family = none)]
523 pub unsafe fn performKeyEquivalent(&self, key: &NSEvent) -> bool;
524
525 #[cfg(feature = "NSUserInterfaceCompression")]
526 #[unsafe(method(compressWithPrioritizedCompressionOptions:))]
527 #[unsafe(method_family = none)]
528 pub unsafe fn compressWithPrioritizedCompressionOptions(
529 &self,
530 prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
531 );
532
533 #[cfg(feature = "NSUserInterfaceCompression")]
534 #[unsafe(method(minimumSizeWithPrioritizedCompressionOptions:))]
535 #[unsafe(method_family = none)]
536 pub unsafe fn minimumSizeWithPrioritizedCompressionOptions(
537 &self,
538 prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
539 ) -> NSSize;
540
541 #[cfg(feature = "NSUserInterfaceCompression")]
542 #[unsafe(method(activeCompressionOptions))]
543 #[unsafe(method_family = none)]
544 pub unsafe fn activeCompressionOptions(
545 &self,
546 ) -> Retained<NSUserInterfaceCompressionOptions>;
547 );
548}
549
550#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
552impl NSButton {
553 extern_methods!(
554 #[unsafe(method(initWithFrame:))]
555 #[unsafe(method_family = init)]
556 pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
557
558 #[unsafe(method(initWithCoder:))]
559 #[unsafe(method_family = init)]
560 pub unsafe fn initWithCoder(
561 this: Allocated<Self>,
562 coder: &NSCoder,
563 ) -> Option<Retained<Self>>;
564 );
565}
566
567#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
569impl NSButton {
570 extern_methods!(
571 #[unsafe(method(init))]
572 #[unsafe(method_family = init)]
573 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
574 );
575}
576
577#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
579impl NSButton {
580 extern_methods!(
581 #[unsafe(method(new))]
582 #[unsafe(method_family = new)]
583 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
584 );
585}
586
587#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
589impl NSButton {
590 extern_methods!(
591 #[deprecated = "Mnemonics are not used on macOS. Set the title property directly instead."]
592 #[unsafe(method(setTitleWithMnemonic:))]
593 #[unsafe(method_family = none)]
594 pub unsafe fn setTitleWithMnemonic(&self, string_with_ampersand: Option<&NSString>);
595 );
596}