objc2_app_kit/generated/
NSMenuItemBadge.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9/// The badge type is used to specify one of the pre-defined or custom
10/// string portions of a menu item badge, ensuring appropriate localization
11/// and pluralization behaviors automatically when using a pre-defined type.
12///
13/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmenuitembadgetype?language=objc)
14// NS_ENUM
15#[repr(transparent)]
16#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
17pub struct NSMenuItemBadgeType(pub NSInteger);
18impl NSMenuItemBadgeType {
19    /// The badge should have no string portion.
20    #[doc(alias = "NSMenuItemBadgeTypeNone")]
21    pub const None: Self = Self(0);
22    /// The badge represents the number of available updates.
23    #[doc(alias = "NSMenuItemBadgeTypeUpdates")]
24    pub const Updates: Self = Self(1);
25    /// The badge represents the number of new items.
26    #[doc(alias = "NSMenuItemBadgeTypeNewItems")]
27    pub const NewItems: Self = Self(2);
28    /// The badge represents the number of alerts.
29    #[doc(alias = "NSMenuItemBadgeTypeAlerts")]
30    pub const Alerts: Self = Self(3);
31}
32
33unsafe impl Encode for NSMenuItemBadgeType {
34    const ENCODING: Encoding = NSInteger::ENCODING;
35}
36
37unsafe impl RefEncode for NSMenuItemBadgeType {
38    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
39}
40
41extern_class!(
42    /// A badge used to provide additional quantitative information specific
43    /// to the menu item, such as the number of available updates.
44    ///
45    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmenuitembadge?language=objc)
46    #[unsafe(super(NSObject))]
47    #[derive(Debug, PartialEq, Eq, Hash)]
48    pub struct NSMenuItemBadge;
49);
50
51unsafe impl NSCopying for NSMenuItemBadge {}
52
53unsafe impl CopyingHelper for NSMenuItemBadge {
54    type Result = Self;
55}
56
57unsafe impl NSObjectProtocol for NSMenuItemBadge {}
58
59impl NSMenuItemBadge {
60    extern_methods!(
61        /// Creates a badge with an integer count and a label representing
62        /// the number of available updates.
63        #[unsafe(method(updatesWithCount:))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn updatesWithCount(item_count: NSInteger) -> Retained<Self>;
66
67        /// Creates a badge with an integer count and a label representing
68        /// the number of new items.
69        #[unsafe(method(newItemsWithCount:))]
70        #[unsafe(method_family = new)]
71        pub unsafe fn newItemsWithCount(item_count: NSInteger) -> Retained<Self>;
72
73        /// Creates a badge with an integer count and a label representing
74        /// the number of alerts.
75        #[unsafe(method(alertsWithCount:))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn alertsWithCount(item_count: NSInteger) -> Retained<Self>;
78
79        /// Initializes the badge with a count and a pre-defined badge type.
80        #[unsafe(method(initWithCount:type:))]
81        #[unsafe(method_family = init)]
82        pub unsafe fn initWithCount_type(
83            this: Allocated<Self>,
84            item_count: NSInteger,
85            r#type: NSMenuItemBadgeType,
86        ) -> Retained<Self>;
87
88        /// Initializes the badge with an integer count and an empty string.
89        #[unsafe(method(initWithCount:))]
90        #[unsafe(method_family = init)]
91        pub unsafe fn initWithCount(this: Allocated<Self>, item_count: NSInteger)
92            -> Retained<Self>;
93
94        /// Initializes the badge with the provided custom string.
95        #[unsafe(method(initWithString:))]
96        #[unsafe(method_family = init)]
97        pub unsafe fn initWithString(this: Allocated<Self>, string: &NSString) -> Retained<Self>;
98
99        #[unsafe(method(init))]
100        #[unsafe(method_family = init)]
101        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
102
103        /// The count of items the badge displays. If a custom string was used
104        /// to create a badge, the value is 0.
105        #[unsafe(method(itemCount))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn itemCount(&self) -> NSInteger;
108
109        /// The type of items the badge displays. If a custom string was used
110        /// to create a badge, this value is
111        /// `NSMenuItemBadgeTypeNone.`
112        #[unsafe(method(type))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn r#type(&self) -> NSMenuItemBadgeType;
115
116        /// The string representation of the badge as it would appear when the
117        /// badge is displayed.
118        #[unsafe(method(stringValue))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn stringValue(&self) -> Option<Retained<NSString>>;
121    );
122}
123
124/// Methods declared on superclass `NSObject`.
125impl NSMenuItemBadge {
126    extern_methods!(
127        #[unsafe(method(new))]
128        #[unsafe(method_family = new)]
129        pub unsafe fn new() -> Retained<Self>;
130    );
131}