objc2_app_kit/generated/
NSTokenFieldCell.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
10/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstokenstyle?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct NSTokenStyle(pub NSUInteger);
15impl NSTokenStyle {
16    #[doc(alias = "NSTokenStyleDefault")]
17    pub const Default: Self = Self(0);
18    #[doc(alias = "NSTokenStyleNone")]
19    pub const None: Self = Self(1);
20    #[doc(alias = "NSTokenStyleRounded")]
21    pub const Rounded: Self = Self(2);
22    #[doc(alias = "NSTokenStyleSquared")]
23    pub const Squared: Self = Self(3);
24    #[doc(alias = "NSTokenStylePlainSquared")]
25    pub const PlainSquared: Self = Self(4);
26}
27
28unsafe impl Encode for NSTokenStyle {
29    const ENCODING: Encoding = NSUInteger::ENCODING;
30}
31
32unsafe impl RefEncode for NSTokenStyle {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36extern_class!(
37    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstokenfieldcell?language=objc)
38    #[unsafe(super(NSTextFieldCell, NSActionCell, NSCell, NSObject))]
39    #[derive(Debug, PartialEq, Eq, Hash)]
40    #[cfg(all(
41        feature = "NSActionCell",
42        feature = "NSCell",
43        feature = "NSTextFieldCell"
44    ))]
45    pub struct NSTokenFieldCell;
46);
47
48#[cfg(all(
49    feature = "NSAccessibilityProtocols",
50    feature = "NSActionCell",
51    feature = "NSCell",
52    feature = "NSTextFieldCell"
53))]
54extern_conformance!(
55    unsafe impl NSAccessibility for NSTokenFieldCell {}
56);
57
58#[cfg(all(
59    feature = "NSAccessibilityProtocols",
60    feature = "NSActionCell",
61    feature = "NSCell",
62    feature = "NSTextFieldCell"
63))]
64extern_conformance!(
65    unsafe impl NSAccessibilityElementProtocol for NSTokenFieldCell {}
66);
67
68#[cfg(all(
69    feature = "NSActionCell",
70    feature = "NSCell",
71    feature = "NSTextFieldCell"
72))]
73extern_conformance!(
74    unsafe impl NSCoding for NSTokenFieldCell {}
75);
76
77#[cfg(all(
78    feature = "NSActionCell",
79    feature = "NSCell",
80    feature = "NSTextFieldCell"
81))]
82extern_conformance!(
83    unsafe impl NSCopying for NSTokenFieldCell {}
84);
85
86#[cfg(all(
87    feature = "NSActionCell",
88    feature = "NSCell",
89    feature = "NSTextFieldCell"
90))]
91unsafe impl CopyingHelper for NSTokenFieldCell {
92    type Result = Self;
93}
94
95#[cfg(all(
96    feature = "NSActionCell",
97    feature = "NSCell",
98    feature = "NSTextFieldCell"
99))]
100extern_conformance!(
101    unsafe impl NSObjectProtocol for NSTokenFieldCell {}
102);
103
104#[cfg(all(
105    feature = "NSActionCell",
106    feature = "NSCell",
107    feature = "NSTextFieldCell",
108    feature = "NSUserInterfaceItemIdentification"
109))]
110extern_conformance!(
111    unsafe impl NSUserInterfaceItemIdentification for NSTokenFieldCell {}
112);
113
114#[cfg(all(
115    feature = "NSActionCell",
116    feature = "NSCell",
117    feature = "NSTextFieldCell"
118))]
119impl NSTokenFieldCell {
120    extern_methods!(
121        #[unsafe(method(tokenStyle))]
122        #[unsafe(method_family = none)]
123        pub fn tokenStyle(&self) -> NSTokenStyle;
124
125        /// Setter for [`tokenStyle`][Self::tokenStyle].
126        #[unsafe(method(setTokenStyle:))]
127        #[unsafe(method_family = none)]
128        pub fn setTokenStyle(&self, token_style: NSTokenStyle);
129
130        #[unsafe(method(completionDelay))]
131        #[unsafe(method_family = none)]
132        pub fn completionDelay(&self) -> NSTimeInterval;
133
134        /// Setter for [`completionDelay`][Self::completionDelay].
135        #[unsafe(method(setCompletionDelay:))]
136        #[unsafe(method_family = none)]
137        pub fn setCompletionDelay(&self, completion_delay: NSTimeInterval);
138
139        #[unsafe(method(defaultCompletionDelay))]
140        #[unsafe(method_family = none)]
141        pub fn defaultCompletionDelay(mtm: MainThreadMarker) -> NSTimeInterval;
142
143        #[unsafe(method(tokenizingCharacterSet))]
144        #[unsafe(method_family = none)]
145        pub fn tokenizingCharacterSet(&self) -> Retained<NSCharacterSet>;
146
147        /// Setter for [`tokenizingCharacterSet`][Self::tokenizingCharacterSet].
148        ///
149        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
150        #[unsafe(method(setTokenizingCharacterSet:))]
151        #[unsafe(method_family = none)]
152        pub fn setTokenizingCharacterSet(&self, tokenizing_character_set: Option<&NSCharacterSet>);
153
154        #[unsafe(method(defaultTokenizingCharacterSet))]
155        #[unsafe(method_family = none)]
156        pub fn defaultTokenizingCharacterSet(mtm: MainThreadMarker) -> Retained<NSCharacterSet>;
157
158        #[unsafe(method(delegate))]
159        #[unsafe(method_family = none)]
160        pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSTokenFieldCellDelegate>>>;
161
162        /// Setter for [`delegate`][Self::delegate].
163        ///
164        /// This is a [weak property][objc2::topics::weak_property].
165        #[unsafe(method(setDelegate:))]
166        #[unsafe(method_family = none)]
167        pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSTokenFieldCellDelegate>>);
168    );
169}
170
171/// Methods declared on superclass `NSTextFieldCell`.
172#[cfg(all(
173    feature = "NSActionCell",
174    feature = "NSCell",
175    feature = "NSTextFieldCell"
176))]
177impl NSTokenFieldCell {
178    extern_methods!(
179        #[unsafe(method(initTextCell:))]
180        #[unsafe(method_family = init)]
181        pub fn initTextCell(this: Allocated<Self>, string: &NSString) -> Retained<Self>;
182
183        /// # Safety
184        ///
185        /// `coder` possibly has further requirements.
186        #[unsafe(method(initWithCoder:))]
187        #[unsafe(method_family = init)]
188        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
189
190        #[cfg(feature = "NSImage")]
191        #[unsafe(method(initImageCell:))]
192        #[unsafe(method_family = init)]
193        pub unsafe fn initImageCell(
194            this: Allocated<Self>,
195            image: Option<&NSImage>,
196        ) -> Retained<Self>;
197    );
198}
199
200/// Methods declared on superclass `NSCell`.
201#[cfg(all(
202    feature = "NSActionCell",
203    feature = "NSCell",
204    feature = "NSTextFieldCell"
205))]
206impl NSTokenFieldCell {
207    extern_methods!(
208        #[unsafe(method(init))]
209        #[unsafe(method_family = init)]
210        pub fn init(this: Allocated<Self>) -> Retained<Self>;
211    );
212}
213
214/// Methods declared on superclass `NSObject`.
215#[cfg(all(
216    feature = "NSActionCell",
217    feature = "NSCell",
218    feature = "NSTextFieldCell"
219))]
220impl NSTokenFieldCell {
221    extern_methods!(
222        #[unsafe(method(new))]
223        #[unsafe(method_family = new)]
224        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
225    );
226}
227
228extern_protocol!(
229    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstokenfieldcelldelegate?language=objc)
230    pub unsafe trait NSTokenFieldCellDelegate: NSObjectProtocol + MainThreadOnly {
231        #[cfg(all(
232            feature = "NSActionCell",
233            feature = "NSCell",
234            feature = "NSTextFieldCell"
235        ))]
236        /// Allows the delegate to provide an array of appropriate completions for the contents of the receiver
237        ///
238        /// Parameter `tokenFieldCell`: The token field cell where editing is occurring
239        ///
240        /// Parameter `substring`: The partial string that is being completed
241        ///
242        /// Parameter `tokenIndex`: The index of the token being completed
243        ///
244        /// Parameter `selectedIndex`: Optionally, you can return by reference an index into the returned array that specifies which of the completions should be initially selected. If none are to be selected, return by reference `-1`.
245        ///
246        /// Returns: An array of strings (`NSString`) that are possible completions
247        ///
248        /// If the delegate does not implement this method, no completions are provided
249        ///
250        /// # Safety
251        ///
252        /// `selected_index` must be a valid pointer.
253        #[optional]
254        #[unsafe(method(tokenFieldCell:completionsForSubstring:indexOfToken:indexOfSelectedItem:))]
255        #[unsafe(method_family = none)]
256        unsafe fn tokenFieldCell_completionsForSubstring_indexOfToken_indexOfSelectedItem(
257            &self,
258            token_field_cell: &NSTokenFieldCell,
259            substring: &NSString,
260            token_index: NSInteger,
261            selected_index: NonNull<NSInteger>,
262        ) -> Retained<NSArray>;
263
264        #[cfg(all(
265            feature = "NSActionCell",
266            feature = "NSCell",
267            feature = "NSTextFieldCell"
268        ))]
269        /// # Safety
270        ///
271        /// `tokens` generic should be of the correct type.
272        #[optional]
273        #[unsafe(method(tokenFieldCell:shouldAddObjects:atIndex:))]
274        #[unsafe(method_family = none)]
275        unsafe fn tokenFieldCell_shouldAddObjects_atIndex(
276            &self,
277            token_field_cell: &NSTokenFieldCell,
278            tokens: &NSArray,
279            index: NSUInteger,
280        ) -> Retained<NSArray>;
281
282        #[cfg(all(
283            feature = "NSActionCell",
284            feature = "NSCell",
285            feature = "NSTextFieldCell"
286        ))]
287        /// # Safety
288        ///
289        /// `represented_object` should be of the correct type.
290        #[optional]
291        #[unsafe(method(tokenFieldCell:displayStringForRepresentedObject:))]
292        #[unsafe(method_family = none)]
293        unsafe fn tokenFieldCell_displayStringForRepresentedObject(
294            &self,
295            token_field_cell: &NSTokenFieldCell,
296            represented_object: &AnyObject,
297        ) -> Option<Retained<NSString>>;
298
299        #[cfg(all(
300            feature = "NSActionCell",
301            feature = "NSCell",
302            feature = "NSTextFieldCell"
303        ))]
304        /// # Safety
305        ///
306        /// `represented_object` should be of the correct type.
307        #[optional]
308        #[unsafe(method(tokenFieldCell:editingStringForRepresentedObject:))]
309        #[unsafe(method_family = none)]
310        unsafe fn tokenFieldCell_editingStringForRepresentedObject(
311            &self,
312            token_field_cell: &NSTokenFieldCell,
313            represented_object: &AnyObject,
314        ) -> Option<Retained<NSString>>;
315
316        #[cfg(all(
317            feature = "NSActionCell",
318            feature = "NSCell",
319            feature = "NSTextFieldCell"
320        ))]
321        #[optional]
322        #[unsafe(method(tokenFieldCell:representedObjectForEditingString:))]
323        #[unsafe(method_family = none)]
324        fn tokenFieldCell_representedObjectForEditingString(
325            &self,
326            token_field_cell: &NSTokenFieldCell,
327            editing_string: &NSString,
328        ) -> Option<Retained<AnyObject>>;
329
330        #[cfg(all(
331            feature = "NSActionCell",
332            feature = "NSCell",
333            feature = "NSPasteboard",
334            feature = "NSTextFieldCell"
335        ))]
336        /// # Safety
337        ///
338        /// `objects` generic should be of the correct type.
339        #[optional]
340        #[unsafe(method(tokenFieldCell:writeRepresentedObjects:toPasteboard:))]
341        #[unsafe(method_family = none)]
342        unsafe fn tokenFieldCell_writeRepresentedObjects_toPasteboard(
343            &self,
344            token_field_cell: &NSTokenFieldCell,
345            objects: &NSArray,
346            pboard: &NSPasteboard,
347        ) -> bool;
348
349        #[cfg(all(
350            feature = "NSActionCell",
351            feature = "NSCell",
352            feature = "NSPasteboard",
353            feature = "NSTextFieldCell"
354        ))]
355        #[optional]
356        #[unsafe(method(tokenFieldCell:readFromPasteboard:))]
357        #[unsafe(method_family = none)]
358        fn tokenFieldCell_readFromPasteboard(
359            &self,
360            token_field_cell: &NSTokenFieldCell,
361            pboard: &NSPasteboard,
362        ) -> Option<Retained<NSArray>>;
363
364        #[cfg(all(
365            feature = "NSActionCell",
366            feature = "NSCell",
367            feature = "NSMenu",
368            feature = "NSTextFieldCell"
369        ))]
370        /// # Safety
371        ///
372        /// `represented_object` should be of the correct type.
373        #[optional]
374        #[unsafe(method(tokenFieldCell:menuForRepresentedObject:))]
375        #[unsafe(method_family = none)]
376        unsafe fn tokenFieldCell_menuForRepresentedObject(
377            &self,
378            token_field_cell: &NSTokenFieldCell,
379            represented_object: &AnyObject,
380        ) -> Option<Retained<NSMenu>>;
381
382        #[cfg(all(
383            feature = "NSActionCell",
384            feature = "NSCell",
385            feature = "NSTextFieldCell"
386        ))]
387        /// # Safety
388        ///
389        /// `represented_object` should be of the correct type.
390        #[optional]
391        #[unsafe(method(tokenFieldCell:hasMenuForRepresentedObject:))]
392        #[unsafe(method_family = none)]
393        unsafe fn tokenFieldCell_hasMenuForRepresentedObject(
394            &self,
395            token_field_cell: &NSTokenFieldCell,
396            represented_object: &AnyObject,
397        ) -> bool;
398
399        #[cfg(all(
400            feature = "NSActionCell",
401            feature = "NSCell",
402            feature = "NSTextFieldCell"
403        ))]
404        /// # Safety
405        ///
406        /// `represented_object` should be of the correct type.
407        #[optional]
408        #[unsafe(method(tokenFieldCell:styleForRepresentedObject:))]
409        #[unsafe(method_family = none)]
410        unsafe fn tokenFieldCell_styleForRepresentedObject(
411            &self,
412            token_field_cell: &NSTokenFieldCell,
413            represented_object: &AnyObject,
414        ) -> NSTokenStyle;
415    }
416);
417
418/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsdefaulttokenstyle?language=objc)
419#[deprecated]
420pub static NSDefaultTokenStyle: NSTokenStyle = NSTokenStyle(NSTokenStyle::Default.0);
421
422/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsplaintexttokenstyle?language=objc)
423#[deprecated]
424pub static NSPlainTextTokenStyle: NSTokenStyle = NSTokenStyle(NSTokenStyle::None.0);
425
426/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsroundedtokenstyle?language=objc)
427#[deprecated]
428pub static NSRoundedTokenStyle: NSTokenStyle = NSTokenStyle(NSTokenStyle::Rounded.0);