use crate::common::*;
use crate::AppKit::*;
use crate::CoreData::*;
use crate::Foundation::*;
typed_enum!(
pub type NSGraphicsContextAttributeKey = NSString;
);
extern_static!(NSGraphicsContextDestinationAttributeName: &'static NSGraphicsContextAttributeKey);
extern_static!(NSGraphicsContextRepresentationFormatAttributeName: &'static NSGraphicsContextAttributeKey);
typed_enum!(
pub type NSGraphicsContextRepresentationFormatName = NSString;
);
extern_static!(NSGraphicsContextPSFormat: &'static NSGraphicsContextRepresentationFormatName);
extern_static!(NSGraphicsContextPDFFormat: &'static NSGraphicsContextRepresentationFormatName);
ns_enum!(
#[underlying(NSUInteger)]
pub enum NSImageInterpolation {
NSImageInterpolationDefault = 0,
NSImageInterpolationNone = 1,
NSImageInterpolationLow = 2,
NSImageInterpolationMedium = 4,
NSImageInterpolationHigh = 3,
}
);
extern_class!(
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "AppKit_NSGraphicsContext")]
pub struct NSGraphicsContext;
#[cfg(feature = "AppKit_NSGraphicsContext")]
unsafe impl ClassType for NSGraphicsContext {
type Super = NSObject;
type Mutability = InteriorMutable;
}
);
#[cfg(feature = "AppKit_NSGraphicsContext")]
unsafe impl NSObjectProtocol for NSGraphicsContext {}
extern_methods!(
#[cfg(feature = "AppKit_NSGraphicsContext")]
unsafe impl NSGraphicsContext {
#[cfg(feature = "Foundation_NSDictionary")]
#[method_id(@__retain_semantics Other graphicsContextWithAttributes:)]
pub unsafe fn graphicsContextWithAttributes(
attributes: &NSDictionary<NSGraphicsContextAttributeKey, AnyObject>,
) -> Option<Id<NSGraphicsContext>>;
#[cfg(feature = "AppKit_NSWindow")]
#[method_id(@__retain_semantics Other graphicsContextWithWindow:)]
pub unsafe fn graphicsContextWithWindow(window: &NSWindow) -> Id<NSGraphicsContext>;
#[cfg(feature = "AppKit_NSBitmapImageRep")]
#[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();
#[cfg(feature = "Foundation_NSDictionary")]
#[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!(
#[cfg(feature = "AppKit_NSGraphicsContext")]
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!(
#[cfg(feature = "AppKit_NSGraphicsContext")]
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);
#[method(compositingOperation)]
pub unsafe fn compositingOperation(&self) -> NSCompositingOperation;
#[method(setCompositingOperation:)]
pub unsafe fn setCompositingOperation(&self, compositing_operation: NSCompositingOperation);
#[method(colorRenderingIntent)]
pub unsafe fn colorRenderingIntent(&self) -> NSColorRenderingIntent;
#[method(setColorRenderingIntent:)]
pub unsafe fn setColorRenderingIntent(
&self,
color_rendering_intent: NSColorRenderingIntent,
);
}
);
extern_methods!(
#[cfg(feature = "AppKit_NSGraphicsContext")]
unsafe impl NSGraphicsContext {}
);
extern_methods!(
#[cfg(feature = "AppKit_NSGraphicsContext")]
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>;
}
);