//! 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/uikit/uigraphicsimagedrawingactions?language=objc)
#[cfg(all(feature = "UIGraphicsRenderer", feature = "block2"))]
pub type UIGraphicsImageDrawingActions =
    *mut block2::DynBlock<dyn Fn(NonNull<UIGraphicsImageRendererContext>)>;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigraphicsimagerendererformatrange?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIGraphicsImageRendererFormatRange(pub NSInteger);
impl UIGraphicsImageRendererFormatRange {
    #[doc(alias = "UIGraphicsImageRendererFormatRangeUnspecified")]
    pub const Unspecified: Self = Self(-1);
    #[doc(alias = "UIGraphicsImageRendererFormatRangeAutomatic")]
    pub const Automatic: Self = Self(0);
    #[doc(alias = "UIGraphicsImageRendererFormatRangeExtended")]
    pub const Extended: Self = Self(1);
    #[doc(alias = "UIGraphicsImageRendererFormatRangeStandard")]
    pub const Standard: Self = Self(2);
}

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

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigraphicsimagerendererformat?language=objc)
    #[unsafe(super(UIGraphicsRendererFormat, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "UIGraphicsRenderer")]
    pub struct UIGraphicsImageRendererFormat;
);

#[cfg(feature = "UIGraphicsRenderer")]
extern_conformance!(
    unsafe impl NSCopying for UIGraphicsImageRendererFormat {}
);

#[cfg(feature = "UIGraphicsRenderer")]
unsafe impl CopyingHelper for UIGraphicsImageRendererFormat {
    type Result = Self;
}

#[cfg(feature = "UIGraphicsRenderer")]
extern_conformance!(
    unsafe impl NSObjectProtocol for UIGraphicsImageRendererFormat {}
);

#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsImageRendererFormat {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(scale))]
        #[unsafe(method_family = none)]
        pub fn scale(&self) -> CGFloat;

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

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

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

        #[deprecated = "Use the preferredRange property instead"]
        #[unsafe(method(prefersExtendedRange))]
        #[unsafe(method_family = none)]
        pub fn prefersExtendedRange(&self) -> bool;

        /// Setter for [`prefersExtendedRange`][Self::prefersExtendedRange].
        #[deprecated = "Use the preferredRange property instead"]
        #[unsafe(method(setPrefersExtendedRange:))]
        #[unsafe(method_family = none)]
        pub fn setPrefersExtendedRange(&self, prefers_extended_range: bool);

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

        /// indicates if the format supports high dynamic range rendering.
        #[unsafe(method(preferredRange))]
        #[unsafe(method_family = none)]
        pub fn preferredRange(&self) -> UIGraphicsImageRendererFormatRange;

        /// Setter for [`preferredRange`][Self::preferredRange].
        #[unsafe(method(setPreferredRange:))]
        #[unsafe(method_family = none)]
        pub fn setPreferredRange(&self, preferred_range: UIGraphicsImageRendererFormatRange);

        #[cfg(feature = "UITraitCollection")]
        #[unsafe(method(formatForTraitCollection:))]
        #[unsafe(method_family = none)]
        pub fn formatForTraitCollection(trait_collection: &UITraitCollection) -> Retained<Self>;
    );
}

/// Methods declared on superclass `UIGraphicsRendererFormat`.
#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsImageRendererFormat {
    extern_methods!(
        #[deprecated]
        #[unsafe(method(defaultFormat))]
        #[unsafe(method_family = none)]
        pub fn defaultFormat() -> Retained<Self>;

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

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsImageRendererFormat {
    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>;
    );
}

#[cfg(feature = "UIGraphicsRenderer")]
impl DefaultRetained for UIGraphicsImageRendererFormat {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigraphicsimagerenderercontext?language=objc)
    #[unsafe(super(UIGraphicsRendererContext, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "UIGraphicsRenderer")]
    pub struct UIGraphicsImageRendererContext;
);

#[cfg(feature = "UIGraphicsRenderer")]
extern_conformance!(
    unsafe impl NSObjectProtocol for UIGraphicsImageRendererContext {}
);

#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsImageRendererContext {
    extern_methods!(
        #[cfg(feature = "UIImage")]
        #[unsafe(method(currentImage))]
        #[unsafe(method_family = none)]
        pub fn currentImage(&self) -> Retained<UIImage>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsImageRendererContext {
    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>;
    );
}

#[cfg(feature = "UIGraphicsRenderer")]
impl DefaultRetained for UIGraphicsImageRendererContext {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigraphicsimagerenderer?language=objc)
    #[unsafe(super(UIGraphicsRenderer, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "UIGraphicsRenderer")]
    pub struct UIGraphicsImageRenderer;
);

#[cfg(feature = "UIGraphicsRenderer")]
extern_conformance!(
    unsafe impl NSObjectProtocol for UIGraphicsImageRenderer {}
);

#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsImageRenderer {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(initWithSize:))]
        #[unsafe(method_family = init)]
        pub fn initWithSize(this: Allocated<Self>, size: CGSize) -> Retained<Self>;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(initWithSize:format:))]
        #[unsafe(method_family = init)]
        pub fn initWithSize_format(
            this: Allocated<Self>,
            size: CGSize,
            format: &UIGraphicsImageRendererFormat,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(initWithBounds:format:))]
        #[unsafe(method_family = init)]
        pub fn initWithBounds_format(
            this: Allocated<Self>,
            bounds: CGRect,
            format: &UIGraphicsImageRendererFormat,
        ) -> Retained<Self>;

        #[cfg(all(feature = "UIImage", feature = "block2"))]
        /// # Safety
        ///
        /// `actions` must be a valid pointer.
        #[unsafe(method(imageWithActions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn imageWithActions(
            &self,
            actions: UIGraphicsImageDrawingActions,
        ) -> Retained<UIImage>;

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// `actions` must be a valid pointer.
        #[unsafe(method(PNGDataWithActions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn PNGDataWithActions(
            &self,
            actions: UIGraphicsImageDrawingActions,
        ) -> Retained<NSData>;

        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
        /// # Safety
        ///
        /// `actions` must be a valid pointer.
        #[unsafe(method(JPEGDataWithCompressionQuality:actions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn JPEGDataWithCompressionQuality_actions(
            &self,
            compression_quality: CGFloat,
            actions: UIGraphicsImageDrawingActions,
        ) -> Retained<NSData>;
    );
}

/// Methods declared on superclass `UIGraphicsRenderer`.
#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsImageRenderer {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(initWithBounds:))]
        #[unsafe(method_family = init)]
        pub fn initWithBounds(this: Allocated<Self>, bounds: CGRect) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsImageRenderer {
    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>;
    );
}

#[cfg(feature = "UIGraphicsRenderer")]
impl DefaultRetained for UIGraphicsImageRenderer {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}
