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::*;
pub type NSGraphicsContextAttributeKey = NSString;
extern "C" {
pub static NSGraphicsContextDestinationAttributeName: &'static NSGraphicsContextAttributeKey;
}
extern "C" {
pub static NSGraphicsContextRepresentationFormatAttributeName:
&'static NSGraphicsContextAttributeKey;
}
pub type NSGraphicsContextRepresentationFormatName = NSString;
extern "C" {
pub static NSGraphicsContextPSFormat: &'static NSGraphicsContextRepresentationFormatName;
}
extern "C" {
pub static NSGraphicsContextPDFFormat: &'static NSGraphicsContextRepresentationFormatName;
}
#[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!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSGraphicsContext;
);
extern_conformance!(
unsafe impl NSObjectProtocol for NSGraphicsContext {}
);
impl NSGraphicsContext {
extern_methods!(
#[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>>;
#[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;
);
}
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()
}
}
impl NSGraphicsContext {
extern_methods!(
#[unsafe(method(shouldAntialias))]
#[unsafe(method_family = none)]
pub fn shouldAntialias(&self) -> bool;
#[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;
#[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;
#[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")]
#[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")]
#[unsafe(method(setColorRenderingIntent:))]
#[unsafe(method_family = none)]
pub fn setColorRenderingIntent(&self, color_rendering_intent: NSColorRenderingIntent);
);
}
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>>;
);
}
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>>;
#[deprecated]
#[unsafe(method(setFocusStack:))]
#[unsafe(method_family = none)]
pub unsafe fn setFocusStack(&self, stack: Option<&AnyObject>);
#[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>;
);
}