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

use crate::*;

#[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
#[inline]
pub extern "C-unwind" fn UIGraphicsGetCurrentContext() -> Option<CFRetained<CGContext>> {
    extern "C-unwind" {
        fn UIGraphicsGetCurrentContext() -> Option<NonNull<CGContext>>;
    }
    let ret = unsafe { UIGraphicsGetCurrentContext() };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

extern "C-unwind" {
    #[cfg(feature = "objc2-core-graphics")]
    pub fn UIGraphicsPushContext(context: &CGContext);
}

extern "C-unwind" {
    pub fn UIGraphicsPopContext();
}

#[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
#[inline]
pub extern "C-unwind" fn UIRectFillUsingBlendMode(rect: CGRect, blend_mode: CGBlendMode) {
    extern "C-unwind" {
        fn UIRectFillUsingBlendMode(rect: CGRect, blend_mode: CGBlendMode);
    }
    unsafe { UIRectFillUsingBlendMode(rect, blend_mode) }
}

#[cfg(feature = "objc2-core-foundation")]
#[inline]
pub extern "C-unwind" fn UIRectFill(rect: CGRect) {
    extern "C-unwind" {
        fn UIRectFill(rect: CGRect);
    }
    unsafe { UIRectFill(rect) }
}

#[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
#[inline]
pub extern "C-unwind" fn UIRectFrameUsingBlendMode(rect: CGRect, blend_mode: CGBlendMode) {
    extern "C-unwind" {
        fn UIRectFrameUsingBlendMode(rect: CGRect, blend_mode: CGBlendMode);
    }
    unsafe { UIRectFrameUsingBlendMode(rect, blend_mode) }
}

#[cfg(feature = "objc2-core-foundation")]
#[inline]
pub extern "C-unwind" fn UIRectFrame(rect: CGRect) {
    extern "C-unwind" {
        fn UIRectFrame(rect: CGRect);
    }
    unsafe { UIRectFrame(rect) }
}

#[cfg(feature = "objc2-core-foundation")]
#[inline]
pub extern "C-unwind" fn UIRectClip(rect: CGRect) {
    extern "C-unwind" {
        fn UIRectClip(rect: CGRect);
    }
    unsafe { UIRectClip(rect) }
}

#[cfg(feature = "objc2-core-foundation")]
#[deprecated = "Replace usage of UIGraphicsBeginImageContext with UIGraphicsImageRenderer."]
#[inline]
pub extern "C-unwind" fn UIGraphicsBeginImageContext(size: CGSize) {
    extern "C-unwind" {
        fn UIGraphicsBeginImageContext(size: CGSize);
    }
    unsafe { UIGraphicsBeginImageContext(size) }
}

#[cfg(feature = "objc2-core-foundation")]
#[deprecated = "Replace usage of UIGraphicsBeginImageContextWithOptions with UIGraphicsImageRenderer."]
#[inline]
pub extern "C-unwind" fn UIGraphicsBeginImageContextWithOptions(
    size: CGSize,
    opaque: bool,
    scale: CGFloat,
) {
    extern "C-unwind" {
        fn UIGraphicsBeginImageContextWithOptions(size: CGSize, opaque: Bool, scale: CGFloat);
    }
    unsafe { UIGraphicsBeginImageContextWithOptions(size, Bool::new(opaque), scale) }
}

#[cfg(feature = "UIImage")]
#[deprecated = "Replace usage of UIGraphicsGetImageFromCurrentImageContext with UIGraphicsImageRendererContext.currentImage."]
#[inline]
pub extern "C-unwind" fn UIGraphicsGetImageFromCurrentImageContext() -> Option<Retained<UIImage>> {
    extern "C-unwind" {
        fn UIGraphicsGetImageFromCurrentImageContext() -> *mut UIImage;
    }
    let ret = unsafe { UIGraphicsGetImageFromCurrentImageContext() };
    unsafe { Retained::retain_autoreleased(ret) }
}

#[deprecated = "UIGraphicsEndImageContext should only be used alongside UIGraphicsBeginImageContext[WithOptions]."]
#[inline]
pub extern "C-unwind" fn UIGraphicsEndImageContext() {
    extern "C-unwind" {
        fn UIGraphicsEndImageContext();
    }
    unsafe { UIGraphicsEndImageContext() }
}

/// # Safety
///
/// `document_info` generic should be of the correct type.
#[cfg(feature = "objc2-core-foundation")]
#[inline]
pub unsafe extern "C-unwind" fn UIGraphicsBeginPDFContextToFile(
    path: &NSString,
    bounds: CGRect,
    document_info: Option<&NSDictionary>,
) -> bool {
    extern "C-unwind" {
        fn UIGraphicsBeginPDFContextToFile(
            path: &NSString,
            bounds: CGRect,
            document_info: Option<&NSDictionary>,
        ) -> Bool;
    }
    unsafe { UIGraphicsBeginPDFContextToFile(path, bounds, document_info) }.as_bool()
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `document_info` generic should be of the correct type.
    #[cfg(feature = "objc2-core-foundation")]
    pub fn UIGraphicsBeginPDFContextToData(
        data: &NSMutableData,
        bounds: CGRect,
        document_info: Option<&NSDictionary>,
    );
}

#[inline]
pub extern "C-unwind" fn UIGraphicsEndPDFContext() {
    extern "C-unwind" {
        fn UIGraphicsEndPDFContext();
    }
    unsafe { UIGraphicsEndPDFContext() }
}

#[inline]
pub extern "C-unwind" fn UIGraphicsBeginPDFPage() {
    extern "C-unwind" {
        fn UIGraphicsBeginPDFPage();
    }
    unsafe { UIGraphicsBeginPDFPage() }
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `page_info` generic should be of the correct type.
    #[cfg(feature = "objc2-core-foundation")]
    pub fn UIGraphicsBeginPDFPageWithInfo(bounds: CGRect, page_info: Option<&NSDictionary>);
}

#[cfg(feature = "objc2-core-foundation")]
#[inline]
pub extern "C-unwind" fn UIGraphicsGetPDFContextBounds() -> CGRect {
    extern "C-unwind" {
        fn UIGraphicsGetPDFContextBounds() -> CGRect;
    }
    unsafe { UIGraphicsGetPDFContextBounds() }
}

#[cfg(feature = "objc2-core-foundation")]
#[inline]
pub extern "C-unwind" fn UIGraphicsSetPDFContextURLForRect(url: &NSURL, rect: CGRect) {
    extern "C-unwind" {
        fn UIGraphicsSetPDFContextURLForRect(url: &NSURL, rect: CGRect);
    }
    unsafe { UIGraphicsSetPDFContextURLForRect(url, rect) }
}

#[cfg(feature = "objc2-core-foundation")]
#[inline]
pub extern "C-unwind" fn UIGraphicsAddPDFContextDestinationAtPoint(
    name: &NSString,
    point: CGPoint,
) {
    extern "C-unwind" {
        fn UIGraphicsAddPDFContextDestinationAtPoint(name: &NSString, point: CGPoint);
    }
    unsafe { UIGraphicsAddPDFContextDestinationAtPoint(name, point) }
}

#[cfg(feature = "objc2-core-foundation")]
#[inline]
pub extern "C-unwind" fn UIGraphicsSetPDFContextDestinationForRect(name: &NSString, rect: CGRect) {
    extern "C-unwind" {
        fn UIGraphicsSetPDFContextDestinationForRect(name: &NSString, rect: CGRect);
    }
    unsafe { UIGraphicsSetPDFContextDestinationForRect(name, rect) }
}
