objc2_quick_look_ui/generated/QLPreviewPanel.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
12extern_class!(
13 /// A class that implements the Quick Look preview panel to display a preview of
14 /// a list of items.
15 ///
16 /// Every application has a single shared instance of
17 /// ``QuickLookUI/QLPreviewPanel`` accessible through
18 /// ``QuickLookUI/QLPreviewPanel/sharedPreviewPanel``. The preview panel follows
19 /// the responder chain and adapts to the first responder willing to control it.
20 /// A preview panel controller provides the content through methods defined in
21 /// the ``QuickLookUI/QLPreviewPanelDataSource`` protocol.
22 ///
23 /// You can’t subclass ``QuickLookUI/QLPreviewPanel``; you can, however,
24 /// customize its behavior using a ``QuickLookUI/QLPreviewPanel/delegate``. See
25 /// the ``QuickLookUI/QLPreviewPanelDelegate`` protocol for the methods to
26 /// customize a preview panel’s behavior.
27 ///
28 /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewpanel?language=objc)
29 #[unsafe(super(NSPanel, NSWindow, NSResponder, NSObject))]
30 #[derive(Debug, PartialEq, Eq, Hash)]
31 #[cfg(feature = "objc2-app-kit")]
32 pub struct QLPreviewPanel;
33);
34
35#[cfg(feature = "objc2-app-kit")]
36extern_conformance!(
37 unsafe impl NSAccessibility for QLPreviewPanel {}
38);
39
40#[cfg(feature = "objc2-app-kit")]
41extern_conformance!(
42 unsafe impl NSAccessibilityElementProtocol for QLPreviewPanel {}
43);
44
45#[cfg(feature = "objc2-app-kit")]
46extern_conformance!(
47 unsafe impl NSAnimatablePropertyContainer for QLPreviewPanel {}
48);
49
50#[cfg(feature = "objc2-app-kit")]
51extern_conformance!(
52 unsafe impl NSAppearanceCustomization for QLPreviewPanel {}
53);
54
55#[cfg(feature = "objc2-app-kit")]
56extern_conformance!(
57 unsafe impl NSCoding for QLPreviewPanel {}
58);
59
60#[cfg(feature = "objc2-app-kit")]
61extern_conformance!(
62 unsafe impl NSMenuItemValidation for QLPreviewPanel {}
63);
64
65#[cfg(feature = "objc2-app-kit")]
66extern_conformance!(
67 unsafe impl NSObjectProtocol for QLPreviewPanel {}
68);
69
70#[cfg(feature = "objc2-app-kit")]
71extern_conformance!(
72 unsafe impl NSUserInterfaceItemIdentification for QLPreviewPanel {}
73);
74
75#[cfg(feature = "objc2-app-kit")]
76extern_conformance!(
77 unsafe impl NSUserInterfaceValidations for QLPreviewPanel {}
78);
79
80#[cfg(feature = "objc2-app-kit")]
81impl QLPreviewPanel {
82 extern_methods!(
83 /// Returns the shared Quick Look preview panel instance.
84 ///
85 /// This method creates the panel if it doesn’t exist yet. Use
86 /// ``QuickLookUI/QLPreviewPanel/sharedPreviewPanelExists`` if you want to
87 /// determine whether the panel exists without creating it.
88 ///
89 /// - Returns: The shared Quick Look preview panel instance for the application.
90 #[unsafe(method(sharedPreviewPanel))]
91 #[unsafe(method_family = none)]
92 pub unsafe fn sharedPreviewPanel(mtm: MainThreadMarker)
93 -> Option<Retained<QLPreviewPanel>>;
94
95 /// Returns a Boolean value that indicates whether the system has created a
96 /// shared Quick Look preview panel.
97 ///
98 /// - Returns:
99 /// <doc
100 /// ://com.apple.documentation/documentation/objectivec/yes> if
101 /// the shared Quick Look preview panel instance has been created, otherwise
102 /// <doc
103 /// ://com.apple.documentation/documentation/objectivec/no>.
104 #[unsafe(method(sharedPreviewPanelExists))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn sharedPreviewPanelExists(mtm: MainThreadMarker) -> bool;
107
108 /// The current first responder accepting to control the preview panel.
109 ///
110 /// You should never change the preview panel’s state (for example, its
111 /// delegate, datasource, and so on) if you aren’t controlling it.
112 #[unsafe(method(currentController))]
113 #[unsafe(method_family = none)]
114 pub unsafe fn currentController(&self) -> Option<Retained<AnyObject>>;
115
116 /// Asks the preview panel to update its current controller.
117 ///
118 /// The preview panel automatically updates its controller (by searching the
119 /// responder chain) whenever the main or key window changes. You should only
120 /// invoke this method if the responder chain changes without explicit notice.
121 #[unsafe(method(updateController))]
122 #[unsafe(method_family = none)]
123 pub unsafe fn updateController(&self);
124
125 /// The preview panel data source.
126 ///
127 /// # Safety
128 ///
129 /// This is not retained internally, you must ensure the object is still alive.
130 #[unsafe(method(dataSource))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn dataSource(
133 &self,
134 ) -> Option<Retained<ProtocolObject<dyn QLPreviewPanelDataSource>>>;
135
136 /// Setter for [`dataSource`][Self::dataSource].
137 ///
138 /// # Safety
139 ///
140 /// - `data_source` might not allow `None`.
141 /// - This is unretained, you must ensure the object is kept alive while in use.
142 #[unsafe(method(setDataSource:))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn setDataSource(
145 &self,
146 data_source: Option<&ProtocolObject<dyn QLPreviewPanelDataSource>>,
147 );
148
149 /// Asks the preview panel to reload its data from its data source.
150 ///
151 /// This method doesn’t refresh the visible item if it hasn’t changed.
152 #[unsafe(method(reloadData))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn reloadData(&self);
155
156 /// Asks the preview panel to recompute the preview of the current preview item.
157 #[unsafe(method(refreshCurrentPreviewItem))]
158 #[unsafe(method_family = none)]
159 pub unsafe fn refreshCurrentPreviewItem(&self);
160
161 /// The index of the current preview item.
162 ///
163 /// The value is `NSNotFound` if there’s no current preview item.
164 #[unsafe(method(currentPreviewItemIndex))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn currentPreviewItemIndex(&self) -> NSInteger;
167
168 /// Setter for [`currentPreviewItemIndex`][Self::currentPreviewItemIndex].
169 #[unsafe(method(setCurrentPreviewItemIndex:))]
170 #[unsafe(method_family = none)]
171 pub unsafe fn setCurrentPreviewItemIndex(&self, current_preview_item_index: NSInteger);
172
173 #[cfg(feature = "QLPreviewItem")]
174 /// The currently previewed item.
175 ///
176 /// The value is `nil` if there’s no current preview item.
177 #[unsafe(method(currentPreviewItem))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn currentPreviewItem(
180 &self,
181 ) -> Option<Retained<ProtocolObject<dyn QLPreviewItem>>>;
182
183 /// The preview panel’s display state.
184 ///
185 /// This property is an opaque object that Quick Look uses to get and set the
186 /// current display state of the preview. The display state could be, for
187 /// example, the currently displayed page, the zoom factor on an image, or the
188 /// position in a movie.
189 ///
190 /// You can use this property to get and save the current display state of the
191 /// preview before switching to another. This saving allows you to restore a
192 /// preview later on when the user switches back to it.
193 #[unsafe(method(displayState))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn displayState(&self) -> Option<Retained<AnyObject>>;
196
197 /// Setter for [`displayState`][Self::displayState].
198 ///
199 /// # Safety
200 ///
201 /// - `display_state` should be of the correct type.
202 /// - `display_state` might not allow `None`.
203 #[unsafe(method(setDisplayState:))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn setDisplayState(&self, display_state: Option<&AnyObject>);
206
207 /// The delegate object that controls the preview panel’s behavior.
208 ///
209 /// The class assigned as the delegate should conform to the
210 /// ``QuickLookUI/QLPreviewPanelDelegate`` protocol.
211 ///
212 /// # Safety
213 ///
214 /// This is not retained internally, you must ensure the object is still alive.
215 #[unsafe(method(delegate))]
216 #[unsafe(method_family = none)]
217 pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;
218
219 /// Setter for [`delegate`][Self::delegate].
220 ///
221 /// # Safety
222 ///
223 /// - `delegate` should be of the correct type.
224 /// - `delegate` might not allow `None`.
225 /// - This is unretained, you must ensure the object is kept alive while in use.
226 #[unsafe(method(setDelegate:))]
227 #[unsafe(method_family = none)]
228 pub unsafe fn setDelegate(&self, delegate: Option<&AnyObject>);
229
230 /// Instructs the panel to enter full screen mode.
231 ///
232 /// If the panel isn’t onscreen, the panel goes directly to full screen mode.
233 ///
234 /// The panel chooses the appropriate screen depending on where the panel is or,
235 /// if entering fullscreen directly, where the panel zooms from.
236 ///
237 /// - Parameters:
238 /// - screen: This parameter isn’t currently used—pass `nil`.
239 ///
240 /// - options: This parameter isn’t currently used—pass `nil`.
241 ///
242 /// - Returns:
243 /// <doc
244 /// ://com.apple.documentation/documentation/objectivec/yes> if
245 /// the panel was able to enter full screen mode; otherwise,
246 /// <doc
247 /// ://com.apple.documentation/documentation/objectivec/no>.
248 ///
249 /// # Safety
250 ///
251 /// - `screen` might not allow `None`.
252 /// - `options` generic should be of the correct type.
253 /// - `options` might not allow `None`.
254 #[unsafe(method(enterFullScreenMode:withOptions:))]
255 #[unsafe(method_family = none)]
256 pub unsafe fn enterFullScreenMode_withOptions(
257 &self,
258 screen: Option<&NSScreen>,
259 options: Option<&NSDictionary>,
260 ) -> bool;
261
262 /// Instructs the panel to exit full screen mode.
263 ///
264 /// - Parameters:
265 /// - options: This parameter isn’t used — pass `nil`.
266 ///
267 /// # Safety
268 ///
269 /// - `options` generic should be of the correct type.
270 /// - `options` might not allow `None`.
271 #[unsafe(method(exitFullScreenModeWithOptions:))]
272 #[unsafe(method_family = none)]
273 pub unsafe fn exitFullScreenModeWithOptions(&self, options: Option<&NSDictionary>);
274
275 /// The property that indicates whether the panel is in full screen mode.
276 ///
277 /// The value is
278 /// <doc
279 /// ://com.apple.documentation/documentation/objectivec/yes> if
280 /// the panel is currently open and in full screen mode; otherwise it’s
281 /// <doc
282 /// ://com.apple.documentation/documentation/objectivec/no>.
283 #[unsafe(method(isInFullScreenMode))]
284 #[unsafe(method_family = none)]
285 pub unsafe fn isInFullScreenMode(&self) -> bool;
286 );
287}
288
289/// Methods declared on superclass `NSWindow`.
290#[cfg(feature = "objc2-app-kit")]
291impl QLPreviewPanel {
292 extern_methods!(
293 #[unsafe(method(initWithContentRect:styleMask:backing:defer:))]
294 #[unsafe(method_family = init)]
295 pub unsafe fn initWithContentRect_styleMask_backing_defer(
296 this: Allocated<Self>,
297 content_rect: NSRect,
298 style: NSWindowStyleMask,
299 backing_store_type: NSBackingStoreType,
300 flag: bool,
301 ) -> Retained<Self>;
302
303 #[unsafe(method(initWithContentRect:styleMask:backing:defer:screen:))]
304 #[unsafe(method_family = init)]
305 pub unsafe fn initWithContentRect_styleMask_backing_defer_screen(
306 this: Allocated<Self>,
307 content_rect: NSRect,
308 style: NSWindowStyleMask,
309 backing_store_type: NSBackingStoreType,
310 flag: bool,
311 screen: Option<&NSScreen>,
312 ) -> Retained<Self>;
313
314 /// # Safety
315 ///
316 /// `coder` possibly has further requirements.
317 #[unsafe(method(initWithCoder:))]
318 #[unsafe(method_family = init)]
319 pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
320
321 /// Convenience method for creating an autoreleased titled window with the given contentViewController. A basic NSWindow with the following attributes is made: titled, closable, resizable, miniaturizable. The window's title is automatically bound to the contentViewController's title. The size of the window can easily be controlled by utilizing autolayout and applying size constraints to the view (or its subviews). The window has isReleasedWhenClosed set to NO, and it must be explicitly retained to keep the window instance alive. To have it automatically be freed when it is closed, do the following: [window retain] and [window setReleasedWhenClosed:YES].
322 #[unsafe(method(windowWithContentViewController:))]
323 #[unsafe(method_family = none)]
324 pub unsafe fn windowWithContentViewController(
325 content_view_controller: &NSViewController,
326 ) -> Retained<Self>;
327 );
328}
329
330/// Methods declared on superclass `NSResponder`.
331#[cfg(feature = "objc2-app-kit")]
332impl QLPreviewPanel {
333 extern_methods!(
334 #[unsafe(method(init))]
335 #[unsafe(method_family = init)]
336 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
337 );
338}
339
340/// Methods declared on superclass `NSObject`.
341#[cfg(feature = "objc2-app-kit")]
342impl QLPreviewPanel {
343 extern_methods!(
344 #[unsafe(method(new))]
345 #[unsafe(method_family = new)]
346 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
347 );
348}
349
350mod private_NSObjectQLPreviewPanelController {
351 pub trait Sealed {}
352}
353
354/// Category "QLPreviewPanelController" on [`NSObject`].
355///
356/// Methods to implement by any object in the responder chain to control the Preview Panel
357///
358/// QLPreviewPanel shows previews for items provided by the first object in the responder chain accepting to control it. You generally implement these methods in your window controller or delegate. You should never try to modify Preview panel state if you're not controlling the panel.
359#[doc(alias = "QLPreviewPanelController")]
360pub unsafe trait NSObjectQLPreviewPanelController:
361 ClassType + Sized + private_NSObjectQLPreviewPanelController::Sealed
362{
363 extern_methods!(
364 #[cfg(feature = "objc2-app-kit")]
365 /// Sent to each object in the responder chain to find a controller.
366 ///
367 /// Parameter `panel`: The Preview Panel looking for a controller.
368 ///
369 /// Returns: YES if the receiver accepts to control the panel. You should never call this method directly.
370 ///
371 /// # Safety
372 ///
373 /// `panel` might not allow `None`.
374 #[unsafe(method(acceptsPreviewPanelControl:))]
375 #[unsafe(method_family = none)]
376 unsafe fn acceptsPreviewPanelControl(&self, panel: Option<&QLPreviewPanel>) -> bool;
377
378 #[cfg(feature = "objc2-app-kit")]
379 /// Sent to the object taking control of the Preview Panel.
380 ///
381 /// Parameter `panel`: The Preview Panel the receiver will control.
382 ///
383 /// The receiver should setup the preview panel (data source, delegate, binding, etc.) here. You should never call this method directly.
384 ///
385 /// # Safety
386 ///
387 /// `panel` might not allow `None`.
388 #[unsafe(method(beginPreviewPanelControl:))]
389 #[unsafe(method_family = none)]
390 unsafe fn beginPreviewPanelControl(&self, panel: Option<&QLPreviewPanel>);
391
392 #[cfg(feature = "objc2-app-kit")]
393 /// Sent to the object in control of the Preview Panel just before stopping its control.
394 ///
395 /// Parameter `panel`: The Preview Panel that the receiver will stop controlling.
396 ///
397 /// The receiver should unsetup the preview panel (data source, delegate, binding, etc.) here. You should never call this method directly.
398 ///
399 /// # Safety
400 ///
401 /// `panel` might not allow `None`.
402 #[unsafe(method(endPreviewPanelControl:))]
403 #[unsafe(method_family = none)]
404 unsafe fn endPreviewPanelControl(&self, panel: Option<&QLPreviewPanel>);
405 );
406}
407
408impl private_NSObjectQLPreviewPanelController::Sealed for NSObject {}
409unsafe impl NSObjectQLPreviewPanelController for NSObject {}
410
411extern_protocol!(
412 /// A protocol that the Quick Look preview panel uses to access the contents of
413 /// its data source object.
414 ///
415 /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewpaneldatasource?language=objc)
416 pub unsafe trait QLPreviewPanelDataSource {
417 #[cfg(feature = "objc2-app-kit")]
418 /// Returns the number of items that the preview panel should preview.
419 ///
420 /// - Parameters:
421 /// - panel: The preview panel.
422 ///
423 /// - Returns: The number of items the preview panel should display.
424 ///
425 /// # Safety
426 ///
427 /// `panel` might not allow `None`.
428 #[unsafe(method(numberOfPreviewItemsInPreviewPanel:))]
429 #[unsafe(method_family = none)]
430 unsafe fn numberOfPreviewItemsInPreviewPanel(
431 &self,
432 panel: Option<&QLPreviewPanel>,
433 ) -> NSInteger;
434
435 #[cfg(all(feature = "QLPreviewItem", feature = "objc2-app-kit"))]
436 /// Returns the item that the preview panel should preview at a given index.
437 ///
438 /// - Parameters:
439 /// - panel: The preview panel.
440 ///
441 /// - index: The index of the item to preview.
442 ///
443 /// - Returns: The item that the preview panel should preview at index `index`.
444 ///
445 /// # Safety
446 ///
447 /// `panel` might not allow `None`.
448 #[unsafe(method(previewPanel:previewItemAtIndex:))]
449 #[unsafe(method_family = none)]
450 unsafe fn previewPanel_previewItemAtIndex(
451 &self,
452 panel: Option<&QLPreviewPanel>,
453 index: NSInteger,
454 ) -> Option<Retained<ProtocolObject<dyn QLPreviewItem>>>;
455 }
456);
457
458extern_protocol!(
459 /// A protocol for the delegate of the Quick Look preview panel.
460 ///
461 /// You can implement these methods to perform custom tasks in response to
462 /// events in the preview panel.
463 ///
464 /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewpaneldelegate?language=objc)
465 #[cfg(feature = "objc2-app-kit")]
466 pub unsafe trait QLPreviewPanelDelegate: NSWindowDelegate {
467 /// Handles an event that the preview panel receives, but doesn’t handle.
468 ///
469 /// The preview panel invokes this optional method when it receives an event it
470 /// doesn’t handle.
471 ///
472 /// - Parameters:
473 /// - panel: The preview panel.
474 ///
475 /// - event: The event that the preview panel wasn’t able to handle.
476 ///
477 /// - Returns:
478 /// <doc
479 /// ://com.apple.documentation/documentation/objectivec/yes> if
480 /// the receiver handled the event; otherwise,
481 /// <doc
482 /// ://com.apple.documentation/documentation/objectivec/no>.
483 ///
484 /// # Safety
485 ///
486 /// - `panel` might not allow `None`.
487 /// - `event` might not allow `None`.
488 #[optional]
489 #[unsafe(method(previewPanel:handleEvent:))]
490 #[unsafe(method_family = none)]
491 unsafe fn previewPanel_handleEvent(
492 &self,
493 panel: Option<&QLPreviewPanel>,
494 event: Option<&NSEvent>,
495 ) -> bool;
496
497 #[cfg(feature = "QLPreviewItem")]
498 /// Returns the screen rectangle for a given preview item.
499 ///
500 /// The system invokes this optional method when the preview panel opens or
501 /// closes to provide a zoom effect. You should return — in screen coordinates —
502 /// the rectangle that displays the specified preview item.
503 ///
504 /// - Parameters:
505 /// - panel: The preview panel.
506 ///
507 /// - item: The preview item for which the screen rectangle is required.
508 ///
509 /// - Returns: The screen rectangle for the given preview item. Return
510 /// <doc
511 /// ://com.apple.documentation/documentation/foundation/nszerorect> if there
512 /// is no origin point (this will produce a fade of the panel).
513 ///
514 /// # Safety
515 ///
516 /// - `panel` might not allow `None`.
517 /// - `item` might not allow `None`.
518 #[optional]
519 #[unsafe(method(previewPanel:sourceFrameOnScreenForPreviewItem:))]
520 #[unsafe(method_family = none)]
521 unsafe fn previewPanel_sourceFrameOnScreenForPreviewItem(
522 &self,
523 panel: Option<&QLPreviewPanel>,
524 item: Option<&ProtocolObject<dyn QLPreviewItem>>,
525 ) -> NSRect;
526
527 #[cfg(feature = "QLPreviewItem")]
528 /// Returns the image to use for the transition zoom effect for a given item.
529 ///
530 /// The system invokes this optional method when the preview panel opens or
531 /// closes to provide a smooth transition when zooming. The return type of the
532 /// function should be an instance of
533 /// <doc
534 /// ://com.apple.documentation/documentation/appkit/nsimage>.
535 ///
536 /// - Parameters:
537 /// - panel: The preview panel.
538 ///
539 /// - item: The item the system is previewing.
540 ///
541 /// - contentRect: The rectangle within a preview image that actually represents
542 /// the content of the document. For icons, the actual rectangle is typically
543 /// smaller than the icon itself.
544 ///
545 /// - Returns: The image to use for the transition zoom effect for the `item`.
546 ///
547 /// # Safety
548 ///
549 /// - `panel` might not allow `None`.
550 /// - `item` might not allow `None`.
551 /// - `content_rect` must be a valid pointer.
552 #[optional]
553 #[unsafe(method(previewPanel:transitionImageForPreviewItem:contentRect:))]
554 #[unsafe(method_family = none)]
555 unsafe fn previewPanel_transitionImageForPreviewItem_contentRect(
556 &self,
557 panel: Option<&QLPreviewPanel>,
558 item: Option<&ProtocolObject<dyn QLPreviewItem>>,
559 content_rect: *mut NSRect,
560 ) -> Option<Retained<AnyObject>>;
561 }
562);