//! 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/appkit/nscandidatelisttouchbaritem?language=objc)
    #[unsafe(super(NSTouchBarItem, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSTouchBarItem")]
    pub struct NSCandidateListTouchBarItem<CandidateType: ?Sized = AnyObject>;
);

#[cfg(feature = "NSTouchBarItem")]
unsafe impl<CandidateType: ?Sized + NSCoding> NSCoding
    for NSCandidateListTouchBarItem<CandidateType>
{
}

#[cfg(feature = "NSTouchBarItem")]
unsafe impl<CandidateType: ?Sized> NSObjectProtocol for NSCandidateListTouchBarItem<CandidateType> {}

#[cfg(feature = "NSTouchBarItem")]
impl<CandidateType: Message> NSCandidateListTouchBarItem<CandidateType> {
    extern_methods!(
        #[cfg(all(
            feature = "NSResponder",
            feature = "NSTextInputClient",
            feature = "NSView"
        ))]
        #[unsafe(method(client))]
        #[unsafe(method_family = none)]
        pub unsafe fn client(&self) -> Option<Retained<NSView>>;

        #[cfg(all(
            feature = "NSResponder",
            feature = "NSTextInputClient",
            feature = "NSView"
        ))]
        /// This is a [weak property][objc2::topics::weak_property].
        /// Setter for [`client`][Self::client].
        #[unsafe(method(setClient:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setClient(&self, client: Option<&NSView>);

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

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

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

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

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

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

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

        #[unsafe(method(updateWithInsertionPointVisibility:))]
        #[unsafe(method_family = none)]
        pub unsafe fn updateWithInsertionPointVisibility(&self, is_visible: bool);

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

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

        #[cfg(feature = "block2")]
        #[unsafe(method(attributedStringForCandidate))]
        #[unsafe(method_family = none)]
        pub unsafe fn attributedStringForCandidate(
            &self,
        ) -> *mut block2::Block<
            dyn Fn(NonNull<CandidateType>, NSInteger) -> NonNull<NSAttributedString>,
        >;

        #[cfg(feature = "block2")]
        /// Setter for [`attributedStringForCandidate`][Self::attributedStringForCandidate].
        #[unsafe(method(setAttributedStringForCandidate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAttributedStringForCandidate(
            &self,
            attributed_string_for_candidate: Option<
                &block2::Block<
                    dyn Fn(NonNull<CandidateType>, NSInteger) -> NonNull<NSAttributedString>,
                >,
            >,
        );

        #[unsafe(method(candidates))]
        #[unsafe(method_family = none)]
        pub unsafe fn candidates(&self) -> Retained<NSArray<CandidateType>>;

        #[unsafe(method(setCandidates:forSelectedRange:inString:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setCandidates_forSelectedRange_inString(
            &self,
            candidates: &NSArray<CandidateType>,
            selected_range: NSRange,
            original_string: Option<&NSString>,
        );

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

        /// Setter for [`customizationLabel`][Self::customizationLabel].
        #[unsafe(method(setCustomizationLabel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setCustomizationLabel(&self, customization_label: Option<&NSString>);
    );
}

/// Methods declared on superclass `NSTouchBarItem`.
#[cfg(feature = "NSTouchBarItem")]
impl<CandidateType: Message> NSCandidateListTouchBarItem<CandidateType> {
    extern_methods!(
        #[unsafe(method(initWithIdentifier:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithIdentifier(
            this: Allocated<Self>,
            identifier: &NSTouchBarItemIdentifier,
        ) -> Retained<Self>;

        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSTouchBarItem")]
impl<CandidateType: Message> NSCandidateListTouchBarItem<CandidateType> {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscandidatelisttouchbaritemdelegate?language=objc)
    pub unsafe trait NSCandidateListTouchBarItemDelegate:
        NSObjectProtocol + MainThreadOnly
    {
        #[cfg(feature = "NSTouchBarItem")]
        #[optional]
        #[unsafe(method(candidateListTouchBarItem:beginSelectingCandidateAtIndex:))]
        #[unsafe(method_family = none)]
        unsafe fn candidateListTouchBarItem_beginSelectingCandidateAtIndex(
            &self,
            an_item: &NSCandidateListTouchBarItem,
            index: NSInteger,
        );

        #[cfg(feature = "NSTouchBarItem")]
        #[optional]
        #[unsafe(method(candidateListTouchBarItem:changeSelectionFromCandidateAtIndex:toIndex:))]
        #[unsafe(method_family = none)]
        unsafe fn candidateListTouchBarItem_changeSelectionFromCandidateAtIndex_toIndex(
            &self,
            an_item: &NSCandidateListTouchBarItem,
            previous_index: NSInteger,
            index: NSInteger,
        );

        #[cfg(feature = "NSTouchBarItem")]
        #[optional]
        #[unsafe(method(candidateListTouchBarItem:endSelectingCandidateAtIndex:))]
        #[unsafe(method_family = none)]
        unsafe fn candidateListTouchBarItem_endSelectingCandidateAtIndex(
            &self,
            an_item: &NSCandidateListTouchBarItem,
            index: NSInteger,
        );

        #[cfg(feature = "NSTouchBarItem")]
        #[optional]
        #[unsafe(method(candidateListTouchBarItem:changedCandidateListVisibility:))]
        #[unsafe(method_family = none)]
        unsafe fn candidateListTouchBarItem_changedCandidateListVisibility(
            &self,
            an_item: &NSCandidateListTouchBarItem,
            is_visible: bool,
        );
    }
);

/// NSCandidateListTouchBarItem.
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
impl NSView {
    extern_methods!(
        #[cfg(feature = "NSTouchBarItem")]
        #[unsafe(method(candidateListTouchBarItem))]
        #[unsafe(method_family = none)]
        pub unsafe fn candidateListTouchBarItem(
            &self,
        ) -> Option<Retained<NSCandidateListTouchBarItem>>;
    );
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstouchbaritemidentifiercandidatelist?language=objc)
    #[cfg(feature = "NSTouchBarItem")]
    pub static NSTouchBarItemIdentifierCandidateList: &'static NSTouchBarItemIdentifier;
}
