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::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-graphics")]
#[cfg(target_vendor = "apple")]
use objc2_core_graphics::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-quartz-core")]
#[cfg(target_vendor = "apple")]
use objc2_quartz_core::*;

use crate::*;

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

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

impl NSScreen {
    extern_methods!(
        #[unsafe(method(screens))]
        #[unsafe(method_family = none)]
        pub fn screens(mtm: MainThreadMarker) -> Retained<NSArray<NSScreen>>;

        #[unsafe(method(mainScreen))]
        #[unsafe(method_family = none)]
        pub fn mainScreen(mtm: MainThreadMarker) -> Option<Retained<NSScreen>>;

        #[unsafe(method(deepestScreen))]
        #[unsafe(method_family = none)]
        pub fn deepestScreen(mtm: MainThreadMarker) -> Option<Retained<NSScreen>>;

        #[unsafe(method(screensHaveSeparateSpaces))]
        #[unsafe(method_family = none)]
        pub fn screensHaveSeparateSpaces(mtm: MainThreadMarker) -> bool;

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

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

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

        #[cfg(feature = "NSGraphics")]
        #[unsafe(method(deviceDescription))]
        #[unsafe(method_family = none)]
        pub fn deviceDescription(
            &self,
        ) -> Retained<NSDictionary<NSDeviceDescriptionKey, AnyObject>>;

        #[cfg(feature = "NSColorSpace")]
        #[unsafe(method(colorSpace))]
        #[unsafe(method_family = none)]
        pub fn colorSpace(&self) -> Option<Retained<NSColorSpace>>;

        #[cfg(feature = "NSGraphics")]
        #[unsafe(method(supportedWindowDepths))]
        #[unsafe(method_family = none)]
        pub fn supportedWindowDepths(&self) -> NonNull<NSWindowDepth>;

        #[cfg(feature = "NSGraphics")]
        #[unsafe(method(canRepresentDisplayGamut:))]
        #[unsafe(method_family = none)]
        pub fn canRepresentDisplayGamut(&self, display_gamut: NSDisplayGamut) -> bool;

        #[unsafe(method(convertRectToBacking:))]
        #[unsafe(method_family = none)]
        pub fn convertRectToBacking(&self, rect: NSRect) -> NSRect;

        #[unsafe(method(convertRectFromBacking:))]
        #[unsafe(method_family = none)]
        pub fn convertRectFromBacking(&self, rect: NSRect) -> NSRect;

        #[unsafe(method(backingAlignedRect:options:))]
        #[unsafe(method_family = none)]
        pub fn backingAlignedRect_options(
            &self,
            rect: NSRect,
            options: NSAlignmentOptions,
        ) -> NSRect;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(backingScaleFactor))]
        #[unsafe(method_family = none)]
        pub fn backingScaleFactor(&self) -> CGFloat;

        #[unsafe(method(localizedName))]
        #[unsafe(method_family = none)]
        pub fn localizedName(&self) -> Retained<NSString>;

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

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

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

        #[cfg(feature = "objc2-core-graphics")]
        #[cfg(target_vendor = "apple")]
        /// The CGDirectDisplayID for this screen. This will return kCGNullDirectDisplay if there isn't one.
        #[unsafe(method(CGDirectDisplayID))]
        #[unsafe(method_family = none)]
        pub fn CGDirectDisplayID(&self) -> CGDirectDisplayID;
    );
}

/// Methods declared on superclass `NSObject`.
impl NSScreen {
    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(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

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

impl NSScreen {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(maximumExtendedDynamicRangeColorComponentValue))]
        #[unsafe(method_family = none)]
        pub fn maximumExtendedDynamicRangeColorComponentValue(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(maximumPotentialExtendedDynamicRangeColorComponentValue))]
        #[unsafe(method_family = none)]
        pub fn maximumPotentialExtendedDynamicRangeColorComponentValue(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(maximumReferenceExtendedDynamicRangeColorComponentValue))]
        #[unsafe(method_family = none)]
        pub fn maximumReferenceExtendedDynamicRangeColorComponentValue(&self) -> CGFloat;
    );
}

impl NSScreen {
    extern_methods!(
        /// The maximum frames per second this screen supports.
        #[unsafe(method(maximumFramesPerSecond))]
        #[unsafe(method_family = none)]
        pub fn maximumFramesPerSecond(&self) -> NSInteger;

        /// The minimum refresh interval this screen supports, in seconds.
        ///
        /// This is the shortest amount of time a frame will be present on screen.
        /// minimumRefreshInterval and maximumRefreshInterval will be the same for displays that do not support variable refresh rates.
        #[unsafe(method(minimumRefreshInterval))]
        #[unsafe(method_family = none)]
        pub fn minimumRefreshInterval(&self) -> NSTimeInterval;

        /// The maximum refresh interval this screen supports, in seconds.
        ///
        /// minimumRefreshInterval and maximumRefreshInterval will be the same for displays that do not support variable refresh rates.
        #[unsafe(method(maximumRefreshInterval))]
        #[unsafe(method_family = none)]
        pub fn maximumRefreshInterval(&self) -> NSTimeInterval;

        /// The update granularity of the screen's current mode, in seconds.
        ///
        /// The display will update at the next boundary defined by the granularity, after the minimum refresh interval has been reached. When 0, the display can update at any time between the minimum and maximum refresh rate intervals of the screen. Fixed refresh rate screen modes will return the refresh interval as the update granularity (e.g. 16.66ms for 60Hz refresh rates), meaning updates only occur at refresh rate boundaries.
        #[unsafe(method(displayUpdateGranularity))]
        #[unsafe(method_family = none)]
        pub fn displayUpdateGranularity(&self) -> NSTimeInterval;

        /// The time at which the last framebuffer update occurred on the display, in seconds since startup that the system has been awake.
        #[unsafe(method(lastDisplayUpdateTimestamp))]
        #[unsafe(method_family = none)]
        pub fn lastDisplayUpdateTimestamp(&self) -> NSTimeInterval;
    );
}

/// NSDisplayLink.
impl NSScreen {
    extern_methods!(
        #[cfg(feature = "objc2-quartz-core")]
        #[cfg(target_vendor = "apple")]
        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `selector` must be a valid selector.
        #[unsafe(method(displayLinkWithTarget:selector:))]
        #[unsafe(method_family = none)]
        pub unsafe fn displayLinkWithTarget_selector(
            &self,
            target: &AnyObject,
            selector: Sel,
        ) -> Retained<CADisplayLink>;
    );
}

/// NSDeprecated.
impl NSScreen {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        #[deprecated = "Use -convertRectToBacking: or -backingScaleFactor instead"]
        #[unsafe(method(userSpaceScaleFactor))]
        #[unsafe(method_family = none)]
        pub fn userSpaceScaleFactor(&self) -> CGFloat;
    );
}