//! 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/nstextinsertionindicatordisplaymode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTextInsertionIndicatorDisplayMode(pub NSInteger);
impl NSTextInsertionIndicatorDisplayMode {
    #[doc(alias = "NSTextInsertionIndicatorDisplayModeAutomatic")]
    pub const Automatic: Self = Self(0);
    #[doc(alias = "NSTextInsertionIndicatorDisplayModeHidden")]
    pub const Hidden: Self = Self(1);
    #[doc(alias = "NSTextInsertionIndicatorDisplayModeVisible")]
    pub const Visible: Self = Self(2);
}

unsafe impl Encode for NSTextInsertionIndicatorDisplayMode {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSTextInsertionIndicatorDisplayMode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextinsertionindicatorautomaticmodeoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTextInsertionIndicatorAutomaticModeOptions(pub NSInteger);
bitflags::bitflags! {
    impl NSTextInsertionIndicatorAutomaticModeOptions: NSInteger {
        #[doc(alias = "NSTextInsertionIndicatorAutomaticModeOptionsShowEffectsView")]
        const ShowEffectsView = 1<<0;
        #[doc(alias = "NSTextInsertionIndicatorAutomaticModeOptionsShowWhileTracking")]
        const ShowWhileTracking = 1<<1;
    }
}

unsafe impl Encode for NSTextInsertionIndicatorAutomaticModeOptions {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSTextInsertionIndicatorAutomaticModeOptions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

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

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

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

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

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

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

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

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

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

#[cfg(all(feature = "NSResponder", feature = "NSView"))]
impl NSTextInsertionIndicator {
    extern_methods!(
        /// Sets-returns the indicator's display mode.
        #[unsafe(method(displayMode))]
        #[unsafe(method_family = none)]
        pub fn displayMode(&self) -> NSTextInsertionIndicatorDisplayMode;

        /// Setter for [`displayMode`][Self::displayMode].
        #[unsafe(method(setDisplayMode:))]
        #[unsafe(method_family = none)]
        pub fn setDisplayMode(&self, display_mode: NSTextInsertionIndicatorDisplayMode);

        #[cfg(feature = "NSColor")]
        /// The color of the indicator.
        ///
        /// Defaults to NSColor.textInsertionPointColor.
        ///
        /// Note: If set to
        /// `nil,`uses NSColor.textInsertionPointColor.
        #[unsafe(method(color))]
        #[unsafe(method_family = none)]
        pub fn color(&self) -> Retained<NSColor>;

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

        /// Options for the NSTextInsertionIndicatorDisplayModeAutomatic display mode.
        /// Defaults to NSTextInsertionIndicatorAutomaticModeOptionsShowEffectsView.
        #[unsafe(method(automaticModeOptions))]
        #[unsafe(method_family = none)]
        pub fn automaticModeOptions(&self) -> NSTextInsertionIndicatorAutomaticModeOptions;

        /// Setter for [`automaticModeOptions`][Self::automaticModeOptions].
        #[unsafe(method(setAutomaticModeOptions:))]
        #[unsafe(method_family = none)]
        pub fn setAutomaticModeOptions(
            &self,
            automatic_mode_options: NSTextInsertionIndicatorAutomaticModeOptions,
        );

        #[cfg(feature = "block2")]
        /// Sets-returns a block that inserts a view into the view hierarchy.
        ///
        /// During dictation the NSTextInsertionIndicator displays a glow effect by inserting a view below the text view. If an application needs to insert the view in a different way, the application can specify a block of code that will be called when the glow effect needs to be displayed.
        ///
        /// # Safety
        ///
        /// The returned block's argument must be a valid pointer.
        #[unsafe(method(effectsViewInserter))]
        #[unsafe(method_family = none)]
        pub unsafe fn effectsViewInserter(&self) -> *mut block2::DynBlock<dyn Fn(NonNull<NSView>)>;

        #[cfg(feature = "block2")]
        /// Setter for [`effectsViewInserter`][Self::effectsViewInserter].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setEffectsViewInserter:))]
        #[unsafe(method_family = none)]
        pub fn setEffectsViewInserter(
            &self,
            effects_view_inserter: Option<&block2::DynBlock<dyn Fn(NonNull<NSView>)>>,
        );
    );
}

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