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