//! 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_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeycommand?language=objc)
    #[unsafe(super(UICommand, UIMenuElement, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
    pub struct UIKeyCommand;
);

#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
extern_conformance!(
    unsafe impl NSCoding for UIKeyCommand {}
);

#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
extern_conformance!(
    unsafe impl NSCopying for UIKeyCommand {}
);

#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
unsafe impl CopyingHelper for UIKeyCommand {
    type Result = Self;
}

#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for UIKeyCommand {}
);

#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
extern_conformance!(
    unsafe impl NSSecureCoding for UIKeyCommand {}
);

#[cfg(all(
    feature = "UICommand",
    feature = "UIMenuElement",
    feature = "UIMenuLeaf"
))]
extern_conformance!(
    unsafe impl UIMenuLeaf for UIKeyCommand {}
);

#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
impl UIKeyCommand {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> 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>>;

        /// Short display title.
        #[unsafe(method(title))]
        #[unsafe(method_family = none)]
        pub fn title(&self) -> Retained<NSString>;

        /// Setter for [`title`][Self::title].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setTitle:))]
        #[unsafe(method_family = none)]
        pub fn setTitle(&self, title: &NSString);

        #[cfg(feature = "UIImage")]
        /// Image that can appear next to this command.
        #[unsafe(method(image))]
        #[unsafe(method_family = none)]
        pub fn image(&self) -> Option<Retained<UIImage>>;

        #[cfg(feature = "UIImage")]
        /// Setter for [`image`][Self::image].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setImage:))]
        #[unsafe(method_family = none)]
        pub fn setImage(&self, image: Option<&UIImage>);

        /// Elaborated title, if any.
        #[unsafe(method(discoverabilityTitle))]
        #[unsafe(method_family = none)]
        pub fn discoverabilityTitle(&self) -> Option<Retained<NSString>>;

        /// Setter for [`discoverabilityTitle`][Self::discoverabilityTitle].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setDiscoverabilityTitle:))]
        #[unsafe(method_family = none)]
        pub fn setDiscoverabilityTitle(&self, discoverability_title: Option<&NSString>);

        /// Action to take on choosing this command.
        #[unsafe(method(action))]
        #[unsafe(method_family = none)]
        pub unsafe fn action(&self) -> Option<Sel>;

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

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

        /// Property list object to distinguish commands, if needed.
        #[unsafe(method(propertyList))]
        #[unsafe(method_family = none)]
        pub fn propertyList(&self) -> Option<Retained<AnyObject>>;

        /// Command attributes.
        #[unsafe(method(attributes))]
        #[unsafe(method_family = none)]
        pub fn attributes(&self) -> UIMenuElementAttributes;

        /// Setter for [`attributes`][Self::attributes].
        #[unsafe(method(setAttributes:))]
        #[unsafe(method_family = none)]
        pub fn setAttributes(&self, attributes: UIMenuElementAttributes);

        /// State that can appear next to this command.
        #[unsafe(method(state))]
        #[unsafe(method_family = none)]
        pub fn state(&self) -> UIMenuElementState;

        /// Setter for [`state`][Self::state].
        #[unsafe(method(setState:))]
        #[unsafe(method_family = none)]
        pub fn setState(&self, state: UIMenuElementState);

        /// Alternates that differ in modifier flags, if any.
        #[unsafe(method(alternates))]
        #[unsafe(method_family = none)]
        pub fn alternates(&self) -> Retained<NSArray<UICommandAlternate>>;

        /// Indicates whether the key command should execute if it conflicts with focus or text-editing system commands, defaults to
        /// `NO`
        #[unsafe(method(wantsPriorityOverSystemBehavior))]
        #[unsafe(method_family = none)]
        pub fn wantsPriorityOverSystemBehavior(&self) -> bool;

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

        /// Suppose the system detects a given key command that is not reachable in the current keyboard layout; it will localize the key command to something reachable. By setting this property to NO, you will opt-out this menu item from the system-provided localization. YES by default for apps linked against 15.0 and later SDK.
        #[unsafe(method(allowsAutomaticLocalization))]
        #[unsafe(method_family = none)]
        pub fn allowsAutomaticLocalization(&self) -> bool;

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

        /// Suppose the system detects a given key command with the following input string [ ] { } ( )
        /// <
        /// > ← → in a right-to-left user interface environment (UIUserInterfaceLayoutDirectionRightToLeft); in that case, the system will automatically mirror the key command. For example, a pair of key commands with input { and } will be localized to } and { in a right-to-left user interface. By setting this property to NO, you will opt-out this key command of automatically mirroring in RTL. It would be best only to do this if your action will result in some sort of directional change in the UI, e.g. a segmented control for text alignment or a D-pad in a game. YES by default for apps linked against 15.0 and later SDK.
        #[unsafe(method(allowsAutomaticMirroring))]
        #[unsafe(method_family = none)]
        pub fn allowsAutomaticMirroring(&self) -> bool;

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

        #[cfg(feature = "UIImage")]
        /// Initializes a key command.
        ///
        ///
        /// Parameter `title`: Short display title. This should be localized.
        ///
        /// Parameter `image`: Image that can appear next to this command, if needed.
        ///
        /// Parameter `action`: Action to take on choosing this command.
        ///
        /// Parameter `input`: Keys that must be pressed to choose this command.
        ///
        /// Parameter `modifierFlags`: Bit mask of key modifier flags to choose this command.
        ///
        /// Parameter `propertyList`: Property list object to distinguish commands, if needed.
        ///
        /// Returns: A new key command.
        ///
        /// # Safety
        ///
        /// - `action` must be a valid selector.
        /// - `property_list` should be of the correct type.
        #[unsafe(method(commandWithTitle:image:action:input:modifierFlags:propertyList:))]
        #[unsafe(method_family = none)]
        pub unsafe fn commandWithTitle_image_action_input_modifierFlags_propertyList(
            title: &NSString,
            image: Option<&UIImage>,
            action: Sel,
            input: &NSString,
            modifier_flags: UIKeyModifierFlags,
            property_list: Option<&AnyObject>,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[cfg(feature = "UIImage")]
        /// Initializes a key command with alternates.
        ///
        ///
        /// Parameter `title`: Short display title. This should be localized.
        ///
        /// Parameter `image`: Image that can appear next to this command, if needed.
        ///
        /// Parameter `action`: Action to take on choosing this command.
        ///
        /// Parameter `input`: Keys that must be pressed to choose this command.
        ///
        /// Parameter `modifierFlags`: Bit mask of key modifier flags to choose this command.
        ///
        /// Parameter `propertyList`: Property list object to distinguish commands, if needed.
        ///
        /// Parameter `alternates`: Alternates that differ in modifier flags.
        ///
        /// Returns: A new key command.
        ///
        /// # Safety
        ///
        /// - `action` must be a valid selector.
        /// - `property_list` should be of the correct type.
        #[unsafe(method(commandWithTitle:image:action:input:modifierFlags:propertyList:alternates:))]
        #[unsafe(method_family = none)]
        pub unsafe fn commandWithTitle_image_action_input_modifierFlags_propertyList_alternates(
            title: &NSString,
            image: Option<&UIImage>,
            action: Sel,
            input: &NSString,
            modifier_flags: UIKeyModifierFlags,
            property_list: Option<&AnyObject>,
            alternates: &NSArray<UICommandAlternate>,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        /// # Safety
        ///
        /// `action` must be a valid selector.
        #[unsafe(method(keyCommandWithInput:modifierFlags:action:))]
        #[unsafe(method_family = none)]
        pub unsafe fn keyCommandWithInput_modifierFlags_action(
            input: &NSString,
            modifier_flags: UIKeyModifierFlags,
            action: Sel,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        /// # Safety
        ///
        /// `action` must be a valid selector.
        #[deprecated]
        #[unsafe(method(keyCommandWithInput:modifierFlags:action:discoverabilityTitle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn keyCommandWithInput_modifierFlags_action_discoverabilityTitle(
            input: &NSString,
            modifier_flags: UIKeyModifierFlags,
            action: Sel,
            discoverability_title: &NSString,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[cfg(feature = "UIImage")]
        /// # Safety
        ///
        /// - `action` must be a valid selector.
        /// - `property_list` should be of the correct type.
        #[unsafe(method(commandWithTitle:image:action:propertyList:))]
        #[unsafe(method_family = none)]
        pub unsafe fn commandWithTitle_image_action_propertyList(
            title: &NSString,
            image: Option<&UIImage>,
            action: Sel,
            property_list: Option<&AnyObject>,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[cfg(feature = "UIImage")]
        /// # Safety
        ///
        /// - `action` must be a valid selector.
        /// - `property_list` should be of the correct type.
        #[unsafe(method(commandWithTitle:image:action:propertyList:alternates:))]
        #[unsafe(method_family = none)]
        pub unsafe fn commandWithTitle_image_action_propertyList_alternates(
            title: &NSString,
            image: Option<&UIImage>,
            action: Sel,
            property_list: Option<&AnyObject>,
            alternates: &NSArray<UICommandAlternate>,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `UICommand`.
#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
impl UIKeyCommand {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}
