objc2-core-graphics 0.3.2

Bindings to the CoreGraphics framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;

use crate::*;

/// # Safety
///
/// - `media_box` must be a valid pointer or null.
/// - `auxiliary_info` generics must be of the correct type.
#[cfg(all(feature = "CGContext", feature = "CGDataConsumer"))]
#[inline]
pub unsafe extern "C-unwind" fn CGPDFContextCreate(
    consumer: Option<&CGDataConsumer>,
    media_box: *const CGRect,
    auxiliary_info: Option<&CFDictionary>,
) -> Option<CFRetained<CGContext>> {
    extern "C-unwind" {
        fn CGPDFContextCreate(
            consumer: Option<&CGDataConsumer>,
            media_box: *const CGRect,
            auxiliary_info: Option<&CFDictionary>,
        ) -> Option<NonNull<CGContext>>;
    }
    let ret = unsafe { CGPDFContextCreate(consumer, media_box, auxiliary_info) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

/// # Safety
///
/// - `media_box` must be a valid pointer or null.
/// - `auxiliary_info` generics must be of the correct type.
#[cfg(feature = "CGContext")]
#[inline]
pub unsafe extern "C-unwind" fn CGPDFContextCreateWithURL(
    url: Option<&CFURL>,
    media_box: *const CGRect,
    auxiliary_info: Option<&CFDictionary>,
) -> Option<CFRetained<CGContext>> {
    extern "C-unwind" {
        fn CGPDFContextCreateWithURL(
            url: Option<&CFURL>,
            media_box: *const CGRect,
            auxiliary_info: Option<&CFDictionary>,
        ) -> Option<NonNull<CGContext>>;
    }
    let ret = unsafe { CGPDFContextCreateWithURL(url, media_box, auxiliary_info) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "CGContext")]
#[inline]
pub extern "C-unwind" fn CGPDFContextClose(context: Option<&CGContext>) {
    extern "C-unwind" {
        fn CGPDFContextClose(context: Option<&CGContext>);
    }
    unsafe { CGPDFContextClose(context) }
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `page_info` generics must be of the correct type.
    #[cfg(feature = "CGContext")]
    pub fn CGPDFContextBeginPage(context: Option<&CGContext>, page_info: Option<&CFDictionary>);
}

#[cfg(feature = "CGContext")]
#[inline]
pub extern "C-unwind" fn CGPDFContextEndPage(context: Option<&CGContext>) {
    extern "C-unwind" {
        fn CGPDFContextEndPage(context: Option<&CGContext>);
    }
    unsafe { CGPDFContextEndPage(context) }
}

#[cfg(feature = "CGContext")]
#[inline]
pub extern "C-unwind" fn CGPDFContextAddDocumentMetadata(
    context: Option<&CGContext>,
    metadata: Option<&CFData>,
) {
    extern "C-unwind" {
        fn CGPDFContextAddDocumentMetadata(context: Option<&CGContext>, metadata: Option<&CFData>);
    }
    unsafe { CGPDFContextAddDocumentMetadata(context, metadata) }
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `parent_tree_dictionary` must be a valid pointer.
    #[cfg(all(feature = "CGContext", feature = "CGPDFDictionary"))]
    pub fn CGPDFContextSetParentTree(
        context: Option<&CGContext>,
        parent_tree_dictionary: CGPDFDictionaryRef,
    );
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `id_tree_dictionary` must be a valid pointer.
    #[cfg(all(feature = "CGContext", feature = "CGPDFDictionary"))]
    pub fn CGPDFContextSetIDTree(
        context: Option<&CGContext>,
        id_tree_dictionary: CGPDFDictionaryRef,
    );
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `page_tag_structure_tree_dictionary` generics must be of the correct type.
    #[cfg(feature = "CGContext")]
    pub fn CGPDFContextSetPageTagStructureTree(
        context: Option<&CGContext>,
        page_tag_structure_tree_dictionary: &CFDictionary,
    );
}

#[cfg(feature = "CGContext")]
#[inline]
pub extern "C-unwind" fn CGPDFContextSetURLForRect(
    context: Option<&CGContext>,
    url: &CFURL,
    rect: CGRect,
) {
    extern "C-unwind" {
        fn CGPDFContextSetURLForRect(context: Option<&CGContext>, url: &CFURL, rect: CGRect);
    }
    unsafe { CGPDFContextSetURLForRect(context, url, rect) }
}

#[cfg(feature = "CGContext")]
#[inline]
pub extern "C-unwind" fn CGPDFContextAddDestinationAtPoint(
    context: Option<&CGContext>,
    name: &CFString,
    point: CGPoint,
) {
    extern "C-unwind" {
        fn CGPDFContextAddDestinationAtPoint(
            context: Option<&CGContext>,
            name: &CFString,
            point: CGPoint,
        );
    }
    unsafe { CGPDFContextAddDestinationAtPoint(context, name, point) }
}

#[cfg(feature = "CGContext")]
#[inline]
pub extern "C-unwind" fn CGPDFContextSetDestinationForRect(
    context: Option<&CGContext>,
    name: &CFString,
    rect: CGRect,
) {
    extern "C-unwind" {
        fn CGPDFContextSetDestinationForRect(
            context: Option<&CGContext>,
            name: &CFString,
            rect: CGRect,
        );
    }
    unsafe { CGPDFContextSetDestinationForRect(context, name, rect) }
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextmediabox?language=objc)
    pub static kCGPDFContextMediaBox: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextcropbox?language=objc)
    pub static kCGPDFContextCropBox: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextbleedbox?language=objc)
    pub static kCGPDFContextBleedBox: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontexttrimbox?language=objc)
    pub static kCGPDFContextTrimBox: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextartbox?language=objc)
    pub static kCGPDFContextArtBox: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontexttitle?language=objc)
    pub static kCGPDFContextTitle: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextauthor?language=objc)
    pub static kCGPDFContextAuthor: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextsubject?language=objc)
    pub static kCGPDFContextSubject: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextkeywords?language=objc)
    pub static kCGPDFContextKeywords: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextcreator?language=objc)
    pub static kCGPDFContextCreator: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextownerpassword?language=objc)
    pub static kCGPDFContextOwnerPassword: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextuserpassword?language=objc)
    pub static kCGPDFContextUserPassword: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextencryptionkeylength?language=objc)
    pub static kCGPDFContextEncryptionKeyLength: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextallowsprinting?language=objc)
    pub static kCGPDFContextAllowsPrinting: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextallowscopying?language=objc)
    pub static kCGPDFContextAllowsCopying: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextoutputintent?language=objc)
    pub static kCGPDFContextOutputIntent: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfxoutputintentsubtype?language=objc)
    pub static kCGPDFXOutputIntentSubtype: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfxoutputconditionidentifier?language=objc)
    pub static kCGPDFXOutputConditionIdentifier: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfxoutputcondition?language=objc)
    pub static kCGPDFXOutputCondition: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfxregistryname?language=objc)
    pub static kCGPDFXRegistryName: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfxinfo?language=objc)
    pub static kCGPDFXInfo: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfxdestinationoutputprofile?language=objc)
    pub static kCGPDFXDestinationOutputProfile: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextoutputintents?language=objc)
    pub static kCGPDFContextOutputIntents: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextaccesspermissions?language=objc)
    pub static kCGPDFContextAccessPermissions: &'static CFString;
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `outline` generics must be of the correct type.
    #[cfg(feature = "CGContext")]
    pub fn CGPDFContextSetOutline(context: &CGContext, outline: Option<&CFDictionary>);
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextcreatelinearizedpdf?language=objc)
    pub static kCGPDFContextCreateLinearizedPDF: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdfcontextcreatepdfa?language=objc)
    pub static kCGPDFContextCreatePDFA: &'static CFString;
}

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgpdftagtype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CGPDFTagType(pub i32);
impl CGPDFTagType {
    #[doc(alias = "CGPDFTagTypeDocument")]
    pub const Document: Self = Self(100);
    #[doc(alias = "CGPDFTagTypePart")]
    pub const Part: Self = Self(101);
    #[doc(alias = "CGPDFTagTypeArt")]
    pub const Art: Self = Self(102);
    #[doc(alias = "CGPDFTagTypeSection")]
    pub const Section: Self = Self(103);
    #[doc(alias = "CGPDFTagTypeDiv")]
    pub const Div: Self = Self(104);
    #[doc(alias = "CGPDFTagTypeBlockQuote")]
    pub const BlockQuote: Self = Self(105);
    #[doc(alias = "CGPDFTagTypeCaption")]
    pub const Caption: Self = Self(106);
    #[doc(alias = "CGPDFTagTypeTOC")]
    pub const TOC: Self = Self(107);
    #[doc(alias = "CGPDFTagTypeTOCI")]
    pub const TOCI: Self = Self(108);
    #[doc(alias = "CGPDFTagTypeIndex")]
    pub const Index: Self = Self(109);
    #[doc(alias = "CGPDFTagTypeNonStructure")]
    pub const NonStructure: Self = Self(110);
    #[doc(alias = "CGPDFTagTypePrivate")]
    pub const Private: Self = Self(111);
    #[doc(alias = "CGPDFTagTypeParagraph")]
    pub const Paragraph: Self = Self(200);
    #[doc(alias = "CGPDFTagTypeHeader")]
    pub const Header: Self = Self(201);
    #[doc(alias = "CGPDFTagTypeHeader1")]
    pub const Header1: Self = Self(202);
    #[doc(alias = "CGPDFTagTypeHeader2")]
    pub const Header2: Self = Self(203);
    #[doc(alias = "CGPDFTagTypeHeader3")]
    pub const Header3: Self = Self(204);
    #[doc(alias = "CGPDFTagTypeHeader4")]
    pub const Header4: Self = Self(205);
    #[doc(alias = "CGPDFTagTypeHeader5")]
    pub const Header5: Self = Self(206);
    #[doc(alias = "CGPDFTagTypeHeader6")]
    pub const Header6: Self = Self(207);
    #[doc(alias = "CGPDFTagTypeList")]
    pub const List: Self = Self(300);
    #[doc(alias = "CGPDFTagTypeListItem")]
    pub const ListItem: Self = Self(301);
    #[doc(alias = "CGPDFTagTypeLabel")]
    pub const Label: Self = Self(302);
    #[doc(alias = "CGPDFTagTypeListBody")]
    pub const ListBody: Self = Self(303);
    #[doc(alias = "CGPDFTagTypeTable")]
    pub const Table: Self = Self(400);
    #[doc(alias = "CGPDFTagTypeTableRow")]
    pub const TableRow: Self = Self(401);
    #[doc(alias = "CGPDFTagTypeTableHeaderCell")]
    pub const TableHeaderCell: Self = Self(402);
    #[doc(alias = "CGPDFTagTypeTableDataCell")]
    pub const TableDataCell: Self = Self(403);
    #[doc(alias = "CGPDFTagTypeTableHeader")]
    pub const TableHeader: Self = Self(404);
    #[doc(alias = "CGPDFTagTypeTableBody")]
    pub const TableBody: Self = Self(405);
    #[doc(alias = "CGPDFTagTypeTableFooter")]
    pub const TableFooter: Self = Self(406);
    #[doc(alias = "CGPDFTagTypeSpan")]
    pub const Span: Self = Self(500);
    #[doc(alias = "CGPDFTagTypeQuote")]
    pub const Quote: Self = Self(501);
    #[doc(alias = "CGPDFTagTypeNote")]
    pub const Note: Self = Self(502);
    #[doc(alias = "CGPDFTagTypeReference")]
    pub const Reference: Self = Self(503);
    #[doc(alias = "CGPDFTagTypeBibliography")]
    pub const Bibliography: Self = Self(504);
    #[doc(alias = "CGPDFTagTypeCode")]
    pub const Code: Self = Self(505);
    #[doc(alias = "CGPDFTagTypeLink")]
    pub const Link: Self = Self(506);
    #[doc(alias = "CGPDFTagTypeAnnotation")]
    pub const Annotation: Self = Self(507);
    #[doc(alias = "CGPDFTagTypeRuby")]
    pub const Ruby: Self = Self(600);
    #[doc(alias = "CGPDFTagTypeRubyBaseText")]
    pub const RubyBaseText: Self = Self(601);
    #[doc(alias = "CGPDFTagTypeRubyAnnotationText")]
    pub const RubyAnnotationText: Self = Self(602);
    #[doc(alias = "CGPDFTagTypeRubyPunctuation")]
    pub const RubyPunctuation: Self = Self(603);
    #[doc(alias = "CGPDFTagTypeWarichu")]
    pub const Warichu: Self = Self(604);
    #[doc(alias = "CGPDFTagTypeWarichuText")]
    pub const WarichuText: Self = Self(605);
    #[doc(alias = "CGPDFTagTypeWarichuPunctiation")]
    pub const WarichuPunctiation: Self = Self(606);
    #[doc(alias = "CGPDFTagTypeFigure")]
    pub const Figure: Self = Self(700);
    #[doc(alias = "CGPDFTagTypeFormula")]
    pub const Formula: Self = Self(701);
    #[doc(alias = "CGPDFTagTypeForm")]
    pub const Form: Self = Self(702);
    #[doc(alias = "CGPDFTagTypeObject")]
    pub const Object: Self = Self(800);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CGPDFTagType {
    const ENCODING: Encoding = i32::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for CGPDFTagType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

impl CGPDFTagType {
    #[doc(alias = "CGPDFTagTypeGetName")]
    #[inline]
    pub fn name(self) -> *const c_char {
        extern "C-unwind" {
            fn CGPDFTagTypeGetName(tag_type: CGPDFTagType) -> *const c_char;
        }
        unsafe { CGPDFTagTypeGetName(self) }
    }
}

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgpdftagproperty?language=objc)
// NS_TYPED_ENUM
pub type CGPDFTagProperty = CFString;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdftagpropertyactualtext?language=objc)
    pub static kCGPDFTagPropertyActualText: &'static CGPDFTagProperty;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdftagpropertyalternativetext?language=objc)
    pub static kCGPDFTagPropertyAlternativeText: &'static CGPDFTagProperty;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdftagpropertytitletext?language=objc)
    pub static kCGPDFTagPropertyTitleText: &'static CGPDFTagProperty;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgpdftagpropertylanguagetext?language=objc)
    pub static kCGPDFTagPropertyLanguageText: &'static CGPDFTagProperty;
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `tag_properties` generics must be of the correct type.
    #[cfg(feature = "CGContext")]
    pub fn CGPDFContextBeginTag(
        context: &CGContext,
        tag_type: CGPDFTagType,
        tag_properties: Option<&CFDictionary>,
    );
}

#[cfg(feature = "CGContext")]
#[inline]
pub extern "C-unwind" fn CGPDFContextEndTag(context: &CGContext) {
    extern "C-unwind" {
        fn CGPDFContextEndTag(context: &CGContext);
    }
    unsafe { CGPDFContextEndTag(context) }
}

#[deprecated = "renamed to `CGPDFTagType::name`"]
#[inline]
pub extern "C-unwind" fn CGPDFTagTypeGetName(tag_type: CGPDFTagType) -> *const c_char {
    extern "C-unwind" {
        fn CGPDFTagTypeGetName(tag_type: CGPDFTagType) -> *const c_char;
    }
    unsafe { CGPDFTagTypeGetName(tag_type) }
}