objc2-app-kit 0.2.2

Bindings to the AppKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSDocumentController;

    unsafe impl ClassType for NSDocumentController {
        type Super = NSObject;
        type Mutability = MainThreadOnly;
    }
);

unsafe impl NSCoding for NSDocumentController {}

#[cfg(feature = "NSMenu")]
unsafe impl NSMenuItemValidation for NSDocumentController {}

unsafe impl NSObjectProtocol for NSDocumentController {}

#[cfg(feature = "NSUserInterfaceValidation")]
unsafe impl NSUserInterfaceValidations for NSDocumentController {}

extern_methods!(
    unsafe impl NSDocumentController {
        #[method_id(@__retain_semantics Other sharedDocumentController)]
        pub unsafe fn sharedDocumentController(
            mtm: MainThreadMarker,
        ) -> Retained<NSDocumentController>;

        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics Init initWithCoder:)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

        #[cfg(feature = "NSDocument")]
        #[method_id(@__retain_semantics Other documents)]
        pub unsafe fn documents(&self) -> Retained<NSArray<NSDocument>>;

        #[cfg(feature = "NSDocument")]
        #[method_id(@__retain_semantics Other currentDocument)]
        pub unsafe fn currentDocument(&self) -> Option<Retained<NSDocument>>;

        #[method_id(@__retain_semantics Other currentDirectory)]
        pub unsafe fn currentDirectory(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSDocument")]
        #[method_id(@__retain_semantics Other documentForURL:)]
        pub unsafe fn documentForURL(&self, url: &NSURL) -> Option<Retained<NSDocument>>;

        #[cfg(all(feature = "NSDocument", feature = "NSResponder", feature = "NSWindow"))]
        #[method_id(@__retain_semantics Other documentForWindow:)]
        pub unsafe fn documentForWindow(&self, window: &NSWindow) -> Option<Retained<NSDocument>>;

        #[cfg(feature = "NSDocument")]
        #[method(addDocument:)]
        pub unsafe fn addDocument(&self, document: &NSDocument);

        #[cfg(feature = "NSDocument")]
        #[method(removeDocument:)]
        pub unsafe fn removeDocument(&self, document: &NSDocument);

        #[method(newDocument:)]
        pub unsafe fn newDocument(&self, sender: Option<&AnyObject>);

        #[cfg(feature = "NSDocument")]
        #[method_id(@__retain_semantics Other openUntitledDocumentAndDisplay:error:_)]
        pub unsafe fn openUntitledDocumentAndDisplay_error(
            &self,
            display_document: bool,
        ) -> Result<Retained<NSDocument>, Retained<NSError>>;

        #[cfg(feature = "NSDocument")]
        #[method_id(@__retain_semantics Other makeUntitledDocumentOfType:error:_)]
        pub unsafe fn makeUntitledDocumentOfType_error(
            &self,
            type_name: &NSString,
        ) -> Result<Retained<NSDocument>, Retained<NSError>>;

        #[method(openDocument:)]
        pub unsafe fn openDocument(&self, sender: Option<&AnyObject>);

        #[method_id(@__retain_semantics Other URLsFromRunningOpenPanel)]
        pub unsafe fn URLsFromRunningOpenPanel(&self) -> Option<Retained<NSArray<NSURL>>>;

        #[cfg(all(
            feature = "NSOpenPanel",
            feature = "NSPanel",
            feature = "NSResponder",
            feature = "NSSavePanel",
            feature = "NSWindow"
        ))]
        #[method(runModalOpenPanel:forTypes:)]
        pub unsafe fn runModalOpenPanel_forTypes(
            &self,
            open_panel: &NSOpenPanel,
            types: Option<&NSArray<NSString>>,
        ) -> NSInteger;

        #[cfg(feature = "block2")]
        #[method(beginOpenPanelWithCompletionHandler:)]
        pub unsafe fn beginOpenPanelWithCompletionHandler(
            &self,
            completion_handler: &block2::Block<dyn Fn(*mut NSArray<NSURL>)>,
        );

        #[cfg(all(
            feature = "NSOpenPanel",
            feature = "NSPanel",
            feature = "NSResponder",
            feature = "NSSavePanel",
            feature = "NSWindow",
            feature = "block2"
        ))]
        #[method(beginOpenPanel:forTypes:completionHandler:)]
        pub unsafe fn beginOpenPanel_forTypes_completionHandler(
            &self,
            open_panel: &NSOpenPanel,
            in_types: Option<&NSArray<NSString>>,
            completion_handler: &block2::Block<dyn Fn(NSInteger)>,
        );

        #[cfg(all(feature = "NSDocument", feature = "block2"))]
        #[method(openDocumentWithContentsOfURL:display:completionHandler:)]
        pub unsafe fn openDocumentWithContentsOfURL_display_completionHandler(
            &self,
            url: &NSURL,
            display_document: bool,
            completion_handler: &block2::Block<dyn Fn(*mut NSDocument, Bool, *mut NSError)>,
        );

        #[cfg(feature = "NSDocument")]
        #[method_id(@__retain_semantics Other makeDocumentWithContentsOfURL:ofType:error:_)]
        pub unsafe fn makeDocumentWithContentsOfURL_ofType_error(
            &self,
            url: &NSURL,
            type_name: &NSString,
        ) -> Result<Retained<NSDocument>, Retained<NSError>>;

        #[cfg(all(feature = "NSDocument", feature = "block2"))]
        #[method(reopenDocumentForURL:withContentsOfURL:display:completionHandler:)]
        pub unsafe fn reopenDocumentForURL_withContentsOfURL_display_completionHandler(
            &self,
            url_or_nil: Option<&NSURL>,
            contents_url: &NSURL,
            display_document: bool,
            completion_handler: &block2::Block<dyn Fn(*mut NSDocument, Bool, *mut NSError)>,
        );

        #[cfg(feature = "NSDocument")]
        #[method_id(@__retain_semantics Other makeDocumentForURL:withContentsOfURL:ofType:error:_)]
        pub unsafe fn makeDocumentForURL_withContentsOfURL_ofType_error(
            &self,
            url_or_nil: Option<&NSURL>,
            contents_url: &NSURL,
            type_name: &NSString,
        ) -> Result<Retained<NSDocument>, Retained<NSError>>;

        #[method(autosavingDelay)]
        pub unsafe fn autosavingDelay(&self) -> NSTimeInterval;

        #[method(setAutosavingDelay:)]
        pub unsafe fn setAutosavingDelay(&self, autosaving_delay: NSTimeInterval);

        #[method(saveAllDocuments:)]
        pub unsafe fn saveAllDocuments(&self, sender: Option<&AnyObject>);

        #[method(hasEditedDocuments)]
        pub unsafe fn hasEditedDocuments(&self) -> bool;

        #[method(reviewUnsavedDocumentsWithAlertTitle:cancellable:delegate:didReviewAllSelector:contextInfo:)]
        pub unsafe fn reviewUnsavedDocumentsWithAlertTitle_cancellable_delegate_didReviewAllSelector_contextInfo(
            &self,
            title: Option<&NSString>,
            cancellable: bool,
            delegate: Option<&AnyObject>,
            did_review_all_selector: Option<Sel>,
            context_info: *mut c_void,
        );

        #[method(closeAllDocumentsWithDelegate:didCloseAllSelector:contextInfo:)]
        pub unsafe fn closeAllDocumentsWithDelegate_didCloseAllSelector_contextInfo(
            &self,
            delegate: Option<&AnyObject>,
            did_close_all_selector: Option<Sel>,
            context_info: *mut c_void,
        );

        #[cfg(feature = "NSDocument")]
        #[method_id(@__retain_semantics Other duplicateDocumentWithContentsOfURL:copying:displayName:error:_)]
        pub unsafe fn duplicateDocumentWithContentsOfURL_copying_displayName_error(
            &self,
            url: &NSURL,
            duplicate_by_copying: bool,
            display_name_or_nil: Option<&NSString>,
        ) -> Result<Retained<NSDocument>, Retained<NSError>>;

        #[method(allowsAutomaticShareMenu)]
        pub unsafe fn allowsAutomaticShareMenu(&self) -> bool;

        #[cfg(feature = "NSMenuItem")]
        #[method_id(@__retain_semantics Other standardShareMenuItem)]
        pub unsafe fn standardShareMenuItem(&self) -> Retained<NSMenuItem>;

        #[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
        #[method(presentError:modalForWindow:delegate:didPresentSelector:contextInfo:)]
        pub unsafe fn presentError_modalForWindow_delegate_didPresentSelector_contextInfo(
            &self,
            error: &NSError,
            window: &NSWindow,
            delegate: Option<&AnyObject>,
            did_present_selector: Option<Sel>,
            context_info: *mut c_void,
        );

        #[method(presentError:)]
        pub unsafe fn presentError(&self, error: &NSError) -> bool;

        #[method_id(@__retain_semantics Other willPresentError:)]
        pub unsafe fn willPresentError(&self, error: &NSError) -> Retained<NSError>;

        #[method(maximumRecentDocumentCount)]
        pub unsafe fn maximumRecentDocumentCount(&self) -> NSUInteger;

        #[method(clearRecentDocuments:)]
        pub unsafe fn clearRecentDocuments(&self, sender: Option<&AnyObject>);

        #[cfg(feature = "NSDocument")]
        #[method(noteNewRecentDocument:)]
        pub unsafe fn noteNewRecentDocument(&self, document: &NSDocument);

        #[method(noteNewRecentDocumentURL:)]
        pub unsafe fn noteNewRecentDocumentURL(&self, url: &NSURL);

        #[method_id(@__retain_semantics Other recentDocumentURLs)]
        pub unsafe fn recentDocumentURLs(&self) -> Retained<NSArray<NSURL>>;

        #[method_id(@__retain_semantics Other defaultType)]
        pub unsafe fn defaultType(&self) -> Option<Retained<NSString>>;

        #[method_id(@__retain_semantics Other typeForContentsOfURL:error:_)]
        pub unsafe fn typeForContentsOfURL_error(
            &self,
            url: &NSURL,
        ) -> Result<Retained<NSString>, Retained<NSError>>;

        #[method_id(@__retain_semantics Other documentClassNames)]
        pub unsafe fn documentClassNames(&self) -> Retained<NSArray<NSString>>;

        #[method(documentClassForType:)]
        pub unsafe fn documentClassForType(
            &self,
            type_name: &NSString,
        ) -> Option<&'static AnyClass>;

        #[method_id(@__retain_semantics Other displayNameForType:)]
        pub unsafe fn displayNameForType(&self, type_name: &NSString)
            -> Option<Retained<NSString>>;

        #[cfg(feature = "NSUserInterfaceValidation")]
        #[method(validateUserInterfaceItem:)]
        pub unsafe fn validateUserInterfaceItem(
            &self,
            item: &ProtocolObject<dyn NSValidatedUserInterfaceItem>,
        ) -> bool;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSDocumentController {
        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    }
);

extern_methods!(
    /// NSDeprecated
    unsafe impl NSDocumentController {
        #[deprecated = "Use -openDocumentWithContentsOfURL:display:completionHandler: instead"]
        #[method_id(@__retain_semantics Other openDocumentWithContentsOfURL:display:error:_)]
        pub unsafe fn openDocumentWithContentsOfURL_display_error(
            &self,
            url: &NSURL,
            display_document: bool,
        ) -> Result<Retained<AnyObject>, Retained<NSError>>;

        #[deprecated = "Use -reopenDocumentForURL:withContentsOfURL:display:completionHandler: instead"]
        #[method(reopenDocumentForURL:withContentsOfURL:error:_)]
        pub unsafe fn reopenDocumentForURL_withContentsOfURL_error(
            &self,
            url: Option<&NSURL>,
            contents_url: &NSURL,
        ) -> Result<(), Retained<NSError>>;

        #[deprecated]
        #[method_id(@__retain_semantics Other fileExtensionsFromType:)]
        pub unsafe fn fileExtensionsFromType(
            &self,
            type_name: &NSString,
        ) -> Option<Retained<NSArray>>;

        #[deprecated]
        #[method_id(@__retain_semantics Other typeFromFileExtension:)]
        pub unsafe fn typeFromFileExtension(
            &self,
            file_name_extension_or_hfs_file_type: &NSString,
        ) -> Option<Retained<NSString>>;

        #[deprecated]
        #[method_id(@__retain_semantics Other documentForFileName:)]
        pub unsafe fn documentForFileName(
            &self,
            file_name: &NSString,
        ) -> Option<Retained<AnyObject>>;

        #[deprecated]
        #[method_id(@__retain_semantics Other fileNamesFromRunningOpenPanel)]
        pub unsafe fn fileNamesFromRunningOpenPanel(&self) -> Option<Retained<NSArray>>;

        #[deprecated]
        #[method_id(@__retain_semantics Other makeDocumentWithContentsOfFile:ofType:)]
        pub unsafe fn makeDocumentWithContentsOfFile_ofType(
            &self,
            file_name: &NSString,
            r#type: &NSString,
        ) -> Option<Retained<AnyObject>>;

        #[deprecated]
        #[method_id(@__retain_semantics Other makeDocumentWithContentsOfURL:ofType:)]
        pub unsafe fn makeDocumentWithContentsOfURL_ofType(
            &self,
            url: &NSURL,
            r#type: Option<&NSString>,
        ) -> Option<Retained<AnyObject>>;

        #[deprecated]
        #[method_id(@__retain_semantics Other makeUntitledDocumentOfType:)]
        pub unsafe fn makeUntitledDocumentOfType(
            &self,
            r#type: &NSString,
        ) -> Option<Retained<AnyObject>>;

        #[deprecated]
        #[method_id(@__retain_semantics Other openDocumentWithContentsOfFile:display:)]
        pub unsafe fn openDocumentWithContentsOfFile_display(
            &self,
            file_name: &NSString,
            display: bool,
        ) -> Option<Retained<AnyObject>>;

        #[deprecated]
        #[method_id(@__retain_semantics Other openDocumentWithContentsOfURL:display:)]
        pub unsafe fn openDocumentWithContentsOfURL_display(
            &self,
            url: &NSURL,
            display: bool,
        ) -> Option<Retained<AnyObject>>;

        #[deprecated]
        #[method_id(@__retain_semantics Other openUntitledDocumentOfType:display:)]
        pub unsafe fn openUntitledDocumentOfType_display(
            &self,
            r#type: &NSString,
            display: bool,
        ) -> Option<Retained<AnyObject>>;

        #[deprecated]
        #[method(setShouldCreateUI:)]
        pub unsafe fn setShouldCreateUI(&self, flag: bool);

        #[deprecated]
        #[method(shouldCreateUI)]
        pub unsafe fn shouldCreateUI(&self) -> bool;
    }
);