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
51extern_conformance!(
52    unsafe impl NSCopying for NSMenuItemBadge {}
53);
54
55unsafe impl CopyingHelper for NSMenuItemBadge {
56    type Result = Self;
57}
58
59extern_conformance!(
60    unsafe impl NSObjectProtocol for NSMenuItemBadge {}
61);
62
63impl NSMenuItemBadge {
64    extern_methods!(
65        /// Creates a badge with an integer count and a label representing
66        /// the number of available updates.
67        #[unsafe(method(updatesWithCount:))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn updatesWithCount(item_count: NSInteger) -> Retained<Self>;
70
71        /// Creates a badge with an integer count and a label representing
72        /// the number of new items.
73        #[unsafe(method(newItemsWithCount:))]
74        #[unsafe(method_family = new)]
75        pub unsafe fn newItemsWithCount(item_count: NSInteger) -> Retained<Self>;
76
77        /// Creates a badge with an integer count and a label representing
78        /// the number of alerts.
79        #[unsafe(method(alertsWithCount:))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn alertsWithCount(item_count: NSInteger) -> Retained<Self>;
82
83        /// Initializes the badge with a count and a pre-defined badge type.
84        #[unsafe(method(initWithCount:type:))]
85        #[unsafe(method_family = init)]
86        pub unsafe fn initWithCount_type(
87            this: Allocated<Self>,
88            item_count: NSInteger,
89            r#type: NSMenuItemBadgeType,
90        ) -> Retained<Self>;
91
92        /// Initializes the badge with an integer count and an empty string.
93        #[unsafe(method(initWithCount:))]
94        #[unsafe(method_family = init)]
95        pub unsafe fn initWithCount(this: Allocated<Self>, item_count: NSInteger)
96            -> Retained<Self>;
97
98        /// Initializes the badge with the provided custom string.
99        #[unsafe(method(initWithString:))]
100        #[unsafe(method_family = init)]
101        pub unsafe fn initWithString(this: Allocated<Self>, string: &NSString) -> Retained<Self>;
102
103        #[unsafe(method(init))]
104        #[unsafe(method_family = init)]
105        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
106
107        /// The count of items the badge displays. If a custom string was used
108        /// to create a badge, the value is 0.
109        #[unsafe(method(itemCount))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn itemCount(&self) -> NSInteger;
112
113        /// The type of items the badge displays. If a custom string was used
114        /// to create a badge, this value is
115        /// `NSMenuItemBadgeTypeNone.`
116        #[unsafe(method(type))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn r#type(&self) -> NSMenuItemBadgeType;
119
120        /// The string representation of the badge as it would appear when the
121        /// badge is displayed.
122        #[unsafe(method(stringValue))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn stringValue(&self) -> Option<Retained<NSString>>;
125    );
126}
127
128/// Methods declared on superclass `NSObject`.
129impl NSMenuItemBadge {
130    extern_methods!(
131        #[unsafe(method(new))]
132        #[unsafe(method_family = new)]
133        pub unsafe fn new() -> Retained<Self>;
134    );
135}