objc2_input_method_kit/generated/IMKCandidates.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::*;
6#[cfg(feature = "objc2-app-kit")]
7use objc2_app_kit::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/kimksinglecolumnscrollingcandidatepanel?language=objc)
13pub const kIMKSingleColumnScrollingCandidatePanel: c_uint = 1;
14/// [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/kimkscrollinggridcandidatepanel?language=objc)
15pub const kIMKScrollingGridCandidatePanel: c_uint = 2;
16/// [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/kimksinglerowsteppingcandidatepanel?language=objc)
17pub const kIMKSingleRowSteppingCandidatePanel: c_uint = 3;
18
19/// [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/imkcandidatepaneltype?language=objc)
20pub type IMKCandidatePanelType = NSUInteger;
21
22/// [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/kimkmain?language=objc)
23pub const kIMKMain: c_uint = 0;
24/// [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/kimkannotation?language=objc)
25pub const kIMKAnnotation: c_uint = 1;
26/// [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/kimksublist?language=objc)
27pub const kIMKSubList: c_uint = 2;
28
29/// [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/imkstyletype?language=objc)
30pub type IMKStyleType = NSUInteger;
31
32/// [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/kimklocatecandidatesabovehint?language=objc)
33pub const kIMKLocateCandidatesAboveHint: c_uint = 1;
34/// [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/kimklocatecandidatesbelowhint?language=objc)
35pub const kIMKLocateCandidatesBelowHint: c_uint = 2;
36/// [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/kimklocatecandidateslefthint?language=objc)
37pub const kIMKLocateCandidatesLeftHint: c_uint = 3;
38/// [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/kimklocatecandidatesrighthint?language=objc)
39pub const kIMKLocateCandidatesRightHint: c_uint = 4;
40
41/// [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/imkcandidateslocationhint?language=objc)
42pub type IMKCandidatesLocationHint = NSUInteger;
43
44extern "C" {
45 /// The level of opacity.
46 ///
47 ///
48 /// Value must be a NSNumber with a value from 0 to 1.
49 ///
50 /// See also [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/imkcandidatesopacityattributename?language=objc)
51 pub static IMKCandidatesOpacityAttributeName: &'static NSString;
52}
53
54extern "C" {
55 /// Control when key events are sent to a candidate window.
56 ///
57 ///
58 /// Value is a NSNumber with a boolean value of NO (key events are sent to the candidate window first) or YES (key events are sent to the IMKInputController first). Note that this is only applicable when a candidate window is displayed. The default behavior is to send the key event to the candidate window first, and if it is not processed there, to send it on to the input controller.
59 ///
60 /// See also [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/imkcandidatessendserverkeyeventfirst?language=objc)
61 pub static IMKCandidatesSendServerKeyEventFirst: &'static NSString;
62}
63
64extern_class!(
65 /// [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/imkcandidates?language=objc)
66 #[unsafe(super(NSResponder, NSObject))]
67 #[derive(Debug, PartialEq, Eq, Hash)]
68 #[cfg(feature = "objc2-app-kit")]
69 pub struct IMKCandidates;
70);
71
72#[cfg(feature = "objc2-app-kit")]
73extern_conformance!(
74 unsafe impl NSCoding for IMKCandidates {}
75);
76
77#[cfg(feature = "objc2-app-kit")]
78extern_conformance!(
79 unsafe impl NSObjectProtocol for IMKCandidates {}
80);
81
82#[cfg(feature = "objc2-app-kit")]
83impl IMKCandidates {
84 extern_methods!(
85 #[cfg(feature = "IMKServer")]
86 /// Default initializer for the class.
87 ///
88 /// When an input method allocates an IMKCandidate object it should initialize that object by calling this method passing the IMKServer that will manage the candidates and the initial panel type.
89 ///
90 /// # Safety
91 ///
92 /// `server` might not allow `None`.
93 #[unsafe(method(initWithServer:panelType:))]
94 #[unsafe(method_family = init)]
95 pub unsafe fn initWithServer_panelType(
96 this: Allocated<Self>,
97 server: Option<&IMKServer>,
98 panel_type: IMKCandidatePanelType,
99 ) -> Option<Retained<Self>>;
100
101 #[cfg(feature = "IMKServer")]
102 /// # Safety
103 ///
104 /// `server` might not allow `None`.
105 #[unsafe(method(initWithServer:panelType:styleType:))]
106 #[unsafe(method_family = init)]
107 pub unsafe fn initWithServer_panelType_styleType(
108 this: Allocated<Self>,
109 server: Option<&IMKServer>,
110 panel_type: IMKCandidatePanelType,
111 style: IMKStyleType,
112 ) -> Option<Retained<Self>>;
113
114 /// Return the panel type.
115 #[unsafe(method(panelType))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn panelType(&self) -> IMKCandidatePanelType;
118
119 /// Change the panel type.
120 #[unsafe(method(setPanelType:))]
121 #[unsafe(method_family = none)]
122 pub unsafe fn setPanelType(&self, panel_type: IMKCandidatePanelType);
123
124 /// If a candidate window type has been provided, show the candidate window. The caller provides a location hint that is used to position the window.
125 ///
126 /// Input methods call this method when it is appropriate, during text conversion, to display a list of candidates.
127 #[unsafe(method(show:))]
128 #[unsafe(method_family = none)]
129 pub unsafe fn show(&self, location_hint: IMKCandidatesLocationHint);
130
131 /// If the candidate window is visible, hide it.
132 #[unsafe(method(hide))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn hide(&self);
135
136 /// Utility method returns YES if a candidate display is visible.
137 #[unsafe(method(isVisible))]
138 #[unsafe(method_family = none)]
139 pub unsafe fn isVisible(&self) -> bool;
140
141 /// Call this method to update the candidates displayed in the candidate window.
142 ///
143 /// Calling this method will result in a call being made to the IMKInputController's candidates method. Note that the candidate list will be updated, but the window's visible state will not change; that is to say, if the window is hidden it will remain hidden, and vice versa.
144 #[unsafe(method(updateCandidates))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn updateCandidates(&self);
147
148 /// Displays an annotation window whose contents are the annotationString.
149 ///
150 /// An annotation is additional text that explains or somehow adds to the candidate string in a candidate window. Annotations are displayed in a small borderless window that is aligned with the current candidate panel. An input method calls showAnnotation: when the method [IMKInputController candidateSelectionChanged:] is called, and the candidateString has annotations.
151 ///
152 /// # Safety
153 ///
154 /// `annotation_string` might not allow `None`.
155 #[unsafe(method(showAnnotation:))]
156 #[unsafe(method_family = none)]
157 pub unsafe fn showAnnotation(&self, annotation_string: Option<&NSAttributedString>);
158
159 /// # Safety
160 ///
161 /// - `candidates` generic should be of the correct type.
162 /// - `candidates` might not allow `None`.
163 /// - `delegate` should be of the correct type.
164 /// - `delegate` might not allow `None`.
165 #[unsafe(method(showSublist:subListDelegate:))]
166 #[unsafe(method_family = none)]
167 pub unsafe fn showSublist_subListDelegate(
168 &self,
169 candidates: Option<&NSArray>,
170 delegate: Option<&AnyObject>,
171 );
172
173 #[unsafe(method(candidateFrame))]
174 #[unsafe(method_family = none)]
175 pub unsafe fn candidateFrame(&self) -> NSRect;
176
177 /// Set the selection keys for the candidates.
178 ///
179 /// Selection keys are an array of NSNumbers where each NSNumber is a virtual key code that the controller will map to characters that are displayed either across the top of the candidates, if the candidates are laid out horizontally, or along the left edge of the candidates, if they are aligned vertically.
180 ///
181 /// The number of selection keys determines how many candidates are displayed per page. For example, if you
182 /// passed an array of 4 key codes, then 4 candidates are displayed per page. If you passed 11 key codes, then 11 candidates would be displayed.
183 ///
184 /// By default the key codes are mapped using the keyboard layout whose source id is com.apple.keylayout.US. The default layout can be replaced by calling
185 /// setSelectionKeysKeylayout (see below).
186 ///
187 /// The default selection keys are the digits 1 through 9, or in terms of key codes: 18-21,23,22, 26, 28, 25.
188 ///
189 /// # Safety
190 ///
191 /// - `key_codes` generic should be of the correct type.
192 /// - `key_codes` might not allow `None`.
193 #[unsafe(method(setSelectionKeys:))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn setSelectionKeys(&self, key_codes: Option<&NSArray>);
196
197 /// Returns an NSArray of NSNumbers where each NSNumber is a virtual key code.
198 ///
199 /// The NSArray is an autoreleased object. Do not release unless it is first retained.
200 #[unsafe(method(selectionKeys))]
201 #[unsafe(method_family = none)]
202 pub unsafe fn selectionKeys(&self) -> Option<Retained<NSArray>>;
203
204 /// Sets the "style" attributes for the candidates window. The keys for the attributes dictionary and the values are:
205 ///
206 /// NSFontAttributeName (value = NSFont) Setting the font attribute sets the font that is used to draw Candidates. It does not effect the selection keys which are always drawn in the same font. Note that to set the font size you should use this key/value pair.
207 ///
208 /// IMKCandidatesOpacityAttributeName (value = NSNumber with a float value between 0 and 1). Sets the opacity level to transparent (0.0) to completely opaque (1.0). The default opacity is 1.0. This constant is declared above.
209 ///
210 /// NSForegroundColorAttributeName (value = NSColor) Sets the text color used for the candidate text. By default it is black.
211 ///
212 /// NSBackgroundColorDocumentAttribute (value = NSColor). Set the background color that is drawn behind the candidate text.
213 ///
214 /// IMKCandidatesSendServerKeyEventFirst (value = NSNumber). NO (default) gives the candidate window first chance at key events. YES causes events to first be routed to the current IMKInputController. In that case, if the event is not handled, it will then be sent to the candidate window.
215 ///
216 /// # Safety
217 ///
218 /// - `attributes` generic should be of the correct type.
219 /// - `attributes` might not allow `None`.
220 #[unsafe(method(setAttributes:))]
221 #[unsafe(method_family = none)]
222 pub unsafe fn setAttributes(&self, attributes: Option<&NSDictionary>);
223
224 /// Returns the attributes dictionary.
225 #[unsafe(method(attributes))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn attributes(&self) -> Option<Retained<NSDictionary>>;
228
229 /// Setting the dismissesAutomatically flag determines what happens to displayed candidates when the return key or enter key is typed.
230 ///
231 /// By default, if a return or enter key is typed, the candidates are dismissed and a candidateSelected: message is sent to the input controller. However if setDismissesAutomatically is passed a NO flag the candidate display will not be dismissed when a return or enter key is typed. The input controller will still be sent the candidatesSelected: message, but, as stated, the candidates display will not be dismissed.
232 ///
233 /// Setting this flag to NO lets an input method process text input while keeping a dynamically changing candidates display in view throughout the text input process.
234 ///
235 /// When you set this to NO the candidate display will still be hidden when when a session deactivates.
236 #[unsafe(method(setDismissesAutomatically:))]
237 #[unsafe(method_family = none)]
238 pub unsafe fn setDismissesAutomatically(&self, flag: bool);
239
240 /// Returns the dismissesAutomatically flag.
241 #[unsafe(method(dismissesAutomatically))]
242 #[unsafe(method_family = none)]
243 pub unsafe fn dismissesAutomatically(&self) -> bool;
244
245 /// Returns the currently selected candidate identifer.
246 ///
247 /// Attempts to determine the identifier for the selected candidate. If there is no selection the return value will be NSNotFound.
248 #[unsafe(method(selectedCandidate))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn selectedCandidate(&self) -> NSInteger;
251
252 /// Positions the top-left corner of the candidate window’s frame rectangle at a given point in screen coordinates.
253 #[unsafe(method(setCandidateFrameTopLeft:))]
254 #[unsafe(method_family = none)]
255 pub unsafe fn setCandidateFrameTopLeft(&self, point: NSPoint);
256
257 /// If the current selection has a child IMKCandidates object that will be shown.
258 ///
259 /// If there is a failure in showing the child this method will throw an exception.
260 #[unsafe(method(showChild))]
261 #[unsafe(method_family = none)]
262 pub unsafe fn showChild(&self);
263
264 /// If the current selection has a child IMKCandidates that is being shown hide it.
265 ///
266 /// Typically a client will not need to call this as IMKCandidates automatically hides and shows children.
267 #[unsafe(method(hideChild))]
268 #[unsafe(method_family = none)]
269 pub unsafe fn hideChild(&self);
270
271 /// Attach an IMKCandidates object to the specified selection.
272 ///
273 /// The IMKCandidate can be a sublist or an annotation.
274 ///
275 /// # Safety
276 ///
277 /// `child` might not allow `None`.
278 #[unsafe(method(attachChild:toCandidate:type:))]
279 #[unsafe(method_family = none)]
280 pub unsafe fn attachChild_toCandidate_type(
281 &self,
282 child: Option<&IMKCandidates>,
283 candidate_identifier: NSInteger,
284 the_type: IMKStyleType,
285 );
286
287 /// Detach the IMKCandidates object attached to candidate
288 #[unsafe(method(detachChild:))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn detachChild(&self, candidate_identifier: NSInteger);
291
292 /// Set the candidates data directly rather than supplying data via [IMKInputContoller candidates:].
293 ///
294 /// The elements of the array can be strings or attributed strings.
295 ///
296 /// # Safety
297 ///
298 /// - `candidates_array` generic should be of the correct type.
299 /// - `candidates_array` might not allow `None`.
300 #[unsafe(method(setCandidateData:))]
301 #[unsafe(method_family = none)]
302 pub unsafe fn setCandidateData(&self, candidates_array: Option<&NSArray>);
303
304 /// Select the candidate whose identifier matches the identifier parameter.
305 ///
306 /// Returns: YES if the candidateIdentifier is valid an the selection was made. NO if canidateIdentifier is invalid or it was not possible make the selection.
307 ///
308 /// Parameter `An`: identifier for a candidate. You can obtain an identifier by mapping a candidate to an identifier via the [IMKCandidates candidateStringIdentifier:].
309 #[unsafe(method(selectCandidateWithIdentifier:))]
310 #[unsafe(method_family = none)]
311 pub unsafe fn selectCandidateWithIdentifier(&self, candidate_identifier: NSInteger)
312 -> bool;
313
314 #[unsafe(method(selectCandidate:))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn selectCandidate(&self, candidate_identifier: NSInteger);
317
318 /// Show the candidate window.
319 ///
320 /// This simply shows the candidates. No effort is made to position the candidate. The caller should move the candidate window to an appropriate location prior to showing.
321 #[unsafe(method(showCandidates))]
322 #[unsafe(method_family = none)]
323 pub unsafe fn showCandidates(&self);
324
325 /// Map a candidateString to an identifier.
326 ///
327 /// Beginning with MacOS 10.7, candidate strings are mapped internally to an unique identifier of type NSInteger. Using identifiers to identify a particular candidate is the first stage of enabling data types other than NSString and NSAttributedString for containing the contents of a candidate.
328 ///
329 /// # Safety
330 ///
331 /// - `candidate_string` should be of the correct type.
332 /// - `candidate_string` might not allow `None`.
333 #[unsafe(method(candidateStringIdentifier:))]
334 #[unsafe(method_family = none)]
335 pub unsafe fn candidateStringIdentifier(
336 &self,
337 candidate_string: Option<&AnyObject>,
338 ) -> NSInteger;
339
340 /// Returns the currently selected candidate string.
341 ///
342 /// Attempts to determine the string for the selected candidate. If there is no selection the return value can be nil. The attributed string is an autoreleased object.
343 #[unsafe(method(selectedCandidateString))]
344 #[unsafe(method_family = none)]
345 pub unsafe fn selectedCandidateString(&self) -> Option<Retained<NSAttributedString>>;
346
347 /// Returns the candidate identifier for a given line in the candidate window display.
348 ///
349 /// Maps the lineNumber to a candidate identifier. Line number 0 corresponds to the candidate in the cell currently in the first (top for vertical) line of the candidate window. This is convienient for input methods that support selecting a candidate by a number key. Line Number values depend on the column arrangement of your candidate. If you are displaying a single column candidate window, lines that have been scrolled out of view will have negative values. For a single row grid line, numbers will correspond to the cell's position in the row (i.e. the first cell will be 0, the second 1, etc). Finally, for a grid, the line numbers correspond to the grid row. If the line number is invalid, NSNotFound is returned.
350 ///
351 /// Parameter `lineNumber`: a number representing a cells position in the candidate window.
352 #[unsafe(method(candidateIdentifierAtLineNumber:))]
353 #[unsafe(method_family = none)]
354 pub unsafe fn candidateIdentifierAtLineNumber(&self, line_number: NSInteger) -> NSInteger;
355
356 /// Returns the line number for a given CandidateID.
357 ///
358 /// Returns: The line number. NSNotFound if the candidateID is invalid.
359 ///
360 /// Parameter `candidateIdentifier`: - A valid identifier for a candidate.
361 ///
362 /// If the cell that contains the candidate is at the top line of the candidate window, the return value will be 0.
363 #[unsafe(method(lineNumberForCandidateWithIdentifier:))]
364 #[unsafe(method_family = none)]
365 pub unsafe fn lineNumberForCandidateWithIdentifier(
366 &self,
367 candidate_identifier: NSInteger,
368 ) -> NSInteger;
369
370 /// Clears the current selection.
371 #[unsafe(method(clearSelection))]
372 #[unsafe(method_family = none)]
373 pub unsafe fn clearSelection(&self);
374 );
375}
376
377/// Methods declared on superclass `NSResponder`.
378#[cfg(feature = "objc2-app-kit")]
379impl IMKCandidates {
380 extern_methods!(
381 #[unsafe(method(init))]
382 #[unsafe(method_family = init)]
383 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
384
385 /// # Safety
386 ///
387 /// `coder` possibly has further requirements.
388 #[unsafe(method(initWithCoder:))]
389 #[unsafe(method_family = init)]
390 pub unsafe fn initWithCoder(
391 this: Allocated<Self>,
392 coder: &NSCoder,
393 ) -> Option<Retained<Self>>;
394 );
395}
396
397/// Methods declared on superclass `NSObject`.
398#[cfg(feature = "objc2-app-kit")]
399impl IMKCandidates {
400 extern_methods!(
401 #[unsafe(method(new))]
402 #[unsafe(method_family = new)]
403 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
404 );
405}