1 { CoreGraphics - CGPDFPage.h
2    Copyright (c) 2001-2011 Apple Inc.
3    All rights reserved. }
4 {       Pascal Translation:  Peter N Lewis, <peter@stairways.com.au>, August 2005 }
5 {       Pascal Translation Updated:  Jonas Maebe, <jonas@freepascal.org>, October 2009 }
6 {       Pascal Translation Updated:  Jonas Maebe, <jonas@freepascal.org>, October 2012 }
7 {       Pascal Translation Updated:  Jonas Maebe, <jonas@freepascal.org>, August 2015 }
8 {
9     Modified for use with Free Pascal
10     Version 308
11     Please report any bugs to <gpc@microbizz.nl>
12 }
13 
14 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
15 {$mode macpas}
16 {$modeswitch cblocks}
17 {$packenum 1}
18 {$macro on}
19 {$inline on}
20 {$calling mwpascal}
21 
22 unit CGPDFPage;
23 interface
24 {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
25 {$setc GAP_INTERFACES_VERSION := $0308}
26 
27 {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
28     {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
29 {$endc}
30 
31 {$ifc defined CPUPOWERPC and defined CPUI386}
32 	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
33 {$endc}
34 {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
35 	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
36 {$endc}
37 
38 {$ifc not defined __ppc__ and defined CPUPOWERPC32}
39 	{$setc __ppc__ := 1}
40 {$elsec}
41 	{$setc __ppc__ := 0}
42 {$endc}
43 {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
44 	{$setc __ppc64__ := 1}
45 {$elsec}
46 	{$setc __ppc64__ := 0}
47 {$endc}
48 {$ifc not defined __i386__ and defined CPUI386}
49 	{$setc __i386__ := 1}
50 {$elsec}
51 	{$setc __i386__ := 0}
52 {$endc}
53 {$ifc not defined __x86_64__ and defined CPUX86_64}
54 	{$setc __x86_64__ := 1}
55 {$elsec}
56 	{$setc __x86_64__ := 0}
57 {$endc}
58 {$ifc not defined __arm__ and defined CPUARM}
59 	{$setc __arm__ := 1}
60 {$elsec}
61 	{$setc __arm__ := 0}
62 {$endc}
63 {$ifc not defined __arm64__ and defined CPUAARCH64}
64   {$setc __arm64__ := 1}
65 {$elsec}
66   {$setc __arm64__ := 0}
67 {$endc}
68 
69 {$ifc defined cpu64}
70   {$setc __LP64__ := 1}
71 {$elsec}
72   {$setc __LP64__ := 0}
73 {$endc}
74 
75 
76 {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
77 	{$error Conflicting definitions for __ppc__ and __i386__}
78 {$endc}
79 
80 {$ifc defined __ppc__ and __ppc__}
81 	{$setc TARGET_CPU_PPC := TRUE}
82 	{$setc TARGET_CPU_PPC64 := FALSE}
83 	{$setc TARGET_CPU_X86 := FALSE}
84 	{$setc TARGET_CPU_X86_64 := FALSE}
85 	{$setc TARGET_CPU_ARM := FALSE}
86 	{$setc TARGET_CPU_ARM64 := FALSE}
87 	{$setc TARGET_OS_MAC := TRUE}
88 	{$setc TARGET_OS_IPHONE := FALSE}
89 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
90 	{$setc TARGET_OS_EMBEDDED := FALSE}
91 {$elifc defined __ppc64__ and __ppc64__}
92 	{$setc TARGET_CPU_PPC := FALSE}
93 	{$setc TARGET_CPU_PPC64 := TRUE}
94 	{$setc TARGET_CPU_X86 := FALSE}
95 	{$setc TARGET_CPU_X86_64 := FALSE}
96 	{$setc TARGET_CPU_ARM := FALSE}
97 	{$setc TARGET_CPU_ARM64 := FALSE}
98 	{$setc TARGET_OS_MAC := TRUE}
99 	{$setc TARGET_OS_IPHONE := FALSE}
100 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
101 	{$setc TARGET_OS_EMBEDDED := FALSE}
102 {$elifc defined __i386__ and __i386__}
103 	{$setc TARGET_CPU_PPC := FALSE}
104 	{$setc TARGET_CPU_PPC64 := FALSE}
105 	{$setc TARGET_CPU_X86 := TRUE}
106 	{$setc TARGET_CPU_X86_64 := FALSE}
107 	{$setc TARGET_CPU_ARM := FALSE}
108 	{$setc TARGET_CPU_ARM64 := FALSE}
109 {$ifc defined iphonesim}
110  	{$setc TARGET_OS_MAC := FALSE}
111 	{$setc TARGET_OS_IPHONE := TRUE}
112 	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
113 {$elsec}
114 	{$setc TARGET_OS_MAC := TRUE}
115 	{$setc TARGET_OS_IPHONE := FALSE}
116 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
117 {$endc}
118 	{$setc TARGET_OS_EMBEDDED := FALSE}
119 {$elifc defined __x86_64__ and __x86_64__}
120 	{$setc TARGET_CPU_PPC := FALSE}
121 	{$setc TARGET_CPU_PPC64 := FALSE}
122 	{$setc TARGET_CPU_X86 := FALSE}
123 	{$setc TARGET_CPU_X86_64 := TRUE}
124 	{$setc TARGET_CPU_ARM := FALSE}
125 	{$setc TARGET_CPU_ARM64 := FALSE}
126 {$ifc defined iphonesim}
127  	{$setc TARGET_OS_MAC := FALSE}
128 	{$setc TARGET_OS_IPHONE := TRUE}
129 	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
130 {$elsec}
131 	{$setc TARGET_OS_MAC := TRUE}
132 	{$setc TARGET_OS_IPHONE := FALSE}
133 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
134 {$endc}
135 	{$setc TARGET_OS_EMBEDDED := FALSE}
136 {$elifc defined __arm__ and __arm__}
137 	{$setc TARGET_CPU_PPC := FALSE}
138 	{$setc TARGET_CPU_PPC64 := FALSE}
139 	{$setc TARGET_CPU_X86 := FALSE}
140 	{$setc TARGET_CPU_X86_64 := FALSE}
141 	{$setc TARGET_CPU_ARM := TRUE}
142 	{$setc TARGET_CPU_ARM64 := FALSE}
143 	{$setc TARGET_OS_MAC := FALSE}
144 	{$setc TARGET_OS_IPHONE := TRUE}
145 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
146 	{$setc TARGET_OS_EMBEDDED := TRUE}
147 {$elifc defined __arm64__ and __arm64__}
148 	{$setc TARGET_CPU_PPC := FALSE}
149 	{$setc TARGET_CPU_PPC64 := FALSE}
150 	{$setc TARGET_CPU_X86 := FALSE}
151 	{$setc TARGET_CPU_X86_64 := FALSE}
152 	{$setc TARGET_CPU_ARM := FALSE}
153 	{$setc TARGET_CPU_ARM64 := TRUE}
154 {$ifc defined ios}
155 	{$setc TARGET_OS_MAC := FALSE}
156 	{$setc TARGET_OS_IPHONE := TRUE}
157 	{$setc TARGET_OS_EMBEDDED := TRUE}
158 {$elsec}
159 	{$setc TARGET_OS_MAC := TRUE}
160 	{$setc TARGET_OS_IPHONE := FALSE}
161 	{$setc TARGET_OS_EMBEDDED := FALSE}
162 {$endc}
163 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
164 {$elsec}
165 	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
166 {$endc}
167 
168 {$ifc defined __LP64__ and __LP64__ }
169   {$setc TARGET_CPU_64 := TRUE}
170 {$elsec}
171   {$setc TARGET_CPU_64 := FALSE}
172 {$endc}
173 
174 {$ifc defined FPC_BIG_ENDIAN}
175 	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
176 	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
177 {$elifc defined FPC_LITTLE_ENDIAN}
178 	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
179 	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
180 {$elsec}
181 	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
182 {$endc}
183 {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
184 {$setc CALL_NOT_IN_CARBON := FALSE}
185 {$setc OLDROUTINENAMES := FALSE}
186 {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
187 {$setc OPAQUE_UPP_TYPES := TRUE}
188 {$setc OTCARBONAPPLICATION := TRUE}
189 {$setc OTKERNEL := FALSE}
190 {$setc PM_USE_SESSION_APIS := TRUE}
191 {$setc TARGET_API_MAC_CARBON := TRUE}
192 {$setc TARGET_API_MAC_OS8 := FALSE}
193 {$setc TARGET_API_MAC_OSX := TRUE}
194 {$setc TARGET_CARBON := TRUE}
195 {$setc TARGET_CPU_68K := FALSE}
196 {$setc TARGET_CPU_MIPS := FALSE}
197 {$setc TARGET_CPU_SPARC := FALSE}
198 {$setc TARGET_OS_UNIX := FALSE}
199 {$setc TARGET_OS_WIN32 := FALSE}
200 {$setc TARGET_RT_MAC_68881 := FALSE}
201 {$setc TARGET_RT_MAC_CFM := FALSE}
202 {$setc TARGET_RT_MAC_MACHO := TRUE}
203 {$setc TYPED_FUNCTION_POINTERS := TRUE}
204 {$setc TYPE_BOOL := FALSE}
205 {$setc TYPE_EXTENDED := FALSE}
206 {$setc TYPE_LONGLONG := TRUE}
207 uses MacTypes,CGAffineTransforms,CFBase,CGBase,CGPDFDocument,CGGeometry;
208 {$endc} {not MACOSALLINCLUDE}
209 
210 {$ALIGN POWER}
211 
212 
213 // CGPDFPageRef defined in CGBase
214 
215 
216 type
217 	CGPDFBox = SInt32;
218 const
219 	kCGPDFMediaBox = 0;
220 	kCGPDFCropBox = 1;
221 	kCGPDFBleedBox = 2;
222 	kCGPDFTrimBox = 3;
223 	kCGPDFArtBox = 4;
224 
225 { Equivalent to `CFRetain(page)', except it doesn't crash (as CFRetain
226    does) if `page' is NULL. }
227 
CGPDFPageRetainnull228 function CGPDFPageRetain( page: CGPDFPageRef ): CGPDFPageRef; external name '_CGPDFPageRetain';
229 (* CG_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_2_0) *)
230 
231 { Equivalent to `CFRelease(page)', except it doesn't crash (as CFRelease
232    does) if `page' is NULL. }
233 
234 procedure CGPDFPageRelease( page: CGPDFPageRef ); external name '_CGPDFPageRelease';
235 (* CG_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_2_0) *)
236 
237 { Return the document of `page'. }
238 
CGPDFPageGetDocumentnull239 function CGPDFPageGetDocument( page: CGPDFPageRef ): CGPDFDocumentRef; external name '_CGPDFPageGetDocument';
240 (* CG_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_2_0) *)
241 
242 { Return the page number of `page'. }
243 
CGPDFPageGetPageNumbernull244 function CGPDFPageGetPageNumber( page: CGPDFPageRef ): size_t; external name '_CGPDFPageGetPageNumber';
245 (* CG_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_2_0) *)
246 
247 { Return the rectangle associated with `box' in `page'. This is the value
248    of the corresponding entry (such as /MediaBox, /ArtBox, and so on) in the
249    page's dictionary. }
250 
CGPDFPageGetBoxRectnull251 function CGPDFPageGetBoxRect( page: CGPDFPageRef; box: CGPDFBox ): CGRect; external name '_CGPDFPageGetBoxRect';
252 (* CG_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_2_0) *)
253 
254 { Return the rotation angle (in degrees) of `page'. This is the value of
255    the /Rotate entry in the page's dictionary. }
256 
CGPDFPageGetRotationAnglenull257 function CGPDFPageGetRotationAngle( page: CGPDFPageRef ): SInt32; external name '_CGPDFPageGetRotationAngle';
258 (* CG_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_2_0) *)
259 
260 { Return a transform mapping the box specified by `box' to `rect' as
261    follows:
262      - Compute the effective rect by intersecting the rect associated with
263        `box' and the /MediaBox entry of the page.
264      - Rotate the effective rect according to the page's /Rotate entry.
265      - Center the resulting rect on `rect'. If `rotation' is non-zero, then
266        the rect will rotated clockwise by `rotation' degrees. `rotation'
267        must be a multiple of 90.
268      - Scale the rect down, if necessary, so that it coincides with the
269        edges of `rect'. If `preserveAspectRatio' is true, then the final
270        rect will coincide with the edges of `rect' only in the more
271        restrictive dimension. }
272 
CGPDFPageGetDrawingTransformnull273 function CGPDFPageGetDrawingTransform( page: CGPDFPageRef; box: CGPDFBox; rect: CGRect; rotate: SInt32; preserveAspectRatio: CBool ): CGAffineTransform; external name '_CGPDFPageGetDrawingTransform';
274 (* CG_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_2_0) *)
275 
276 { Return the dictionary of `page'. }
277 
CGPDFPageGetDictionarynull278 function CGPDFPageGetDictionary( page: CGPDFPageRef ): CGPDFDictionaryRef; external name '_CGPDFPageGetDictionary';
279 (* CG_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_2_0) *)
280 
281 { Return the CFTypeID for CGPDFPageRefs. }
282 
CGPDFPageGetTypeIDnull283 function CGPDFPageGetTypeID: CFTypeID; external name '_CGPDFPageGetTypeID';
284 (* CG_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_2_0) *)
285 
286 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
287 
288 end.
289 {$endc} {not MACOSALLINCLUDE}
290