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 unsafe 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 unsafe 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))]
51unsafe impl NSAccessibility for NSSearchField {}
52
53#[cfg(all(
54 feature = "NSAccessibilityProtocols",
55 feature = "NSControl",
56 feature = "NSResponder",
57 feature = "NSTextField",
58 feature = "NSView"
59))]
60unsafe impl NSAccessibilityElementProtocol for NSSearchField {}
61
62#[cfg(all(
63 feature = "NSAccessibilityProtocols",
64 feature = "NSControl",
65 feature = "NSResponder",
66 feature = "NSTextField",
67 feature = "NSView"
68))]
69unsafe impl NSAccessibilityNavigableStaticText for NSSearchField {}
70
71#[cfg(all(
72 feature = "NSAccessibilityProtocols",
73 feature = "NSControl",
74 feature = "NSResponder",
75 feature = "NSTextField",
76 feature = "NSView"
77))]
78unsafe impl NSAccessibilityStaticText for NSSearchField {}
79
80#[cfg(all(
81 feature = "NSAnimation",
82 feature = "NSControl",
83 feature = "NSResponder",
84 feature = "NSTextField",
85 feature = "NSView"
86))]
87unsafe impl NSAnimatablePropertyContainer for NSSearchField {}
88
89#[cfg(all(
90 feature = "NSAppearance",
91 feature = "NSControl",
92 feature = "NSResponder",
93 feature = "NSTextField",
94 feature = "NSView"
95))]
96unsafe impl NSAppearanceCustomization for NSSearchField {}
97
98#[cfg(all(
99 feature = "NSControl",
100 feature = "NSResponder",
101 feature = "NSTextField",
102 feature = "NSView"
103))]
104unsafe impl NSCoding for NSSearchField {}
105
106#[cfg(all(
107 feature = "NSControl",
108 feature = "NSDragging",
109 feature = "NSResponder",
110 feature = "NSTextField",
111 feature = "NSView"
112))]
113unsafe impl NSDraggingDestination for NSSearchField {}
114
115#[cfg(all(
116 feature = "NSControl",
117 feature = "NSResponder",
118 feature = "NSTextField",
119 feature = "NSView"
120))]
121unsafe impl NSObjectProtocol for NSSearchField {}
122
123#[cfg(all(
124 feature = "NSControl",
125 feature = "NSResponder",
126 feature = "NSTextContent",
127 feature = "NSTextField",
128 feature = "NSView"
129))]
130unsafe impl NSTextContent for NSSearchField {}
131
132#[cfg(all(
133 feature = "NSControl",
134 feature = "NSResponder",
135 feature = "NSTextField",
136 feature = "NSUserInterfaceItemIdentification",
137 feature = "NSView"
138))]
139unsafe impl NSUserInterfaceItemIdentification for NSSearchField {}
140
141#[cfg(all(
142 feature = "NSControl",
143 feature = "NSResponder",
144 feature = "NSTextField",
145 feature = "NSUserInterfaceValidation",
146 feature = "NSView"
147))]
148unsafe impl NSUserInterfaceValidations for NSSearchField {}
149
150#[cfg(all(
151 feature = "NSControl",
152 feature = "NSResponder",
153 feature = "NSTextField",
154 feature = "NSView"
155))]
156impl NSSearchField {
157 extern_methods!(
158 #[unsafe(method(searchTextBounds))]
159 #[unsafe(method_family = none)]
160 pub unsafe fn searchTextBounds(&self) -> NSRect;
161
162 #[unsafe(method(searchButtonBounds))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn searchButtonBounds(&self) -> NSRect;
165
166 #[unsafe(method(cancelButtonBounds))]
167 #[unsafe(method_family = none)]
168 pub unsafe fn cancelButtonBounds(&self) -> NSRect;
169
170 #[unsafe(method(recentSearches))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn recentSearches(&self) -> Retained<NSArray<NSString>>;
173
174 #[unsafe(method(setRecentSearches:))]
176 #[unsafe(method_family = none)]
177 pub unsafe fn setRecentSearches(&self, recent_searches: &NSArray<NSString>);
178
179 #[unsafe(method(recentsAutosaveName))]
180 #[unsafe(method_family = none)]
181 pub unsafe fn recentsAutosaveName(
182 &self,
183 ) -> Option<Retained<NSSearchFieldRecentsAutosaveName>>;
184
185 #[unsafe(method(setRecentsAutosaveName:))]
187 #[unsafe(method_family = none)]
188 pub unsafe fn setRecentsAutosaveName(
189 &self,
190 recents_autosave_name: Option<&NSSearchFieldRecentsAutosaveName>,
191 );
192
193 #[cfg(feature = "NSMenu")]
194 #[unsafe(method(searchMenuTemplate))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn searchMenuTemplate(&self) -> Option<Retained<NSMenu>>;
197
198 #[cfg(feature = "NSMenu")]
199 #[unsafe(method(setSearchMenuTemplate:))]
201 #[unsafe(method_family = none)]
202 pub unsafe fn setSearchMenuTemplate(&self, search_menu_template: Option<&NSMenu>);
203
204 #[unsafe(method(sendsWholeSearchString))]
205 #[unsafe(method_family = none)]
206 pub unsafe fn sendsWholeSearchString(&self) -> bool;
207
208 #[unsafe(method(setSendsWholeSearchString:))]
210 #[unsafe(method_family = none)]
211 pub unsafe fn setSendsWholeSearchString(&self, sends_whole_search_string: bool);
212
213 #[unsafe(method(maximumRecents))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn maximumRecents(&self) -> NSInteger;
216
217 #[unsafe(method(setMaximumRecents:))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn setMaximumRecents(&self, maximum_recents: NSInteger);
221
222 #[unsafe(method(sendsSearchStringImmediately))]
223 #[unsafe(method_family = none)]
224 pub unsafe fn sendsSearchStringImmediately(&self) -> bool;
225
226 #[unsafe(method(setSendsSearchStringImmediately:))]
228 #[unsafe(method_family = none)]
229 pub unsafe fn setSendsSearchStringImmediately(&self, sends_search_string_immediately: bool);
230
231 #[unsafe(method(delegate))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn delegate(
234 &self,
235 ) -> Option<Retained<ProtocolObject<dyn NSSearchFieldDelegate>>>;
236
237 #[unsafe(method(setDelegate:))]
240 #[unsafe(method_family = none)]
241 pub unsafe fn setDelegate(
242 &self,
243 delegate: Option<&ProtocolObject<dyn NSSearchFieldDelegate>>,
244 );
245 );
246}
247
248#[cfg(all(
250 feature = "NSControl",
251 feature = "NSResponder",
252 feature = "NSTextField",
253 feature = "NSView"
254))]
255impl NSSearchField {
256 extern_methods!(
257 #[unsafe(method(initWithFrame:))]
258 #[unsafe(method_family = init)]
259 pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
260
261 #[unsafe(method(initWithCoder:))]
262 #[unsafe(method_family = init)]
263 pub unsafe fn initWithCoder(
264 this: Allocated<Self>,
265 coder: &NSCoder,
266 ) -> Option<Retained<Self>>;
267 );
268}
269
270#[cfg(all(
272 feature = "NSControl",
273 feature = "NSResponder",
274 feature = "NSTextField",
275 feature = "NSView"
276))]
277impl NSSearchField {
278 extern_methods!(
279 #[unsafe(method(init))]
280 #[unsafe(method_family = init)]
281 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
282 );
283}
284
285#[cfg(all(
287 feature = "NSControl",
288 feature = "NSResponder",
289 feature = "NSTextField",
290 feature = "NSView"
291))]
292impl NSSearchField {
293 extern_methods!(
294 #[unsafe(method(new))]
295 #[unsafe(method_family = new)]
296 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
297 );
298}
299
300#[cfg(all(
302 feature = "NSControl",
303 feature = "NSResponder",
304 feature = "NSTextField",
305 feature = "NSView"
306))]
307impl NSSearchField {
308 extern_methods!(
309 #[deprecated]
310 #[unsafe(method(rectForSearchTextWhenCentered:))]
311 #[unsafe(method_family = none)]
312 pub unsafe fn rectForSearchTextWhenCentered(&self, is_centered: bool) -> NSRect;
313
314 #[deprecated]
315 #[unsafe(method(rectForSearchButtonWhenCentered:))]
316 #[unsafe(method_family = none)]
317 pub unsafe fn rectForSearchButtonWhenCentered(&self, is_centered: bool) -> NSRect;
318
319 #[deprecated]
320 #[unsafe(method(rectForCancelButtonWhenCentered:))]
321 #[unsafe(method_family = none)]
322 pub unsafe fn rectForCancelButtonWhenCentered(&self, is_centered: bool) -> NSRect;
323
324 #[deprecated = "The placeholder centering UI design is no longer available. Setting this property is no-op."]
325 #[unsafe(method(centersPlaceholder))]
326 #[unsafe(method_family = none)]
327 pub unsafe fn centersPlaceholder(&self) -> bool;
328
329 #[deprecated = "The placeholder centering UI design is no longer available. Setting this property is no-op."]
331 #[unsafe(method(setCentersPlaceholder:))]
332 #[unsafe(method_family = none)]
333 pub unsafe fn setCentersPlaceholder(&self, centers_placeholder: bool);
334 );
335}