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 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 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 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 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 fn initWithCount(this: Allocated<Self>, item_count: NSInteger) -> Retained<Self>;
96
97        /// Initializes the badge with the provided custom string.
98        #[unsafe(method(initWithString:))]
99        #[unsafe(method_family = init)]
100        pub fn initWithString(this: Allocated<Self>, string: &NSString) -> Retained<Self>;
101
102        #[unsafe(method(init))]
103        #[unsafe(method_family = init)]
104        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
105
106        /// The count of items the badge displays. If a custom string was used
107        /// to create a badge, the value is 0.
108        #[unsafe(method(itemCount))]
109        #[unsafe(method_family = none)]
110        pub fn itemCount(&self) -> NSInteger;
111
112        /// The type of items the badge displays. If a custom string was used
113        /// to create a badge, this value is
114        /// `NSMenuItemBadgeTypeNone.`
115        #[unsafe(method(type))]
116        #[unsafe(method_family = none)]
117        pub fn r#type(&self) -> NSMenuItemBadgeType;
118
119        /// The string representation of the badge as it would appear when the
120        /// badge is displayed.
121        #[unsafe(method(stringValue))]
122        #[unsafe(method_family = none)]
123        pub fn stringValue(&self) -> Option<Retained<NSString>>;
124    );
125}
126
127/// Methods declared on superclass `NSObject`.
128impl NSMenuItemBadge {
129    extern_methods!(
130        #[unsafe(method(new))]
131        #[unsafe(method_family = new)]
132        pub unsafe fn new() -> Retained<Self>;
133    );
134}