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

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssearchfieldrecentsautosavename?language=objc)
pub type NSSearchFieldRecentsAutosaveName = NSString;

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssearchfielddelegate?language=objc)
    #[cfg(all(feature = "NSControl", feature = "NSTextField"))]
    pub unsafe trait NSSearchFieldDelegate: NSTextFieldDelegate + MainThreadOnly {
        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[unsafe(method(searchFieldDidStartSearching:))]
        #[unsafe(method_family = none)]
        fn searchFieldDidStartSearching(&self, sender: &NSSearchField);

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[unsafe(method(searchFieldDidEndSearching:))]
        #[unsafe(method_family = none)]
        fn searchFieldDidEndSearching(&self, sender: &NSSearchField);
    }
);

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssearchfield?language=objc)
    #[unsafe(super(NSTextField, NSControl, NSView, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(
        feature = "NSControl",
        feature = "NSResponder",
        feature = "NSTextField",
        feature = "NSView"
    ))]
    pub struct NSSearchField;
);

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSTextField",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSAccessibility for NSSearchField {}
);

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSTextField",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSAccessibilityElementProtocol for NSSearchField {}
);

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSTextField",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSAccessibilityNavigableStaticText for NSSearchField {}
);

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSTextField",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSAccessibilityStaticText for NSSearchField {}
);

#[cfg(all(
    feature = "NSAnimation",
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSTextField",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSAnimatablePropertyContainer for NSSearchField {}
);

#[cfg(all(
    feature = "NSAppearance",
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSTextField",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSAppearanceCustomization for NSSearchField {}
);

#[cfg(all(
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSTextField",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSCoding for NSSearchField {}
);

#[cfg(all(
    feature = "NSControl",
    feature = "NSDragging",
    feature = "NSResponder",
    feature = "NSTextField",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSDraggingDestination for NSSearchField {}
);

#[cfg(all(
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSTextField",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSSearchField {}
);

#[cfg(all(
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSTextContent",
    feature = "NSTextField",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSTextContent for NSSearchField {}
);

#[cfg(all(
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSTextField",
    feature = "NSUserInterfaceItemIdentification",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSUserInterfaceItemIdentification for NSSearchField {}
);

#[cfg(all(
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSTextField",
    feature = "NSUserInterfaceValidation",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSUserInterfaceValidations for NSSearchField {}
);

#[cfg(all(
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSTextField",
    feature = "NSView"
))]
impl NSSearchField {
    extern_methods!(
        #[unsafe(method(searchTextBounds))]
        #[unsafe(method_family = none)]
        pub fn searchTextBounds(&self) -> NSRect;

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

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

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

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

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

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

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

        #[cfg(feature = "NSMenu")]
        /// Setter for [`searchMenuTemplate`][Self::searchMenuTemplate].
        #[unsafe(method(setSearchMenuTemplate:))]
        #[unsafe(method_family = none)]
        pub fn setSearchMenuTemplate(&self, search_menu_template: Option<&NSMenu>);

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

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

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

        /// Setter for [`maximumRecents`][Self::maximumRecents].
        #[unsafe(method(setMaximumRecents:))]
        #[unsafe(method_family = none)]
        pub fn setMaximumRecents(&self, maximum_recents: NSInteger);

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

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

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

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

/// Methods declared on superclass `NSControl`.
#[cfg(all(
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSTextField",
    feature = "NSView"
))]
impl NSSearchField {
    extern_methods!(
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> 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>>;
    );
}

/// Methods declared on superclass `NSResponder`.
#[cfg(all(
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSTextField",
    feature = "NSView"
))]
impl NSSearchField {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

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

/// NSSearchField_Deprecated.
#[cfg(all(
    feature = "NSControl",
    feature = "NSResponder",
    feature = "NSTextField",
    feature = "NSView"
))]
impl NSSearchField {
    extern_methods!(
        #[deprecated]
        #[unsafe(method(rectForSearchTextWhenCentered:))]
        #[unsafe(method_family = none)]
        pub fn rectForSearchTextWhenCentered(&self, is_centered: bool) -> NSRect;

        #[deprecated]
        #[unsafe(method(rectForSearchButtonWhenCentered:))]
        #[unsafe(method_family = none)]
        pub fn rectForSearchButtonWhenCentered(&self, is_centered: bool) -> NSRect;

        #[deprecated]
        #[unsafe(method(rectForCancelButtonWhenCentered:))]
        #[unsafe(method_family = none)]
        pub fn rectForCancelButtonWhenCentered(&self, is_centered: bool) -> NSRect;

        #[deprecated = "The placeholder centering UI design is no longer available. Setting this property is no-op."]
        #[unsafe(method(centersPlaceholder))]
        #[unsafe(method_family = none)]
        pub fn centersPlaceholder(&self) -> bool;

        /// Setter for [`centersPlaceholder`][Self::centersPlaceholder].
        #[deprecated = "The placeholder centering UI design is no longer available. Setting this property is no-op."]
        #[unsafe(method(setCentersPlaceholder:))]
        #[unsafe(method_family = none)]
        pub fn setCentersPlaceholder(&self, centers_placeholder: bool);
    );
}
