objc2_quick_look_ui/generated/
QLPreviewView.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
12/// Styles for a Preview View.
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewviewstyle?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct QLPreviewViewStyle(pub NSUInteger);
19impl QLPreviewViewStyle {
20    /// Provides the default preview style for larger, full-sized previews.
21    ///
22    /// The default style for a ``QuickLookUI/QLPreviewView`` object. Use this
23    /// style should for larger, full-size previews.
24    #[doc(alias = "QLPreviewViewStyleNormal")]
25    pub const Normal: Self = Self(0);
26    /// Provides a compact preview style suited for smaller previews or inspectors.
27    ///
28    /// A more compact style for a ``QuickLookUI/QLPreviewView`` object. Use this
29    /// style for smaller previews or inspectors.
30    #[doc(alias = "QLPreviewViewStyleCompact")]
31    pub const Compact: Self = Self(1);
32}
33
34unsafe impl Encode for QLPreviewViewStyle {
35    const ENCODING: Encoding = NSUInteger::ENCODING;
36}
37
38unsafe impl RefEncode for QLPreviewViewStyle {
39    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
40}
41
42extern_class!(
43    /// A Quick Look preview of an item that you can embed into your view hierarchy.
44    ///
45    /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewview?language=objc)
46    #[unsafe(super(NSView, NSResponder, NSObject))]
47    #[derive(Debug, PartialEq, Eq, Hash)]
48    #[cfg(feature = "objc2-app-kit")]
49    pub struct QLPreviewView;
50);
51
52#[cfg(feature = "objc2-app-kit")]
53extern_conformance!(
54    unsafe impl NSAccessibility for QLPreviewView {}
55);
56
57#[cfg(feature = "objc2-app-kit")]
58extern_conformance!(
59    unsafe impl NSAccessibilityElementProtocol for QLPreviewView {}
60);
61
62#[cfg(feature = "objc2-app-kit")]
63extern_conformance!(
64    unsafe impl NSAnimatablePropertyContainer for QLPreviewView {}
65);
66
67#[cfg(feature = "objc2-app-kit")]
68extern_conformance!(
69    unsafe impl NSAppearanceCustomization for QLPreviewView {}
70);
71
72#[cfg(feature = "objc2-app-kit")]
73extern_conformance!(
74    unsafe impl NSCoding for QLPreviewView {}
75);
76
77#[cfg(feature = "objc2-app-kit")]
78extern_conformance!(
79    unsafe impl NSDraggingDestination for QLPreviewView {}
80);
81
82#[cfg(feature = "objc2-app-kit")]
83extern_conformance!(
84    unsafe impl NSObjectProtocol for QLPreviewView {}
85);
86
87#[cfg(feature = "objc2-app-kit")]
88extern_conformance!(
89    unsafe impl NSUserInterfaceItemIdentification for QLPreviewView {}
90);
91
92#[cfg(feature = "objc2-app-kit")]
93impl QLPreviewView {
94    extern_methods!(
95        /// Creates a preview view with the provided frame and style.
96        ///
97        /// This is the designated initializer for the `QLPreviewView` class.
98        ///
99        /// - Parameters:
100        /// - frame: The frame rectangle for the initialized `QLPreviewView` object.
101        /// - style: The desired style for the `QLPreviewView` object. For a list of
102        /// possible styles, see ``QuickLookUI/QLPreviewViewStyle``.
103        ///
104        /// - Returns: Returns a `QLPreviewView` object with the designated frame and
105        /// style.
106        #[unsafe(method(initWithFrame:style:))]
107        #[unsafe(method_family = init)]
108        pub unsafe fn initWithFrame_style(
109            this: Allocated<Self>,
110            frame: NSRect,
111            style: QLPreviewViewStyle,
112        ) -> Option<Retained<Self>>;
113
114        /// Creates a preview view with the provided frame.
115        ///
116        /// Calling this method is equivalent to calling
117        /// ``QuickLookUI/QLPreviewView/initWithFrame:style:`` with the `style`
118        /// parameter being ``QuickLookUI/QLPreviewViewStyle/QLPreviewViewStyleNormal``.
119        ///
120        /// - Parameters:
121        /// - frame: The frame rectangle for the initialized `QLPreviewView` object.
122        ///
123        /// - Returns: Returns a `QLPreviewView` object with the designated frame and
124        /// the default style.
125        #[unsafe(method(initWithFrame:))]
126        #[unsafe(method_family = init)]
127        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: NSRect)
128            -> Option<Retained<Self>>;
129
130        #[cfg(feature = "QLPreviewItem")]
131        /// The item to preview.
132        ///
133        /// Quick Look requires Items you wish to conform to the
134        /// <doc
135        /// ://com.apple.documentation/documentation/quicklook/qlpreviewitem>
136        /// protocol. When you set this property, the ``QuickLookUI/QLPreviewView``
137        /// loads the preview asynchronously. Due to this asynchronous behavior, don’t
138        /// assume that the preview is ready immediately after assigning it to this
139        /// property.
140        #[unsafe(method(previewItem))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn previewItem(&self) -> Option<Retained<ProtocolObject<dyn QLPreviewItem>>>;
143
144        #[cfg(feature = "QLPreviewItem")]
145        /// Setter for [`previewItem`][Self::previewItem].
146        #[unsafe(method(setPreviewItem:))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn setPreviewItem(
149            &self,
150            preview_item: Option<&ProtocolObject<dyn QLPreviewItem>>,
151        );
152
153        /// Updates the preview to display the currently previewed item.
154        ///
155        /// When you modify the object that the
156        /// ``QuickLookUI/QLPreviewView/previewItem`` property points to, call this
157        /// method to generate and display the new preview.
158        #[unsafe(method(refreshPreviewItem))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn refreshPreviewItem(&self);
161
162        /// The current display state of the
163        /// <doc
164        /// ://com.apple.documentation/documentation/quicklookui/qlpreviewview/1504747-previewitem>.
165        ///
166        /// This property is an opaque object that Quick Look uses to get and set the
167        /// current display state of the preview. The display state could be, for
168        /// example, the currently displayed page, the zoom factor on an image, or the
169        /// position in a movie.
170        ///
171        /// You can use this property to get and save the current display state of the
172        /// preview before switching to another. This saving allows you to restore a
173        /// preview later on when the user switches back to it.
174        #[unsafe(method(displayState))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn displayState(&self) -> Option<Retained<AnyObject>>;
177
178        /// Setter for [`displayState`][Self::displayState].
179        #[unsafe(method(setDisplayState:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn setDisplayState(&self, display_state: Option<&AnyObject>);
182
183        /// Closes the view, releasing the current preview item.
184        ///
185        /// Once a ``QuickLookUI/QLPreviewView`` is closed, it won’t accept any more
186        /// preview items. You only need to call this method if
187        /// ``QuickLookUI/QLPreviewView/shouldCloseWithWindow`` is set to
188        /// <doc
189        /// ://com.apple.documentation/documentation/objectivec/no>. If you don’t
190        /// close a ``QuickLookUI/QLPreviewView`` when you are done using it, your app
191        /// will leak memory.
192        #[unsafe(method(close))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn close(&self);
195
196        /// A Boolean value that determines whether the preview should close when its
197        /// window closes.
198        ///
199        /// The default value of this property is
200        /// <doc
201        /// ://com.apple.documentation/documentation/objectivec/yes>, which means
202        /// that the preview automatically closes when its window closes. If you set
203        /// this property to
204        /// <doc
205        /// ://com.apple.documentation/documentation/objectivec/no>, close the
206        /// preview by calling the ``QuickLookUI/QLPreviewView/close`` method when
207        /// finished with it. Once you close a ``QuickLookUI/QLPreviewView``, it won’t
208        /// accept any more preview items.
209        #[unsafe(method(shouldCloseWithWindow))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn shouldCloseWithWindow(&self) -> bool;
212
213        /// Setter for [`shouldCloseWithWindow`][Self::shouldCloseWithWindow].
214        #[unsafe(method(setShouldCloseWithWindow:))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn setShouldCloseWithWindow(&self, should_close_with_window: bool);
217
218        /// A Boolean value that determines whether the preview starts automatically.
219        ///
220        /// Set this property to allow previews of movie files to start playback
221        /// automatically when displayed.
222        #[unsafe(method(autostarts))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn autostarts(&self) -> bool;
225
226        /// Setter for [`autostarts`][Self::autostarts].
227        #[unsafe(method(setAutostarts:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn setAutostarts(&self, autostarts: bool);
230    );
231}
232
233/// Methods declared on superclass `NSView`.
234#[cfg(feature = "objc2-app-kit")]
235impl QLPreviewView {
236    extern_methods!(
237        #[unsafe(method(initWithCoder:))]
238        #[unsafe(method_family = init)]
239        pub unsafe fn initWithCoder(
240            this: Allocated<Self>,
241            coder: &NSCoder,
242        ) -> Option<Retained<Self>>;
243    );
244}
245
246/// Methods declared on superclass `NSResponder`.
247#[cfg(feature = "objc2-app-kit")]
248impl QLPreviewView {
249    extern_methods!(
250        #[unsafe(method(init))]
251        #[unsafe(method_family = init)]
252        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
253    );
254}
255
256/// Methods declared on superclass `NSObject`.
257#[cfg(feature = "objc2-app-kit")]
258impl QLPreviewView {
259    extern_methods!(
260        #[unsafe(method(new))]
261        #[unsafe(method_family = new)]
262        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
263    );
264}