//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-cloud-kit")]
#[cfg(target_vendor = "apple")]
use objc2_cloud_kit::*;
use objc2_foundation::*;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversion?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
pub type NSAppKitVersion = c_double;
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber?language=objc)
pub static NSAppKitVersionNumber: NSAppKitVersion;
}
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_0?language=objc)
pub static NSAppKitVersionNumber10_0: NSAppKitVersion = 577 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_1?language=objc)
pub static NSAppKitVersionNumber10_1: NSAppKitVersion = 620 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_2?language=objc)
pub static NSAppKitVersionNumber10_2: NSAppKitVersion = 663 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_2_3?language=objc)
pub static NSAppKitVersionNumber10_2_3: NSAppKitVersion = 663.6 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_3?language=objc)
pub static NSAppKitVersionNumber10_3: NSAppKitVersion = 743 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_3_2?language=objc)
pub static NSAppKitVersionNumber10_3_2: NSAppKitVersion = 743.14 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_3_3?language=objc)
pub static NSAppKitVersionNumber10_3_3: NSAppKitVersion = 743.2 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_3_5?language=objc)
pub static NSAppKitVersionNumber10_3_5: NSAppKitVersion = 743.24 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_3_7?language=objc)
pub static NSAppKitVersionNumber10_3_7: NSAppKitVersion = 743.33 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_3_9?language=objc)
pub static NSAppKitVersionNumber10_3_9: NSAppKitVersion = 743.36 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_4?language=objc)
pub static NSAppKitVersionNumber10_4: NSAppKitVersion = 824 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_4_1?language=objc)
pub static NSAppKitVersionNumber10_4_1: NSAppKitVersion = 824.1 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_4_3?language=objc)
pub static NSAppKitVersionNumber10_4_3: NSAppKitVersion = 824.23 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_4_4?language=objc)
pub static NSAppKitVersionNumber10_4_4: NSAppKitVersion = 824.33 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_4_7?language=objc)
pub static NSAppKitVersionNumber10_4_7: NSAppKitVersion = 824.41 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_5?language=objc)
pub static NSAppKitVersionNumber10_5: NSAppKitVersion = 949 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_5_2?language=objc)
pub static NSAppKitVersionNumber10_5_2: NSAppKitVersion = 949.27 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_5_3?language=objc)
pub static NSAppKitVersionNumber10_5_3: NSAppKitVersion = 949.33 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_6?language=objc)
pub static NSAppKitVersionNumber10_6: NSAppKitVersion = 1038 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_7?language=objc)
pub static NSAppKitVersionNumber10_7: NSAppKitVersion = 1138 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_7_2?language=objc)
pub static NSAppKitVersionNumber10_7_2: NSAppKitVersion = 1138.23 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_7_3?language=objc)
pub static NSAppKitVersionNumber10_7_3: NSAppKitVersion = 1138.32 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_7_4?language=objc)
pub static NSAppKitVersionNumber10_7_4: NSAppKitVersion = 1138.47 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_8?language=objc)
pub static NSAppKitVersionNumber10_8: NSAppKitVersion = 1187 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_9?language=objc)
pub static NSAppKitVersionNumber10_9: NSAppKitVersion = 1265 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_10?language=objc)
pub static NSAppKitVersionNumber10_10: NSAppKitVersion = 1343 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_10_2?language=objc)
pub static NSAppKitVersionNumber10_10_2: NSAppKitVersion = 1344 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_10_3?language=objc)
pub static NSAppKitVersionNumber10_10_3: NSAppKitVersion = 1347 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_10_4?language=objc)
pub static NSAppKitVersionNumber10_10_4: NSAppKitVersion = 1348 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_10_5?language=objc)
pub static NSAppKitVersionNumber10_10_5: NSAppKitVersion = 1348 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_10_max?language=objc)
pub static NSAppKitVersionNumber10_10_Max: NSAppKitVersion = 1349 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_11?language=objc)
pub static NSAppKitVersionNumber10_11: NSAppKitVersion = 1404 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_11_1?language=objc)
pub static NSAppKitVersionNumber10_11_1: NSAppKitVersion = 1404.13 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_11_2?language=objc)
pub static NSAppKitVersionNumber10_11_2: NSAppKitVersion = 1404.34 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_11_3?language=objc)
pub static NSAppKitVersionNumber10_11_3: NSAppKitVersion = 1404.34 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_12?language=objc)
pub static NSAppKitVersionNumber10_12: NSAppKitVersion = 1504 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_12_1?language=objc)
pub static NSAppKitVersionNumber10_12_1: NSAppKitVersion = 1504.6 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_12_2?language=objc)
pub static NSAppKitVersionNumber10_12_2: NSAppKitVersion = 1504.76 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_13?language=objc)
pub static NSAppKitVersionNumber10_13: NSAppKitVersion = 1561 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_13_1?language=objc)
pub static NSAppKitVersionNumber10_13_1: NSAppKitVersion = 1561.1 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_13_2?language=objc)
pub static NSAppKitVersionNumber10_13_2: NSAppKitVersion = 1561.2 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_13_4?language=objc)
pub static NSAppKitVersionNumber10_13_4: NSAppKitVersion = 1561.4 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_14?language=objc)
pub static NSAppKitVersionNumber10_14: NSAppKitVersion = 1671 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_14_1?language=objc)
pub static NSAppKitVersionNumber10_14_1: NSAppKitVersion = 1671.1 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_14_2?language=objc)
pub static NSAppKitVersionNumber10_14_2: NSAppKitVersion = 1671.2 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_14_3?language=objc)
pub static NSAppKitVersionNumber10_14_3: NSAppKitVersion = 1671.3 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_14_4?language=objc)
pub static NSAppKitVersionNumber10_14_4: NSAppKitVersion = 1671.4 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_14_5?language=objc)
pub static NSAppKitVersionNumber10_14_5: NSAppKitVersion = 1671.5 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_15?language=objc)
pub static NSAppKitVersionNumber10_15: NSAppKitVersion = 1894 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_15_1?language=objc)
pub static NSAppKitVersionNumber10_15_1: NSAppKitVersion = 1894.1 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_15_2?language=objc)
pub static NSAppKitVersionNumber10_15_2: NSAppKitVersion = 1894.2 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_15_3?language=objc)
pub static NSAppKitVersionNumber10_15_3: NSAppKitVersion = 1894.3 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_15_4?language=objc)
pub static NSAppKitVersionNumber10_15_4: NSAppKitVersion = 1894.4 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_15_5?language=objc)
pub static NSAppKitVersionNumber10_15_5: NSAppKitVersion = 1894.5 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber10_15_6?language=objc)
pub static NSAppKitVersionNumber10_15_6: NSAppKitVersion = 1894.6 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber11_0?language=objc)
pub static NSAppKitVersionNumber11_0: NSAppKitVersion = 2022 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber11_1?language=objc)
pub static NSAppKitVersionNumber11_1: NSAppKitVersion = 2022.2 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber11_2?language=objc)
pub static NSAppKitVersionNumber11_2: NSAppKitVersion = 2022.3 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber11_3?language=objc)
pub static NSAppKitVersionNumber11_3: NSAppKitVersion = 2022.4 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber11_4?language=objc)
pub static NSAppKitVersionNumber11_4: NSAppKitVersion = 2022.5 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber11_5?language=objc)
pub static NSAppKitVersionNumber11_5: NSAppKitVersion = 2022.6 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber12_0?language=objc)
pub static NSAppKitVersionNumber12_0: NSAppKitVersion = 2113 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber12_1?language=objc)
pub static NSAppKitVersionNumber12_1: NSAppKitVersion = 2113.2 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber12_2?language=objc)
pub static NSAppKitVersionNumber12_2: NSAppKitVersion = 2113.3 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber12_3?language=objc)
pub static NSAppKitVersionNumber12_3: NSAppKitVersion = 2113.4 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber12_4?language=objc)
pub static NSAppKitVersionNumber12_4: NSAppKitVersion = 2113.5 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber12_5?language=objc)
pub static NSAppKitVersionNumber12_5: NSAppKitVersion = 2113.6 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber13_0?language=objc)
pub static NSAppKitVersionNumber13_0: NSAppKitVersion = 2299 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber13_1?language=objc)
pub static NSAppKitVersionNumber13_1: NSAppKitVersion = 2299.3 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber13_2?language=objc)
pub static NSAppKitVersionNumber13_2: NSAppKitVersion = 2299.3 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber13_3?language=objc)
pub static NSAppKitVersionNumber13_3: NSAppKitVersion = 2299.4 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber13_4?language=objc)
pub static NSAppKitVersionNumber13_4: NSAppKitVersion = 2299.5 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber13_5?language=objc)
pub static NSAppKitVersionNumber13_5: NSAppKitVersion = 2299.6 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber13_6?language=objc)
pub static NSAppKitVersionNumber13_6: NSAppKitVersion = 2299.7 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber14_0?language=objc)
pub static NSAppKitVersionNumber14_0: NSAppKitVersion = 2487 as _;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumber14_1?language=objc)
pub static NSAppKitVersionNumber14_1: NSAppKitVersion = 2487.2 as _;
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmodalpanelrunloopmode?language=objc)
pub static NSModalPanelRunLoopMode: &'static NSRunLoopMode;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nseventtrackingrunloopmode?language=objc)
pub static NSEventTrackingRunLoopMode: &'static NSRunLoopMode;
}
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmodalresponse?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
pub type NSModalResponse = NSInteger;
/// Also used as the default response for sheets
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmodalresponsestop?language=objc)
pub static NSModalResponseStop: NSModalResponse = -1000;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmodalresponseabort?language=objc)
pub static NSModalResponseAbort: NSModalResponse = -1001;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmodalresponsecontinue?language=objc)
pub static NSModalResponseContinue: NSModalResponse = -1002;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsupdatewindowsrunloopordering?language=objc)
pub const NSUpdateWindowsRunLoopOrdering: c_uint = 500000;
/// Flags that comprise an application's
/// `presentationOptions.`
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationpresentationoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSApplicationPresentationOptions(pub NSUInteger);
bitflags::bitflags! {
impl NSApplicationPresentationOptions: NSUInteger {
#[doc(alias = "NSApplicationPresentationDefault")]
const Default = 0;
/// Dock appears when moused to.
#[doc(alias = "NSApplicationPresentationAutoHideDock")]
const AutoHideDock = 1<<0;
/// Dock is entirely unavailable.
#[doc(alias = "NSApplicationPresentationHideDock")]
const HideDock = 1<<1;
/// Menu Bar appears when moused to.
#[doc(alias = "NSApplicationPresentationAutoHideMenuBar")]
const AutoHideMenuBar = 1<<2;
/// Menu Bar is entirely unavailable.
#[doc(alias = "NSApplicationPresentationHideMenuBar")]
const HideMenuBar = 1<<3;
/// All Apple menu items are disabled.
#[doc(alias = "NSApplicationPresentationDisableAppleMenu")]
const DisableAppleMenu = 1<<4;
/// Cmd+Tab UI is disabled.
#[doc(alias = "NSApplicationPresentationDisableProcessSwitching")]
const DisableProcessSwitching = 1<<5;
/// Cmd+Opt+Esc panel is disabled.
#[doc(alias = "NSApplicationPresentationDisableForceQuit")]
const DisableForceQuit = 1<<6;
/// PowerKey panel and Restart/Shut Down/Log Out disabled.
#[doc(alias = "NSApplicationPresentationDisableSessionTermination")]
const DisableSessionTermination = 1<<7;
/// Application "Hide" menu item is disabled.
#[doc(alias = "NSApplicationPresentationDisableHideApplication")]
const DisableHideApplication = 1<<8;
/// Menu Bar's transparent appearance is disabled.
#[doc(alias = "NSApplicationPresentationDisableMenuBarTransparency")]
const DisableMenuBarTransparency = 1<<9;
/// Application is in fullscreen mode.
#[doc(alias = "NSApplicationPresentationFullScreen")]
const FullScreen = 1<<10;
/// Fullscreen window toolbar is detached from window and hides/shows on rollover.
/// May be used only when both
/// `NSApplicationPresentationFullScreen`is also set.
#[doc(alias = "NSApplicationPresentationAutoHideToolbar")]
const AutoHideToolbar = 1<<11;
/// "Shake mouse pointer to locate" is disabled for this application.
#[doc(alias = "NSApplicationPresentationDisableCursorLocationAssistance")]
const DisableCursorLocationAssistance = 1<<12;
}
}
unsafe impl Encode for NSApplicationPresentationOptions {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSApplicationPresentationOptions {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationocclusionstate?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSApplicationOcclusionState(pub NSUInteger);
bitflags::bitflags! {
impl NSApplicationOcclusionState: NSUInteger {
/// If set, at least part of any window owned by this application is visible. If not set, all parts of all windows owned by this application are completely occluded. The menu bar does not count as a window owned by this application, so if only the menu bar is showing then the application is considered not visible. Status items, however, have windows owned by your application. If the status item is present in the menu bar, your application will be considered visible as long as the menu bar is visible.
#[doc(alias = "NSApplicationOcclusionStateVisible")]
const Visible = 1<<1;
}
}
unsafe impl Encode for NSApplicationOcclusionState {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSApplicationOcclusionState {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nswindowlistoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSWindowListOptions(pub NSInteger);
bitflags::bitflags! {
impl NSWindowListOptions: NSInteger {
/// Onscreen application windows in front to back order. By default, -[NSApp windows] is used.
#[doc(alias = "NSWindowListOrderedFrontToBack")]
const OrderedFrontToBack = 1<<0;
}
}
unsafe impl Encode for NSWindowListOptions {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSWindowListOptions {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/_nsmodalsession?language=objc)
#[repr(C)]
#[derive(Debug)]
pub struct _NSModalSession {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
unsafe impl RefEncode for _NSModalSession {
const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("_NSModalSession", &[]));
}
/// Information used by the system during modal sessions.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmodalsession?language=objc)
pub type NSModalSession = *mut _NSModalSession;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrequestuserattentiontype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSRequestUserAttentionType(pub NSUInteger);
impl NSRequestUserAttentionType {
#[doc(alias = "NSCriticalRequest")]
pub const CriticalRequest: Self = Self(0);
#[doc(alias = "NSInformationalRequest")]
pub const InformationalRequest: Self = Self(10);
}
unsafe impl Encode for NSRequestUserAttentionType {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSRequestUserAttentionType {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationdelegatereply?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSApplicationDelegateReply(pub NSUInteger);
impl NSApplicationDelegateReply {
#[doc(alias = "NSApplicationDelegateReplySuccess")]
pub const Success: Self = Self(0);
#[doc(alias = "NSApplicationDelegateReplyCancel")]
pub const Cancel: Self = Self(1);
#[doc(alias = "NSApplicationDelegateReplyFailure")]
pub const Failure: Self = Self(2);
}
unsafe impl Encode for NSApplicationDelegateReply {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSApplicationDelegateReply {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplication?language=objc)
#[unsafe(super(NSResponder, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "NSResponder")]
pub struct NSApplication;
);
#[cfg(all(feature = "NSAccessibilityProtocols", feature = "NSResponder"))]
extern_conformance!(
unsafe impl NSAccessibility for NSApplication {}
);
#[cfg(all(feature = "NSAccessibilityProtocols", feature = "NSResponder"))]
extern_conformance!(
unsafe impl NSAccessibilityElementProtocol for NSApplication {}
);
#[cfg(feature = "NSResponder")]
extern_conformance!(
unsafe impl NSCoding for NSApplication {}
);
#[cfg(all(feature = "NSMenu", feature = "NSResponder"))]
extern_conformance!(
unsafe impl NSMenuItemValidation for NSApplication {}
);
#[cfg(feature = "NSResponder")]
extern_conformance!(
unsafe impl NSObjectProtocol for NSApplication {}
);
#[cfg(all(feature = "NSResponder", feature = "NSUserInterfaceValidation"))]
extern_conformance!(
unsafe impl NSUserInterfaceValidations for NSApplication {}
);
#[cfg(feature = "NSResponder")]
impl NSApplication {
extern_methods!(
#[unsafe(method(sharedApplication))]
#[unsafe(method_family = none)]
pub fn sharedApplication(mtm: MainThreadMarker) -> Retained<NSApplication>;
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSApplicationDelegate>>>;
/// Setter for [`delegate`][Self::delegate].
///
/// This is a [weak property][objc2::topics::weak_property].
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSApplicationDelegate>>);
#[unsafe(method(hide:))]
#[unsafe(method_family = none)]
pub fn hide(&self, sender: Option<&AnyObject>);
#[unsafe(method(unhide:))]
#[unsafe(method_family = none)]
pub fn unhide(&self, sender: Option<&AnyObject>);
#[unsafe(method(unhideWithoutActivation))]
#[unsafe(method_family = none)]
pub fn unhideWithoutActivation(&self);
#[cfg(feature = "NSWindow")]
#[unsafe(method(windowWithWindowNumber:))]
#[unsafe(method_family = none)]
pub fn windowWithWindowNumber(&self, window_num: NSInteger) -> Option<Retained<NSWindow>>;
#[cfg(feature = "NSWindow")]
#[unsafe(method(mainWindow))]
#[unsafe(method_family = none)]
pub fn mainWindow(&self) -> Option<Retained<NSWindow>>;
#[cfg(feature = "NSWindow")]
#[unsafe(method(keyWindow))]
#[unsafe(method_family = none)]
pub fn keyWindow(&self) -> Option<Retained<NSWindow>>;
#[unsafe(method(isActive))]
#[unsafe(method_family = none)]
pub fn isActive(&self) -> bool;
#[unsafe(method(isHidden))]
#[unsafe(method_family = none)]
pub fn isHidden(&self) -> bool;
#[unsafe(method(isRunning))]
#[unsafe(method_family = none)]
pub fn isRunning(&self) -> bool;
/// A boolean value indicating whether your application should suppress HDR content based on established policy.
/// Built-in AppKit components such as NSImageView will automatically behave correctly with HDR content. You should use this value in conjunction with notifications (`NSApplicationShouldBeginSuppressingHighDynamicRangeContentNotification` and `NSApplicationShouldEndSuppressingHighDynamicRangeContentNotification`) to suppress HDR content in your application when signaled to do so.
#[unsafe(method(applicationShouldSuppressHighDynamicRangeContent))]
#[unsafe(method_family = none)]
pub fn applicationShouldSuppressHighDynamicRangeContent(&self) -> bool;
#[unsafe(method(deactivate))]
#[unsafe(method_family = none)]
pub fn deactivate(&self);
/// Makes the receiver the active app.
/// - Parameter ignoreOtherApps: If `NO`, the app is activated only if no other app is currently active. If `YES`, the app activates regardless.
#[deprecated = "This method will be deprecated in a future release. Use NSApp.activate instead."]
#[unsafe(method(activateIgnoringOtherApps:))]
#[unsafe(method_family = none)]
pub fn activateIgnoringOtherApps(&self, ignore_other_apps: bool);
/// Makes the receiver the active app, if possible.
///
/// You shouldn’t assume the app will be active immediately
/// after sending this message. The framework also does not
/// guarantee that the app will be activated at all.
///
/// For cooperative activation, the other application should
/// call `-yieldActivationToApplication:` or equivalent prior
/// to the target application invoking `-activate`.
///
/// Invoking `-activate` on an already-active application
/// cancels any pending activation yields by the receiver.
#[unsafe(method(activate))]
#[unsafe(method_family = none)]
pub fn activate(&self);
#[cfg(feature = "NSRunningApplication")]
/// Explicitly allows another application to make itself active.
///
/// Calling this method will not deactivate the current app, nor
/// will it activate the other app. For cooperative or coordinated
/// activation, the other app should request to be activated at
/// some point in the future by calling `activate` or equivalent.
#[unsafe(method(yieldActivationToApplication:))]
#[unsafe(method_family = none)]
pub fn yieldActivationToApplication(&self, application: &NSRunningApplication);
/// Same as `-yieldActivationToApplication:`, but the provided
/// bundle identifier does not have to correspond to a currently
/// running application.
///
/// This method should be used to yield activation to apps that
/// may not be running at the time of invoking it. If it is known
/// that the target application is currently running, use
/// `-yieldActivationToApplication:` instead.
#[unsafe(method(yieldActivationToApplicationWithBundleIdentifier:))]
#[unsafe(method_family = none)]
pub fn yieldActivationToApplicationWithBundleIdentifier(
&self,
bundle_identifier: &NSString,
);
#[unsafe(method(hideOtherApplications:))]
#[unsafe(method_family = none)]
pub fn hideOtherApplications(&self, sender: Option<&AnyObject>);
#[unsafe(method(unhideAllApplications:))]
#[unsafe(method_family = none)]
pub fn unhideAllApplications(&self, sender: Option<&AnyObject>);
#[unsafe(method(finishLaunching))]
#[unsafe(method_family = none)]
pub fn finishLaunching(&self);
#[unsafe(method(run))]
#[unsafe(method_family = none)]
pub fn run(&self);
#[cfg(feature = "NSWindow")]
#[unsafe(method(runModalForWindow:))]
#[unsafe(method_family = none)]
pub fn runModalForWindow(&self, window: &NSWindow) -> NSModalResponse;
#[unsafe(method(stop:))]
#[unsafe(method_family = none)]
pub fn stop(&self, sender: Option<&AnyObject>);
#[unsafe(method(stopModal))]
#[unsafe(method_family = none)]
pub fn stopModal(&self);
#[unsafe(method(stopModalWithCode:))]
#[unsafe(method_family = none)]
pub fn stopModalWithCode(&self, return_code: NSModalResponse);
#[unsafe(method(abortModal))]
#[unsafe(method_family = none)]
pub fn abortModal(&self);
#[cfg(feature = "NSWindow")]
#[unsafe(method(modalWindow))]
#[unsafe(method_family = none)]
pub fn modalWindow(&self) -> Option<Retained<NSWindow>>;
#[cfg(feature = "NSWindow")]
#[unsafe(method(beginModalSessionForWindow:))]
#[unsafe(method_family = none)]
pub fn beginModalSessionForWindow(&self, window: &NSWindow) -> NSModalSession;
/// # Safety
///
/// `session` must be a valid pointer.
#[unsafe(method(runModalSession:))]
#[unsafe(method_family = none)]
pub unsafe fn runModalSession(&self, session: NSModalSession) -> NSModalResponse;
/// # Safety
///
/// `session` must be a valid pointer.
#[unsafe(method(endModalSession:))]
#[unsafe(method_family = none)]
pub unsafe fn endModalSession(&self, session: NSModalSession);
#[unsafe(method(terminate:))]
#[unsafe(method_family = none)]
pub fn terminate(&self, sender: Option<&AnyObject>);
/// Inform the user that this application needs attention - call this method only if your application is not already active.
#[unsafe(method(requestUserAttention:))]
#[unsafe(method_family = none)]
pub fn requestUserAttention(&self, request_type: NSRequestUserAttentionType) -> NSInteger;
#[unsafe(method(cancelUserAttentionRequest:))]
#[unsafe(method_family = none)]
pub fn cancelUserAttentionRequest(&self, request: NSInteger);
#[cfg(all(feature = "NSWindow", feature = "block2"))]
/// Execute a block for each of the app's windows. Set `*stop = YES` if desired, to halt the enumeration early.
#[unsafe(method(enumerateWindowsWithOptions:usingBlock:))]
#[unsafe(method_family = none)]
pub fn enumerateWindowsWithOptions_usingBlock(
&self,
options: NSWindowListOptions,
block: &block2::DynBlock<dyn Fn(NonNull<NSWindow>, NonNull<Bool>) + '_>,
);
#[unsafe(method(preventWindowOrdering))]
#[unsafe(method_family = none)]
pub fn preventWindowOrdering(&self);
#[cfg(feature = "NSWindow")]
#[unsafe(method(windows))]
#[unsafe(method_family = none)]
pub fn windows(&self) -> Retained<NSArray<NSWindow>>;
#[unsafe(method(setWindowsNeedUpdate:))]
#[unsafe(method_family = none)]
pub fn setWindowsNeedUpdate(&self, need_update: bool);
#[unsafe(method(updateWindows))]
#[unsafe(method_family = none)]
pub fn updateWindows(&self);
#[cfg(feature = "NSMenu")]
#[unsafe(method(mainMenu))]
#[unsafe(method_family = none)]
pub fn mainMenu(&self) -> Option<Retained<NSMenu>>;
#[cfg(feature = "NSMenu")]
/// Setter for [`mainMenu`][Self::mainMenu].
#[unsafe(method(setMainMenu:))]
#[unsafe(method_family = none)]
pub fn setMainMenu(&self, main_menu: Option<&NSMenu>);
#[cfg(feature = "NSMenu")]
/// Set or get the Help menu for the app. If a non-nil menu is set as the Help menu, Spotlight for Help will be installed in it; otherwise AppKit will install Spotlight for Help into a menu of its choosing (and that menu is not returned from `-helpMenu`). If you wish to completely suppress Spotlight for Help, you can set a menu that does not appear in the menu bar.
/// `NSApplication`retains its Help menu and releases it when a different menu is set.
#[unsafe(method(helpMenu))]
#[unsafe(method_family = none)]
pub fn helpMenu(&self) -> Option<Retained<NSMenu>>;
#[cfg(feature = "NSMenu")]
/// Setter for [`helpMenu`][Self::helpMenu].
#[unsafe(method(setHelpMenu:))]
#[unsafe(method_family = none)]
pub fn setHelpMenu(&self, help_menu: Option<&NSMenu>);
#[cfg(feature = "NSImage")]
#[unsafe(method(applicationIconImage))]
#[unsafe(method_family = none)]
pub fn applicationIconImage(&self) -> Option<Retained<NSImage>>;
#[cfg(feature = "NSImage")]
/// Setter for [`applicationIconImage`][Self::applicationIconImage].
///
/// # Safety
///
/// `application_icon_image` might not allow `None`.
#[unsafe(method(setApplicationIconImage:))]
#[unsafe(method_family = none)]
pub unsafe fn setApplicationIconImage(&self, application_icon_image: Option<&NSImage>);
#[cfg(feature = "NSRunningApplication")]
/// Returns: The activation policy of the application.
#[unsafe(method(activationPolicy))]
#[unsafe(method_family = none)]
pub fn activationPolicy(&self) -> NSApplicationActivationPolicy;
#[cfg(feature = "NSRunningApplication")]
/// Attempts to modify the application's activation policy. In OS X 10.9, any policy may be set; prior to 10.9, the activation policy may be changed to
/// `NSApplicationActivationPolicyProhibited`or
/// `NSApplicationActivationPolicyRegular,`but may not be changed to
/// `NSApplicationActivationPolicyAccessory.`This returns
/// `YES`if setting the activation policy is successful, and
/// `NO`if not.
#[unsafe(method(setActivationPolicy:))]
#[unsafe(method_family = none)]
pub fn setActivationPolicy(&self, activation_policy: NSApplicationActivationPolicy)
-> bool;
#[cfg(feature = "NSDockTile")]
#[unsafe(method(dockTile))]
#[unsafe(method_family = none)]
pub fn dockTile(&self) -> Retained<NSDockTile>;
#[unsafe(method(reportException:))]
#[unsafe(method_family = none)]
pub fn reportException(&self, exception: &NSException);
/// # Safety
///
/// - `selector` must be a valid selector.
/// - `target` should be of the correct type.
/// - `argument` should be of the correct type.
#[unsafe(method(detachDrawingThread:toTarget:withObject:))]
#[unsafe(method_family = none)]
pub unsafe fn detachDrawingThread_toTarget_withObject(
selector: Sel,
target: &AnyObject,
argument: Option<&AnyObject>,
mtm: MainThreadMarker,
);
/// If an application delegate returns NSTerminateLater from -applicationShouldTerminate:, -replyToApplicationShouldTerminate: must be called with YES or NO once the application decides if it can terminate.
#[unsafe(method(replyToApplicationShouldTerminate:))]
#[unsafe(method_family = none)]
pub fn replyToApplicationShouldTerminate(&self, should_terminate: bool);
/// If an application delegate encounters an error while handling `-application:openFiles:` or` -application:printFiles:`, `-replyToOpenOrPrint:` should be called with
/// `NSApplicationDelegateReplyFailure.`If the user cancels the operation,
/// `NSApplicationDelegateReplyCancel`should be used, and if the operation succeeds,
/// `NSApplicationDelegateReplySuccess`should be used .
#[unsafe(method(replyToOpenOrPrint:))]
#[unsafe(method_family = none)]
pub fn replyToOpenOrPrint(&self, reply: NSApplicationDelegateReply);
/// Opens the character palette.
#[unsafe(method(orderFrontCharacterPalette:))]
#[unsafe(method_family = none)]
pub fn orderFrontCharacterPalette(&self, sender: Option<&AnyObject>);
/// Gets or sets the
/// `presentationOptions`that should be in effect for the system when this application is the active application. Only certain combinations of
/// `NSApplicationPresentationOptions`flags are allowed, as detailed in the AppKit Release Notes and the reference documentation for `-setPresentationOptions:`. When given an invalid combination of option flags, `-setPresentationOptions:` raises an exception.
#[unsafe(method(presentationOptions))]
#[unsafe(method_family = none)]
pub fn presentationOptions(&self) -> NSApplicationPresentationOptions;
/// Setter for [`presentationOptions`][Self::presentationOptions].
#[unsafe(method(setPresentationOptions:))]
#[unsafe(method_family = none)]
pub fn setPresentationOptions(
&self,
presentation_options: NSApplicationPresentationOptions,
);
/// Returns: The set of application presentation options that are currently in effect for the system.
/// These are the presentation options that have been put into effect by the currently active application.
#[unsafe(method(currentSystemPresentationOptions))]
#[unsafe(method_family = none)]
pub fn currentSystemPresentationOptions(&self) -> NSApplicationPresentationOptions;
#[unsafe(method(occlusionState))]
#[unsafe(method_family = none)]
pub fn occlusionState(&self) -> NSApplicationOcclusionState;
#[unsafe(method(isProtectedDataAvailable))]
#[unsafe(method_family = none)]
pub fn isProtectedDataAvailable(&self) -> bool;
);
}
/// Methods declared on superclass `NSResponder`.
#[cfg(feature = "NSResponder")]
impl NSApplication {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
/// # Safety
///
/// `coder` possibly has further requirements.
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>;
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSResponder")]
impl NSApplication {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}
/// NSAppearanceCustomization.
#[cfg(feature = "NSResponder")]
impl NSApplication {
extern_methods!(
#[cfg(feature = "NSAppearance")]
#[unsafe(method(appearance))]
#[unsafe(method_family = none)]
pub fn appearance(&self) -> Option<Retained<NSAppearance>>;
#[cfg(feature = "NSAppearance")]
/// Setter for [`appearance`][Self::appearance].
#[unsafe(method(setAppearance:))]
#[unsafe(method_family = none)]
pub fn setAppearance(&self, appearance: Option<&NSAppearance>);
#[cfg(feature = "NSAppearance")]
#[unsafe(method(effectiveAppearance))]
#[unsafe(method_family = none)]
pub fn effectiveAppearance(&self) -> Retained<NSAppearance>;
);
}
#[cfg(all(feature = "NSAppearance", feature = "NSResponder"))]
extern_conformance!(
unsafe impl NSAppearanceCustomization for NSApplication {}
);
/// NSEvent.
#[cfg(feature = "NSResponder")]
impl NSApplication {
extern_methods!(
#[cfg(feature = "NSEvent")]
#[unsafe(method(sendEvent:))]
#[unsafe(method_family = none)]
pub fn sendEvent(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(postEvent:atStart:))]
#[unsafe(method_family = none)]
pub fn postEvent_atStart(&self, event: &NSEvent, at_start: bool);
#[cfg(feature = "NSEvent")]
#[unsafe(method(currentEvent))]
#[unsafe(method_family = none)]
pub fn currentEvent(&self) -> Option<Retained<NSEvent>>;
#[cfg(feature = "NSEvent")]
#[unsafe(method(nextEventMatchingMask:untilDate:inMode:dequeue:))]
#[unsafe(method_family = none)]
pub fn nextEventMatchingMask_untilDate_inMode_dequeue(
&self,
mask: NSEventMask,
expiration: Option<&NSDate>,
mode: &NSRunLoopMode,
deq_flag: bool,
) -> Option<Retained<NSEvent>>;
#[cfg(feature = "NSEvent")]
#[unsafe(method(discardEventsMatchingMask:beforeEvent:))]
#[unsafe(method_family = none)]
pub fn discardEventsMatchingMask_beforeEvent(
&self,
mask: NSEventMask,
last_event: Option<&NSEvent>,
);
);
}
/// NSResponder.
#[cfg(feature = "NSResponder")]
impl NSApplication {
extern_methods!(
/// # Safety
///
/// - `action` must be a valid selector.
/// - `target` should be of the correct type.
/// - `sender` should be of the correct type.
#[unsafe(method(sendAction:to:from:))]
#[unsafe(method_family = none)]
pub unsafe fn sendAction_to_from(
&self,
action: Sel,
target: Option<&AnyObject>,
sender: Option<&AnyObject>,
) -> bool;
/// # Safety
///
/// `action` must be a valid selector.
#[unsafe(method(targetForAction:))]
#[unsafe(method_family = none)]
pub unsafe fn targetForAction(&self, action: Sel) -> Option<Retained<AnyObject>>;
/// # Safety
///
/// - `action` must be a valid selector.
/// - `target` should be of the correct type.
/// - `sender` should be of the correct type.
#[unsafe(method(targetForAction:to:from:))]
#[unsafe(method_family = none)]
pub unsafe fn targetForAction_to_from(
&self,
action: Sel,
target: Option<&AnyObject>,
sender: Option<&AnyObject>,
) -> Option<Retained<AnyObject>>;
/// # Safety
///
/// - `action` must be a valid selector.
/// - `object` should be of the correct type.
#[unsafe(method(tryToPerform:with:))]
#[unsafe(method_family = none)]
pub unsafe fn tryToPerform_with(&self, action: Sel, object: Option<&AnyObject>) -> bool;
#[cfg(feature = "NSPasteboard")]
#[unsafe(method(validRequestorForSendType:returnType:))]
#[unsafe(method_family = none)]
pub fn validRequestorForSendType_returnType(
&self,
send_type: Option<&NSPasteboardType>,
return_type: Option<&NSPasteboardType>,
) -> Option<Retained<AnyObject>>;
);
}
/// NSWindowsMenu.
#[cfg(feature = "NSResponder")]
impl NSApplication {
extern_methods!(
#[cfg(feature = "NSMenu")]
#[unsafe(method(windowsMenu))]
#[unsafe(method_family = none)]
pub fn windowsMenu(&self) -> Option<Retained<NSMenu>>;
#[cfg(feature = "NSMenu")]
/// Setter for [`windowsMenu`][Self::windowsMenu].
#[unsafe(method(setWindowsMenu:))]
#[unsafe(method_family = none)]
pub fn setWindowsMenu(&self, windows_menu: Option<&NSMenu>);
#[unsafe(method(arrangeInFront:))]
#[unsafe(method_family = none)]
pub fn arrangeInFront(&self, sender: Option<&AnyObject>);
#[cfg(feature = "NSWindow")]
#[unsafe(method(removeWindowsItem:))]
#[unsafe(method_family = none)]
pub fn removeWindowsItem(&self, win: &NSWindow);
#[cfg(feature = "NSWindow")]
#[unsafe(method(addWindowsItem:title:filename:))]
#[unsafe(method_family = none)]
pub fn addWindowsItem_title_filename(
&self,
win: &NSWindow,
string: &NSString,
is_filename: bool,
);
#[cfg(feature = "NSWindow")]
#[unsafe(method(changeWindowsItem:title:filename:))]
#[unsafe(method_family = none)]
pub fn changeWindowsItem_title_filename(
&self,
win: &NSWindow,
string: &NSString,
is_filename: bool,
);
#[cfg(feature = "NSWindow")]
#[unsafe(method(updateWindowsItem:))]
#[unsafe(method_family = none)]
pub fn updateWindowsItem(&self, win: &NSWindow);
#[unsafe(method(miniaturizeAll:))]
#[unsafe(method_family = none)]
pub fn miniaturizeAll(&self, sender: Option<&AnyObject>);
);
}
/// NSFullKeyboardAccess.
#[cfg(feature = "NSResponder")]
impl NSApplication {
extern_methods!(
/// A Boolean value indicating whether keyboard navigation is enabled in System Settings > Keyboard.
/// - Note: The value of this property is `YES` if keyboard navigation is enabled or `NO` if it’s not. You might use this value to implement your own key loop or to implement in-control tabbing behavior similar to `NSTableView`. Because of the nature of the preference storage, you won’t be notified of changes to this property if you attempt to observe it through key-value observing; however, accessing this property is fairly inexpensive, so you can access it directly rather than caching it.
/// - Note: This property’s value isn’t necessarily reflective of the separate accessibility setting named “Full Keyboard Access” in System Settings > Accessibility > Keyboard.
#[unsafe(method(isFullKeyboardAccessEnabled))]
#[unsafe(method_family = none)]
pub fn isFullKeyboardAccessEnabled(&self) -> bool;
);
}
/// Return values for `-applicationShouldTerminate:`.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationterminatereply?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSApplicationTerminateReply(pub NSUInteger);
impl NSApplicationTerminateReply {
#[doc(alias = "NSTerminateCancel")]
pub const TerminateCancel: Self = Self(0);
#[doc(alias = "NSTerminateNow")]
pub const TerminateNow: Self = Self(1);
#[doc(alias = "NSTerminateLater")]
pub const TerminateLater: Self = Self(2);
}
unsafe impl Encode for NSApplicationTerminateReply {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSApplicationTerminateReply {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// Return values for `-application:printFiles:withSettings:showPrintPanels:`.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationprintreply?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSApplicationPrintReply(pub NSUInteger);
impl NSApplicationPrintReply {
#[doc(alias = "NSPrintingCancelled")]
pub const PrintingCancelled: Self = Self(0);
#[doc(alias = "NSPrintingSuccess")]
pub const PrintingSuccess: Self = Self(1);
#[doc(alias = "NSPrintingReplyLater")]
pub const PrintingReplyLater: Self = Self(2);
#[doc(alias = "NSPrintingFailure")]
pub const PrintingFailure: Self = Self(3);
}
unsafe impl Encode for NSApplicationPrintReply {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSApplicationPrintReply {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationdelegate?language=objc)
pub unsafe trait NSApplicationDelegate: NSObjectProtocol + MainThreadOnly {
#[cfg(feature = "NSResponder")]
/// Allowable return values are:
/// `NSTerminateNow`- it is ok to proceed with termination
/// `NSTerminateCancel`- the application should not be terminated
/// `NSTerminateLater`- it may be ok to proceed with termination later. The application must call `-replyToApplicationShouldTerminate:` with
/// `YES`or
/// `NO`once the answer is known
///
/// Note: This return value is for delegates who need to provide document modal alerts (sheets) in order to decide whether to quit.
#[optional]
#[unsafe(method(applicationShouldTerminate:))]
#[unsafe(method_family = none)]
fn applicationShouldTerminate(&self, sender: &NSApplication)
-> NSApplicationTerminateReply;
#[cfg(feature = "NSResponder")]
/// This will be called for any URLs your application is asked to open. This includes URL types (CFBundleURLTypes) defined in your Info.plist, and Document types (
/// `CFBundleDocumentTypes)`that have no associated
/// `NSDocument`class. Document URLs that have an associated
/// `NSDocument`class will be opened through
/// `NSDocumentController.`If this is implemented, `-application:openFiles:` and `-application:openFile:` will not be called.
#[optional]
#[unsafe(method(application:openURLs:))]
#[unsafe(method_family = none)]
fn application_openURLs(&self, application: &NSApplication, urls: &NSArray<NSURL>);
#[cfg(feature = "NSResponder")]
#[optional]
#[unsafe(method(application:openFile:))]
#[unsafe(method_family = none)]
fn application_openFile(&self, sender: &NSApplication, filename: &NSString) -> bool;
#[cfg(feature = "NSResponder")]
#[optional]
#[unsafe(method(application:openFiles:))]
#[unsafe(method_family = none)]
fn application_openFiles(&self, sender: &NSApplication, filenames: &NSArray<NSString>);
#[cfg(feature = "NSResponder")]
#[optional]
#[unsafe(method(application:openTempFile:))]
#[unsafe(method_family = none)]
fn application_openTempFile(&self, sender: &NSApplication, filename: &NSString) -> bool;
#[cfg(feature = "NSResponder")]
#[optional]
#[unsafe(method(applicationShouldOpenUntitledFile:))]
#[unsafe(method_family = none)]
fn applicationShouldOpenUntitledFile(&self, sender: &NSApplication) -> bool;
#[cfg(feature = "NSResponder")]
#[optional]
#[unsafe(method(applicationOpenUntitledFile:))]
#[unsafe(method_family = none)]
fn applicationOpenUntitledFile(&self, sender: &NSApplication) -> bool;
/// # Safety
///
/// `sender` should be of the correct type.
#[optional]
#[unsafe(method(application:openFileWithoutUI:))]
#[unsafe(method_family = none)]
unsafe fn application_openFileWithoutUI(
&self,
sender: &AnyObject,
filename: &NSString,
) -> bool;
#[cfg(feature = "NSResponder")]
#[optional]
#[unsafe(method(application:printFile:))]
#[unsafe(method_family = none)]
fn application_printFile(&self, sender: &NSApplication, filename: &NSString) -> bool;
#[cfg(all(feature = "NSPrintInfo", feature = "NSResponder"))]
/// # Safety
///
/// `print_settings` generic should be of the correct type.
#[optional]
#[unsafe(method(application:printFiles:withSettings:showPrintPanels:))]
#[unsafe(method_family = none)]
unsafe fn application_printFiles_withSettings_showPrintPanels(
&self,
application: &NSApplication,
file_names: &NSArray<NSString>,
print_settings: &NSDictionary<NSPrintInfoAttributeKey, AnyObject>,
show_print_panels: bool,
) -> NSApplicationPrintReply;
#[cfg(feature = "NSResponder")]
#[optional]
#[unsafe(method(applicationShouldTerminateAfterLastWindowClosed:))]
#[unsafe(method_family = none)]
fn applicationShouldTerminateAfterLastWindowClosed(&self, sender: &NSApplication) -> bool;
#[cfg(feature = "NSResponder")]
#[optional]
#[unsafe(method(applicationShouldHandleReopen:hasVisibleWindows:))]
#[unsafe(method_family = none)]
fn applicationShouldHandleReopen_hasVisibleWindows(
&self,
sender: &NSApplication,
has_visible_windows: bool,
) -> bool;
#[cfg(all(feature = "NSMenu", feature = "NSResponder"))]
#[optional]
#[unsafe(method(applicationDockMenu:))]
#[unsafe(method_family = none)]
fn applicationDockMenu(&self, sender: &NSApplication) -> Option<Retained<NSMenu>>;
#[cfg(feature = "NSResponder")]
#[optional]
#[unsafe(method(application:willPresentError:))]
#[unsafe(method_family = none)]
fn application_willPresentError(
&self,
application: &NSApplication,
error: &NSError,
) -> Retained<NSError>;
#[cfg(feature = "NSResponder")]
#[optional]
#[unsafe(method(application:didRegisterForRemoteNotificationsWithDeviceToken:))]
#[unsafe(method_family = none)]
fn application_didRegisterForRemoteNotificationsWithDeviceToken(
&self,
application: &NSApplication,
device_token: &NSData,
);
#[cfg(feature = "NSResponder")]
#[optional]
#[unsafe(method(application:didFailToRegisterForRemoteNotificationsWithError:))]
#[unsafe(method_family = none)]
fn application_didFailToRegisterForRemoteNotificationsWithError(
&self,
application: &NSApplication,
error: &NSError,
);
#[cfg(feature = "NSResponder")]
/// # Safety
///
/// `user_info` generic should be of the correct type.
#[optional]
#[unsafe(method(application:didReceiveRemoteNotification:))]
#[unsafe(method_family = none)]
unsafe fn application_didReceiveRemoteNotification(
&self,
application: &NSApplication,
user_info: &NSDictionary<NSString, AnyObject>,
);
#[cfg(feature = "NSResponder")]
/// Method to opt-in to secure restorable state.
///
/// When this returns
/// `YES:`NSCoders that are passed into the various
/// `NSWindowRestoration`methods will
/// `requiresSecureCoding`and have a
/// `decodingFailurePolicy`of
/// `NSDecodingFailurePolicySetErrorAndReturn.`Any
/// `restorationClass`set on a window must explicitly conform to
/// `NSWindowRestoration.`This method will be called prior to any state encoding or restoration.
#[optional]
#[unsafe(method(applicationSupportsSecureRestorableState:))]
#[unsafe(method_family = none)]
fn applicationSupportsSecureRestorableState(&self, app: &NSApplication) -> bool;
#[cfg(feature = "NSResponder")]
/// Method called by `-[NSApplication encodeRestorableStateWithCoder:]` to give the delegate a chance to encode any additional state into the
/// `NSCoder.`If the restorable state managed by the delegate changes, you must call `-[NSApplication invalidateRestorableState]` so that it will be re-encoded. See the header `NSWindowRestoration.h` for more information.
///
/// # Safety
///
/// `coder` possibly has further requirements.
#[optional]
#[unsafe(method(application:willEncodeRestorableState:))]
#[unsafe(method_family = none)]
unsafe fn application_willEncodeRestorableState(
&self,
app: &NSApplication,
coder: &NSCoder,
);
#[cfg(feature = "NSResponder")]
/// Method called by `-[NSApplication restoreStateWithCoder:]` to give the delegate a chance to restore its own state, which it may decode from the
/// `NSCoder.`See the header `NSWindowRestoration.h` for more information.
///
/// # Safety
///
/// `coder` possibly has further requirements.
#[optional]
#[unsafe(method(application:didDecodeRestorableState:))]
#[unsafe(method_family = none)]
unsafe fn application_didDecodeRestorableState(&self, app: &NSApplication, coder: &NSCoder);
#[cfg(feature = "NSResponder")]
/// This will be called on the main thread as soon as the user indicates they want to continue an activity in your application. The
/// `NSUserActivity`object may not be available instantly, so use this as an opportunity to show the user that an activity will be continued shortly. Return
/// `YES`to indicate that you are doing so. Return
/// `NO`(or leave it unimplemented) and AppKit/UIKit will put up a default UI.
///
/// For each `-application:willContinueUserActivityWithType:` invocation, you are guaranteed to get exactly one invocation of `-application:continueUserActivity:restorationHandler:` on success, or `-application:didFailToContinueUserActivityWithType:error:` if an error was encountered.
#[optional]
#[unsafe(method(application:willContinueUserActivityWithType:))]
#[unsafe(method_family = none)]
fn application_willContinueUserActivityWithType(
&self,
application: &NSApplication,
user_activity_type: &NSString,
) -> bool;
#[cfg(all(
feature = "NSResponder",
feature = "NSUserActivity",
feature = "block2"
))]
/// This will be called on the main thread after the
/// `NSUserActivity`object is available. Use the data you stored in the NSUserActivity object to re-create what the user was doing.
///
///
/// Returns: `YES`to indicate that the activity was handled. Return
/// `NO`(or leave it unimplemented) and AppKit will attempt to continue the user activity.
///
/// You should create/fetch any restorable objects associated with the user activity, and pass them to the restorationHandler. They will then get the above `-restoreUserActivityState:` method invoked with the user activity. Invoking the
/// `restorationHandler`is optional. It may be copied and invoked later, but must be invoked on the main thread.
///
/// If this user activity was created automatically by having
/// `NSUbiquitousDocumentUserActivityType`in a
/// `CFBundleDocumentTypes`entry, AppKit can automatically restore the NSUserActivity on OS X if NO is returned, or this method is unimplemented. It will do so by creating a document of the appropriate type using the URL stored in the userInfo under the
/// `NSUserActivityDocumentURLKey.`The document will have `-restoreUserActivity:` called on it.
#[optional]
#[unsafe(method(application:continueUserActivity:restorationHandler:))]
#[unsafe(method_family = none)]
fn application_continueUserActivity_restorationHandler(
&self,
application: &NSApplication,
user_activity: &NSUserActivity,
restoration_handler: &block2::DynBlock<
dyn Fn(NonNull<NSArray<ProtocolObject<dyn NSUserActivityRestoring>>>),
>,
) -> bool;
#[cfg(feature = "NSResponder")]
/// There are instances where continuing a
/// `NSUserActivity`may fail. This will get called on the main thread if it does so. If it is unimplemented, AppKit will present the error.
#[optional]
#[unsafe(method(application:didFailToContinueUserActivityWithType:error:))]
#[unsafe(method_family = none)]
fn application_didFailToContinueUserActivityWithType_error(
&self,
application: &NSApplication,
user_activity_type: &NSString,
error: &NSError,
);
#[cfg(feature = "NSResponder")]
/// This will be called on the main thread when a user activity managed by AppKit/UIKit has been updated. You should use this as a last chance to add additional data to the
/// `userActivity.`
#[optional]
#[unsafe(method(application:didUpdateUserActivity:))]
#[unsafe(method_family = none)]
fn application_didUpdateUserActivity(
&self,
application: &NSApplication,
user_activity: &NSUserActivity,
);
#[cfg(all(feature = "NSResponder", feature = "objc2-cloud-kit"))]
#[cfg(target_vendor = "apple")]
/// This will be called on the main thread after the user indicates they want to accept a CloudKit sharing invitation in your application.
///
/// You should use the
/// `CKShareMetadata`object's
/// `shareURL`and containerIdentifier to schedule a
/// `CKAcceptSharesOperation,`then start using the resulting
/// `CKShare`and its associated record(s), which will appear in the
/// `CKContainer's`shared database in a zone matching that of the record's owner.
#[optional]
#[unsafe(method(application:userDidAcceptCloudKitShareWithMetadata:))]
#[unsafe(method_family = none)]
fn application_userDidAcceptCloudKitShareWithMetadata(
&self,
application: &NSApplication,
metadata: &CKShareMetadata,
);
#[cfg(feature = "NSResponder")]
/// Returns: `YES`if the receiving delegate object can respond to key value coding messages for a specific keyed attribute, to-one relationship, or to-many relationship. Return
/// `NO`otherwise.
#[optional]
#[unsafe(method(application:delegateHandlesKey:))]
#[unsafe(method_family = none)]
fn application_delegateHandlesKey(&self, sender: &NSApplication, key: &NSString) -> bool;
#[cfg(feature = "NSResponder")]
/// This method will be called once during application launch at `-[NSApplication finishLaunching]`.
///
///
/// Returns: `NO`if the receiving delegate object wishes to opt-out of system-wide keyboard shortcut localization for all application-supplied menus. Return
/// `YES`by default for apps linked against 12.0 and later SDK.
#[optional]
#[unsafe(method(applicationShouldAutomaticallyLocalizeKeyEquivalents:))]
#[unsafe(method_family = none)]
fn applicationShouldAutomaticallyLocalizeKeyEquivalents(
&self,
application: &NSApplication,
) -> bool;
#[optional]
#[unsafe(method(applicationWillFinishLaunching:))]
#[unsafe(method_family = none)]
fn applicationWillFinishLaunching(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationDidFinishLaunching:))]
#[unsafe(method_family = none)]
fn applicationDidFinishLaunching(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationWillHide:))]
#[unsafe(method_family = none)]
fn applicationWillHide(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationDidHide:))]
#[unsafe(method_family = none)]
fn applicationDidHide(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationWillUnhide:))]
#[unsafe(method_family = none)]
fn applicationWillUnhide(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationDidUnhide:))]
#[unsafe(method_family = none)]
fn applicationDidUnhide(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationWillBecomeActive:))]
#[unsafe(method_family = none)]
fn applicationWillBecomeActive(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationDidBecomeActive:))]
#[unsafe(method_family = none)]
fn applicationDidBecomeActive(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationWillResignActive:))]
#[unsafe(method_family = none)]
fn applicationWillResignActive(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationDidResignActive:))]
#[unsafe(method_family = none)]
fn applicationDidResignActive(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationWillUpdate:))]
#[unsafe(method_family = none)]
fn applicationWillUpdate(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationDidUpdate:))]
#[unsafe(method_family = none)]
fn applicationDidUpdate(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationWillTerminate:))]
#[unsafe(method_family = none)]
fn applicationWillTerminate(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationDidChangeScreenParameters:))]
#[unsafe(method_family = none)]
fn applicationDidChangeScreenParameters(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationDidChangeOcclusionState:))]
#[unsafe(method_family = none)]
fn applicationDidChangeOcclusionState(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationProtectedDataWillBecomeUnavailable:))]
#[unsafe(method_family = none)]
fn applicationProtectedDataWillBecomeUnavailable(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(applicationProtectedDataDidBecomeAvailable:))]
#[unsafe(method_family = none)]
fn applicationProtectedDataDidBecomeAvailable(&self, notification: &NSNotification);
}
);
/// NSServicesMenu.
#[cfg(feature = "NSResponder")]
impl NSApplication {
extern_methods!(
#[cfg(feature = "NSMenu")]
#[unsafe(method(servicesMenu))]
#[unsafe(method_family = none)]
pub fn servicesMenu(&self) -> Option<Retained<NSMenu>>;
#[cfg(feature = "NSMenu")]
/// Setter for [`servicesMenu`][Self::servicesMenu].
#[unsafe(method(setServicesMenu:))]
#[unsafe(method_family = none)]
pub fn setServicesMenu(&self, services_menu: Option<&NSMenu>);
#[cfg(feature = "NSPasteboard")]
#[unsafe(method(registerServicesMenuSendTypes:returnTypes:))]
#[unsafe(method_family = none)]
pub fn registerServicesMenuSendTypes_returnTypes(
&self,
send_types: &NSArray<NSPasteboardType>,
return_types: &NSArray<NSPasteboardType>,
);
);
}
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsservicesmenurequestor?language=objc)
pub unsafe trait NSServicesMenuRequestor: NSObjectProtocol {
#[cfg(feature = "NSPasteboard")]
#[optional]
#[unsafe(method(writeSelectionToPasteboard:types:))]
#[unsafe(method_family = none)]
fn writeSelectionToPasteboard_types(
&self,
pboard: &NSPasteboard,
types: &NSArray<NSPasteboardType>,
) -> bool;
#[cfg(feature = "NSPasteboard")]
#[optional]
#[unsafe(method(readSelectionFromPasteboard:))]
#[unsafe(method_family = none)]
fn readSelectionFromPasteboard(&self, pboard: &NSPasteboard) -> bool;
}
);
/// NSServicesHandling.
#[cfg(feature = "NSResponder")]
impl NSApplication {
extern_methods!(
#[unsafe(method(servicesProvider))]
#[unsafe(method_family = none)]
pub fn servicesProvider(&self) -> Option<Retained<AnyObject>>;
/// Setter for [`servicesProvider`][Self::servicesProvider].
///
/// # Safety
///
/// `services_provider` should be of the correct type.
#[unsafe(method(setServicesProvider:))]
#[unsafe(method_family = none)]
pub unsafe fn setServicesProvider(&self, services_provider: Option<&AnyObject>);
);
}
/// Optional keys in `-orderFrontStandardAboutPanelWithOptions:`
/// `optionsDictionary.`
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsaboutpaneloptionkey?language=objc)
// NS_TYPED_ENUM
pub type NSAboutPanelOptionKey = NSString;
extern "C" {
/// NSAttributedString displayed in the info area of the panel. If not specified, contents obtained from "Credits.rtf" (.rtfd, .html) in [NSBundle mainBundle]; if not available, blank. Note that in applications built against the 10.14 SDK or earlier, the credits are shown in light appearance even when the application is running in dark appearance, except when the credits are specified as an attributed string, or come from a file are the text is just pure black. In applications built against the 10.15 SDK or newer, credits will be shown in dark appearance, using the "adaptive color mapping" setting in NSTextView.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsaboutpaneloptioncredits?language=objc)
pub static NSAboutPanelOptionCredits: &'static NSAboutPanelOptionKey;
}
extern "C" {
/// NSString displayed in place of the default app name. If not specified, uses the value of CFBundleName (localizable). Fallback is [[NSProcessInfo processInfo] processName].
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsaboutpaneloptionapplicationname?language=objc)
pub static NSAboutPanelOptionApplicationName: &'static NSAboutPanelOptionKey;
}
extern "C" {
/// NSImage displayed in place of NSApplicationIcon. If not specified, use [NSImage imageNamed:
/// "
/// NSApplicationIcon"]; if not available, generic icon.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsaboutpaneloptionapplicationicon?language=objc)
pub static NSAboutPanelOptionApplicationIcon: &'static NSAboutPanelOptionKey;
}
extern "C" {
/// NSString containing the build version number of the application ("58.4", "1.2d3"); displayed as "Version 58.4" or "Version 1.0 (58.4) depending on the presence of ApplicationVersion. If not specified, obtain from the CFBundleVersion key in infoDictionary; if not specified or empty string, leave blank.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsaboutpaneloptionversion?language=objc)
pub static NSAboutPanelOptionVersion: &'static NSAboutPanelOptionKey;
}
extern "C" {
/// NSString displayed as the marketing version ("1.0", "Mac OS X", "3", "WebObjects 3.5", ...), before the build version. If not specified, obtain from CFBundleShortVersionString key in infoDictionary. Prefixed with word "Version" if it looks like a number.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsaboutpaneloptionapplicationversion?language=objc)
pub static NSAboutPanelOptionApplicationVersion: &'static NSAboutPanelOptionKey;
}
/// NSStandardAboutPanel.
#[cfg(feature = "NSResponder")]
impl NSApplication {
extern_methods!(
#[unsafe(method(orderFrontStandardAboutPanel:))]
#[unsafe(method_family = none)]
pub fn orderFrontStandardAboutPanel(&self, sender: Option<&AnyObject>);
/// # Safety
///
/// `options_dictionary` generic should be of the correct type.
#[unsafe(method(orderFrontStandardAboutPanelWithOptions:))]
#[unsafe(method_family = none)]
pub unsafe fn orderFrontStandardAboutPanelWithOptions(
&self,
options_dictionary: &NSDictionary<NSAboutPanelOptionKey, AnyObject>,
);
);
}
/// NSApplicationLayoutDirection.
#[cfg(feature = "NSResponder")]
impl NSApplication {
extern_methods!(
#[cfg(feature = "NSUserInterfaceLayout")]
#[unsafe(method(userInterfaceLayoutDirection))]
#[unsafe(method_family = none)]
pub fn userInterfaceLayoutDirection(&self) -> NSUserInterfaceLayoutDirection;
);
}
/// NSRestorableUserInterface.
#[cfg(feature = "NSResponder")]
impl NSApplication {
extern_methods!(
/// Disable or reenable relaunching this app on login, if the app was running at the time the user logged out. These methods increment and decrement a counter respectively; if the counter is 0 at the time the user logs out, then the app may be relaunched when the user logs back in. The counter is initially zero, so by default apps are relaunched.
///
/// If your app should not be relaunched because it launches via some other mechanism (e.g. launchd), then the recommended usage is to call `-[NSApp disableRelaunchOnLogin]` once, and never pair it with an -enable call.
///
/// If your app should not be relaunched because it triggers a restart (e.g. an installer), then the recommended usage is to call `-[NSApp disableRelaunchOnLogin]` immediately before you attempt to trigger a restart, and `-[NSApp enableRelaunchOnLogin]` immediately after. This is because the user may cancel restarting; if the user later restarts for another reason, then your app should be brought back.
///
/// These methods are thread safe.
#[unsafe(method(disableRelaunchOnLogin))]
#[unsafe(method_family = none)]
pub fn disableRelaunchOnLogin(&self);
#[unsafe(method(enableRelaunchOnLogin))]
#[unsafe(method_family = none)]
pub fn enableRelaunchOnLogin(&self);
);
}
/// Soft deprecated.
/// Please use `NSApplication`'s `-registerForRemoteNotifications` along with `-requestAuthorizationWithOptions:` from the `UserNotifications.framework` to specify allowable notification types.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsremotenotificationtype?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSRemoteNotificationType(pub NSUInteger);
bitflags::bitflags! {
impl NSRemoteNotificationType: NSUInteger {
#[doc(alias = "NSRemoteNotificationTypeNone")]
const None = 0;
#[doc(alias = "NSRemoteNotificationTypeBadge")]
const Badge = 1<<0;
#[doc(alias = "NSRemoteNotificationTypeSound")]
const Sound = 1<<1;
#[doc(alias = "NSRemoteNotificationTypeAlert")]
const Alert = 1<<2;
}
}
unsafe impl Encode for NSRemoteNotificationType {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSRemoteNotificationType {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// NSRemoteNotifications.
#[cfg(feature = "NSResponder")]
impl NSApplication {
extern_methods!(
#[unsafe(method(registerForRemoteNotifications))]
#[unsafe(method_family = none)]
pub fn registerForRemoteNotifications(&self);
#[unsafe(method(unregisterForRemoteNotifications))]
#[unsafe(method_family = none)]
pub fn unregisterForRemoteNotifications(&self);
/// Returns: `YES`if the application is currently registered for remote notifications, taking into account any systemwide settings; doesn't relate to connectivity.
#[unsafe(method(isRegisteredForRemoteNotifications))]
#[unsafe(method_family = none)]
pub fn isRegisteredForRemoteNotifications(&self) -> bool;
/// The following are soft deprecated.
/// Please use the `-registerForRemoteNotifications` above and `-requestAuthorizationWithOptions:` from `UserNotifications.framework`.
#[unsafe(method(registerForRemoteNotificationTypes:))]
#[unsafe(method_family = none)]
pub fn registerForRemoteNotificationTypes(&self, types: NSRemoteNotificationType);
#[unsafe(method(enabledRemoteNotificationTypes))]
#[unsafe(method_family = none)]
pub fn enabledRemoteNotificationTypes(&self) -> NSRemoteNotificationType;
);
}
#[cfg(feature = "NSResponder")]
impl NSApplication {
/// An Application's startup function.
///
/// # Safety
///
/// `argv` must be a valid pointer.
#[doc(alias = "NSApplicationMain")]
#[inline]
pub(crate) unsafe fn __main(argc: c_int, argv: NonNull<NonNull<c_char>>) -> c_int {
extern "C-unwind" {
fn NSApplicationMain(argc: c_int, argv: NonNull<NonNull<c_char>>) -> c_int;
}
unsafe { NSApplicationMain(argc, argv) }
}
/// `NSApplicationLoad`should be called when loading a Cocoa bundle in a Carbon app in order to initialize
/// `NSApplication`and other Cocoa objects. Redundant calls are ignored.
#[doc(alias = "NSApplicationLoad")]
#[inline]
pub fn load() -> bool {
extern "C-unwind" {
fn NSApplicationLoad() -> Bool;
}
unsafe { NSApplicationLoad() }.as_bool()
}
}
/// `NSShowsServicesMenuItem()`always returns
/// `YES.`
#[inline]
pub extern "C-unwind" fn NSShowsServicesMenuItem(item_name: &NSString) -> bool {
extern "C-unwind" {
fn NSShowsServicesMenuItem(item_name: &NSString) -> Bool;
}
unsafe { NSShowsServicesMenuItem(item_name) }.as_bool()
}
/// `NSSetShowsServicesMenuItem()`has no effect, and always returns 0.
#[inline]
pub extern "C-unwind" fn NSSetShowsServicesMenuItem(
item_name: &NSString,
enabled: bool,
) -> NSInteger {
extern "C-unwind" {
fn NSSetShowsServicesMenuItem(item_name: &NSString, enabled: Bool) -> NSInteger;
}
unsafe { NSSetShowsServicesMenuItem(item_name, Bool::new(enabled)) }
}
/// `NSUpdateDynamicServices()`causes the services information for the system to be updated.
/// This will only be necessary if your program adds dynamic services to the system (i.e. services not found in mach-o segments of executables).
#[inline]
pub extern "C-unwind" fn NSUpdateDynamicServices() {
extern "C-unwind" {
fn NSUpdateDynamicServices();
}
unsafe { NSUpdateDynamicServices() }
}
#[cfg(feature = "NSPasteboard")]
#[inline]
pub extern "C-unwind" fn NSPerformService(
item_name: &NSString,
pboard: Option<&NSPasteboard>,
) -> bool {
extern "C-unwind" {
fn NSPerformService(item_name: &NSString, pboard: Option<&NSPasteboard>) -> Bool;
}
unsafe { NSPerformService(item_name, pboard) }.as_bool()
}
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsserviceprovidername?language=objc)
pub type NSServiceProviderName = NSString;
extern "C-unwind" {
/// Apps should use -setServicesProvider.
///
/// # Safety
///
/// `provider` should be of the correct type.
pub fn NSRegisterServicesProvider(provider: Option<&AnyObject>, name: &NSServiceProviderName);
}
#[inline]
pub extern "C-unwind" fn NSUnregisterServicesProvider(name: &NSServiceProviderName) {
extern "C-unwind" {
fn NSUnregisterServicesProvider(name: &NSServiceProviderName);
}
unsafe { NSUnregisterServicesProvider(name) }
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationdidbecomeactivenotification?language=objc)
pub static NSApplicationDidBecomeActiveNotification: &'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationdidhidenotification?language=objc)
pub static NSApplicationDidHideNotification: &'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationdidfinishlaunchingnotification?language=objc)
pub static NSApplicationDidFinishLaunchingNotification: &'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationdidresignactivenotification?language=objc)
pub static NSApplicationDidResignActiveNotification: &'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationdidunhidenotification?language=objc)
pub static NSApplicationDidUnhideNotification: &'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationdidupdatenotification?language=objc)
pub static NSApplicationDidUpdateNotification: &'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationwillbecomeactivenotification?language=objc)
pub static NSApplicationWillBecomeActiveNotification: &'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationwillhidenotification?language=objc)
pub static NSApplicationWillHideNotification: &'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationwillfinishlaunchingnotification?language=objc)
pub static NSApplicationWillFinishLaunchingNotification: &'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationwillresignactivenotification?language=objc)
pub static NSApplicationWillResignActiveNotification: &'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationwillunhidenotification?language=objc)
pub static NSApplicationWillUnhideNotification: &'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationwillupdatenotification?language=objc)
pub static NSApplicationWillUpdateNotification: &'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationwillterminatenotification?language=objc)
pub static NSApplicationWillTerminateNotification: &'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationdidchangescreenparametersnotification?language=objc)
pub static NSApplicationDidChangeScreenParametersNotification: &'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationprotecteddatawillbecomeunavailablenotification?language=objc)
pub static NSApplicationProtectedDataWillBecomeUnavailableNotification:
&'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationprotecteddatadidbecomeavailablenotification?language=objc)
pub static NSApplicationProtectedDataDidBecomeAvailableNotification:
&'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationshouldbeginsuppressinghighdynamicrangecontentnotification?language=objc)
pub static NSApplicationShouldBeginSuppressingHighDynamicRangeContentNotification:
&'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationshouldendsuppressinghighdynamicrangecontentnotification?language=objc)
pub static NSApplicationShouldEndSuppressingHighDynamicRangeContentNotification:
&'static NSNotificationName;
}
extern "C" {
/// The following key is present in the userInfo of NSApplicationDidFinishLaunchingNotification. Its value is an NSNumber containing a bool. It will be NO if the app was launched to open or print a file, to perform a Service, if the app had saved state that will be restored, or if the app launch was in some other sense not a "default" launch. Otherwise its value will be YES.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationlaunchisdefaultlaunchkey?language=objc)
pub static NSApplicationLaunchIsDefaultLaunchKey: &'static NSString;
}
extern "C" {
/// The following key is present in the userInfo of NSApplicationDidFinishLaunchingNotification. It will be present if your application was launched because a user activated a notification in the Notification Center. Its value is an NSUserNotification object.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationlaunchusernotificationkey?language=objc)
pub static NSApplicationLaunchUserNotificationKey: &'static NSString;
}
extern "C" {
/// NSApplicationLaunchRemoteNotificationKey is unimplemented. Please use NSApplicationLaunchUserNotificationKey to get the NSUserNotification object. The NSUserNotification object has an isRemote property to indicate whether this application was launched as a result of a remote notification
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationlaunchremotenotificationkey?language=objc)
#[deprecated]
pub static NSApplicationLaunchRemoteNotificationKey: &'static NSString;
}
extern "C" {
/// Upon receiving this notification, you can query the NSApplication for its occlusion state. Note that this only notifies about changes in the state of the occlusion, not when the occlusion region changes. You can use this notification to increase responsiveness and save power, by halting any expensive calculations that the user can not see.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationdidchangeocclusionstatenotification?language=objc)
pub static NSApplicationDidChangeOcclusionStateNotification: &'static NSNotificationName;
}
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrunstoppedresponse?language=objc)
#[deprecated = "Use NSModalResponseStop instead"]
pub const NSRunStoppedResponse: c_int = -1000;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrunabortedresponse?language=objc)
#[deprecated = "Use NSModalResponseAbort instead"]
pub const NSRunAbortedResponse: c_int = -1001;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsruncontinuesresponse?language=objc)
#[deprecated = "Use NSModalResponseContinue instead"]
pub const NSRunContinuesResponse: c_int = -1002;
/// NSDeprecated.
#[cfg(feature = "NSResponder")]
impl NSApplication {
extern_methods!(
#[cfg(feature = "NSWindow")]
/// `-runModalForWindow:relativeToWindow:` was deprecated in Mac OS X 10.0. Please use `-[NSWindow beginSheet:completionHandler:]` instead.
///
/// # Safety
///
/// - `window` might not allow `None`.
/// - `doc_window` might not allow `None`.
#[deprecated = "Use -[NSWindow beginSheet:completionHandler:] instead"]
#[unsafe(method(runModalForWindow:relativeToWindow:))]
#[unsafe(method_family = none)]
pub unsafe fn runModalForWindow_relativeToWindow(
&self,
window: Option<&NSWindow>,
doc_window: Option<&NSWindow>,
) -> NSInteger;
#[cfg(feature = "NSWindow")]
/// `-beginModalSessionForWindow:relativeToWindow:` was deprecated in Mac OS X 10.0. Please use `-[NSWindow beginSheet:completionHandler:]` instead.
///
/// # Safety
///
/// - `window` might not allow `None`.
/// - `doc_window` might not allow `None`.
#[deprecated = "Use -[NSWindow beginSheet:completionHandler:] instead"]
#[unsafe(method(beginModalSessionForWindow:relativeToWindow:))]
#[unsafe(method_family = none)]
pub unsafe fn beginModalSessionForWindow_relativeToWindow(
&self,
window: Option<&NSWindow>,
doc_window: Option<&NSWindow>,
) -> NSModalSession;
/// `-application:printFiles:` was deprecated in Mac OS X 10.4.
/// Implement `-application:printFiles:withSettings:showPrintPanels:` in your application delegate instead.
///
/// # Safety
///
/// - `sender` might not allow `None`.
/// - `filenames` might not allow `None`.
#[deprecated]
#[unsafe(method(application:printFiles:))]
#[unsafe(method_family = none)]
pub unsafe fn application_printFiles(
&self,
sender: Option<&NSApplication>,
filenames: Option<&NSArray<NSString>>,
);
#[cfg(feature = "NSWindow")]
/// `NSWindow`'s `-beginSheet:completionHandler:` and `-endSheet:returnCode:` should be used instead. `NSApplication`'s `-beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:` will continue to work as it previously did, leaking contextInfo and failing when there is already an existing sheet.
///
/// # Safety
///
/// - `modal_delegate` should be of the correct type.
/// - `did_end_selector` must be a valid selector.
/// - `context_info` must be a valid pointer.
#[deprecated = "Use -[NSWindow beginSheet:completionHandler:] instead"]
#[unsafe(method(beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:))]
#[unsafe(method_family = none)]
pub unsafe fn beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo(
&self,
sheet: &NSWindow,
doc_window: &NSWindow,
modal_delegate: Option<&AnyObject>,
did_end_selector: Option<Sel>,
context_info: *mut c_void,
);
#[cfg(feature = "NSWindow")]
#[deprecated = "Use -[NSWindow endSheet:] instead"]
#[unsafe(method(endSheet:))]
#[unsafe(method_family = none)]
pub fn endSheet(&self, sheet: &NSWindow);
#[cfg(feature = "NSWindow")]
#[deprecated = "Use -[NSWindow endSheet:returnCode:] instead"]
#[unsafe(method(endSheet:returnCode:))]
#[unsafe(method_family = none)]
pub fn endSheet_returnCode(&self, sheet: &NSWindow, return_code: NSInteger);
#[cfg(feature = "NSWindow")]
/// # Safety
///
/// `selector` must be a valid selector.
#[deprecated = "Use -enumerateWindowsWithOptions:usingBlock: instead"]
#[unsafe(method(makeWindowsPerform:inOrder:))]
#[unsafe(method_family = none)]
pub unsafe fn makeWindowsPerform_inOrder(
&self,
selector: Sel,
in_order: bool,
) -> Option<Retained<NSWindow>>;
#[cfg(feature = "NSGraphicsContext")]
/// This method is deprecated as of macOS 10.12. Beginning in OS X 10.11 it would always return nil. Prior to this it would return an undefined graphics context that was not generally suitable for drawing.
#[deprecated = "This method always returns nil. If you need access to the current drawing context, use [NSGraphicsContext currentContext] inside of a draw operation."]
#[unsafe(method(context))]
#[unsafe(method_family = none)]
pub fn context(&self) -> Option<Retained<NSGraphicsContext>>;
);
}
extern "C-unwind" {
#[deprecated = "renamed to `NSApplication::__main`"]
pub fn NSApplicationMain(argc: c_int, argv: NonNull<NonNull<c_char>>) -> c_int;
}
#[deprecated = "renamed to `NSApplication::load`"]
#[inline]
pub extern "C-unwind" fn NSApplicationLoad() -> bool {
extern "C-unwind" {
fn NSApplicationLoad() -> Bool;
}
unsafe { NSApplicationLoad() }.as_bool()
}