objc2_ui_kit/generated/
UIWindow.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-quartz-core")]
10#[cfg(not(target_os = "watchos"))]
11use objc2_quartz_core::*;
12
13use crate::*;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowlevel?language=objc)
16// NS_TYPED_EXTENSIBLE_ENUM
17#[cfg(feature = "objc2-core-foundation")]
18pub type UIWindowLevel = CGFloat;
19
20extern_class!(
21    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindow?language=objc)
22    #[unsafe(super(UIView, UIResponder, NSObject))]
23    #[thread_kind = MainThreadOnly]
24    #[derive(Debug, PartialEq, Eq, Hash)]
25    #[cfg(all(feature = "UIResponder", feature = "UIView"))]
26    pub struct UIWindow;
27);
28
29#[cfg(all(
30    feature = "UIResponder",
31    feature = "UIView",
32    feature = "objc2-quartz-core"
33))]
34#[cfg(not(target_os = "watchos"))]
35unsafe impl CALayerDelegate for UIWindow {}
36
37#[cfg(all(feature = "UIResponder", feature = "UIView"))]
38unsafe impl NSCoding for UIWindow {}
39
40#[cfg(all(feature = "UIResponder", feature = "UIView"))]
41unsafe impl NSObjectProtocol for UIWindow {}
42
43#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
44unsafe impl UIAppearance for UIWindow {}
45
46#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
47unsafe impl UIAppearanceContainer for UIWindow {}
48
49#[cfg(all(feature = "UIResponder", feature = "UIView"))]
50unsafe impl UICoordinateSpace for UIWindow {}
51
52#[cfg(all(
53    feature = "UIDynamicBehavior",
54    feature = "UIResponder",
55    feature = "UIView"
56))]
57unsafe impl UIDynamicItem for UIWindow {}
58
59#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
60unsafe impl UIFocusEnvironment for UIWindow {}
61
62#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
63unsafe impl UIFocusItem for UIWindow {}
64
65#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
66unsafe impl UIFocusItemContainer for UIWindow {}
67
68#[cfg(all(feature = "UIResponder", feature = "UIView"))]
69unsafe impl UIResponderStandardEditActions for UIWindow {}
70
71#[cfg(all(
72    feature = "UIResponder",
73    feature = "UITraitCollection",
74    feature = "UIView"
75))]
76unsafe impl UITraitEnvironment for UIWindow {}
77
78#[cfg(all(feature = "UIResponder", feature = "UIView"))]
79impl UIWindow {
80    extern_methods!(
81        #[cfg(all(feature = "UIScene", feature = "UIWindowScene"))]
82        #[unsafe(method(initWithWindowScene:))]
83        #[unsafe(method_family = init)]
84        pub unsafe fn initWithWindowScene(
85            this: Allocated<Self>,
86            window_scene: &UIWindowScene,
87        ) -> Retained<Self>;
88
89        #[cfg(all(feature = "UIScene", feature = "UIWindowScene"))]
90        #[unsafe(method(windowScene))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn windowScene(&self) -> Option<Retained<UIWindowScene>>;
93
94        #[cfg(all(feature = "UIScene", feature = "UIWindowScene"))]
95        /// This is a [weak property][objc2::topics::weak_property].
96        /// Setter for [`windowScene`][Self::windowScene].
97        #[unsafe(method(setWindowScene:))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn setWindowScene(&self, window_scene: Option<&UIWindowScene>);
100
101        #[unsafe(method(canResizeToFitContent))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn canResizeToFitContent(&self) -> bool;
104
105        /// Setter for [`canResizeToFitContent`][Self::canResizeToFitContent].
106        #[unsafe(method(setCanResizeToFitContent:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn setCanResizeToFitContent(&self, can_resize_to_fit_content: bool);
109
110        #[cfg(feature = "UIScreen")]
111        #[unsafe(method(screen))]
112        #[unsafe(method_family = none)]
113        pub fn screen(&self) -> Retained<UIScreen>;
114
115        #[cfg(feature = "UIScreen")]
116        /// Setter for [`screen`][Self::screen].
117        #[unsafe(method(setScreen:))]
118        #[unsafe(method_family = none)]
119        pub fn setScreen(&self, screen: &UIScreen);
120
121        #[cfg(feature = "objc2-core-foundation")]
122        #[unsafe(method(windowLevel))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn windowLevel(&self) -> UIWindowLevel;
125
126        #[cfg(feature = "objc2-core-foundation")]
127        /// Setter for [`windowLevel`][Self::windowLevel].
128        #[unsafe(method(setWindowLevel:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setWindowLevel(&self, window_level: UIWindowLevel);
131
132        #[unsafe(method(isKeyWindow))]
133        #[unsafe(method_family = none)]
134        pub fn isKeyWindow(&self) -> bool;
135
136        #[unsafe(method(canBecomeKeyWindow))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn canBecomeKeyWindow(&self) -> bool;
139
140        #[unsafe(method(becomeKeyWindow))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn becomeKeyWindow(&self);
143
144        #[unsafe(method(resignKeyWindow))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn resignKeyWindow(&self);
147
148        #[unsafe(method(makeKeyWindow))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn makeKeyWindow(&self);
151
152        #[unsafe(method(makeKeyAndVisible))]
153        #[unsafe(method_family = none)]
154        pub fn makeKeyAndVisible(&self);
155
156        #[cfg(feature = "UIViewController")]
157        #[unsafe(method(rootViewController))]
158        #[unsafe(method_family = none)]
159        pub fn rootViewController(&self) -> Option<Retained<UIViewController>>;
160
161        #[cfg(feature = "UIViewController")]
162        /// Setter for [`rootViewController`][Self::rootViewController].
163        #[unsafe(method(setRootViewController:))]
164        #[unsafe(method_family = none)]
165        pub fn setRootViewController(&self, root_view_controller: Option<&UIViewController>);
166
167        #[cfg(feature = "UIEvent")]
168        #[unsafe(method(sendEvent:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn sendEvent(&self, event: &UIEvent);
171
172        #[cfg(feature = "objc2-core-foundation")]
173        #[unsafe(method(convertPoint:toWindow:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn convertPoint_toWindow(
176            &self,
177            point: CGPoint,
178            window: Option<&UIWindow>,
179        ) -> CGPoint;
180
181        #[cfg(feature = "objc2-core-foundation")]
182        #[unsafe(method(convertPoint:fromWindow:))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn convertPoint_fromWindow(
185            &self,
186            point: CGPoint,
187            window: Option<&UIWindow>,
188        ) -> CGPoint;
189
190        #[cfg(feature = "objc2-core-foundation")]
191        #[unsafe(method(convertRect:toWindow:))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn convertRect_toWindow(
194            &self,
195            rect: CGRect,
196            window: Option<&UIWindow>,
197        ) -> CGRect;
198
199        #[cfg(feature = "objc2-core-foundation")]
200        #[unsafe(method(convertRect:fromWindow:))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn convertRect_fromWindow(
203            &self,
204            rect: CGRect,
205            window: Option<&UIWindow>,
206        ) -> CGRect;
207    );
208}
209
210/// Methods declared on superclass `UIView`.
211#[cfg(all(feature = "UIResponder", feature = "UIView"))]
212impl UIWindow {
213    extern_methods!(
214        #[cfg(feature = "objc2-core-foundation")]
215        #[unsafe(method(initWithFrame:))]
216        #[unsafe(method_family = init)]
217        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
218
219        #[unsafe(method(initWithCoder:))]
220        #[unsafe(method_family = init)]
221        pub unsafe fn initWithCoder(
222            this: Allocated<Self>,
223            coder: &NSCoder,
224        ) -> Option<Retained<Self>>;
225    );
226}
227
228/// Methods declared on superclass `NSObject`.
229#[cfg(all(feature = "UIResponder", feature = "UIView"))]
230impl UIWindow {
231    extern_methods!(
232        #[unsafe(method(init))]
233        #[unsafe(method_family = init)]
234        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
235
236        #[unsafe(method(new))]
237        #[unsafe(method_family = new)]
238        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
239    );
240}
241
242extern_protocol!(
243    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uilayoutguideaspectfitting?language=objc)
244    pub unsafe trait UILayoutGuideAspectFitting: NSObjectProtocol {
245        #[cfg(feature = "objc2-core-foundation")]
246        /// Update the aspect ratio (width / height) for the given content
247        /// Defaults to 1.0. Must be > 0.0 and values may be clamped within a reasonable range of approximately 1:100 to 100:1.
248        #[unsafe(method(aspectRatio))]
249        #[unsafe(method_family = none)]
250        unsafe fn aspectRatio(&self) -> CGFloat;
251
252        #[cfg(feature = "objc2-core-foundation")]
253        /// Setter for [`aspectRatio`][Self::aspectRatio].
254        #[unsafe(method(setAspectRatio:))]
255        #[unsafe(method_family = none)]
256        unsafe fn setAspectRatio(&self, aspect_ratio: CGFloat);
257    }
258);
259
260/// UIWindowLayout.
261#[cfg(all(feature = "UIResponder", feature = "UIView"))]
262impl UIWindow {
263    extern_methods!(
264        #[cfg(feature = "UILayoutGuide")]
265        /// This layout guide is designed specifically for full-screen media content, and attaching constraints from deep in the window's view hierarchy will raise an exception.
266        ///
267        /// This guide provides a layout area for placing media content of a given aspect ratio (width over height) such that the content will be completely visible within the window.
268        /// Compared to the standard `safeAreaLayoutGuide` on a view, this guide takes into account the aspect ratio of the content, allowing it the maximum size within the window's
269        /// true safe area, including the actual shape of the screen when that is the only factor contributing to the safe area. The rect defined by this guide will be centered within the
270        /// window.
271        ///
272        /// This layout guide should only be used for fixed aspect ratio content that is intended to fill the window (such as image or video content) and is not a replacement for the
273        /// standard `safeAreaLayoutGuide` on each UIView which should be used for most content layout. The `safeAreaAspectFitLayoutGuide` should only be used with views
274        /// that are direct subviews of, or very close descendants of, the guide's window. Creating constraints from this layout guide to views deeper in the view hierarchy or across
275        /// views owned by child view controllers can significantly degrade performance and possibly raise an exception. Additionally, the safe area insets added by child view
276        /// controllers will not be reflected in these cases. For anything other than full-screen/window media content, the standard `safeAreaLayoutGuide` on UIView should be used.
277        #[unsafe(method(safeAreaAspectFitLayoutGuide))]
278        #[unsafe(method_family = none)]
279        pub unsafe fn safeAreaAspectFitLayoutGuide(&self) -> Retained<UILayoutGuide>;
280    );
281}
282
283extern "C" {
284    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowlevelnormal?language=objc)
285    #[cfg(feature = "objc2-core-foundation")]
286    pub static UIWindowLevelNormal: UIWindowLevel;
287}
288
289extern "C" {
290    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowlevelalert?language=objc)
291    #[cfg(feature = "objc2-core-foundation")]
292    pub static UIWindowLevelAlert: UIWindowLevel;
293}
294
295extern "C" {
296    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowlevelstatusbar?language=objc)
297    #[cfg(feature = "objc2-core-foundation")]
298    pub static UIWindowLevelStatusBar: UIWindowLevel;
299}
300
301extern "C" {
302    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowdidbecomevisiblenotification?language=objc)
303    pub static UIWindowDidBecomeVisibleNotification: &'static NSNotificationName;
304}
305
306extern "C" {
307    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowdidbecomehiddennotification?language=objc)
308    pub static UIWindowDidBecomeHiddenNotification: &'static NSNotificationName;
309}
310
311extern "C" {
312    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowdidbecomekeynotification?language=objc)
313    pub static UIWindowDidBecomeKeyNotification: &'static NSNotificationName;
314}
315
316extern "C" {
317    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowdidresignkeynotification?language=objc)
318    pub static UIWindowDidResignKeyNotification: &'static NSNotificationName;
319}
320
321extern "C" {
322    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardwillshownotification?language=objc)
323    pub static UIKeyboardWillShowNotification: &'static NSNotificationName;
324}
325
326extern "C" {
327    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboarddidshownotification?language=objc)
328    pub static UIKeyboardDidShowNotification: &'static NSNotificationName;
329}
330
331extern "C" {
332    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardwillhidenotification?language=objc)
333    pub static UIKeyboardWillHideNotification: &'static NSNotificationName;
334}
335
336extern "C" {
337    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboarddidhidenotification?language=objc)
338    pub static UIKeyboardDidHideNotification: &'static NSNotificationName;
339}
340
341extern "C" {
342    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardframebeginuserinfokey?language=objc)
343    pub static UIKeyboardFrameBeginUserInfoKey: &'static NSString;
344}
345
346extern "C" {
347    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardframeenduserinfokey?language=objc)
348    pub static UIKeyboardFrameEndUserInfoKey: &'static NSString;
349}
350
351extern "C" {
352    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardanimationdurationuserinfokey?language=objc)
353    pub static UIKeyboardAnimationDurationUserInfoKey: &'static NSString;
354}
355
356extern "C" {
357    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardanimationcurveuserinfokey?language=objc)
358    pub static UIKeyboardAnimationCurveUserInfoKey: &'static NSString;
359}
360
361extern "C" {
362    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardislocaluserinfokey?language=objc)
363    pub static UIKeyboardIsLocalUserInfoKey: &'static NSString;
364}
365
366extern "C" {
367    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardwillchangeframenotification?language=objc)
368    pub static UIKeyboardWillChangeFrameNotification: &'static NSNotificationName;
369}
370
371extern "C" {
372    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboarddidchangeframenotification?language=objc)
373    pub static UIKeyboardDidChangeFrameNotification: &'static NSNotificationName;
374}
375
376extern "C" {
377    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardcenterbeginuserinfokey?language=objc)
378    pub static UIKeyboardCenterBeginUserInfoKey: &'static NSString;
379}
380
381extern "C" {
382    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardcenterenduserinfokey?language=objc)
383    pub static UIKeyboardCenterEndUserInfoKey: &'static NSString;
384}
385
386extern "C" {
387    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardboundsuserinfokey?language=objc)
388    pub static UIKeyboardBoundsUserInfoKey: &'static NSString;
389}