objc2_quick_look_ui/generated/QLPreviewReply.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-core-foundation")]
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-graphics")]
9use objc2_core_graphics::*;
10use objc2_foundation::*;
11#[cfg(feature = "objc2-pdf-kit")]
12use objc2_pdf_kit::*;
13#[cfg(feature = "objc2-uniform-type-identifiers")]
14use objc2_uniform_type_identifiers::*;
15
16use crate::*;
17
18extern_class!(
19 /// QLPreviewReplyAttachment is used to provide data for attachment in html data-based previews.
20 ///
21 /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewreplyattachment?language=objc)
22 #[unsafe(super(NSObject))]
23 #[derive(Debug, PartialEq, Eq, Hash)]
24 pub struct QLPreviewReplyAttachment;
25);
26
27extern_conformance!(
28 unsafe impl NSObjectProtocol for QLPreviewReplyAttachment {}
29);
30
31impl QLPreviewReplyAttachment {
32 extern_methods!(
33 /// The data content of an html preview
34 #[unsafe(method(data))]
35 #[unsafe(method_family = none)]
36 pub unsafe fn data(&self) -> Retained<NSData>;
37
38 #[cfg(feature = "objc2-uniform-type-identifiers")]
39 /// The content type of the attachment for an html preview
40 #[unsafe(method(contentType))]
41 #[unsafe(method_family = none)]
42 pub unsafe fn contentType(&self) -> Retained<UTType>;
43
44 #[cfg(feature = "objc2-uniform-type-identifiers")]
45 /// Create an attachment for html previews by providing the data and mime type of the attachment.
46 ///
47 /// Parameter `data`: The data content of an html preview
48 ///
49 /// Parameter `contentType`: The UTType of the attachment for an html preview
50 #[unsafe(method(initWithData:contentType:))]
51 #[unsafe(method_family = init)]
52 pub unsafe fn initWithData_contentType(
53 this: Allocated<Self>,
54 data: &NSData,
55 content_type: &UTType,
56 ) -> Retained<Self>;
57 );
58}
59
60/// Methods declared on superclass `NSObject`.
61impl QLPreviewReplyAttachment {
62 extern_methods!(
63 #[unsafe(method(init))]
64 #[unsafe(method_family = init)]
65 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
66
67 #[unsafe(method(new))]
68 #[unsafe(method_family = new)]
69 pub unsafe fn new() -> Retained<Self>;
70 );
71}
72
73extern_class!(
74 /// To provide a data-based preview, you have to return a QLPreviewReply object.
75 ///
76 /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewreply?language=objc)
77 #[unsafe(super(NSObject))]
78 #[derive(Debug, PartialEq, Eq, Hash)]
79 pub struct QLPreviewReply;
80);
81
82extern_conformance!(
83 unsafe impl NSObjectProtocol for QLPreviewReply {}
84);
85
86impl QLPreviewReply {
87 extern_methods!(
88 /// String encoding for text or html based previews. Defaults to NSUTF8StringEncoding.
89 #[unsafe(method(stringEncoding))]
90 #[unsafe(method_family = none)]
91 pub unsafe fn stringEncoding(&self) -> NSStringEncoding;
92
93 /// Setter for [`stringEncoding`][Self::stringEncoding].
94 #[unsafe(method(setStringEncoding:))]
95 #[unsafe(method_family = none)]
96 pub unsafe fn setStringEncoding(&self, string_encoding: NSStringEncoding);
97
98 /// Attachments for HTML data previews. The keys of the dictionary are the attachment identifiers (eg foo) that can be referenced with the cid:id URL (eg cid:foo).
99 #[unsafe(method(attachments))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn attachments(
102 &self,
103 ) -> Retained<NSDictionary<NSString, QLPreviewReplyAttachment>>;
104
105 /// Setter for [`attachments`][Self::attachments].
106 ///
107 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
108 #[unsafe(method(setAttachments:))]
109 #[unsafe(method_family = none)]
110 pub unsafe fn setAttachments(
111 &self,
112 attachments: &NSDictionary<NSString, QLPreviewReplyAttachment>,
113 );
114
115 /// Custom display title for the preview. If left as the empty string, QuickLook will use the file name.
116 #[unsafe(method(title))]
117 #[unsafe(method_family = none)]
118 pub unsafe fn title(&self) -> Retained<NSString>;
119
120 /// Setter for [`title`][Self::title].
121 ///
122 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
123 #[unsafe(method(setTitle:))]
124 #[unsafe(method_family = none)]
125 pub unsafe fn setTitle(&self, title: &NSString);
126
127 #[cfg(all(
128 feature = "block2",
129 feature = "objc2-core-foundation",
130 feature = "objc2-core-graphics"
131 ))]
132 /// Use this method to provide a preview by drawing into a context.
133 ///
134 ///
135 /// Parameter `contextSize`: The size of your image.
136 ///
137 /// Parameter `isBitmap`: Whether the context should be bitmap or vector.
138 ///
139 /// Parameter `drawingBlock`: The preview should be drawn into the context passed to this block. The QLPreviewReply passed into this block is the same as the one created by this method and is provided for convenience for any further updates to its properties during the drawing block. Return YES if the preview was successfully drawn into the context. Return NO and populate error otherwise.
140 #[unsafe(method(initWithContextSize:isBitmap:drawingBlock:))]
141 #[unsafe(method_family = init)]
142 pub unsafe fn initWithContextSize_isBitmap_drawingBlock(
143 this: Allocated<Self>,
144 context_size: CGSize,
145 is_bitmap: bool,
146 drawing_block: &block2::DynBlock<
147 dyn Fn(NonNull<CGContext>, NonNull<QLPreviewReply>, *mut *mut NSError) -> Bool,
148 >,
149 ) -> Retained<Self>;
150
151 /// Use this method to provide a preview by providing a URL to a file of a supported type.
152 ///
153 ///
154 /// Parameter `fileURL`: A file URL representing a preview of the previewed URL. Currently supported types include: UTTypeImage, UTTypePDF, UTTypeHTML, UTTypeXML, UTTypePlainText, UTTypeRTF, UTTypeRTFD, UTTypeMovie, UTTypeAudio
155 #[unsafe(method(initWithFileURL:))]
156 #[unsafe(method_family = init)]
157 pub unsafe fn initWithFileURL(this: Allocated<Self>, file_url: &NSURL) -> Retained<Self>;
158
159 #[cfg(all(
160 feature = "block2",
161 feature = "objc2-core-foundation",
162 feature = "objc2-uniform-type-identifiers"
163 ))]
164 /// Use this method to provide a preview with data of a supported format.
165 ///
166 ///
167 /// Parameter `contentType`: The content type of the data.
168 ///
169 /// Parameter `contentSize`: A hint for the size you would like to display your content at. If your content has an intrinsic size built in, such as images and PDFs, that will be used as the final size, but providing the correct size here will allow QuickLook to present loading UI at the correct size before you are finished creating the data. QuickLook will use a default size if NSZeroSize is passed in.
170 ///
171 /// Parameter `dataCreationBlock`: Create and return data representing the file preview. Supported types include: UTTypeImage, UTTypePDF, UTTypeHTML, UTTypeXML, UTTypePlainText, UTTypeRTF. Heavy lifting should be done inside of the dataCreationBlock instead of when creating the QLPreviewReply. The QLPreviewReply passed into this block is the same as the one created by this method and is provided for convenience for any further updates to its properties, such as attachments, during the data generation. Return the data if successful. Populate error if unsuccessful.
172 ///
173 /// # Safety
174 ///
175 /// `data_creation_block` block's return must be a valid pointer or null.
176 #[unsafe(method(initWithDataOfContentType:contentSize:dataCreationBlock:))]
177 #[unsafe(method_family = init)]
178 pub unsafe fn initWithDataOfContentType_contentSize_dataCreationBlock(
179 this: Allocated<Self>,
180 content_type: &UTType,
181 content_size: CGSize,
182 data_creation_block: &block2::DynBlock<
183 dyn Fn(NonNull<QLPreviewReply>, *mut *mut NSError) -> *mut NSData,
184 >,
185 ) -> Retained<Self>;
186 );
187}
188
189/// Methods declared on superclass `NSObject`.
190impl QLPreviewReply {
191 extern_methods!(
192 #[unsafe(method(init))]
193 #[unsafe(method_family = init)]
194 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
195
196 #[unsafe(method(new))]
197 #[unsafe(method_family = new)]
198 pub unsafe fn new() -> Retained<Self>;
199 );
200}
201
202/// UI.
203impl QLPreviewReply {
204 extern_methods!(
205 #[cfg(all(
206 feature = "block2",
207 feature = "objc2-core-foundation",
208 feature = "objc2-pdf-kit"
209 ))]
210 /// Use this method to provide a preview with a PDFDocument
211 ///
212 ///
213 /// Parameter `defaultPageSize`: The size of your pages in the document. If the page size varies, use the first page's size.
214 ///
215 /// Parameter `documentCreationBlock`: Create and return the PDFDocument. Heavy lifting should be done inside of the documentCreationBlock instead of when creating the QLPreviewReply. The QLPreviewReply passed into this block is the same as the one created by this method and is provided for convenience for any further updates to its properties during document creation. Return the PDFDocument if successfully created. Populate error if unsuccessful.
216 ///
217 /// # Safety
218 ///
219 /// `document_creation_block` block's return must be a valid pointer or null.
220 #[unsafe(method(initForPDFWithPageSize:documentCreationBlock:))]
221 #[unsafe(method_family = init)]
222 pub unsafe fn initForPDFWithPageSize_documentCreationBlock(
223 this: Allocated<Self>,
224 default_page_size: CGSize,
225 document_creation_block: &block2::DynBlock<
226 dyn Fn(NonNull<QLPreviewReply>, *mut *mut NSError) -> *mut PDFDocument,
227 >,
228 ) -> Retained<Self>;
229 );
230}