1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10pub type NSSearchFieldRecentsAutosaveName = NSString;
12
13extern_protocol!(
14 #[cfg(all(feature = "NSControl", feature = "NSTextField"))]
16 pub unsafe trait NSSearchFieldDelegate: NSTextFieldDelegate + MainThreadOnly {
17 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
18 #[optional]
19 #[unsafe(method(searchFieldDidStartSearching:))]
20 #[unsafe(method_family = none)]
21 fn searchFieldDidStartSearching(&self, sender: &NSSearchField);
22
23 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
24 #[optional]
25 #[unsafe(method(searchFieldDidEndSearching:))]
26 #[unsafe(method_family = none)]
27 fn searchFieldDidEndSearching(&self, sender: &NSSearchField);
28 }
29);
30
31extern_class!(
32 #[unsafe(super(NSTextField, NSControl, NSView, NSResponder, NSObject))]
34 #[derive(Debug, PartialEq, Eq, Hash)]
35 #[cfg(all(
36 feature = "NSControl",
37 feature = "NSResponder",
38 feature = "NSTextField",
39 feature = "NSView"
40 ))]
41 pub struct NSSearchField;
42);
43
44#[cfg(all(
45 feature = "NSAccessibilityProtocols",
46 feature = "NSControl",
47 feature = "NSResponder",
48 feature = "NSTextField",
49 feature = "NSView"
50))]
51extern_conformance!(
52 unsafe impl NSAccessibility for NSSearchField {}
53);
54
55#[cfg(all(
56 feature = "NSAccessibilityProtocols",
57 feature = "NSControl",
58 feature = "NSResponder",
59 feature = "NSTextField",
60 feature = "NSView"
61))]
62extern_conformance!(
63 unsafe impl NSAccessibilityElementProtocol for NSSearchField {}
64);
65
66#[cfg(all(
67 feature = "NSAccessibilityProtocols",
68 feature = "NSControl",
69 feature = "NSResponder",
70 feature = "NSTextField",
71 feature = "NSView"
72))]
73extern_conformance!(
74 unsafe impl NSAccessibilityNavigableStaticText for NSSearchField {}
75);
76
77#[cfg(all(
78 feature = "NSAccessibilityProtocols",
79 feature = "NSControl",
80 feature = "NSResponder",
81 feature = "NSTextField",
82 feature = "NSView"
83))]
84extern_conformance!(
85 unsafe impl NSAccessibilityStaticText for NSSearchField {}
86);
87
88#[cfg(all(
89 feature = "NSAnimation",
90 feature = "NSControl",
91 feature = "NSResponder",
92 feature = "NSTextField",
93 feature = "NSView"
94))]
95extern_conformance!(
96 unsafe impl NSAnimatablePropertyContainer for NSSearchField {}
97);
98
99#[cfg(all(
100 feature = "NSAppearance",
101 feature = "NSControl",
102 feature = "NSResponder",
103 feature = "NSTextField",
104 feature = "NSView"
105))]
106extern_conformance!(
107 unsafe impl NSAppearanceCustomization for NSSearchField {}
108);
109
110#[cfg(all(
111 feature = "NSControl",
112 feature = "NSResponder",
113 feature = "NSTextField",
114 feature = "NSView"
115))]
116extern_conformance!(
117 unsafe impl NSCoding for NSSearchField {}
118);
119
120#[cfg(all(
121 feature = "NSControl",
122 feature = "NSDragging",
123 feature = "NSResponder",
124 feature = "NSTextField",
125 feature = "NSView"
126))]
127extern_conformance!(
128 unsafe impl NSDraggingDestination for NSSearchField {}
129);
130
131#[cfg(all(
132 feature = "NSControl",
133 feature = "NSResponder",
134 feature = "NSTextField",
135 feature = "NSView"
136))]
137extern_conformance!(
138 unsafe impl NSObjectProtocol for NSSearchField {}
139);
140
141#[cfg(all(
142 feature = "NSControl",
143 feature = "NSResponder",
144 feature = "NSTextContent",
145 feature = "NSTextField",
146 feature = "NSView"
147))]
148extern_conformance!(
149 unsafe impl NSTextContent for NSSearchField {}
150);
151
152#[cfg(all(
153 feature = "NSControl",
154 feature = "NSResponder",
155 feature = "NSTextField",
156 feature = "NSUserInterfaceItemIdentification",
157 feature = "NSView"
158))]
159extern_conformance!(
160 unsafe impl NSUserInterfaceItemIdentification for NSSearchField {}
161);
162
163#[cfg(all(
164 feature = "NSControl",
165 feature = "NSResponder",
166 feature = "NSTextField",
167 feature = "NSUserInterfaceValidation",
168 feature = "NSView"
169))]
170extern_conformance!(
171 unsafe impl NSUserInterfaceValidations for NSSearchField {}
172);
173
174#[cfg(all(
175 feature = "NSControl",
176 feature = "NSResponder",
177 feature = "NSTextField",
178 feature = "NSView"
179))]
180impl NSSearchField {
181 extern_methods!(
182 #[unsafe(method(searchTextBounds))]
183 #[unsafe(method_family = none)]
184 pub fn searchTextBounds(&self) -> NSRect;
185
186 #[unsafe(method(searchButtonBounds))]
187 #[unsafe(method_family = none)]
188 pub fn searchButtonBounds(&self) -> NSRect;
189
190 #[unsafe(method(cancelButtonBounds))]
191 #[unsafe(method_family = none)]
192 pub fn cancelButtonBounds(&self) -> NSRect;
193
194 #[unsafe(method(recentSearches))]
195 #[unsafe(method_family = none)]
196 pub fn recentSearches(&self) -> Retained<NSArray<NSString>>;
197
198 #[unsafe(method(setRecentSearches:))]
202 #[unsafe(method_family = none)]
203 pub fn setRecentSearches(&self, recent_searches: &NSArray<NSString>);
204
205 #[unsafe(method(recentsAutosaveName))]
206 #[unsafe(method_family = none)]
207 pub fn recentsAutosaveName(&self) -> Option<Retained<NSSearchFieldRecentsAutosaveName>>;
208
209 #[unsafe(method(setRecentsAutosaveName:))]
213 #[unsafe(method_family = none)]
214 pub fn setRecentsAutosaveName(
215 &self,
216 recents_autosave_name: Option<&NSSearchFieldRecentsAutosaveName>,
217 );
218
219 #[cfg(feature = "NSMenu")]
220 #[unsafe(method(searchMenuTemplate))]
221 #[unsafe(method_family = none)]
222 pub fn searchMenuTemplate(&self) -> Option<Retained<NSMenu>>;
223
224 #[cfg(feature = "NSMenu")]
225 #[unsafe(method(setSearchMenuTemplate:))]
227 #[unsafe(method_family = none)]
228 pub fn setSearchMenuTemplate(&self, search_menu_template: Option<&NSMenu>);
229
230 #[unsafe(method(sendsWholeSearchString))]
231 #[unsafe(method_family = none)]
232 pub fn sendsWholeSearchString(&self) -> bool;
233
234 #[unsafe(method(setSendsWholeSearchString:))]
236 #[unsafe(method_family = none)]
237 pub fn setSendsWholeSearchString(&self, sends_whole_search_string: bool);
238
239 #[unsafe(method(maximumRecents))]
240 #[unsafe(method_family = none)]
241 pub fn maximumRecents(&self) -> NSInteger;
242
243 #[unsafe(method(setMaximumRecents:))]
245 #[unsafe(method_family = none)]
246 pub fn setMaximumRecents(&self, maximum_recents: NSInteger);
247
248 #[unsafe(method(sendsSearchStringImmediately))]
249 #[unsafe(method_family = none)]
250 pub fn sendsSearchStringImmediately(&self) -> bool;
251
252 #[unsafe(method(setSendsSearchStringImmediately:))]
254 #[unsafe(method_family = none)]
255 pub fn setSendsSearchStringImmediately(&self, sends_search_string_immediately: bool);
256
257 #[unsafe(method(delegate))]
258 #[unsafe(method_family = none)]
259 pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSSearchFieldDelegate>>>;
260
261 #[unsafe(method(setDelegate:))]
265 #[unsafe(method_family = none)]
266 pub unsafe fn setDelegate(
267 &self,
268 delegate: Option<&ProtocolObject<dyn NSSearchFieldDelegate>>,
269 );
270 );
271}
272
273#[cfg(all(
275 feature = "NSControl",
276 feature = "NSResponder",
277 feature = "NSTextField",
278 feature = "NSView"
279))]
280impl NSSearchField {
281 extern_methods!(
282 #[unsafe(method(initWithFrame:))]
283 #[unsafe(method_family = init)]
284 pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
285
286 #[unsafe(method(initWithCoder:))]
290 #[unsafe(method_family = init)]
291 pub unsafe fn initWithCoder(
292 this: Allocated<Self>,
293 coder: &NSCoder,
294 ) -> Option<Retained<Self>>;
295 );
296}
297
298#[cfg(all(
300 feature = "NSControl",
301 feature = "NSResponder",
302 feature = "NSTextField",
303 feature = "NSView"
304))]
305impl NSSearchField {
306 extern_methods!(
307 #[unsafe(method(init))]
308 #[unsafe(method_family = init)]
309 pub fn init(this: Allocated<Self>) -> Retained<Self>;
310 );
311}
312
313#[cfg(all(
315 feature = "NSControl",
316 feature = "NSResponder",
317 feature = "NSTextField",
318 feature = "NSView"
319))]
320impl NSSearchField {
321 extern_methods!(
322 #[unsafe(method(new))]
323 #[unsafe(method_family = new)]
324 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
325 );
326}
327
328#[cfg(all(
330 feature = "NSControl",
331 feature = "NSResponder",
332 feature = "NSTextField",
333 feature = "NSView"
334))]
335impl NSSearchField {
336 extern_methods!(
337 #[deprecated]
338 #[unsafe(method(rectForSearchTextWhenCentered:))]
339 #[unsafe(method_family = none)]
340 pub fn rectForSearchTextWhenCentered(&self, is_centered: bool) -> NSRect;
341
342 #[deprecated]
343 #[unsafe(method(rectForSearchButtonWhenCentered:))]
344 #[unsafe(method_family = none)]
345 pub fn rectForSearchButtonWhenCentered(&self, is_centered: bool) -> NSRect;
346
347 #[deprecated]
348 #[unsafe(method(rectForCancelButtonWhenCentered:))]
349 #[unsafe(method_family = none)]
350 pub fn rectForCancelButtonWhenCentered(&self, is_centered: bool) -> NSRect;
351
352 #[deprecated = "The placeholder centering UI design is no longer available. Setting this property is no-op."]
353 #[unsafe(method(centersPlaceholder))]
354 #[unsafe(method_family = none)]
355 pub fn centersPlaceholder(&self) -> bool;
356
357 #[deprecated = "The placeholder centering UI design is no longer available. Setting this property is no-op."]
359 #[unsafe(method(setCentersPlaceholder:))]
360 #[unsafe(method_family = none)]
361 pub fn setCentersPlaceholder(&self, centers_placeholder: bool);
362 );
363}