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

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgradientdrawingoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSGradientDrawingOptions(pub NSUInteger);
bitflags::bitflags! {
    impl NSGradientDrawingOptions: NSUInteger {
        #[doc(alias = "NSGradientDrawsBeforeStartingLocation")]
        const DrawsBeforeStartingLocation = 1<<0;
        #[doc(alias = "NSGradientDrawsAfterEndingLocation")]
        const DrawsAfterEndingLocation = 1<<1;
    }
}

unsafe impl Encode for NSGradientDrawingOptions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgradient?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSGradient;
);

unsafe impl Send for NSGradient {}

unsafe impl Sync for NSGradient {}

extern_conformance!(
    unsafe impl NSCoding for NSGradient {}
);

extern_conformance!(
    unsafe impl NSCopying for NSGradient {}
);

unsafe impl CopyingHelper for NSGradient {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for NSGradient {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for NSGradient {}
);

impl NSGradient {
    extern_methods!(
        #[cfg(feature = "NSColor")]
        #[unsafe(method(initWithStartingColor:endingColor:))]
        #[unsafe(method_family = init)]
        pub fn initWithStartingColor_endingColor(
            this: Allocated<Self>,
            starting_color: &NSColor,
            ending_color: &NSColor,
        ) -> Option<Retained<Self>>;

        #[cfg(feature = "NSColor")]
        #[unsafe(method(initWithColors:))]
        #[unsafe(method_family = init)]
        pub fn initWithColors(
            this: Allocated<Self>,
            color_array: &NSArray<NSColor>,
        ) -> Option<Retained<Self>>;

        #[cfg(all(
            feature = "NSColor",
            feature = "NSColorSpace",
            feature = "objc2-core-foundation"
        ))]
        /// # Safety
        ///
        /// `locations` must be a valid pointer or null.
        #[unsafe(method(initWithColors:atLocations:colorSpace:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithColors_atLocations_colorSpace(
            this: Allocated<Self>,
            color_array: &NSArray<NSColor>,
            locations: *const CGFloat,
            color_space: &NSColorSpace,
        ) -> Option<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>>;

        #[unsafe(method(drawFromPoint:toPoint:options:))]
        #[unsafe(method_family = none)]
        pub fn drawFromPoint_toPoint_options(
            &self,
            starting_point: NSPoint,
            ending_point: NSPoint,
            options: NSGradientDrawingOptions,
        );

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(drawInRect:angle:))]
        #[unsafe(method_family = none)]
        pub fn drawInRect_angle(&self, rect: NSRect, angle: CGFloat);

        #[cfg(all(feature = "NSBezierPath", feature = "objc2-core-foundation"))]
        #[unsafe(method(drawInBezierPath:angle:))]
        #[unsafe(method_family = none)]
        pub fn drawInBezierPath_angle(&self, path: &NSBezierPath, angle: CGFloat);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(drawFromCenter:radius:toCenter:radius:options:))]
        #[unsafe(method_family = none)]
        pub fn drawFromCenter_radius_toCenter_radius_options(
            &self,
            start_center: NSPoint,
            start_radius: CGFloat,
            end_center: NSPoint,
            end_radius: CGFloat,
            options: NSGradientDrawingOptions,
        );

        #[unsafe(method(drawInRect:relativeCenterPosition:))]
        #[unsafe(method_family = none)]
        pub fn drawInRect_relativeCenterPosition(
            &self,
            rect: NSRect,
            relative_center_position: NSPoint,
        );

        #[cfg(feature = "NSBezierPath")]
        #[unsafe(method(drawInBezierPath:relativeCenterPosition:))]
        #[unsafe(method_family = none)]
        pub fn drawInBezierPath_relativeCenterPosition(
            &self,
            path: &NSBezierPath,
            relative_center_position: NSPoint,
        );

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

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

        #[cfg(all(feature = "NSColor", feature = "objc2-core-foundation"))]
        /// # Safety
        ///
        /// `location` must be a valid pointer or null.
        #[unsafe(method(getColor:location:atIndex:))]
        #[unsafe(method_family = none)]
        pub unsafe fn getColor_location_atIndex(
            &self,
            color: Option<&mut Retained<NSColor>>,
            location: *mut CGFloat,
            index: NSInteger,
        );

        #[cfg(all(feature = "NSColor", feature = "objc2-core-foundation"))]
        #[unsafe(method(interpolatedColorAtLocation:))]
        #[unsafe(method_family = none)]
        pub fn interpolatedColorAtLocation(&self, location: CGFloat) -> Retained<NSColor>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NSGradient {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl DefaultRetained for NSGradient {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}
