1 {
2  *  QLThumbnail.h
3  *  Quick Look
4  *
5  *  Copyright 2007-2010 Apple Inc.
6  *  All rights reserved.
7  *
8  }
9 { Initial Pascal Translation: Jonas Maebe <jonas@freepascal.org>, October 2012 }
10 {
11     Modified for use with Free Pascal
12     Version 308
13     Please report any bugs to <gpc@microbizz.nl>
14 }
15 
16 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
17 {$mode macpas}
18 {$modeswitch cblocks}
19 {$packenum 1}
20 {$macro on}
21 {$inline on}
22 {$calling mwpascal}
23 
24 unit QLThumbnail;
25 interface
26 {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
27 {$setc GAP_INTERFACES_VERSION := $0308}
28 
29 {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
30     {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
31 {$endc}
32 
33 {$ifc defined CPUPOWERPC and defined CPUI386}
34 	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
35 {$endc}
36 {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
37 	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
38 {$endc}
39 
40 {$ifc not defined __ppc__ and defined CPUPOWERPC32}
41 	{$setc __ppc__ := 1}
42 {$elsec}
43 	{$setc __ppc__ := 0}
44 {$endc}
45 {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
46 	{$setc __ppc64__ := 1}
47 {$elsec}
48 	{$setc __ppc64__ := 0}
49 {$endc}
50 {$ifc not defined __i386__ and defined CPUI386}
51 	{$setc __i386__ := 1}
52 {$elsec}
53 	{$setc __i386__ := 0}
54 {$endc}
55 {$ifc not defined __x86_64__ and defined CPUX86_64}
56 	{$setc __x86_64__ := 1}
57 {$elsec}
58 	{$setc __x86_64__ := 0}
59 {$endc}
60 {$ifc not defined __arm__ and defined CPUARM}
61 	{$setc __arm__ := 1}
62 {$elsec}
63 	{$setc __arm__ := 0}
64 {$endc}
65 {$ifc not defined __arm64__ and defined CPUAARCH64}
66   {$setc __arm64__ := 1}
67 {$elsec}
68   {$setc __arm64__ := 0}
69 {$endc}
70 
71 {$ifc defined cpu64}
72   {$setc __LP64__ := 1}
73 {$elsec}
74   {$setc __LP64__ := 0}
75 {$endc}
76 
77 
78 {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
79 	{$error Conflicting definitions for __ppc__ and __i386__}
80 {$endc}
81 
82 {$ifc defined __ppc__ and __ppc__}
83 	{$setc TARGET_CPU_PPC := TRUE}
84 	{$setc TARGET_CPU_PPC64 := FALSE}
85 	{$setc TARGET_CPU_X86 := FALSE}
86 	{$setc TARGET_CPU_X86_64 := FALSE}
87 	{$setc TARGET_CPU_ARM := FALSE}
88 	{$setc TARGET_CPU_ARM64 := FALSE}
89 	{$setc TARGET_OS_MAC := TRUE}
90 	{$setc TARGET_OS_IPHONE := FALSE}
91 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
92 	{$setc TARGET_OS_EMBEDDED := FALSE}
93 {$elifc defined __ppc64__ and __ppc64__}
94 	{$setc TARGET_CPU_PPC := FALSE}
95 	{$setc TARGET_CPU_PPC64 := TRUE}
96 	{$setc TARGET_CPU_X86 := FALSE}
97 	{$setc TARGET_CPU_X86_64 := FALSE}
98 	{$setc TARGET_CPU_ARM := FALSE}
99 	{$setc TARGET_CPU_ARM64 := FALSE}
100 	{$setc TARGET_OS_MAC := TRUE}
101 	{$setc TARGET_OS_IPHONE := FALSE}
102 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
103 	{$setc TARGET_OS_EMBEDDED := FALSE}
104 {$elifc defined __i386__ and __i386__}
105 	{$setc TARGET_CPU_PPC := FALSE}
106 	{$setc TARGET_CPU_PPC64 := FALSE}
107 	{$setc TARGET_CPU_X86 := TRUE}
108 	{$setc TARGET_CPU_X86_64 := FALSE}
109 	{$setc TARGET_CPU_ARM := FALSE}
110 	{$setc TARGET_CPU_ARM64 := FALSE}
111 {$ifc defined iphonesim}
112  	{$setc TARGET_OS_MAC := FALSE}
113 	{$setc TARGET_OS_IPHONE := TRUE}
114 	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
115 {$elsec}
116 	{$setc TARGET_OS_MAC := TRUE}
117 	{$setc TARGET_OS_IPHONE := FALSE}
118 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
119 {$endc}
120 	{$setc TARGET_OS_EMBEDDED := FALSE}
121 {$elifc defined __x86_64__ and __x86_64__}
122 	{$setc TARGET_CPU_PPC := FALSE}
123 	{$setc TARGET_CPU_PPC64 := FALSE}
124 	{$setc TARGET_CPU_X86 := FALSE}
125 	{$setc TARGET_CPU_X86_64 := TRUE}
126 	{$setc TARGET_CPU_ARM := FALSE}
127 	{$setc TARGET_CPU_ARM64 := FALSE}
128 {$ifc defined iphonesim}
129  	{$setc TARGET_OS_MAC := FALSE}
130 	{$setc TARGET_OS_IPHONE := TRUE}
131 	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
132 {$elsec}
133 	{$setc TARGET_OS_MAC := TRUE}
134 	{$setc TARGET_OS_IPHONE := FALSE}
135 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
136 {$endc}
137 	{$setc TARGET_OS_EMBEDDED := FALSE}
138 {$elifc defined __arm__ and __arm__}
139 	{$setc TARGET_CPU_PPC := FALSE}
140 	{$setc TARGET_CPU_PPC64 := FALSE}
141 	{$setc TARGET_CPU_X86 := FALSE}
142 	{$setc TARGET_CPU_X86_64 := FALSE}
143 	{$setc TARGET_CPU_ARM := TRUE}
144 	{$setc TARGET_CPU_ARM64 := FALSE}
145 	{$setc TARGET_OS_MAC := FALSE}
146 	{$setc TARGET_OS_IPHONE := TRUE}
147 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
148 	{$setc TARGET_OS_EMBEDDED := TRUE}
149 {$elifc defined __arm64__ and __arm64__}
150 	{$setc TARGET_CPU_PPC := FALSE}
151 	{$setc TARGET_CPU_PPC64 := FALSE}
152 	{$setc TARGET_CPU_X86 := FALSE}
153 	{$setc TARGET_CPU_X86_64 := FALSE}
154 	{$setc TARGET_CPU_ARM := FALSE}
155 	{$setc TARGET_CPU_ARM64 := TRUE}
156 {$ifc defined ios}
157 	{$setc TARGET_OS_MAC := FALSE}
158 	{$setc TARGET_OS_IPHONE := TRUE}
159 	{$setc TARGET_OS_EMBEDDED := TRUE}
160 {$elsec}
161 	{$setc TARGET_OS_MAC := TRUE}
162 	{$setc TARGET_OS_IPHONE := FALSE}
163 	{$setc TARGET_OS_EMBEDDED := FALSE}
164 {$endc}
165 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
166 {$elsec}
167 	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
168 {$endc}
169 
170 {$ifc defined __LP64__ and __LP64__ }
171   {$setc TARGET_CPU_64 := TRUE}
172 {$elsec}
173   {$setc TARGET_CPU_64 := FALSE}
174 {$endc}
175 
176 {$ifc defined FPC_BIG_ENDIAN}
177 	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
178 	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
179 {$elifc defined FPC_LITTLE_ENDIAN}
180 	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
181 	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
182 {$elsec}
183 	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
184 {$endc}
185 {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
186 {$setc CALL_NOT_IN_CARBON := FALSE}
187 {$setc OLDROUTINENAMES := FALSE}
188 {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
189 {$setc OPAQUE_UPP_TYPES := TRUE}
190 {$setc OTCARBONAPPLICATION := TRUE}
191 {$setc OTKERNEL := FALSE}
192 {$setc PM_USE_SESSION_APIS := TRUE}
193 {$setc TARGET_API_MAC_CARBON := TRUE}
194 {$setc TARGET_API_MAC_OS8 := FALSE}
195 {$setc TARGET_API_MAC_OSX := TRUE}
196 {$setc TARGET_CARBON := TRUE}
197 {$setc TARGET_CPU_68K := FALSE}
198 {$setc TARGET_CPU_MIPS := FALSE}
199 {$setc TARGET_CPU_SPARC := FALSE}
200 {$setc TARGET_OS_UNIX := FALSE}
201 {$setc TARGET_OS_WIN32 := FALSE}
202 {$setc TARGET_RT_MAC_68881 := FALSE}
203 {$setc TARGET_RT_MAC_CFM := FALSE}
204 {$setc TARGET_RT_MAC_MACHO := TRUE}
205 {$setc TYPED_FUNCTION_POINTERS := TRUE}
206 {$setc TYPE_BOOL := FALSE}
207 {$setc TYPE_EXTENDED := FALSE}
208 {$setc TYPE_LONGLONG := TRUE}
209 uses MacTypes,CFBase,CFURL,CFDictionary,CGGeometry,CGImage,QLBase,QLThumbnailImage;
210 {$endc} {not MACOSALLINCLUDE}
211 
212 
213 {$ifc TARGET_OS_MAC}
214 {$ALIGN POWER}
215 
216 
217 
218 type
219 	QLThumbnailRef = ^__QLThumbnail; { an opaque type }
220 	__QLThumbnail = record end;
221 
QLThumbnailGetTypeIDnull222 function QLThumbnailGetTypeID: CFTypeID; external name '_QLThumbnailGetTypeID';
223 
224 {
225  @function QLThumbnailCreate
226  @abstract Creates a thumbnail instance. The thumbnail image will be computed in background.
227  @param allocator The allocator to use to create the instance.
228  @param url The URL of the document to thumbnail.
229  @param maxThumbnailSize Maximum size (in points) allowed for the thumbnail image.
230  @param options Optional hints for the thumbnail. (Only kQLThumbnailOptionScaleFactorKey is available for now)
231  @result The thumbnail instance.
232  }
QLThumbnailCreatenull233 function QLThumbnailCreate( allocator: CFAllocatorRef; url: CFURLRef; maxThumbnailSize: CGSize; options: CFDictionaryRef ): QLThumbnailRef; external name '_QLThumbnailCreate';
234 (* AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER *)
235 
236 {
237  @function QLThumbnailCopyDocumentURL
238  @abstract Returns the URL of the document to thumbnail.
239  @param thumbnail The thumbnail to compute.
240  }
QLThumbnailCopyDocumentURLnull241 function QLThumbnailCopyDocumentURL( thumbnail: QLThumbnailRef ): CFURLRef; external name '_QLThumbnailCopyDocumentURL';
242 (* AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER *)
243 
244 {
245  @function QLThumbnailGetMaximumSize
246  @abstract Returns the maximum size (in points) allowed for the thumbnail image.
247  @param thumbnail The thumbnail to compute.
248  }
QLThumbnailGetMaximumSizenull249 function QLThumbnailGetMaximumSize( thumbnail: QLThumbnailRef ): CGSize; external name '_QLThumbnailGetMaximumSize';
250 (* AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER *)
251 
252 {
253  @function QLThumbnailCopyOptions
254  @abstract Returns the options for the thumbnail.
255  @param thumbnail The thumbnail to compute.
256  }
QLThumbnailCopyOptionsnull257 function QLThumbnailCopyOptions( thumbnail: QLThumbnailRef ): CFDictionaryRef; external name '_QLThumbnailCopyOptions';
258 (* AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER *)
259 
260 {$ifdef BLOCKS_SUPPORT}
261 {
262  @function QLThumbnailDispatchAsync
263  @abstract Start computing thumbnail in background.
264  @param thumbnail The thumbnail to compute.
265  @param queue Where the completion block will be dispatched.
266  @param completion The completion block called upon thumbnail completion.
267  @discussion The completion block will always be called, even if the thumbnail computation has been cancelled.
268  }
269 procedure QLThumbnailDispatchAsync( thumbnail: QLThumbnailRef; queue: dispatch_queue_t; completion: dispatch_block_t ); external name '_QLThumbnailDispatchAsync';
270 (* AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER *)
271 {$endif}
272 
273 {
274  @function QLThumbnailCopyImage
275  @abstract Returns the image computed by Quick Look or NULL if not thumbnail was created.
276  @param thumbnail The thumbnail to compute.
277  @result The thumbnail image or NULL.
278  @discussion If called without a previous of QLThumbnailDispatchAsync(), the call will block until the thumbnail is computed.
279              QLThumbnailCopyImage() should not be called during async dispatch (before the completion block has been called)
280  }
QLThumbnailCopyImagenull281 function QLThumbnailCopyImage( thumbnail: QLThumbnailRef ): CGImageRef; external name '_QLThumbnailCopyImage';
282 (* AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER *)
283 
284 {
285  @function QLThumbnailGetContentRect
286  @abstract Returns the the effective rect within the thumbnail image representing the
287            content of the document. In icon mode, this is the part of the image without
288            all the image decorations.
289  @param thumbnail The thumbnail to compute.
290  @result The content rect of the thumbnail expressed in pixel coordinates.
291  }
QLThumbnailGetContentRectnull292 function QLThumbnailGetContentRect( thumbnail: QLThumbnailRef ): CGRect; external name '_QLThumbnailGetContentRect';
293 (* AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER *)
294 
295 
296 {
297  @function QLThumbnailCancel
298  @abstract Cancels the computation of the thumbnail.
299  @param thumbnail The thumbnail to compute.
300  @discussion If used with QLThumbnailDispatchAsync() the completion callback will be called.
301              If used in synchronous mode, QLThumbnailCopyImage() will return immediately NULL.
302  }
303 procedure QLThumbnailCancel( thumbnail: QLThumbnailRef ); external name '_QLThumbnailCancel';
304 (* AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER *)
305 
306 {
307  @function QLThumbnailIsCancelled
308  @abstract Returns wether the thumbnail computation has been cancelled.
309  @param thumbnail The thumbnail to compute.
310  }
QLThumbnailIsCancellednull311 function QLThumbnailIsCancelled( thumbnail: QLThumbnailRef ): Boolean; external name '_QLThumbnailIsCancelled';
312 (* AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER *)
313 
314 
315 {$endc} {TARGET_OS_MAC}
316 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
317 
318 end.
319 {$endc} {not MACOSALLINCLUDE}
320