objc2-ui-kit 0.3.2

Bindings to the UIKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-uniform-type-identifiers")]
use objc2_uniform_type_identifiers::*;

use crate::*;

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidocumentpickerdelegate?language=objc)
    pub unsafe trait UIDocumentPickerDelegate: NSObjectProtocol + MainThreadOnly {
        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(documentPicker:didPickDocumentsAtURLs:))]
        #[unsafe(method_family = none)]
        fn documentPicker_didPickDocumentsAtURLs(
            &self,
            controller: &UIDocumentPickerViewController,
            urls: &NSArray<NSURL>,
        );

        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(documentPickerWasCancelled:))]
        #[unsafe(method_family = none)]
        fn documentPickerWasCancelled(&self, controller: &UIDocumentPickerViewController);

        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[deprecated]
        #[optional]
        #[unsafe(method(documentPicker:didPickDocumentAtURL:))]
        #[unsafe(method_family = none)]
        fn documentPicker_didPickDocumentAtURL(
            &self,
            controller: &UIDocumentPickerViewController,
            url: &NSURL,
        );
    }
);

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidocumentpickermode?language=objc)
// NS_ENUM
#[deprecated = "Use appropriate initializers instead"]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIDocumentPickerMode(pub NSUInteger);
impl UIDocumentPickerMode {
    #[doc(alias = "UIDocumentPickerModeImport")]
    #[deprecated = "Use appropriate initializers instead"]
    pub const Import: Self = Self(0);
    #[doc(alias = "UIDocumentPickerModeOpen")]
    #[deprecated = "Use appropriate initializers instead"]
    pub const Open: Self = Self(1);
    #[doc(alias = "UIDocumentPickerModeExportToService")]
    #[deprecated = "Use appropriate initializers instead"]
    pub const ExportToService: Self = Self(2);
    #[doc(alias = "UIDocumentPickerModeMoveToService")]
    #[deprecated = "Use appropriate initializers instead"]
    pub const MoveToService: Self = Self(3);
}

unsafe impl Encode for UIDocumentPickerMode {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for UIDocumentPickerMode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidocumentpickerviewcontroller?language=objc)
    #[unsafe(super(UIViewController, UIResponder, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
    pub struct UIDocumentPickerViewController;
);

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
extern_conformance!(
    unsafe impl NSCoding for UIDocumentPickerViewController {}
);

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for UIDocumentPickerViewController {}
);

#[cfg(all(
    feature = "UIAppearance",
    feature = "UIResponder",
    feature = "UIViewController"
))]
extern_conformance!(
    unsafe impl UIAppearanceContainer for UIDocumentPickerViewController {}
);

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
extern_conformance!(
    unsafe impl UIContentContainer for UIDocumentPickerViewController {}
);

#[cfg(all(
    feature = "UIFocus",
    feature = "UIResponder",
    feature = "UIViewController"
))]
extern_conformance!(
    unsafe impl UIFocusEnvironment for UIDocumentPickerViewController {}
);

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
extern_conformance!(
    unsafe impl UIResponderStandardEditActions for UIDocumentPickerViewController {}
);

#[cfg(all(
    feature = "UIResponder",
    feature = "UITraitCollection",
    feature = "UIViewController"
))]
extern_conformance!(
    unsafe impl UITraitEnvironment for UIDocumentPickerViewController {}
);

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
impl UIDocumentPickerViewController {
    extern_methods!(
        #[deprecated]
        #[unsafe(method(initWithDocumentTypes:inMode:))]
        #[unsafe(method_family = init)]
        pub fn initWithDocumentTypes_inMode(
            this: Allocated<Self>,
            allowed_ut_is: &NSArray<NSString>,
            mode: UIDocumentPickerMode,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-uniform-type-identifiers")]
        /// Initializes the picker instance for selecting a document in a remote location.
        ///
        /// Parameter `asCopy`: if true, the picker will give you access to a local copy of the document, otherwise you will have access to the original document
        #[unsafe(method(initForOpeningContentTypes:asCopy:))]
        #[unsafe(method_family = init)]
        pub fn initForOpeningContentTypes_asCopy(
            this: Allocated<Self>,
            content_types: &NSArray<UTType>,
            as_copy: bool,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-uniform-type-identifiers")]
        /// Initializes the picker instance for selecting a document in a remote location, giving you access to the original document.
        #[unsafe(method(initForOpeningContentTypes:))]
        #[unsafe(method_family = init)]
        pub fn initForOpeningContentTypes(
            this: Allocated<Self>,
            content_types: &NSArray<UTType>,
        ) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

        #[deprecated]
        #[unsafe(method(initWithURL:inMode:))]
        #[unsafe(method_family = init)]
        pub fn initWithURL_inMode(
            this: Allocated<Self>,
            url: &NSURL,
            mode: UIDocumentPickerMode,
        ) -> Retained<Self>;

        #[deprecated]
        #[unsafe(method(initWithURLs:inMode:))]
        #[unsafe(method_family = init)]
        pub fn initWithURLs_inMode(
            this: Allocated<Self>,
            urls: &NSArray<NSURL>,
            mode: UIDocumentPickerMode,
        ) -> Retained<Self>;

        /// Initializes the picker for exporting local documents to an external location. The new locations will be returned using `didPickDocumentAtURLs:`.
        ///
        /// Parameter `asCopy`: if true, a copy will be exported to the destination, otherwise the original document will be moved to the destination. For performance reasons and to avoid copies, we recommend you set `asCopy` to false.
        #[unsafe(method(initForExportingURLs:asCopy:))]
        #[unsafe(method_family = init)]
        pub fn initForExportingURLs_asCopy(
            this: Allocated<Self>,
            urls: &NSArray<NSURL>,
            as_copy: bool,
        ) -> Retained<Self>;

        /// Initializes the picker for exporting local documents to an external location. The new locations will be returned using `didPickDocumentAtURLs:`. The original document will be moved to the destination.
        #[unsafe(method(initForExportingURLs:))]
        #[unsafe(method_family = init)]
        pub fn initForExportingURLs(this: Allocated<Self>, urls: &NSArray<NSURL>)
            -> Retained<Self>;

        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn UIDocumentPickerDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn UIDocumentPickerDelegate>>);

        #[deprecated = "Use appropriate initializers instead"]
        #[unsafe(method(documentPickerMode))]
        #[unsafe(method_family = none)]
        pub fn documentPickerMode(&self) -> UIDocumentPickerMode;

        #[unsafe(method(allowsMultipleSelection))]
        #[unsafe(method_family = none)]
        pub fn allowsMultipleSelection(&self) -> bool;

        /// Setter for [`allowsMultipleSelection`][Self::allowsMultipleSelection].
        #[unsafe(method(setAllowsMultipleSelection:))]
        #[unsafe(method_family = none)]
        pub fn setAllowsMultipleSelection(&self, allows_multiple_selection: bool);

        /// Force the display of supported file extensions (default: NO).
        #[unsafe(method(shouldShowFileExtensions))]
        #[unsafe(method_family = none)]
        pub fn shouldShowFileExtensions(&self) -> bool;

        /// Setter for [`shouldShowFileExtensions`][Self::shouldShowFileExtensions].
        #[unsafe(method(setShouldShowFileExtensions:))]
        #[unsafe(method_family = none)]
        pub fn setShouldShowFileExtensions(&self, should_show_file_extensions: bool);

        /// Picker will try to display this URL when presented
        #[unsafe(method(directoryURL))]
        #[unsafe(method_family = none)]
        pub fn directoryURL(&self) -> Option<Retained<NSURL>>;

        /// Setter for [`directoryURL`][Self::directoryURL].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setDirectoryURL:))]
        #[unsafe(method_family = none)]
        pub fn setDirectoryURL(&self, directory_url: Option<&NSURL>);
    );
}

/// Methods declared on superclass `UIViewController`.
#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
impl UIDocumentPickerViewController {
    extern_methods!(
        #[unsafe(method(initWithNibName:bundle:))]
        #[unsafe(method_family = init)]
        pub fn initWithNibName_bundle(
            this: Allocated<Self>,
            nib_name_or_nil: Option<&NSString>,
            nib_bundle_or_nil: Option<&NSBundle>,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
impl UIDocumentPickerViewController {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}