//! 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::*;

use crate::*;

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextinput?language=objc)
    pub unsafe trait NSTextInput {
        /// # Safety
        ///
        /// - `string` should be of the correct type.
        /// - `string` might not allow `None`.
        #[deprecated]
        #[unsafe(method(insertText:))]
        #[unsafe(method_family = none)]
        unsafe fn insertText(&self, string: Option<&AnyObject>);

        /// # Safety
        ///
        /// `selector` must be a valid selector.
        #[deprecated]
        #[unsafe(method(doCommandBySelector:))]
        #[unsafe(method_family = none)]
        unsafe fn doCommandBySelector(&self, selector: Option<Sel>);

        /// # Safety
        ///
        /// - `string` should be of the correct type.
        /// - `string` might not allow `None`.
        #[deprecated]
        #[unsafe(method(setMarkedText:selectedRange:))]
        #[unsafe(method_family = none)]
        unsafe fn setMarkedText_selectedRange(
            &self,
            string: Option<&AnyObject>,
            sel_range: NSRange,
        );

        #[deprecated]
        #[unsafe(method(unmarkText))]
        #[unsafe(method_family = none)]
        fn unmarkText(&self);

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

        #[deprecated]
        #[unsafe(method(conversationIdentifier))]
        #[unsafe(method_family = none)]
        fn conversationIdentifier(&self) -> NSInteger;

        #[deprecated]
        #[unsafe(method(attributedSubstringFromRange:))]
        #[unsafe(method_family = none)]
        fn attributedSubstringFromRange(
            &self,
            range: NSRange,
        ) -> Option<Retained<NSAttributedString>>;

        #[deprecated]
        #[unsafe(method(markedRange))]
        #[unsafe(method_family = none)]
        fn markedRange(&self) -> NSRange;

        #[deprecated]
        #[unsafe(method(selectedRange))]
        #[unsafe(method_family = none)]
        fn selectedRange(&self) -> NSRange;

        #[deprecated]
        #[unsafe(method(firstRectForCharacterRange:))]
        #[unsafe(method_family = none)]
        fn firstRectForCharacterRange(&self, range: NSRange) -> NSRect;

        #[deprecated]
        #[unsafe(method(characterIndexForPoint:))]
        #[unsafe(method_family = none)]
        fn characterIndexForPoint(&self, point: NSPoint) -> NSUInteger;

        #[deprecated]
        #[unsafe(method(validAttributesForMarkedText))]
        #[unsafe(method_family = none)]
        fn validAttributesForMarkedText(&self) -> Option<Retained<NSArray>>;
    }
);

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsinputmanager?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[deprecated = "Use NSTextInputContext instead"]
    pub struct NSInputManager;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NSInputManager {}
);

extern_conformance!(
    unsafe impl NSTextInput for NSInputManager {}
);

impl NSInputManager {
    extern_methods!(
        #[deprecated]
        #[unsafe(method(currentInputManager))]
        #[unsafe(method_family = none)]
        pub fn currentInputManager() -> Option<Retained<NSInputManager>>;

        /// # Safety
        ///
        /// `sender` should be of the correct type.
        #[deprecated]
        #[unsafe(method(cycleToNextInputLanguage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn cycleToNextInputLanguage(sender: Option<&AnyObject>);

        /// # Safety
        ///
        /// `sender` should be of the correct type.
        #[deprecated]
        #[unsafe(method(cycleToNextInputServerInLanguage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn cycleToNextInputServerInLanguage(sender: Option<&AnyObject>);

        /// # Safety
        ///
        /// - `input_server_name` might not allow `None`.
        /// - `host_name` might not allow `None`.
        #[deprecated]
        #[unsafe(method(initWithName:host:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithName_host(
            this: Allocated<Self>,
            input_server_name: Option<&NSString>,
            host_name: Option<&NSString>,
        ) -> Option<Retained<NSInputManager>>;

        #[deprecated]
        #[unsafe(method(localizedInputManagerName))]
        #[unsafe(method_family = none)]
        pub fn localizedInputManagerName(&self) -> Option<Retained<NSString>>;

        /// # Safety
        ///
        /// - `cli` should be of the correct type.
        /// - `cli` might not allow `None`.
        #[deprecated]
        #[unsafe(method(markedTextAbandoned:))]
        #[unsafe(method_family = none)]
        pub unsafe fn markedTextAbandoned(&self, cli: Option<&AnyObject>);

        /// # Safety
        ///
        /// - `cli` should be of the correct type.
        /// - `cli` might not allow `None`.
        #[deprecated]
        #[unsafe(method(markedTextSelectionChanged:client:))]
        #[unsafe(method_family = none)]
        pub unsafe fn markedTextSelectionChanged_client(
            &self,
            new_sel: NSRange,
            cli: Option<&AnyObject>,
        );

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

        #[deprecated]
        #[unsafe(method(language))]
        #[unsafe(method_family = none)]
        pub fn language(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSImage")]
        #[deprecated]
        #[unsafe(method(image))]
        #[unsafe(method_family = none)]
        pub fn image(&self) -> Option<Retained<NSImage>>;

        #[cfg(feature = "NSInputServer")]
        #[deprecated]
        #[unsafe(method(server))]
        #[unsafe(method_family = none)]
        pub fn server(&self) -> Option<Retained<NSInputServer>>;

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

        #[cfg(feature = "NSEvent")]
        /// # Safety
        ///
        /// `mouse_event` might not allow `None`.
        #[deprecated]
        #[unsafe(method(handleMouseEvent:))]
        #[unsafe(method_family = none)]
        pub unsafe fn handleMouseEvent(&self, mouse_event: Option<&NSEvent>) -> bool;

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

/// Methods declared on superclass `NSObject`.
impl NSInputManager {
    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() -> Retained<Self>;
    );
}

impl DefaultRetained for NSInputManager {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}
