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"))]
35extern_conformance!(
36    unsafe impl CALayerDelegate for UIWindow {}
37);
38
39#[cfg(all(feature = "UIResponder", feature = "UIView"))]
40extern_conformance!(
41    unsafe impl NSCoding for UIWindow {}
42);
43
44#[cfg(all(feature = "UIResponder", feature = "UIView"))]
45extern_conformance!(
46    unsafe impl NSObjectProtocol for UIWindow {}
47);
48
49#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
50extern_conformance!(
51    unsafe impl UIAppearance for UIWindow {}
52);
53
54#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
55extern_conformance!(
56    unsafe impl UIAppearanceContainer for UIWindow {}
57);
58
59#[cfg(all(feature = "UIResponder", feature = "UIView"))]
60extern_conformance!(
61    unsafe impl UICoordinateSpace for UIWindow {}
62);
63
64#[cfg(all(
65    feature = "UIDynamicBehavior",
66    feature = "UIResponder",
67    feature = "UIView"
68))]
69extern_conformance!(
70    unsafe impl UIDynamicItem for UIWindow {}
71);
72
73#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
74extern_conformance!(
75    unsafe impl UIFocusEnvironment for UIWindow {}
76);
77
78#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
79extern_conformance!(
80    unsafe impl UIFocusItem for UIWindow {}
81);
82
83#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
84extern_conformance!(
85    unsafe impl UIFocusItemContainer for UIWindow {}
86);
87
88#[cfg(all(feature = "UIResponder", feature = "UIView"))]
89extern_conformance!(
90    unsafe impl UIResponderStandardEditActions for UIWindow {}
91);
92
93#[cfg(all(
94    feature = "UIResponder",
95    feature = "UITraitCollection",
96    feature = "UIView"
97))]
98extern_conformance!(
99    unsafe impl UITraitEnvironment for UIWindow {}
100);
101
102#[cfg(all(feature = "UIResponder", feature = "UIView"))]
103impl UIWindow {
104    extern_methods!(
105        #[cfg(all(feature = "UIScene", feature = "UIWindowScene"))]
106        #[unsafe(method(initWithWindowScene:))]
107        #[unsafe(method_family = init)]
108        pub fn initWithWindowScene(
109            this: Allocated<Self>,
110            window_scene: &UIWindowScene,
111        ) -> Retained<Self>;
112
113        #[cfg(feature = "objc2-core-foundation")]
114        #[deprecated = "Use init(windowScene:) instead."]
115        #[unsafe(method(initWithFrame:))]
116        #[unsafe(method_family = init)]
117        pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
118
119        #[deprecated = "Use init(windowScene:) instead."]
120        #[unsafe(method(init))]
121        #[unsafe(method_family = init)]
122        pub fn init(this: Allocated<Self>) -> Retained<Self>;
123
124        #[cfg(all(feature = "UIScene", feature = "UIWindowScene"))]
125        #[unsafe(method(windowScene))]
126        #[unsafe(method_family = none)]
127        pub fn windowScene(&self) -> Option<Retained<UIWindowScene>>;
128
129        #[cfg(all(feature = "UIScene", feature = "UIWindowScene"))]
130        /// Setter for [`windowScene`][Self::windowScene].
131        ///
132        /// This is a [weak property][objc2::topics::weak_property].
133        #[unsafe(method(setWindowScene:))]
134        #[unsafe(method_family = none)]
135        pub fn setWindowScene(&self, window_scene: Option<&UIWindowScene>);
136
137        #[unsafe(method(canResizeToFitContent))]
138        #[unsafe(method_family = none)]
139        pub fn canResizeToFitContent(&self) -> bool;
140
141        /// Setter for [`canResizeToFitContent`][Self::canResizeToFitContent].
142        #[unsafe(method(setCanResizeToFitContent:))]
143        #[unsafe(method_family = none)]
144        pub fn setCanResizeToFitContent(&self, can_resize_to_fit_content: bool);
145
146        #[cfg(feature = "UIScreen")]
147        #[unsafe(method(screen))]
148        #[unsafe(method_family = none)]
149        pub fn screen(&self) -> Retained<UIScreen>;
150
151        #[cfg(feature = "UIScreen")]
152        /// Setter for [`screen`][Self::screen].
153        #[unsafe(method(setScreen:))]
154        #[unsafe(method_family = none)]
155        pub fn setScreen(&self, screen: &UIScreen);
156
157        #[cfg(feature = "objc2-core-foundation")]
158        #[unsafe(method(windowLevel))]
159        #[unsafe(method_family = none)]
160        pub fn windowLevel(&self) -> UIWindowLevel;
161
162        #[cfg(feature = "objc2-core-foundation")]
163        /// Setter for [`windowLevel`][Self::windowLevel].
164        #[unsafe(method(setWindowLevel:))]
165        #[unsafe(method_family = none)]
166        pub fn setWindowLevel(&self, window_level: UIWindowLevel);
167
168        #[unsafe(method(isKeyWindow))]
169        #[unsafe(method_family = none)]
170        pub fn isKeyWindow(&self) -> bool;
171
172        #[unsafe(method(canBecomeKeyWindow))]
173        #[unsafe(method_family = none)]
174        pub fn canBecomeKeyWindow(&self) -> bool;
175
176        #[unsafe(method(becomeKeyWindow))]
177        #[unsafe(method_family = none)]
178        pub fn becomeKeyWindow(&self);
179
180        #[unsafe(method(resignKeyWindow))]
181        #[unsafe(method_family = none)]
182        pub fn resignKeyWindow(&self);
183
184        #[unsafe(method(makeKeyWindow))]
185        #[unsafe(method_family = none)]
186        pub fn makeKeyWindow(&self);
187
188        #[unsafe(method(makeKeyAndVisible))]
189        #[unsafe(method_family = none)]
190        pub fn makeKeyAndVisible(&self);
191
192        #[cfg(feature = "UIViewController")]
193        #[unsafe(method(rootViewController))]
194        #[unsafe(method_family = none)]
195        pub fn rootViewController(&self) -> Option<Retained<UIViewController>>;
196
197        #[cfg(feature = "UIViewController")]
198        /// Setter for [`rootViewController`][Self::rootViewController].
199        #[unsafe(method(setRootViewController:))]
200        #[unsafe(method_family = none)]
201        pub fn setRootViewController(&self, root_view_controller: Option<&UIViewController>);
202
203        #[cfg(feature = "UIEvent")]
204        #[unsafe(method(sendEvent:))]
205        #[unsafe(method_family = none)]
206        pub fn sendEvent(&self, event: &UIEvent);
207
208        #[cfg(feature = "objc2-core-foundation")]
209        #[unsafe(method(convertPoint:toWindow:))]
210        #[unsafe(method_family = none)]
211        pub fn convertPoint_toWindow(&self, point: CGPoint, window: Option<&UIWindow>) -> CGPoint;
212
213        #[cfg(feature = "objc2-core-foundation")]
214        #[unsafe(method(convertPoint:fromWindow:))]
215        #[unsafe(method_family = none)]
216        pub fn convertPoint_fromWindow(&self, point: CGPoint, window: Option<&UIWindow>)
217            -> CGPoint;
218
219        #[cfg(feature = "objc2-core-foundation")]
220        #[unsafe(method(convertRect:toWindow:))]
221        #[unsafe(method_family = none)]
222        pub fn convertRect_toWindow(&self, rect: CGRect, window: Option<&UIWindow>) -> CGRect;
223
224        #[cfg(feature = "objc2-core-foundation")]
225        #[unsafe(method(convertRect:fromWindow:))]
226        #[unsafe(method_family = none)]
227        pub fn convertRect_fromWindow(&self, rect: CGRect, window: Option<&UIWindow>) -> CGRect;
228    );
229}
230
231/// Methods declared on superclass `UIView`.
232#[cfg(all(feature = "UIResponder", feature = "UIView"))]
233impl UIWindow {
234    extern_methods!(
235        /// # Safety
236        ///
237        /// `coder` possibly has further requirements.
238        #[unsafe(method(initWithCoder:))]
239        #[unsafe(method_family = init)]
240        pub unsafe fn initWithCoder(
241            this: Allocated<Self>,
242            coder: &NSCoder,
243        ) -> Option<Retained<Self>>;
244    );
245}
246
247/// Methods declared on superclass `NSObject`.
248#[cfg(all(feature = "UIResponder", feature = "UIView"))]
249impl UIWindow {
250    extern_methods!(
251        #[unsafe(method(new))]
252        #[unsafe(method_family = new)]
253        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
254    );
255}
256
257extern_protocol!(
258    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uilayoutguideaspectfitting?language=objc)
259    pub unsafe trait UILayoutGuideAspectFitting: NSObjectProtocol {
260        #[cfg(feature = "objc2-core-foundation")]
261        /// Update the aspect ratio (width / height) for the given content
262        /// Defaults to 1.0. Must be > 0.0 and values may be clamped within a reasonable range of approximately 1:100 to 100:1.
263        #[unsafe(method(aspectRatio))]
264        #[unsafe(method_family = none)]
265        fn aspectRatio(&self) -> CGFloat;
266
267        #[cfg(feature = "objc2-core-foundation")]
268        /// Setter for [`aspectRatio`][Self::aspectRatio].
269        #[unsafe(method(setAspectRatio:))]
270        #[unsafe(method_family = none)]
271        fn setAspectRatio(&self, aspect_ratio: CGFloat);
272    }
273);
274
275/// UIWindowLayout.
276#[cfg(all(feature = "UIResponder", feature = "UIView"))]
277impl UIWindow {
278    extern_methods!(
279        #[cfg(feature = "UILayoutGuide")]
280        /// 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.
281        ///
282        /// 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.
283        /// 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
284        /// 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
285        /// window.
286        ///
287        /// 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
288        /// standard `safeAreaLayoutGuide` on each UIView which should be used for most content layout. The `safeAreaAspectFitLayoutGuide` should only be used with views
289        /// 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
290        /// views owned by child view controllers can significantly degrade performance and possibly raise an exception. Additionally, the safe area insets added by child view
291        /// 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.
292        #[unsafe(method(safeAreaAspectFitLayoutGuide))]
293        #[unsafe(method_family = none)]
294        pub fn safeAreaAspectFitLayoutGuide(&self) -> Retained<UILayoutGuide>;
295    );
296}
297
298extern "C" {
299    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowlevelnormal?language=objc)
300    #[cfg(feature = "objc2-core-foundation")]
301    pub static UIWindowLevelNormal: UIWindowLevel;
302}
303
304extern "C" {
305    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowlevelalert?language=objc)
306    #[cfg(feature = "objc2-core-foundation")]
307    pub static UIWindowLevelAlert: UIWindowLevel;
308}
309
310extern "C" {
311    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowlevelstatusbar?language=objc)
312    #[cfg(feature = "objc2-core-foundation")]
313    pub static UIWindowLevelStatusBar: UIWindowLevel;
314}
315
316extern "C" {
317    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowdidbecomevisiblenotification?language=objc)
318    pub static UIWindowDidBecomeVisibleNotification: &'static NSNotificationName;
319}
320
321extern "C" {
322    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowdidbecomehiddennotification?language=objc)
323    pub static UIWindowDidBecomeHiddenNotification: &'static NSNotificationName;
324}
325
326extern "C" {
327    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowdidbecomekeynotification?language=objc)
328    pub static UIWindowDidBecomeKeyNotification: &'static NSNotificationName;
329}
330
331extern "C" {
332    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowdidresignkeynotification?language=objc)
333    pub static UIWindowDidResignKeyNotification: &'static NSNotificationName;
334}
335
336extern "C" {
337    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardwillshownotification?language=objc)
338    pub static UIKeyboardWillShowNotification: &'static NSNotificationName;
339}
340
341extern "C" {
342    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboarddidshownotification?language=objc)
343    pub static UIKeyboardDidShowNotification: &'static NSNotificationName;
344}
345
346extern "C" {
347    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardwillhidenotification?language=objc)
348    pub static UIKeyboardWillHideNotification: &'static NSNotificationName;
349}
350
351extern "C" {
352    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboarddidhidenotification?language=objc)
353    pub static UIKeyboardDidHideNotification: &'static NSNotificationName;
354}
355
356extern "C" {
357    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardframebeginuserinfokey?language=objc)
358    pub static UIKeyboardFrameBeginUserInfoKey: &'static NSString;
359}
360
361extern "C" {
362    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardframeenduserinfokey?language=objc)
363    pub static UIKeyboardFrameEndUserInfoKey: &'static NSString;
364}
365
366extern "C" {
367    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardanimationdurationuserinfokey?language=objc)
368    pub static UIKeyboardAnimationDurationUserInfoKey: &'static NSString;
369}
370
371extern "C" {
372    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardanimationcurveuserinfokey?language=objc)
373    pub static UIKeyboardAnimationCurveUserInfoKey: &'static NSString;
374}
375
376extern "C" {
377    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardislocaluserinfokey?language=objc)
378    pub static UIKeyboardIsLocalUserInfoKey: &'static NSString;
379}
380
381extern "C" {
382    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardwillchangeframenotification?language=objc)
383    pub static UIKeyboardWillChangeFrameNotification: &'static NSNotificationName;
384}
385
386extern "C" {
387    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboarddidchangeframenotification?language=objc)
388    pub static UIKeyboardDidChangeFrameNotification: &'static NSNotificationName;
389}
390
391extern "C" {
392    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardcenterbeginuserinfokey?language=objc)
393    #[deprecated]
394    pub static UIKeyboardCenterBeginUserInfoKey: &'static NSString;
395}
396
397extern "C" {
398    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardcenterenduserinfokey?language=objc)
399    #[deprecated]
400    pub static UIKeyboardCenterEndUserInfoKey: &'static NSString;
401}
402
403extern "C" {
404    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyboardboundsuserinfokey?language=objc)
405    #[deprecated]
406    pub static UIKeyboardBoundsUserInfoKey: &'static NSString;
407}