use objc2::__framework_prelude::*;
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!(
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSGraphicsContext;
unsafe impl ClassType for NSGraphicsContext {
type Super = NSObject;
type Mutability = InteriorMutable;
}
);
unsafe impl NSObjectProtocol for NSGraphicsContext {}
extern_methods!(
unsafe impl NSGraphicsContext {
#[method_id(@__retain_semantics Other graphicsContextWithAttributes:)]
pub unsafe fn graphicsContextWithAttributes(
attributes: &NSDictionary<NSGraphicsContextAttributeKey, AnyObject>,
) -> Option<Id<NSGraphicsContext>>;
#[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
#[method_id(@__retain_semantics Other graphicsContextWithWindow:)]
pub unsafe fn graphicsContextWithWindow(window: &NSWindow) -> Id<NSGraphicsContext>;
#[cfg(all(feature = "NSBitmapImageRep", feature = "NSImageRep"))]
#[method_id(@__retain_semantics Other graphicsContextWithBitmapImageRep:)]
pub unsafe fn graphicsContextWithBitmapImageRep(
bitmap_rep: &NSBitmapImageRep,
) -> Option<Id<NSGraphicsContext>>;
#[method_id(@__retain_semantics Other currentContext)]
pub unsafe fn currentContext() -> Option<Id<NSGraphicsContext>>;
#[method(setCurrentContext:)]
pub unsafe fn setCurrentContext(current_context: Option<&NSGraphicsContext>);
#[method(currentContextDrawingToScreen)]
pub unsafe fn currentContextDrawingToScreen() -> bool;
#[method(saveGraphicsState)]
pub unsafe fn saveGraphicsState_class();
#[method(restoreGraphicsState)]
pub unsafe fn restoreGraphicsState_class();
#[method_id(@__retain_semantics Other attributes)]
pub unsafe fn attributes(
&self,
) -> Option<Id<NSDictionary<NSGraphicsContextAttributeKey, AnyObject>>>;
#[method(isDrawingToScreen)]
pub unsafe fn isDrawingToScreen(&self) -> bool;
#[method(saveGraphicsState)]
pub unsafe fn saveGraphicsState(&self);
#[method(restoreGraphicsState)]
pub unsafe fn restoreGraphicsState(&self);
#[method(flushGraphics)]
pub unsafe fn flushGraphics(&self);
#[method(isFlipped)]
pub unsafe fn isFlipped(&self) -> bool;
}
);
extern_methods!(
unsafe impl NSGraphicsContext {
#[method_id(@__retain_semantics Init init)]
pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
#[method_id(@__retain_semantics New new)]
pub unsafe fn new() -> Id<Self>;
}
);
extern_methods!(
unsafe impl NSGraphicsContext {
#[method(shouldAntialias)]
pub unsafe fn shouldAntialias(&self) -> bool;
#[method(setShouldAntialias:)]
pub unsafe fn setShouldAntialias(&self, should_antialias: bool);
#[method(imageInterpolation)]
pub unsafe fn imageInterpolation(&self) -> NSImageInterpolation;
#[method(setImageInterpolation:)]
pub unsafe fn setImageInterpolation(&self, image_interpolation: NSImageInterpolation);
#[method(patternPhase)]
pub unsafe fn patternPhase(&self) -> NSPoint;
#[method(setPatternPhase:)]
pub unsafe fn setPatternPhase(&self, pattern_phase: NSPoint);
#[cfg(feature = "NSGraphics")]
#[method(compositingOperation)]
pub unsafe fn compositingOperation(&self) -> NSCompositingOperation;
#[cfg(feature = "NSGraphics")]
#[method(setCompositingOperation:)]
pub unsafe fn setCompositingOperation(&self, compositing_operation: NSCompositingOperation);
#[cfg(feature = "NSGraphics")]
#[method(colorRenderingIntent)]
pub unsafe fn colorRenderingIntent(&self) -> NSColorRenderingIntent;
#[cfg(feature = "NSGraphics")]
#[method(setColorRenderingIntent:)]
pub unsafe fn setColorRenderingIntent(
&self,
color_rendering_intent: NSColorRenderingIntent,
);
}
);
extern_methods!(
unsafe impl NSGraphicsContext {}
);
extern_methods!(
unsafe impl NSGraphicsContext {
#[deprecated = "This method has no effect"]
#[method(setGraphicsState:)]
pub unsafe fn setGraphicsState(g_state: NSInteger);
#[deprecated]
#[method_id(@__retain_semantics Other focusStack)]
pub unsafe fn focusStack(&self) -> Option<Id<AnyObject>>;
#[deprecated]
#[method(setFocusStack:)]
pub unsafe fn setFocusStack(&self, stack: Option<&AnyObject>);
#[deprecated]
#[method_id(@__retain_semantics Other graphicsContextWithGraphicsPort:flipped:)]
pub unsafe fn graphicsContextWithGraphicsPort_flipped(
graphics_port: NonNull<c_void>,
initial_flipped_state: bool,
) -> Id<NSGraphicsContext>;
#[deprecated]
#[method(graphicsPort)]
pub unsafe fn graphicsPort(&self) -> NonNull<c_void>;
}
);