objc2_app_kit/generated/
NSCandidateListTouchBarItem.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscandidatelisttouchbaritem?language=objc)
12    #[unsafe(super(NSTouchBarItem, NSObject))]
13    #[derive(Debug, PartialEq, Eq, Hash)]
14    #[cfg(feature = "NSTouchBarItem")]
15    pub struct NSCandidateListTouchBarItem<CandidateType: ?Sized = AnyObject>;
16);
17
18#[cfg(feature = "NSTouchBarItem")]
19impl<CandidateType: ?Sized + Message> NSCandidateListTouchBarItem<CandidateType> {
20    /// Unchecked conversion of the generic parameter.
21    ///
22    /// # Safety
23    ///
24    /// The generic must be valid to reinterpret as the given type.
25    #[inline]
26    pub unsafe fn cast_unchecked<NewCandidateType: ?Sized + Message>(
27        &self,
28    ) -> &NSCandidateListTouchBarItem<NewCandidateType> {
29        unsafe { &*((self as *const Self).cast()) }
30    }
31}
32
33#[cfg(feature = "NSTouchBarItem")]
34extern_conformance!(
35    unsafe impl<CandidateType: ?Sized + NSCoding> NSCoding
36        for NSCandidateListTouchBarItem<CandidateType>
37    {
38    }
39);
40
41#[cfg(feature = "NSTouchBarItem")]
42extern_conformance!(
43    unsafe impl<CandidateType: ?Sized> NSObjectProtocol for NSCandidateListTouchBarItem<CandidateType> {}
44);
45
46#[cfg(feature = "NSTouchBarItem")]
47impl<CandidateType: Message> NSCandidateListTouchBarItem<CandidateType> {
48    extern_methods!(
49        #[cfg(all(
50            feature = "NSResponder",
51            feature = "NSTextInputClient",
52            feature = "NSView"
53        ))]
54        #[unsafe(method(client))]
55        #[unsafe(method_family = none)]
56        pub fn client(&self) -> Option<Retained<NSView>>;
57
58        #[cfg(all(
59            feature = "NSResponder",
60            feature = "NSTextInputClient",
61            feature = "NSView"
62        ))]
63        /// Setter for [`client`][Self::client].
64        ///
65        /// This is a [weak property][objc2::topics::weak_property].
66        ///
67        /// # Safety
68        ///
69        /// `client` must implement NSTextInputClient.
70        #[unsafe(method(setClient:))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn setClient(&self, client: Option<&NSView>);
73
74        #[unsafe(method(delegate))]
75        #[unsafe(method_family = none)]
76        pub fn delegate(
77            &self,
78        ) -> Option<Retained<ProtocolObject<dyn NSCandidateListTouchBarItemDelegate>>>;
79
80        /// Setter for [`delegate`][Self::delegate].
81        ///
82        /// This is a [weak property][objc2::topics::weak_property].
83        #[unsafe(method(setDelegate:))]
84        #[unsafe(method_family = none)]
85        pub fn setDelegate(
86            &self,
87            delegate: Option<&ProtocolObject<dyn NSCandidateListTouchBarItemDelegate>>,
88        );
89
90        #[unsafe(method(isCollapsed))]
91        #[unsafe(method_family = none)]
92        pub fn isCollapsed(&self) -> bool;
93
94        /// Setter for [`isCollapsed`][Self::isCollapsed].
95        #[unsafe(method(setCollapsed:))]
96        #[unsafe(method_family = none)]
97        pub fn setCollapsed(&self, collapsed: bool);
98
99        #[unsafe(method(allowsCollapsing))]
100        #[unsafe(method_family = none)]
101        pub fn allowsCollapsing(&self) -> bool;
102
103        /// Setter for [`allowsCollapsing`][Self::allowsCollapsing].
104        #[unsafe(method(setAllowsCollapsing:))]
105        #[unsafe(method_family = none)]
106        pub fn setAllowsCollapsing(&self, allows_collapsing: bool);
107
108        #[unsafe(method(isCandidateListVisible))]
109        #[unsafe(method_family = none)]
110        pub fn isCandidateListVisible(&self) -> bool;
111
112        #[unsafe(method(updateWithInsertionPointVisibility:))]
113        #[unsafe(method_family = none)]
114        pub fn updateWithInsertionPointVisibility(&self, is_visible: bool);
115
116        #[unsafe(method(allowsTextInputContextCandidates))]
117        #[unsafe(method_family = none)]
118        pub fn allowsTextInputContextCandidates(&self) -> bool;
119
120        /// Setter for [`allowsTextInputContextCandidates`][Self::allowsTextInputContextCandidates].
121        #[unsafe(method(setAllowsTextInputContextCandidates:))]
122        #[unsafe(method_family = none)]
123        pub fn setAllowsTextInputContextCandidates(
124            &self,
125            allows_text_input_context_candidates: bool,
126        );
127
128        #[cfg(feature = "block2")]
129        /// # Safety
130        ///
131        /// The returned block's argument 1 must be a valid pointer.
132        #[unsafe(method(attributedStringForCandidate))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn attributedStringForCandidate(
135            &self,
136        ) -> *mut block2::DynBlock<
137            dyn Fn(NonNull<CandidateType>, NSInteger) -> NonNull<NSAttributedString>,
138        >;
139
140        #[cfg(feature = "block2")]
141        /// Setter for [`attributedStringForCandidate`][Self::attributedStringForCandidate].
142        ///
143        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
144        ///
145        /// # Safety
146        ///
147        /// `attributed_string_for_candidate` block's return must be a valid pointer.
148        #[unsafe(method(setAttributedStringForCandidate:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn setAttributedStringForCandidate(
151            &self,
152            attributed_string_for_candidate: Option<
153                &block2::DynBlock<
154                    dyn Fn(NonNull<CandidateType>, NSInteger) -> NonNull<NSAttributedString>,
155                >,
156            >,
157        );
158
159        #[unsafe(method(candidates))]
160        #[unsafe(method_family = none)]
161        pub fn candidates(&self) -> Retained<NSArray<CandidateType>>;
162
163        #[unsafe(method(setCandidates:forSelectedRange:inString:))]
164        #[unsafe(method_family = none)]
165        pub fn setCandidates_forSelectedRange_inString(
166            &self,
167            candidates: &NSArray<CandidateType>,
168            selected_range: NSRange,
169            original_string: Option<&NSString>,
170        );
171
172        #[unsafe(method(customizationLabel))]
173        #[unsafe(method_family = none)]
174        pub fn customizationLabel(&self) -> Retained<NSString>;
175
176        /// Setter for [`customizationLabel`][Self::customizationLabel].
177        ///
178        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
179        #[unsafe(method(setCustomizationLabel:))]
180        #[unsafe(method_family = none)]
181        pub fn setCustomizationLabel(&self, customization_label: Option<&NSString>);
182    );
183}
184
185/// Methods declared on superclass `NSTouchBarItem`.
186#[cfg(feature = "NSTouchBarItem")]
187impl<CandidateType: Message> NSCandidateListTouchBarItem<CandidateType> {
188    extern_methods!(
189        #[unsafe(method(initWithIdentifier:))]
190        #[unsafe(method_family = init)]
191        pub fn initWithIdentifier(
192            this: Allocated<Self>,
193            identifier: &NSTouchBarItemIdentifier,
194        ) -> Retained<Self>;
195
196        /// # Safety
197        ///
198        /// `coder` possibly has further requirements.
199        #[unsafe(method(initWithCoder:))]
200        #[unsafe(method_family = init)]
201        pub unsafe fn initWithCoder(
202            this: Allocated<Self>,
203            coder: &NSCoder,
204        ) -> Option<Retained<Self>>;
205
206        #[unsafe(method(init))]
207        #[unsafe(method_family = init)]
208        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
209    );
210}
211
212/// Methods declared on superclass `NSObject`.
213#[cfg(feature = "NSTouchBarItem")]
214impl<CandidateType: Message> NSCandidateListTouchBarItem<CandidateType> {
215    extern_methods!(
216        #[unsafe(method(new))]
217        #[unsafe(method_family = new)]
218        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
219    );
220}
221
222extern_protocol!(
223    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscandidatelisttouchbaritemdelegate?language=objc)
224    pub unsafe trait NSCandidateListTouchBarItemDelegate:
225        NSObjectProtocol + MainThreadOnly
226    {
227        #[cfg(feature = "NSTouchBarItem")]
228        /// # Safety
229        ///
230        /// `an_item` generic should be of the correct type.
231        #[optional]
232        #[unsafe(method(candidateListTouchBarItem:beginSelectingCandidateAtIndex:))]
233        #[unsafe(method_family = none)]
234        unsafe fn candidateListTouchBarItem_beginSelectingCandidateAtIndex(
235            &self,
236            an_item: &NSCandidateListTouchBarItem,
237            index: NSInteger,
238        );
239
240        #[cfg(feature = "NSTouchBarItem")]
241        /// # Safety
242        ///
243        /// `an_item` generic should be of the correct type.
244        #[optional]
245        #[unsafe(method(candidateListTouchBarItem:changeSelectionFromCandidateAtIndex:toIndex:))]
246        #[unsafe(method_family = none)]
247        unsafe fn candidateListTouchBarItem_changeSelectionFromCandidateAtIndex_toIndex(
248            &self,
249            an_item: &NSCandidateListTouchBarItem,
250            previous_index: NSInteger,
251            index: NSInteger,
252        );
253
254        #[cfg(feature = "NSTouchBarItem")]
255        /// # Safety
256        ///
257        /// `an_item` generic should be of the correct type.
258        #[optional]
259        #[unsafe(method(candidateListTouchBarItem:endSelectingCandidateAtIndex:))]
260        #[unsafe(method_family = none)]
261        unsafe fn candidateListTouchBarItem_endSelectingCandidateAtIndex(
262            &self,
263            an_item: &NSCandidateListTouchBarItem,
264            index: NSInteger,
265        );
266
267        #[cfg(feature = "NSTouchBarItem")]
268        /// # Safety
269        ///
270        /// `an_item` generic should be of the correct type.
271        #[optional]
272        #[unsafe(method(candidateListTouchBarItem:changedCandidateListVisibility:))]
273        #[unsafe(method_family = none)]
274        unsafe fn candidateListTouchBarItem_changedCandidateListVisibility(
275            &self,
276            an_item: &NSCandidateListTouchBarItem,
277            is_visible: bool,
278        );
279    }
280);
281
282/// NSCandidateListTouchBarItem.
283#[cfg(all(feature = "NSResponder", feature = "NSView"))]
284impl NSView {
285    extern_methods!(
286        #[cfg(feature = "NSTouchBarItem")]
287        #[unsafe(method(candidateListTouchBarItem))]
288        #[unsafe(method_family = none)]
289        pub fn candidateListTouchBarItem(&self) -> Option<Retained<NSCandidateListTouchBarItem>>;
290    );
291}
292
293extern "C" {
294    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstouchbaritemidentifiercandidatelist?language=objc)
295    #[cfg(feature = "NSTouchBarItem")]
296    pub static NSTouchBarItemIdentifierCandidateList: &'static NSTouchBarItemIdentifier;
297}