objc2_ui_kit/generated/
UIScreenshotService.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::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13    /// This class allows your application to produce a higher fidelity, PDF screenshot to the user. Set the delegate so that when a screenshot is taken, screenshots can show the full document content from the application.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uiscreenshotservice?language=objc)
16    #[unsafe(super(NSObject))]
17    #[thread_kind = MainThreadOnly]
18    #[derive(Debug, PartialEq, Eq, Hash)]
19    pub struct UIScreenshotService;
20);
21
22extern_conformance!(
23    unsafe impl NSObjectProtocol for UIScreenshotService {}
24);
25
26impl UIScreenshotService {
27    extern_methods!(
28        #[unsafe(method(init))]
29        #[unsafe(method_family = init)]
30        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
31
32        #[unsafe(method(new))]
33        #[unsafe(method_family = new)]
34        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
35
36        /// Assign a delegate in order to send PDF data to accompany the screenshot taken by the user
37        #[unsafe(method(delegate))]
38        #[unsafe(method_family = none)]
39        pub unsafe fn delegate(
40            &self,
41        ) -> Option<Retained<ProtocolObject<dyn UIScreenshotServiceDelegate>>>;
42
43        /// This is a [weak property][objc2::topics::weak_property].
44        /// Setter for [`delegate`][Self::delegate].
45        #[unsafe(method(setDelegate:))]
46        #[unsafe(method_family = none)]
47        pub unsafe fn setDelegate(
48            &self,
49            delegate: Option<&ProtocolObject<dyn UIScreenshotServiceDelegate>>,
50        );
51
52        #[cfg(all(
53            feature = "UIResponder",
54            feature = "UIScene",
55            feature = "UIWindowScene"
56        ))]
57        /// The window scene associated with the screenshot service
58        #[unsafe(method(windowScene))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn windowScene(&self) -> Option<Retained<UIWindowScene>>;
61    );
62}
63
64/// UIScreenshotService.
65#[cfg(all(
66    feature = "UIResponder",
67    feature = "UIScene",
68    feature = "UIWindowScene"
69))]
70impl UIWindowScene {
71    extern_methods!(
72        /// The screenshot object associated with the scene
73        ///
74        /// This is non-null if the screenshot service is available for this window scene
75        #[unsafe(method(screenshotService))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn screenshotService(&self) -> Option<Retained<UIScreenshotService>>;
78    );
79}
80
81extern_protocol!(
82    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiscreenshotservicedelegate?language=objc)
83    pub unsafe trait UIScreenshotServiceDelegate: NSObjectProtocol + MainThreadOnly {
84        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
85        /// The delegate method to send the PDF data to screenshots
86        ///
87        /// The delegate is required to send the data via the completion handler
88        ///
89        /// Parameter `screenshotService`: The screenshot service object associated per scene
90        ///
91        /// Parameter `completionHandler`: The block to execute when the PDF data is ready.
92        /// If no PDF data is available, data can be nil. The indexOfCurrentPage is zero-based, and is the index of the current page of the snapshotted PDF. The rectInCurrentPage is the rect in PDF coordinates with respect to the current page. If the receiver cannot provide the visible area, pass CGRectZero for rectInCurrentPage.
93        #[optional]
94        #[unsafe(method(screenshotService:generatePDFRepresentationWithCompletion:))]
95        #[unsafe(method_family = none)]
96        unsafe fn screenshotService_generatePDFRepresentationWithCompletion(
97            &self,
98            screenshot_service: &UIScreenshotService,
99            completion_handler: &block2::DynBlock<dyn Fn(*mut NSData, NSInteger, CGRect)>,
100        );
101    }
102);