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        #[unsafe(method(dataSource))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn dataSource(
129            &self,
130        ) -> Option<Retained<ProtocolObject<dyn QLPreviewPanelDataSource>>>;
131
132        /// Setter for [`dataSource`][Self::dataSource].
133        #[unsafe(method(setDataSource:))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn setDataSource(
136            &self,
137            data_source: Option<&ProtocolObject<dyn QLPreviewPanelDataSource>>,
138        );
139
140        /// Asks the preview panel to reload its data from its data source.
141        ///
142        /// This method doesn’t refresh the visible item if it hasn’t changed.
143        #[unsafe(method(reloadData))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn reloadData(&self);
146
147        /// Asks the preview panel to recompute the preview of the current preview item.
148        #[unsafe(method(refreshCurrentPreviewItem))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn refreshCurrentPreviewItem(&self);
151
152        /// The index of the current preview item.
153        ///
154        /// The value is `NSNotFound` if there’s no current preview item.
155        #[unsafe(method(currentPreviewItemIndex))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn currentPreviewItemIndex(&self) -> NSInteger;
158
159        /// Setter for [`currentPreviewItemIndex`][Self::currentPreviewItemIndex].
160        #[unsafe(method(setCurrentPreviewItemIndex:))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn setCurrentPreviewItemIndex(&self, current_preview_item_index: NSInteger);
163
164        #[cfg(feature = "QLPreviewItem")]
165        /// The currently previewed item.
166        ///
167        /// The value is `nil` if there’s no current preview item.
168        #[unsafe(method(currentPreviewItem))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn currentPreviewItem(
171            &self,
172        ) -> Option<Retained<ProtocolObject<dyn QLPreviewItem>>>;
173
174        /// The preview panel’s display state.
175        ///
176        /// This property is an opaque object that Quick Look uses to get and set the
177        /// current display state of the preview. The display state could be, for
178        /// example, the currently displayed page, the zoom factor on an image, or the
179        /// position in a movie.
180        ///
181        /// You can use this property to get and save the current display state of the
182        /// preview before switching to another. This saving allows you to restore a
183        /// preview later on when the user switches back to it.
184        #[unsafe(method(displayState))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn displayState(&self) -> Option<Retained<AnyObject>>;
187
188        /// Setter for [`displayState`][Self::displayState].
189        #[unsafe(method(setDisplayState:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn setDisplayState(&self, display_state: Option<&AnyObject>);
192
193        /// The delegate object that controls the preview panel’s behavior.
194        ///
195        /// The class assigned as the delegate should conform to the
196        /// ``QuickLookUI/QLPreviewPanelDelegate`` protocol.
197        #[unsafe(method(delegate))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;
200
201        /// Setter for [`delegate`][Self::delegate].
202        #[unsafe(method(setDelegate:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn setDelegate(&self, delegate: Option<&AnyObject>);
205
206        /// Instructs the panel to enter full screen mode.
207        ///
208        /// If the panel isn’t onscreen, the panel goes directly to full screen mode.
209        ///
210        /// The panel chooses the appropriate screen depending on where the panel is or,
211        /// if entering fullscreen directly, where the panel zooms from.
212        ///
213        /// - Parameters:
214        /// - screen: This parameter isn’t currently used—pass `nil`.
215        ///
216        /// - options: This parameter isn’t currently used—pass `nil`.
217        ///
218        /// - Returns:
219        /// <doc
220        /// ://com.apple.documentation/documentation/objectivec/yes> if
221        /// the panel was able to enter full screen mode; otherwise,
222        /// <doc
223        /// ://com.apple.documentation/documentation/objectivec/no>.
224        #[unsafe(method(enterFullScreenMode:withOptions:))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn enterFullScreenMode_withOptions(
227            &self,
228            screen: Option<&NSScreen>,
229            options: Option<&NSDictionary>,
230        ) -> bool;
231
232        /// Instructs the panel to exit full screen mode.
233        ///
234        /// - Parameters:
235        /// - options: This parameter isn’t used — pass `nil`.
236        #[unsafe(method(exitFullScreenModeWithOptions:))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn exitFullScreenModeWithOptions(&self, options: Option<&NSDictionary>);
239
240        /// The property that indicates whether the panel is in full screen mode.
241        ///
242        /// The value is
243        /// <doc
244        /// ://com.apple.documentation/documentation/objectivec/yes> if
245        /// the panel is currently open and in full screen mode; otherwise it’s
246        /// <doc
247        /// ://com.apple.documentation/documentation/objectivec/no>.
248        #[unsafe(method(isInFullScreenMode))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn isInFullScreenMode(&self) -> bool;
251    );
252}
253
254/// Methods declared on superclass `NSWindow`.
255#[cfg(feature = "objc2-app-kit")]
256impl QLPreviewPanel {
257    extern_methods!(
258        #[unsafe(method(initWithContentRect:styleMask:backing:defer:))]
259        #[unsafe(method_family = init)]
260        pub unsafe fn initWithContentRect_styleMask_backing_defer(
261            this: Allocated<Self>,
262            content_rect: NSRect,
263            style: NSWindowStyleMask,
264            backing_store_type: NSBackingStoreType,
265            flag: bool,
266        ) -> Retained<Self>;
267
268        #[unsafe(method(initWithContentRect:styleMask:backing:defer:screen:))]
269        #[unsafe(method_family = init)]
270        pub unsafe fn initWithContentRect_styleMask_backing_defer_screen(
271            this: Allocated<Self>,
272            content_rect: NSRect,
273            style: NSWindowStyleMask,
274            backing_store_type: NSBackingStoreType,
275            flag: bool,
276            screen: Option<&NSScreen>,
277        ) -> Retained<Self>;
278
279        #[unsafe(method(initWithCoder:))]
280        #[unsafe(method_family = init)]
281        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
282
283        /// 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].
284        #[unsafe(method(windowWithContentViewController:))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn windowWithContentViewController(
287            content_view_controller: &NSViewController,
288        ) -> Retained<Self>;
289    );
290}
291
292/// Methods declared on superclass `NSResponder`.
293#[cfg(feature = "objc2-app-kit")]
294impl QLPreviewPanel {
295    extern_methods!(
296        #[unsafe(method(init))]
297        #[unsafe(method_family = init)]
298        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
299    );
300}
301
302/// Methods declared on superclass `NSObject`.
303#[cfg(feature = "objc2-app-kit")]
304impl QLPreviewPanel {
305    extern_methods!(
306        #[unsafe(method(new))]
307        #[unsafe(method_family = new)]
308        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
309    );
310}
311
312mod private_NSObjectQLPreviewPanelController {
313    pub trait Sealed {}
314}
315
316/// Category "QLPreviewPanelController" on [`NSObject`].
317/// Methods to implement by any object in the responder chain to control the Preview Panel
318///
319/// 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.
320#[doc(alias = "QLPreviewPanelController")]
321pub unsafe trait NSObjectQLPreviewPanelController:
322    ClassType + Sized + private_NSObjectQLPreviewPanelController::Sealed
323{
324    extern_methods!(
325        #[cfg(feature = "objc2-app-kit")]
326        /// Sent to each object in the responder chain to find a controller.
327        ///
328        /// Parameter `panel`: The Preview Panel looking for a controller.
329        ///
330        /// Returns: YES if the receiver accepts to control the panel. You should never call this method directly.
331        #[unsafe(method(acceptsPreviewPanelControl:))]
332        #[unsafe(method_family = none)]
333        unsafe fn acceptsPreviewPanelControl(&self, panel: Option<&QLPreviewPanel>) -> bool;
334
335        #[cfg(feature = "objc2-app-kit")]
336        /// Sent to the object taking control of the Preview Panel.
337        ///
338        /// Parameter `panel`: The Preview Panel the receiver will control.
339        ///
340        /// The receiver should setup the preview panel (data source, delegate, binding, etc.) here. You should never call this method directly.
341        #[unsafe(method(beginPreviewPanelControl:))]
342        #[unsafe(method_family = none)]
343        unsafe fn beginPreviewPanelControl(&self, panel: Option<&QLPreviewPanel>);
344
345        #[cfg(feature = "objc2-app-kit")]
346        /// Sent to the object in control of the Preview Panel just before stopping its control.
347        ///
348        /// Parameter `panel`: The Preview Panel that the receiver will stop controlling.
349        ///
350        /// The receiver should unsetup the preview panel (data source, delegate, binding, etc.) here. You should never call this method directly.
351        #[unsafe(method(endPreviewPanelControl:))]
352        #[unsafe(method_family = none)]
353        unsafe fn endPreviewPanelControl(&self, panel: Option<&QLPreviewPanel>);
354    );
355}
356
357impl private_NSObjectQLPreviewPanelController::Sealed for NSObject {}
358unsafe impl NSObjectQLPreviewPanelController for NSObject {}
359
360extern_protocol!(
361    /// A protocol that the Quick Look preview panel uses to access the contents of
362    /// its data source object.
363    ///
364    /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewpaneldatasource?language=objc)
365    pub unsafe trait QLPreviewPanelDataSource {
366        #[cfg(feature = "objc2-app-kit")]
367        /// Returns the number of items that the preview panel should preview.
368        ///
369        /// - Parameters:
370        /// - panel: The preview panel.
371        ///
372        /// - Returns: The number of items the preview panel should display.
373        #[unsafe(method(numberOfPreviewItemsInPreviewPanel:))]
374        #[unsafe(method_family = none)]
375        unsafe fn numberOfPreviewItemsInPreviewPanel(
376            &self,
377            panel: Option<&QLPreviewPanel>,
378        ) -> NSInteger;
379
380        #[cfg(all(feature = "QLPreviewItem", feature = "objc2-app-kit"))]
381        /// Returns the item that the preview panel should preview at a given index.
382        ///
383        /// - Parameters:
384        /// - panel: The preview panel.
385        ///
386        /// - index: The index of the item to preview.
387        ///
388        /// - Returns: The item that the preview panel should preview at index `index`.
389        #[unsafe(method(previewPanel:previewItemAtIndex:))]
390        #[unsafe(method_family = none)]
391        unsafe fn previewPanel_previewItemAtIndex(
392            &self,
393            panel: Option<&QLPreviewPanel>,
394            index: NSInteger,
395        ) -> Option<Retained<ProtocolObject<dyn QLPreviewItem>>>;
396    }
397);
398
399extern_protocol!(
400    /// A protocol for the delegate of the Quick Look preview panel.
401    ///
402    /// You can implement these methods to perform custom tasks in response to
403    /// events in the preview panel.
404    ///
405    /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewpaneldelegate?language=objc)
406    #[cfg(feature = "objc2-app-kit")]
407    pub unsafe trait QLPreviewPanelDelegate: NSWindowDelegate {
408        /// Handles an event that the preview panel receives, but doesn’t handle.
409        ///
410        /// The preview panel invokes this optional method when it receives an event it
411        /// doesn’t handle.
412        ///
413        /// - Parameters:
414        /// - panel: The preview panel.
415        ///
416        /// - event: The event that the preview panel wasn’t able to handle.
417        ///
418        /// - Returns:
419        /// <doc
420        /// ://com.apple.documentation/documentation/objectivec/yes> if
421        /// the receiver handled the event; otherwise,
422        /// <doc
423        /// ://com.apple.documentation/documentation/objectivec/no>.
424        #[optional]
425        #[unsafe(method(previewPanel:handleEvent:))]
426        #[unsafe(method_family = none)]
427        unsafe fn previewPanel_handleEvent(
428            &self,
429            panel: Option<&QLPreviewPanel>,
430            event: Option<&NSEvent>,
431        ) -> bool;
432
433        #[cfg(feature = "QLPreviewItem")]
434        /// Returns the screen rectangle for a given preview item.
435        ///
436        /// The system invokes this optional method when the preview panel opens or
437        /// closes to provide a zoom effect. You should return — in screen coordinates —
438        /// the rectangle that displays the specified preview item.
439        ///
440        /// - Parameters:
441        /// - panel: The preview panel.
442        ///
443        /// - item: The preview item for which the screen rectangle is required.
444        ///
445        /// - Returns: The screen rectangle for the given preview item. Return
446        /// <doc
447        /// ://com.apple.documentation/documentation/foundation/nszerorect> if there
448        /// is no origin point (this will produce a fade of the panel).
449        #[optional]
450        #[unsafe(method(previewPanel:sourceFrameOnScreenForPreviewItem:))]
451        #[unsafe(method_family = none)]
452        unsafe fn previewPanel_sourceFrameOnScreenForPreviewItem(
453            &self,
454            panel: Option<&QLPreviewPanel>,
455            item: Option<&ProtocolObject<dyn QLPreviewItem>>,
456        ) -> NSRect;
457
458        #[cfg(feature = "QLPreviewItem")]
459        /// Returns the image to use for the transition zoom effect for a given item.
460        ///
461        /// The system invokes this optional method when the preview panel opens or
462        /// closes to provide a smooth transition when zooming. The return type of the
463        /// function should be an instance of
464        /// <doc
465        /// ://com.apple.documentation/documentation/appkit/nsimage>.
466        ///
467        /// - Parameters:
468        /// - panel: The preview panel.
469        ///
470        /// - item: The item the system is previewing.
471        ///
472        /// - contentRect: The rectangle within a preview image that actually represents
473        /// the content of the document. For icons, the actual rectangle is typically
474        /// smaller than the icon itself.
475        ///
476        /// - Returns: The image to use for the transition zoom effect for the `item`.
477        #[optional]
478        #[unsafe(method(previewPanel:transitionImageForPreviewItem:contentRect:))]
479        #[unsafe(method_family = none)]
480        unsafe fn previewPanel_transitionImageForPreviewItem_contentRect(
481            &self,
482            panel: Option<&QLPreviewPanel>,
483            item: Option<&ProtocolObject<dyn QLPreviewItem>>,
484            content_rect: *mut NSRect,
485        ) -> Option<Retained<AnyObject>>;
486    }
487);