objc2-quick-look-ui 0.3.2

Bindings to the QuickLookUI framework
Documentation
//! 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::*;

/// Styles for a Preview View.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewviewstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct QLPreviewViewStyle(pub NSUInteger);
impl QLPreviewViewStyle {
    /// Provides the default preview style for larger, full-sized previews.
    ///
    /// The default style for a ``QuickLookUI/QLPreviewView`` object. Use this
    /// style should for larger, full-size previews.
    #[doc(alias = "QLPreviewViewStyleNormal")]
    pub const Normal: Self = Self(0);
    /// Provides a compact preview style suited for smaller previews or inspectors.
    ///
    /// A more compact style for a ``QuickLookUI/QLPreviewView`` object. Use this
    /// style for smaller previews or inspectors.
    #[doc(alias = "QLPreviewViewStyleCompact")]
    pub const Compact: Self = Self(1);
}

unsafe impl Encode for QLPreviewViewStyle {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for QLPreviewViewStyle {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// A Quick Look preview of an item that you can embed into your view hierarchy.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewview?language=objc)
    #[unsafe(super(NSView, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2-app-kit")]
    pub struct QLPreviewView;
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSAccessibility for QLPreviewView {}
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSAccessibilityElementProtocol for QLPreviewView {}
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSAnimatablePropertyContainer for QLPreviewView {}
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSAppearanceCustomization for QLPreviewView {}
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSCoding for QLPreviewView {}
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSDraggingDestination for QLPreviewView {}
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSObjectProtocol for QLPreviewView {}
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSUserInterfaceItemIdentification for QLPreviewView {}
);

#[cfg(feature = "objc2-app-kit")]
impl QLPreviewView {
    extern_methods!(
        /// Creates a preview view with the provided frame and style.
        ///
        /// This is the designated initializer for the `QLPreviewView` class.
        ///
        /// - Parameters:
        /// - frame: The frame rectangle for the initialized `QLPreviewView` object.
        /// - style: The desired style for the `QLPreviewView` object. For a list of
        /// possible styles, see ``QuickLookUI/QLPreviewViewStyle``.
        ///
        /// - Returns: Returns a `QLPreviewView` object with the designated frame and
        /// style.
        #[unsafe(method(initWithFrame:style:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrame_style(
            this: Allocated<Self>,
            frame: NSRect,
            style: QLPreviewViewStyle,
        ) -> Option<Retained<Self>>;

        /// Creates a preview view with the provided frame.
        ///
        /// Calling this method is equivalent to calling
        /// ``QuickLookUI/QLPreviewView/initWithFrame:style:`` with the `style`
        /// parameter being ``QuickLookUI/QLPreviewViewStyle/QLPreviewViewStyleNormal``.
        ///
        /// - Parameters:
        /// - frame: The frame rectangle for the initialized `QLPreviewView` object.
        ///
        /// - Returns: Returns a `QLPreviewView` object with the designated frame and
        /// the default style.
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: NSRect)
            -> Option<Retained<Self>>;

        #[cfg(feature = "QLPreviewItem")]
        /// The item to preview.
        ///
        /// Quick Look requires Items you wish to conform to the
        /// <doc
        /// ://com.apple.documentation/documentation/quicklook/qlpreviewitem>
        /// protocol. When you set this property, the ``QuickLookUI/QLPreviewView``
        /// loads the preview asynchronously. Due to this asynchronous behavior, don’t
        /// assume that the preview is ready immediately after assigning it to this
        /// property.
        #[unsafe(method(previewItem))]
        #[unsafe(method_family = none)]
        pub unsafe fn previewItem(&self) -> Option<Retained<ProtocolObject<dyn QLPreviewItem>>>;

        #[cfg(feature = "QLPreviewItem")]
        /// Setter for [`previewItem`][Self::previewItem].
        ///
        /// # Safety
        ///
        /// `preview_item` might not allow `None`.
        #[unsafe(method(setPreviewItem:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreviewItem(
            &self,
            preview_item: Option<&ProtocolObject<dyn QLPreviewItem>>,
        );

        /// Updates the preview to display the currently previewed item.
        ///
        /// When you modify the object that the
        /// ``QuickLookUI/QLPreviewView/previewItem`` property points to, call this
        /// method to generate and display the new preview.
        #[unsafe(method(refreshPreviewItem))]
        #[unsafe(method_family = none)]
        pub unsafe fn refreshPreviewItem(&self);

        /// The current display state of the
        /// <doc
        /// ://com.apple.documentation/documentation/quicklookui/qlpreviewview/1504747-previewitem>.
        ///
        /// 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>);

        /// Closes the view, releasing the current preview item.
        ///
        /// Once a ``QuickLookUI/QLPreviewView`` is closed, it won’t accept any more
        /// preview items. You only need to call this method if
        /// ``QuickLookUI/QLPreviewView/shouldCloseWithWindow`` is set to
        /// <doc
        /// ://com.apple.documentation/documentation/objectivec/no>. If you don’t
        /// close a ``QuickLookUI/QLPreviewView`` when you are done using it, your app
        /// will leak memory.
        #[unsafe(method(close))]
        #[unsafe(method_family = none)]
        pub unsafe fn close(&self);

        /// A Boolean value that determines whether the preview should close when its
        /// window closes.
        ///
        /// The default value of this property is
        /// <doc
        /// ://com.apple.documentation/documentation/objectivec/yes>, which means
        /// that the preview automatically closes when its window closes. If you set
        /// this property to
        /// <doc
        /// ://com.apple.documentation/documentation/objectivec/no>, close the
        /// preview by calling the ``QuickLookUI/QLPreviewView/close`` method when
        /// finished with it. Once you close a ``QuickLookUI/QLPreviewView``, it won’t
        /// accept any more preview items.
        #[unsafe(method(shouldCloseWithWindow))]
        #[unsafe(method_family = none)]
        pub unsafe fn shouldCloseWithWindow(&self) -> bool;

        /// Setter for [`shouldCloseWithWindow`][Self::shouldCloseWithWindow].
        #[unsafe(method(setShouldCloseWithWindow:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShouldCloseWithWindow(&self, should_close_with_window: bool);

        /// A Boolean value that determines whether the preview starts automatically.
        ///
        /// Set this property to allow previews of movie files to start playback
        /// automatically when displayed.
        #[unsafe(method(autostarts))]
        #[unsafe(method_family = none)]
        pub unsafe fn autostarts(&self) -> bool;

        /// Setter for [`autostarts`][Self::autostarts].
        #[unsafe(method(setAutostarts:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAutostarts(&self, autostarts: bool);
    );
}

/// Methods declared on superclass `NSView`.
#[cfg(feature = "objc2-app-kit")]
impl QLPreviewView {
    extern_methods!(
        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;
    );
}

/// Methods declared on superclass `NSResponder`.
#[cfg(feature = "objc2-app-kit")]
impl QLPreviewView {
    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 QLPreviewView {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}