objc2-app-kit 0.3.2

Bindings to the AppKit framework
Documentation
//! 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-graphics")]
#[cfg(target_vendor = "apple")]
use objc2_core_graphics::*;
#[cfg(feature = "objc2-core-image")]
#[cfg(target_vendor = "apple")]
use objc2_core_image::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgraphicscontextattributekey?language=objc)
// NS_TYPED_ENUM
pub type NSGraphicsContextAttributeKey = NSString;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgraphicscontextdestinationattributename?language=objc)
    pub static NSGraphicsContextDestinationAttributeName: &'static NSGraphicsContextAttributeKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgraphicscontextrepresentationformatattributename?language=objc)
    pub static NSGraphicsContextRepresentationFormatAttributeName:
        &'static NSGraphicsContextAttributeKey;
}

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgraphicscontextrepresentationformatname?language=objc)
// NS_TYPED_ENUM
pub type NSGraphicsContextRepresentationFormatName = NSString;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgraphicscontextpsformat?language=objc)
    pub static NSGraphicsContextPSFormat: &'static NSGraphicsContextRepresentationFormatName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgraphicscontextpdfformat?language=objc)
    pub static NSGraphicsContextPDFFormat: &'static NSGraphicsContextRepresentationFormatName;
}

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsimageinterpolation?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSImageInterpolation(pub NSUInteger);
impl NSImageInterpolation {
    #[doc(alias = "NSImageInterpolationDefault")]
    pub const Default: Self = Self(0);
    #[doc(alias = "NSImageInterpolationNone")]
    pub const None: Self = Self(1);
    #[doc(alias = "NSImageInterpolationLow")]
    pub const Low: Self = Self(2);
    #[doc(alias = "NSImageInterpolationMedium")]
    pub const Medium: Self = Self(4);
    #[doc(alias = "NSImageInterpolationHigh")]
    pub const High: Self = Self(3);
}

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

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

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

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

impl NSGraphicsContext {
    extern_methods!(
        /// # Safety
        ///
        /// `attributes` generic should be of the correct type.
        #[unsafe(method(graphicsContextWithAttributes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn graphicsContextWithAttributes(
            attributes: &NSDictionary<NSGraphicsContextAttributeKey, AnyObject>,
        ) -> Option<Retained<NSGraphicsContext>>;

        #[cfg(all(feature = "NSBitmapImageRep", feature = "NSImageRep"))]
        #[unsafe(method(graphicsContextWithBitmapImageRep:))]
        #[unsafe(method_family = none)]
        pub fn graphicsContextWithBitmapImageRep(
            bitmap_rep: &NSBitmapImageRep,
        ) -> Option<Retained<NSGraphicsContext>>;

        #[cfg(feature = "objc2-core-graphics")]
        #[cfg(target_vendor = "apple")]
        #[unsafe(method(graphicsContextWithCGContext:flipped:))]
        #[unsafe(method_family = none)]
        pub fn graphicsContextWithCGContext_flipped(
            graphics_port: &CGContext,
            initial_flipped_state: bool,
        ) -> Retained<NSGraphicsContext>;

        #[unsafe(method(currentContext))]
        #[unsafe(method_family = none)]
        pub fn currentContext() -> Option<Retained<NSGraphicsContext>>;

        /// Setter for [`currentContext`][Self::currentContext].
        #[unsafe(method(setCurrentContext:))]
        #[unsafe(method_family = none)]
        pub fn setCurrentContext(current_context: Option<&NSGraphicsContext>);

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

        #[unsafe(method(saveGraphicsState))]
        #[unsafe(method_family = none)]
        pub fn saveGraphicsState_class();

        #[unsafe(method(restoreGraphicsState))]
        #[unsafe(method_family = none)]
        pub fn restoreGraphicsState_class();

        #[unsafe(method(attributes))]
        #[unsafe(method_family = none)]
        pub fn attributes(
            &self,
        ) -> Option<Retained<NSDictionary<NSGraphicsContextAttributeKey, AnyObject>>>;

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

        #[unsafe(method(saveGraphicsState))]
        #[unsafe(method_family = none)]
        pub fn saveGraphicsState(&self);

        #[unsafe(method(restoreGraphicsState))]
        #[unsafe(method_family = none)]
        pub fn restoreGraphicsState(&self);

        #[unsafe(method(flushGraphics))]
        #[unsafe(method_family = none)]
        pub fn flushGraphics(&self);

        #[cfg(feature = "objc2-core-graphics")]
        #[cfg(target_vendor = "apple")]
        #[unsafe(method(CGContext))]
        #[unsafe(method_family = none)]
        pub fn CGContext(&self) -> Retained<CGContext>;

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

/// Methods declared on superclass `NSObject`.
impl NSGraphicsContext {
    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 NSGraphicsContext {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

/// NSGraphicsContext_RenderingOptions.
impl NSGraphicsContext {
    extern_methods!(
        #[unsafe(method(shouldAntialias))]
        #[unsafe(method_family = none)]
        pub fn shouldAntialias(&self) -> bool;

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

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

        /// Setter for [`imageInterpolation`][Self::imageInterpolation].
        #[unsafe(method(setImageInterpolation:))]
        #[unsafe(method_family = none)]
        pub fn setImageInterpolation(&self, image_interpolation: NSImageInterpolation);

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

        /// Setter for [`patternPhase`][Self::patternPhase].
        #[unsafe(method(setPatternPhase:))]
        #[unsafe(method_family = none)]
        pub fn setPatternPhase(&self, pattern_phase: NSPoint);

        #[cfg(feature = "NSGraphics")]
        #[unsafe(method(compositingOperation))]
        #[unsafe(method_family = none)]
        pub fn compositingOperation(&self) -> NSCompositingOperation;

        #[cfg(feature = "NSGraphics")]
        /// Setter for [`compositingOperation`][Self::compositingOperation].
        #[unsafe(method(setCompositingOperation:))]
        #[unsafe(method_family = none)]
        pub fn setCompositingOperation(&self, compositing_operation: NSCompositingOperation);

        #[cfg(feature = "NSGraphics")]
        #[unsafe(method(colorRenderingIntent))]
        #[unsafe(method_family = none)]
        pub fn colorRenderingIntent(&self) -> NSColorRenderingIntent;

        #[cfg(feature = "NSGraphics")]
        /// Setter for [`colorRenderingIntent`][Self::colorRenderingIntent].
        #[unsafe(method(setColorRenderingIntent:))]
        #[unsafe(method_family = none)]
        pub fn setColorRenderingIntent(&self, color_rendering_intent: NSColorRenderingIntent);
    );
}

/// NSQuartzCoreAdditions.
impl NSGraphicsContext {
    extern_methods!(
        #[cfg(feature = "objc2-core-image")]
        #[cfg(target_vendor = "apple")]
        #[unsafe(method(CIContext))]
        #[unsafe(method_family = none)]
        pub fn CIContext(&self) -> Option<Retained<CIContext>>;
    );
}

/// NSGraphicsContextDeprecated.
impl NSGraphicsContext {
    extern_methods!(
        #[deprecated = "This method has no effect"]
        #[unsafe(method(setGraphicsState:))]
        #[unsafe(method_family = none)]
        pub fn setGraphicsState(g_state: NSInteger);

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

        /// # Safety
        ///
        /// - `stack` should be of the correct type.
        /// - `stack` might not allow `None`.
        #[deprecated]
        #[unsafe(method(setFocusStack:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFocusStack(&self, stack: Option<&AnyObject>);

        /// # Safety
        ///
        /// `graphics_port` must be a valid pointer.
        #[deprecated]
        #[unsafe(method(graphicsContextWithGraphicsPort:flipped:))]
        #[unsafe(method_family = none)]
        pub unsafe fn graphicsContextWithGraphicsPort_flipped(
            graphics_port: NonNull<c_void>,
            initial_flipped_state: bool,
        ) -> Retained<NSGraphicsContext>;

        #[deprecated]
        #[unsafe(method(graphicsPort))]
        #[unsafe(method_family = none)]
        pub fn graphicsPort(&self) -> NonNull<c_void>;

        #[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
        #[deprecated = "Add instances of NSView to display content in a window"]
        #[unsafe(method(graphicsContextWithWindow:))]
        #[unsafe(method_family = none)]
        pub fn graphicsContextWithWindow(window: &NSWindow) -> Retained<NSGraphicsContext>;
    );
}