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        ///
147        /// # Safety
148        ///
149        /// `preview_item` might not allow `None`.
150        #[unsafe(method(setPreviewItem:))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn setPreviewItem(
153            &self,
154            preview_item: Option<&ProtocolObject<dyn QLPreviewItem>>,
155        );
156
157        /// Updates the preview to display the currently previewed item.
158        ///
159        /// When you modify the object that the
160        /// ``QuickLookUI/QLPreviewView/previewItem`` property points to, call this
161        /// method to generate and display the new preview.
162        #[unsafe(method(refreshPreviewItem))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn refreshPreviewItem(&self);
165
166        /// The current display state of the
167        /// <doc
168        /// ://com.apple.documentation/documentation/quicklookui/qlpreviewview/1504747-previewitem>.
169        ///
170        /// This property is an opaque object that Quick Look uses to get and set the
171        /// current display state of the preview. The display state could be, for
172        /// example, the currently displayed page, the zoom factor on an image, or the
173        /// position in a movie.
174        ///
175        /// You can use this property to get and save the current display state of the
176        /// preview before switching to another. This saving allows you to restore a
177        /// preview later on when the user switches back to it.
178        #[unsafe(method(displayState))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn displayState(&self) -> Option<Retained<AnyObject>>;
181
182        /// Setter for [`displayState`][Self::displayState].
183        ///
184        /// # Safety
185        ///
186        /// - `display_state` should be of the correct type.
187        /// - `display_state` might not allow `None`.
188        #[unsafe(method(setDisplayState:))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn setDisplayState(&self, display_state: Option<&AnyObject>);
191
192        /// Closes the view, releasing the current preview item.
193        ///
194        /// Once a ``QuickLookUI/QLPreviewView`` is closed, it won’t accept any more
195        /// preview items. You only need to call this method if
196        /// ``QuickLookUI/QLPreviewView/shouldCloseWithWindow`` is set to
197        /// <doc
198        /// ://com.apple.documentation/documentation/objectivec/no>. If you don’t
199        /// close a ``QuickLookUI/QLPreviewView`` when you are done using it, your app
200        /// will leak memory.
201        #[unsafe(method(close))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn close(&self);
204
205        /// A Boolean value that determines whether the preview should close when its
206        /// window closes.
207        ///
208        /// The default value of this property is
209        /// <doc
210        /// ://com.apple.documentation/documentation/objectivec/yes>, which means
211        /// that the preview automatically closes when its window closes. If you set
212        /// this property to
213        /// <doc
214        /// ://com.apple.documentation/documentation/objectivec/no>, close the
215        /// preview by calling the ``QuickLookUI/QLPreviewView/close`` method when
216        /// finished with it. Once you close a ``QuickLookUI/QLPreviewView``, it won’t
217        /// accept any more preview items.
218        #[unsafe(method(shouldCloseWithWindow))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn shouldCloseWithWindow(&self) -> bool;
221
222        /// Setter for [`shouldCloseWithWindow`][Self::shouldCloseWithWindow].
223        #[unsafe(method(setShouldCloseWithWindow:))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn setShouldCloseWithWindow(&self, should_close_with_window: bool);
226
227        /// A Boolean value that determines whether the preview starts automatically.
228        ///
229        /// Set this property to allow previews of movie files to start playback
230        /// automatically when displayed.
231        #[unsafe(method(autostarts))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn autostarts(&self) -> bool;
234
235        /// Setter for [`autostarts`][Self::autostarts].
236        #[unsafe(method(setAutostarts:))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn setAutostarts(&self, autostarts: bool);
239    );
240}
241
242/// Methods declared on superclass `NSView`.
243#[cfg(feature = "objc2-app-kit")]
244impl QLPreviewView {
245    extern_methods!(
246        /// # Safety
247        ///
248        /// `coder` possibly has further requirements.
249        #[unsafe(method(initWithCoder:))]
250        #[unsafe(method_family = init)]
251        pub unsafe fn initWithCoder(
252            this: Allocated<Self>,
253            coder: &NSCoder,
254        ) -> Option<Retained<Self>>;
255    );
256}
257
258/// Methods declared on superclass `NSResponder`.
259#[cfg(feature = "objc2-app-kit")]
260impl QLPreviewView {
261    extern_methods!(
262        #[unsafe(method(init))]
263        #[unsafe(method_family = init)]
264        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
265    );
266}
267
268/// Methods declared on superclass `NSObject`.
269#[cfg(feature = "objc2-app-kit")]
270impl QLPreviewView {
271    extern_methods!(
272        #[unsafe(method(new))]
273        #[unsafe(method_family = new)]
274        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
275    );
276}