//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
use objc2_app_kit::*;
use objc2_foundation::*;
use crate::*;
extern_class!(
/// A class that implements the Quick Look preview panel to display a preview of
/// a list of items.
///
/// Every application has a single shared instance of
/// ``QuickLookUI/QLPreviewPanel`` accessible through
/// ``QuickLookUI/QLPreviewPanel/sharedPreviewPanel``. The preview panel follows
/// the responder chain and adapts to the first responder willing to control it.
/// A preview panel controller provides the content through methods defined in
/// the ``QuickLookUI/QLPreviewPanelDataSource`` protocol.
///
/// You can’t subclass ``QuickLookUI/QLPreviewPanel``; you can, however,
/// customize its behavior using a ``QuickLookUI/QLPreviewPanel/delegate``. See
/// the ``QuickLookUI/QLPreviewPanelDelegate`` protocol for the methods to
/// customize a preview panel’s behavior.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewpanel?language=objc)
#[unsafe(super(NSPanel, NSWindow, NSResponder, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "objc2-app-kit")]
pub struct QLPreviewPanel;
);
#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
unsafe impl NSAccessibility for QLPreviewPanel {}
);
#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
unsafe impl NSAccessibilityElementProtocol for QLPreviewPanel {}
);
#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
unsafe impl NSAnimatablePropertyContainer for QLPreviewPanel {}
);
#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
unsafe impl NSAppearanceCustomization for QLPreviewPanel {}
);
#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
unsafe impl NSCoding for QLPreviewPanel {}
);
#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
unsafe impl NSMenuItemValidation for QLPreviewPanel {}
);
#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
unsafe impl NSObjectProtocol for QLPreviewPanel {}
);
#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
unsafe impl NSUserInterfaceItemIdentification for QLPreviewPanel {}
);
#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
unsafe impl NSUserInterfaceValidations for QLPreviewPanel {}
);
#[cfg(feature = "objc2-app-kit")]
impl QLPreviewPanel {
extern_methods!(
/// Returns the shared Quick Look preview panel instance.
///
/// This method creates the panel if it doesn’t exist yet. Use
/// ``QuickLookUI/QLPreviewPanel/sharedPreviewPanelExists`` if you want to
/// determine whether the panel exists without creating it.
///
/// - Returns: The shared Quick Look preview panel instance for the application.
#[unsafe(method(sharedPreviewPanel))]
#[unsafe(method_family = none)]
pub unsafe fn sharedPreviewPanel(mtm: MainThreadMarker)
-> Option<Retained<QLPreviewPanel>>;
/// Returns a Boolean value that indicates whether the system has created a
/// shared Quick Look preview panel.
///
/// - Returns:
/// <doc
/// ://com.apple.documentation/documentation/objectivec/yes> if
/// the shared Quick Look preview panel instance has been created, otherwise
/// <doc
/// ://com.apple.documentation/documentation/objectivec/no>.
#[unsafe(method(sharedPreviewPanelExists))]
#[unsafe(method_family = none)]
pub unsafe fn sharedPreviewPanelExists(mtm: MainThreadMarker) -> bool;
/// The current first responder accepting to control the preview panel.
///
/// You should never change the preview panel’s state (for example, its
/// delegate, datasource, and so on) if you aren’t controlling it.
#[unsafe(method(currentController))]
#[unsafe(method_family = none)]
pub unsafe fn currentController(&self) -> Option<Retained<AnyObject>>;
/// Asks the preview panel to update its current controller.
///
/// The preview panel automatically updates its controller (by searching the
/// responder chain) whenever the main or key window changes. You should only
/// invoke this method if the responder chain changes without explicit notice.
#[unsafe(method(updateController))]
#[unsafe(method_family = none)]
pub unsafe fn updateController(&self);
/// The preview panel data source.
///
/// # Safety
///
/// This is not retained internally, you must ensure the object is still alive.
#[unsafe(method(dataSource))]
#[unsafe(method_family = none)]
pub unsafe fn dataSource(
&self,
) -> Option<Retained<ProtocolObject<dyn QLPreviewPanelDataSource>>>;
/// Setter for [`dataSource`][Self::dataSource].
///
/// # Safety
///
/// - `data_source` might not allow `None`.
/// - This is unretained, you must ensure the object is kept alive while in use.
#[unsafe(method(setDataSource:))]
#[unsafe(method_family = none)]
pub unsafe fn setDataSource(
&self,
data_source: Option<&ProtocolObject<dyn QLPreviewPanelDataSource>>,
);
/// Asks the preview panel to reload its data from its data source.
///
/// This method doesn’t refresh the visible item if it hasn’t changed.
#[unsafe(method(reloadData))]
#[unsafe(method_family = none)]
pub unsafe fn reloadData(&self);
/// Asks the preview panel to recompute the preview of the current preview item.
#[unsafe(method(refreshCurrentPreviewItem))]
#[unsafe(method_family = none)]
pub unsafe fn refreshCurrentPreviewItem(&self);
/// The index of the current preview item.
///
/// The value is `NSNotFound` if there’s no current preview item.
#[unsafe(method(currentPreviewItemIndex))]
#[unsafe(method_family = none)]
pub unsafe fn currentPreviewItemIndex(&self) -> NSInteger;
/// Setter for [`currentPreviewItemIndex`][Self::currentPreviewItemIndex].
#[unsafe(method(setCurrentPreviewItemIndex:))]
#[unsafe(method_family = none)]
pub unsafe fn setCurrentPreviewItemIndex(&self, current_preview_item_index: NSInteger);
#[cfg(feature = "QLPreviewItem")]
/// The currently previewed item.
///
/// The value is `nil` if there’s no current preview item.
#[unsafe(method(currentPreviewItem))]
#[unsafe(method_family = none)]
pub unsafe fn currentPreviewItem(
&self,
) -> Option<Retained<ProtocolObject<dyn QLPreviewItem>>>;
/// The preview panel’s display state.
///
/// This property is an opaque object that Quick Look uses to get and set the
/// current display state of the preview. The display state could be, for
/// example, the currently displayed page, the zoom factor on an image, or the
/// position in a movie.
///
/// You can use this property to get and save the current display state of the
/// preview before switching to another. This saving allows you to restore a
/// preview later on when the user switches back to it.
#[unsafe(method(displayState))]
#[unsafe(method_family = none)]
pub unsafe fn displayState(&self) -> Option<Retained<AnyObject>>;
/// Setter for [`displayState`][Self::displayState].
///
/// # Safety
///
/// - `display_state` should be of the correct type.
/// - `display_state` might not allow `None`.
#[unsafe(method(setDisplayState:))]
#[unsafe(method_family = none)]
pub unsafe fn setDisplayState(&self, display_state: Option<&AnyObject>);
/// The delegate object that controls the preview panel’s behavior.
///
/// The class assigned as the delegate should conform to the
/// ``QuickLookUI/QLPreviewPanelDelegate`` protocol.
///
/// # Safety
///
/// This is not retained internally, you must ensure the object is still alive.
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;
/// Setter for [`delegate`][Self::delegate].
///
/// # Safety
///
/// - `delegate` should be of the correct type.
/// - `delegate` might not allow `None`.
/// - This is unretained, you must ensure the object is kept alive while in use.
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub unsafe fn setDelegate(&self, delegate: Option<&AnyObject>);
/// Instructs the panel to enter full screen mode.
///
/// If the panel isn’t onscreen, the panel goes directly to full screen mode.
///
/// The panel chooses the appropriate screen depending on where the panel is or,
/// if entering fullscreen directly, where the panel zooms from.
///
/// - Parameters:
/// - screen: This parameter isn’t currently used—pass `nil`.
///
/// - options: This parameter isn’t currently used—pass `nil`.
///
/// - Returns:
/// <doc
/// ://com.apple.documentation/documentation/objectivec/yes> if
/// the panel was able to enter full screen mode; otherwise,
/// <doc
/// ://com.apple.documentation/documentation/objectivec/no>.
///
/// # Safety
///
/// - `screen` might not allow `None`.
/// - `options` generic should be of the correct type.
/// - `options` might not allow `None`.
#[unsafe(method(enterFullScreenMode:withOptions:))]
#[unsafe(method_family = none)]
pub unsafe fn enterFullScreenMode_withOptions(
&self,
screen: Option<&NSScreen>,
options: Option<&NSDictionary>,
) -> bool;
/// Instructs the panel to exit full screen mode.
///
/// - Parameters:
/// - options: This parameter isn’t used — pass `nil`.
///
/// # Safety
///
/// - `options` generic should be of the correct type.
/// - `options` might not allow `None`.
#[unsafe(method(exitFullScreenModeWithOptions:))]
#[unsafe(method_family = none)]
pub unsafe fn exitFullScreenModeWithOptions(&self, options: Option<&NSDictionary>);
/// The property that indicates whether the panel is in full screen mode.
///
/// The value is
/// <doc
/// ://com.apple.documentation/documentation/objectivec/yes> if
/// the panel is currently open and in full screen mode; otherwise it’s
/// <doc
/// ://com.apple.documentation/documentation/objectivec/no>.
#[unsafe(method(isInFullScreenMode))]
#[unsafe(method_family = none)]
pub unsafe fn isInFullScreenMode(&self) -> bool;
);
}
/// Methods declared on superclass `NSWindow`.
#[cfg(feature = "objc2-app-kit")]
impl QLPreviewPanel {
extern_methods!(
#[unsafe(method(initWithContentRect:styleMask:backing:defer:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithContentRect_styleMask_backing_defer(
this: Allocated<Self>,
content_rect: NSRect,
style: NSWindowStyleMask,
backing_store_type: NSBackingStoreType,
flag: bool,
) -> Retained<Self>;
#[unsafe(method(initWithContentRect:styleMask:backing:defer:screen:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithContentRect_styleMask_backing_defer_screen(
this: Allocated<Self>,
content_rect: NSRect,
style: NSWindowStyleMask,
backing_store_type: NSBackingStoreType,
flag: bool,
screen: Option<&NSScreen>,
) -> Retained<Self>;
/// # Safety
///
/// `coder` possibly has further requirements.
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
/// 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].
#[unsafe(method(windowWithContentViewController:))]
#[unsafe(method_family = none)]
pub unsafe fn windowWithContentViewController(
content_view_controller: &NSViewController,
) -> Retained<Self>;
);
}
/// Methods declared on superclass `NSResponder`.
#[cfg(feature = "objc2-app-kit")]
impl QLPreviewPanel {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(feature = "objc2-app-kit")]
impl QLPreviewPanel {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}
mod private_NSObjectQLPreviewPanelController {
pub trait Sealed {}
}
/// Category "QLPreviewPanelController" on [`NSObject`].
///
/// Methods to implement by any object in the responder chain to control the Preview Panel
///
/// 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.
#[doc(alias = "QLPreviewPanelController")]
pub unsafe trait NSObjectQLPreviewPanelController:
ClassType + Sized + private_NSObjectQLPreviewPanelController::Sealed
{
extern_methods!(
#[cfg(feature = "objc2-app-kit")]
/// Sent to each object in the responder chain to find a controller.
///
/// Parameter `panel`: The Preview Panel looking for a controller.
///
/// Returns: YES if the receiver accepts to control the panel. You should never call this method directly.
///
/// # Safety
///
/// `panel` might not allow `None`.
#[unsafe(method(acceptsPreviewPanelControl:))]
#[unsafe(method_family = none)]
unsafe fn acceptsPreviewPanelControl(&self, panel: Option<&QLPreviewPanel>) -> bool;
#[cfg(feature = "objc2-app-kit")]
/// Sent to the object taking control of the Preview Panel.
///
/// Parameter `panel`: The Preview Panel the receiver will control.
///
/// The receiver should setup the preview panel (data source, delegate, binding, etc.) here. You should never call this method directly.
///
/// # Safety
///
/// `panel` might not allow `None`.
#[unsafe(method(beginPreviewPanelControl:))]
#[unsafe(method_family = none)]
unsafe fn beginPreviewPanelControl(&self, panel: Option<&QLPreviewPanel>);
#[cfg(feature = "objc2-app-kit")]
/// Sent to the object in control of the Preview Panel just before stopping its control.
///
/// Parameter `panel`: The Preview Panel that the receiver will stop controlling.
///
/// The receiver should unsetup the preview panel (data source, delegate, binding, etc.) here. You should never call this method directly.
///
/// # Safety
///
/// `panel` might not allow `None`.
#[unsafe(method(endPreviewPanelControl:))]
#[unsafe(method_family = none)]
unsafe fn endPreviewPanelControl(&self, panel: Option<&QLPreviewPanel>);
);
}
impl private_NSObjectQLPreviewPanelController::Sealed for NSObject {}
unsafe impl NSObjectQLPreviewPanelController for NSObject {}
extern_protocol!(
/// A protocol that the Quick Look preview panel uses to access the contents of
/// its data source object.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewpaneldatasource?language=objc)
pub unsafe trait QLPreviewPanelDataSource {
#[cfg(feature = "objc2-app-kit")]
/// Returns the number of items that the preview panel should preview.
///
/// - Parameters:
/// - panel: The preview panel.
///
/// - Returns: The number of items the preview panel should display.
///
/// # Safety
///
/// `panel` might not allow `None`.
#[unsafe(method(numberOfPreviewItemsInPreviewPanel:))]
#[unsafe(method_family = none)]
unsafe fn numberOfPreviewItemsInPreviewPanel(
&self,
panel: Option<&QLPreviewPanel>,
) -> NSInteger;
#[cfg(all(feature = "QLPreviewItem", feature = "objc2-app-kit"))]
/// Returns the item that the preview panel should preview at a given index.
///
/// - Parameters:
/// - panel: The preview panel.
///
/// - index: The index of the item to preview.
///
/// - Returns: The item that the preview panel should preview at index `index`.
///
/// # Safety
///
/// `panel` might not allow `None`.
#[unsafe(method(previewPanel:previewItemAtIndex:))]
#[unsafe(method_family = none)]
unsafe fn previewPanel_previewItemAtIndex(
&self,
panel: Option<&QLPreviewPanel>,
index: NSInteger,
) -> Option<Retained<ProtocolObject<dyn QLPreviewItem>>>;
}
);
extern_protocol!(
/// A protocol for the delegate of the Quick Look preview panel.
///
/// You can implement these methods to perform custom tasks in response to
/// events in the preview panel.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewpaneldelegate?language=objc)
#[cfg(feature = "objc2-app-kit")]
pub unsafe trait QLPreviewPanelDelegate: NSWindowDelegate {
/// Handles an event that the preview panel receives, but doesn’t handle.
///
/// The preview panel invokes this optional method when it receives an event it
/// doesn’t handle.
///
/// - Parameters:
/// - panel: The preview panel.
///
/// - event: The event that the preview panel wasn’t able to handle.
///
/// - Returns:
/// <doc
/// ://com.apple.documentation/documentation/objectivec/yes> if
/// the receiver handled the event; otherwise,
/// <doc
/// ://com.apple.documentation/documentation/objectivec/no>.
///
/// # Safety
///
/// - `panel` might not allow `None`.
/// - `event` might not allow `None`.
#[optional]
#[unsafe(method(previewPanel:handleEvent:))]
#[unsafe(method_family = none)]
unsafe fn previewPanel_handleEvent(
&self,
panel: Option<&QLPreviewPanel>,
event: Option<&NSEvent>,
) -> bool;
#[cfg(feature = "QLPreviewItem")]
/// Returns the screen rectangle for a given preview item.
///
/// The system invokes this optional method when the preview panel opens or
/// closes to provide a zoom effect. You should return — in screen coordinates —
/// the rectangle that displays the specified preview item.
///
/// - Parameters:
/// - panel: The preview panel.
///
/// - item: The preview item for which the screen rectangle is required.
///
/// - Returns: The screen rectangle for the given preview item. Return
/// <doc
/// ://com.apple.documentation/documentation/foundation/nszerorect> if there
/// is no origin point (this will produce a fade of the panel).
///
/// # Safety
///
/// - `panel` might not allow `None`.
/// - `item` might not allow `None`.
#[optional]
#[unsafe(method(previewPanel:sourceFrameOnScreenForPreviewItem:))]
#[unsafe(method_family = none)]
unsafe fn previewPanel_sourceFrameOnScreenForPreviewItem(
&self,
panel: Option<&QLPreviewPanel>,
item: Option<&ProtocolObject<dyn QLPreviewItem>>,
) -> NSRect;
#[cfg(feature = "QLPreviewItem")]
/// Returns the image to use for the transition zoom effect for a given item.
///
/// The system invokes this optional method when the preview panel opens or
/// closes to provide a smooth transition when zooming. The return type of the
/// function should be an instance of
/// <doc
/// ://com.apple.documentation/documentation/appkit/nsimage>.
///
/// - Parameters:
/// - panel: The preview panel.
///
/// - item: The item the system is previewing.
///
/// - contentRect: The rectangle within a preview image that actually represents
/// the content of the document. For icons, the actual rectangle is typically
/// smaller than the icon itself.
///
/// - Returns: The image to use for the transition zoom effect for the `item`.
///
/// # Safety
///
/// - `panel` might not allow `None`.
/// - `item` might not allow `None`.
/// - `content_rect` must be a valid pointer.
#[optional]
#[unsafe(method(previewPanel:transitionImageForPreviewItem:contentRect:))]
#[unsafe(method_family = none)]
unsafe fn previewPanel_transitionImageForPreviewItem_contentRect(
&self,
panel: Option<&QLPreviewPanel>,
item: Option<&ProtocolObject<dyn QLPreviewItem>>,
content_rect: *mut NSRect,
) -> Option<Retained<AnyObject>>;
}
);