//! 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::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

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

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

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

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

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

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

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

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

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

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

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

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

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

#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSTextField {
    extern_methods!(
        #[unsafe(method(placeholderString))]
        #[unsafe(method_family = none)]
        pub fn placeholderString(&self) -> Option<Retained<NSString>>;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        /// 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 NSTextFieldDelegate>>,
        );

        #[cfg(feature = "NSText")]
        #[unsafe(method(textShouldBeginEditing:))]
        #[unsafe(method_family = none)]
        pub fn textShouldBeginEditing(&self, text_object: &NSText) -> bool;

        #[cfg(feature = "NSText")]
        #[unsafe(method(textShouldEndEditing:))]
        #[unsafe(method_family = none)]
        pub fn textShouldEndEditing(&self, text_object: &NSText) -> bool;

        #[unsafe(method(textDidBeginEditing:))]
        #[unsafe(method_family = none)]
        pub fn textDidBeginEditing(&self, notification: &NSNotification);

        #[unsafe(method(textDidEndEditing:))]
        #[unsafe(method_family = none)]
        pub fn textDidEndEditing(&self, notification: &NSNotification);

        #[unsafe(method(textDidChange:))]
        #[unsafe(method_family = none)]
        pub fn textDidChange(&self, notification: &NSNotification);

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

        #[cfg(feature = "NSTextFieldCell")]
        #[unsafe(method(bezelStyle))]
        #[unsafe(method_family = none)]
        pub fn bezelStyle(&self) -> NSTextFieldBezelStyle;

        #[cfg(feature = "NSTextFieldCell")]
        /// Setter for [`bezelStyle`][Self::bezelStyle].
        #[unsafe(method(setBezelStyle:))]
        #[unsafe(method_family = none)]
        pub fn setBezelStyle(&self, bezel_style: NSTextFieldBezelStyle);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(preferredMaxLayoutWidth))]
        #[unsafe(method_family = none)]
        pub fn preferredMaxLayoutWidth(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`preferredMaxLayoutWidth`][Self::preferredMaxLayoutWidth].
        #[unsafe(method(setPreferredMaxLayoutWidth:))]
        #[unsafe(method_family = none)]
        pub fn setPreferredMaxLayoutWidth(&self, preferred_max_layout_width: CGFloat);

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

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

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

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

        #[cfg(feature = "NSParagraphStyle")]
        #[unsafe(method(lineBreakStrategy))]
        #[unsafe(method_family = none)]
        pub fn lineBreakStrategy(&self) -> NSLineBreakStrategy;

        #[cfg(feature = "NSParagraphStyle")]
        /// Setter for [`lineBreakStrategy`][Self::lineBreakStrategy].
        #[unsafe(method(setLineBreakStrategy:))]
        #[unsafe(method_family = none)]
        pub fn setLineBreakStrategy(&self, line_break_strategy: NSLineBreakStrategy);

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

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

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

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

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

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

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

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

        /// Specifies the behavior for resolving ``NSTextAlignment.natural`` to the visual alignment.
        ///
        /// When set to ``true``, the resolved visual alignment is determined by the resolved base writing direction; otherwise, it is using the user’s preferred language.
        /// The default value is ``false``.
        #[unsafe(method(resolvesNaturalAlignmentWithBaseWritingDirection))]
        #[unsafe(method_family = none)]
        pub fn resolvesNaturalAlignmentWithBaseWritingDirection(&self) -> bool;

        /// Setter for [`resolvesNaturalAlignmentWithBaseWritingDirection`][Self::resolvesNaturalAlignmentWithBaseWritingDirection].
        #[unsafe(method(setResolvesNaturalAlignmentWithBaseWritingDirection:))]
        #[unsafe(method_family = none)]
        pub fn setResolvesNaturalAlignmentWithBaseWritingDirection(
            &self,
            resolves_natural_alignment_with_base_writing_direction: bool,
        );
    );
}

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

/// NSTouchBar.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSTextField {
    extern_methods!(
        #[unsafe(method(isAutomaticTextCompletionEnabled))]
        #[unsafe(method_family = none)]
        pub fn isAutomaticTextCompletionEnabled(&self) -> bool;

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

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

        /// Setter for [`allowsCharacterPickerTouchBarItem`][Self::allowsCharacterPickerTouchBarItem].
        #[unsafe(method(setAllowsCharacterPickerTouchBarItem:))]
        #[unsafe(method_family = none)]
        pub fn setAllowsCharacterPickerTouchBarItem(
            &self,
            allows_character_picker_touch_bar_item: bool,
        );
    );
}

/// NSTextFieldConvenience.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSTextField {
    extern_methods!(
        /// Creates a non-wrapping, non-editable, non-selectable text field that displays text in the default system font.
        ///
        /// Parameter `stringValue`: The title text to display in the field.
        ///
        /// Returns: An initialized text field object.
        #[unsafe(method(labelWithString:))]
        #[unsafe(method_family = none)]
        pub fn labelWithString(string_value: &NSString, mtm: MainThreadMarker) -> Retained<Self>;

        /// Creates a wrapping, non-editable, selectable text field that displays text in the default system font.
        ///
        /// Parameter `stringValue`: The title text to display in the field.
        ///
        /// Returns: An initialized text field object.
        #[unsafe(method(wrappingLabelWithString:))]
        #[unsafe(method_family = none)]
        pub fn wrappingLabelWithString(
            string_value: &NSString,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        /// Creates a non-editable, non-selectable text field that displays attributed text.
        /// The line break mode of this field is determined by the attributed string's NSParagraphStyle attribute.
        ///
        /// Parameter `attributedStringValue`: The attributed string to display in the field.
        ///
        /// Returns: An initialized text field object.
        #[unsafe(method(labelWithAttributedString:))]
        #[unsafe(method_family = none)]
        pub fn labelWithAttributedString(
            attributed_string_value: &NSAttributedString,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        /// Creates a non-wrapping editable text field.
        ///
        /// Parameter `stringValue`: The initial contents of the text field, or empty string for an initially empty text field.
        ///
        /// Returns: An initialized text field object.
        #[unsafe(method(textFieldWithString:))]
        #[unsafe(method_family = none)]
        pub fn textFieldWithString(
            string_value: &NSString,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;
    );
}

/// NSTextFieldAttributedStringMethods.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSTextField {
    extern_methods!(
        #[unsafe(method(allowsEditingTextAttributes))]
        #[unsafe(method_family = none)]
        pub fn allowsEditingTextAttributes(&self) -> bool;

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

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

        /// Setter for [`importsGraphics`][Self::importsGraphics].
        #[unsafe(method(setImportsGraphics:))]
        #[unsafe(method_family = none)]
        pub fn setImportsGraphics(&self, imports_graphics: bool);
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextfielddelegate?language=objc)
    #[cfg(feature = "NSControl")]
    pub unsafe trait NSTextFieldDelegate:
        NSControlTextEditingDelegate + MainThreadOnly
    {
        #[cfg(all(
            feature = "NSResponder",
            feature = "NSText",
            feature = "NSTextView",
            feature = "NSView"
        ))]
        /// Provides a customized list of candidates to the text view’s `candidateListTouchBarItem`. Invoked from `-updateCandidates`. `NSTextView` uses the candidates returned from this method and suppress its built-in candidate generation. Returning `nil` from this delegate method allows `NSTextView` to query candidates from `NSSpellChecker`.
        /// - Returns: An array of objects that represent the elements of a selection.
        #[optional]
        #[unsafe(method(textField:textView:candidatesForSelectedRange:))]
        #[unsafe(method_family = none)]
        fn textField_textView_candidatesForSelectedRange(
            &self,
            text_field: &NSTextField,
            text_view: &NSTextView,
            selected_range: NSRange,
        ) -> Option<Retained<NSArray>>;

        #[cfg(all(
            feature = "NSResponder",
            feature = "NSText",
            feature = "NSTextView",
            feature = "NSView"
        ))]
        /// Allows customizing the candidate list queried from `NSSpellChecker`.
        /// - Returns: An array of text objects to include in a text selection.
        #[optional]
        #[unsafe(method(textField:textView:candidates:forSelectedRange:))]
        #[unsafe(method_family = none)]
        fn textField_textView_candidates_forSelectedRange(
            &self,
            text_field: &NSTextField,
            text_view: &NSTextView,
            candidates: &NSArray<NSTextCheckingResult>,
            selected_range: NSRange,
        ) -> Retained<NSArray<NSTextCheckingResult>>;

        #[cfg(all(
            feature = "NSResponder",
            feature = "NSText",
            feature = "NSTextView",
            feature = "NSView"
        ))]
        /// Notifies the delegate that the user selected the candidate at index in `-[NSCandidateListTouchBarItem candidates]` for the text view’s `candidateListTouchBarItem`. Returns a Boolean value that indicates whether to select the text object at the index.
        /// - Parameters:
        /// - textField: The text field that sent the message.
        /// - textView: The text view that sent the message.
        /// - index: The index that represents the start of the candidate text to evaluate, or `NSNotFound` if no candidate is to be selected.
        /// - Returns: `YES` if the framework selects the text. `YES` allows `textView` to insert the candidate into the text storage if it’s `NSString`, `NSAttributedString`, or `NSTextCheckingResult`.
        #[optional]
        #[unsafe(method(textField:textView:shouldSelectCandidateAtIndex:))]
        #[unsafe(method_family = none)]
        fn textField_textView_shouldSelectCandidateAtIndex(
            &self,
            text_field: &NSTextField,
            text_view: &NSTextView,
            index: NSUInteger,
        ) -> bool;
    }
);

/// NSDeprecated.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSTextField {
    extern_methods!(
        /// # Safety
        ///
        /// `string_with_ampersand` might not allow `None`.
        #[deprecated = "Use `-setTitle:` instead"]
        #[unsafe(method(setTitleWithMnemonic:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTitleWithMnemonic(&self, string_with_ampersand: Option<&NSString>);
    );
}
