objc2_app_kit/generated/
NSScreen.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5#[cfg(feature = "objc2-core-foundation")]
6use objc2_core_foundation::*;
7use objc2_foundation::*;
8#[cfg(feature = "objc2-quartz-core")]
9#[cfg(target_vendor = "apple")]
10use objc2_quartz_core::*;
11
12use crate::*;
13
14extern_class!(
15    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsscreen?language=objc)
16    #[unsafe(super(NSObject))]
17    #[thread_kind = MainThreadOnly]
18    #[derive(Debug, PartialEq, Eq, Hash)]
19    pub struct NSScreen;
20);
21
22extern_conformance!(
23    unsafe impl NSObjectProtocol for NSScreen {}
24);
25
26impl NSScreen {
27    extern_methods!(
28        #[unsafe(method(screens))]
29        #[unsafe(method_family = none)]
30        pub fn screens(mtm: MainThreadMarker) -> Retained<NSArray<NSScreen>>;
31
32        #[unsafe(method(mainScreen))]
33        #[unsafe(method_family = none)]
34        pub fn mainScreen(mtm: MainThreadMarker) -> Option<Retained<NSScreen>>;
35
36        #[unsafe(method(deepestScreen))]
37        #[unsafe(method_family = none)]
38        pub unsafe fn deepestScreen(mtm: MainThreadMarker) -> Option<Retained<NSScreen>>;
39
40        #[unsafe(method(screensHaveSeparateSpaces))]
41        #[unsafe(method_family = none)]
42        pub unsafe fn screensHaveSeparateSpaces(mtm: MainThreadMarker) -> bool;
43
44        #[cfg(feature = "NSGraphics")]
45        #[unsafe(method(depth))]
46        #[unsafe(method_family = none)]
47        pub unsafe fn depth(&self) -> NSWindowDepth;
48
49        #[unsafe(method(frame))]
50        #[unsafe(method_family = none)]
51        pub fn frame(&self) -> NSRect;
52
53        #[unsafe(method(visibleFrame))]
54        #[unsafe(method_family = none)]
55        pub fn visibleFrame(&self) -> NSRect;
56
57        #[cfg(feature = "NSGraphics")]
58        #[unsafe(method(deviceDescription))]
59        #[unsafe(method_family = none)]
60        pub fn deviceDescription(
61            &self,
62        ) -> Retained<NSDictionary<NSDeviceDescriptionKey, AnyObject>>;
63
64        #[cfg(feature = "NSColorSpace")]
65        #[unsafe(method(colorSpace))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn colorSpace(&self) -> Option<Retained<NSColorSpace>>;
68
69        #[cfg(feature = "NSGraphics")]
70        #[unsafe(method(supportedWindowDepths))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn supportedWindowDepths(&self) -> NonNull<NSWindowDepth>;
73
74        #[cfg(feature = "NSGraphics")]
75        #[unsafe(method(canRepresentDisplayGamut:))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn canRepresentDisplayGamut(&self, display_gamut: NSDisplayGamut) -> bool;
78
79        #[unsafe(method(convertRectToBacking:))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn convertRectToBacking(&self, rect: NSRect) -> NSRect;
82
83        #[unsafe(method(convertRectFromBacking:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn convertRectFromBacking(&self, rect: NSRect) -> NSRect;
86
87        #[unsafe(method(backingAlignedRect:options:))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn backingAlignedRect_options(
90            &self,
91            rect: NSRect,
92            options: NSAlignmentOptions,
93        ) -> NSRect;
94
95        #[cfg(feature = "objc2-core-foundation")]
96        #[unsafe(method(backingScaleFactor))]
97        #[unsafe(method_family = none)]
98        pub fn backingScaleFactor(&self) -> CGFloat;
99
100        #[unsafe(method(localizedName))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn localizedName(&self) -> Retained<NSString>;
103
104        #[unsafe(method(safeAreaInsets))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn safeAreaInsets(&self) -> NSEdgeInsets;
107
108        #[unsafe(method(auxiliaryTopLeftArea))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn auxiliaryTopLeftArea(&self) -> NSRect;
111
112        #[unsafe(method(auxiliaryTopRightArea))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn auxiliaryTopRightArea(&self) -> NSRect;
115    );
116}
117
118/// Methods declared on superclass `NSObject`.
119impl NSScreen {
120    extern_methods!(
121        #[unsafe(method(init))]
122        #[unsafe(method_family = init)]
123        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
124
125        #[unsafe(method(new))]
126        #[unsafe(method_family = new)]
127        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
128    );
129}
130
131extern "C" {
132    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsscreencolorspacedidchangenotification?language=objc)
133    pub static NSScreenColorSpaceDidChangeNotification: &'static NSNotificationName;
134}
135
136impl NSScreen {
137    extern_methods!(
138        #[cfg(feature = "objc2-core-foundation")]
139        #[unsafe(method(maximumExtendedDynamicRangeColorComponentValue))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn maximumExtendedDynamicRangeColorComponentValue(&self) -> CGFloat;
142
143        #[cfg(feature = "objc2-core-foundation")]
144        #[unsafe(method(maximumPotentialExtendedDynamicRangeColorComponentValue))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn maximumPotentialExtendedDynamicRangeColorComponentValue(&self) -> CGFloat;
147
148        #[cfg(feature = "objc2-core-foundation")]
149        #[unsafe(method(maximumReferenceExtendedDynamicRangeColorComponentValue))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn maximumReferenceExtendedDynamicRangeColorComponentValue(&self) -> CGFloat;
152    );
153}
154
155impl NSScreen {
156    extern_methods!(
157        /// The maximum frames per second this screen supports.
158        #[unsafe(method(maximumFramesPerSecond))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn maximumFramesPerSecond(&self) -> NSInteger;
161
162        /// The minimum refresh interval this screen supports, in seconds.
163        ///
164        /// This is the shortest amount of time a frame will be present on screen.
165        /// minimumRefreshInterval and maximumRefreshInterval will be the same for displays that do not support variable refresh rates.
166        #[unsafe(method(minimumRefreshInterval))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn minimumRefreshInterval(&self) -> NSTimeInterval;
169
170        /// The maximum refresh interval this screen supports, in seconds.
171        ///
172        /// minimumRefreshInterval and maximumRefreshInterval will be the same for displays that do not support variable refresh rates.
173        #[unsafe(method(maximumRefreshInterval))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn maximumRefreshInterval(&self) -> NSTimeInterval;
176
177        /// The update granularity of the screen's current mode, in seconds.
178        ///
179        /// 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.
180        #[unsafe(method(displayUpdateGranularity))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn displayUpdateGranularity(&self) -> NSTimeInterval;
183
184        /// The time at which the last framebuffer update occurred on the display, in seconds since startup that the system has been awake.
185        #[unsafe(method(lastDisplayUpdateTimestamp))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn lastDisplayUpdateTimestamp(&self) -> NSTimeInterval;
188    );
189}
190
191/// NSDisplayLink.
192impl NSScreen {
193    extern_methods!(
194        #[cfg(feature = "objc2-quartz-core")]
195        #[cfg(target_vendor = "apple")]
196        #[unsafe(method(displayLinkWithTarget:selector:))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn displayLinkWithTarget_selector(
199            &self,
200            target: &AnyObject,
201            selector: Sel,
202        ) -> Retained<CADisplayLink>;
203    );
204}
205
206/// NSDeprecated.
207impl NSScreen {
208    extern_methods!(
209        #[cfg(feature = "objc2-core-foundation")]
210        #[deprecated = "Use -convertRectToBacking: or -backingScaleFactor instead"]
211        #[unsafe(method(userSpaceScaleFactor))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn userSpaceScaleFactor(&self) -> CGFloat;
214    );
215}