objc2-app-kit 0.3.2

Bindings to the AppKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspanel?language=objc)
    #[unsafe(super(NSWindow, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
    pub struct NSPanel;
);

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSResponder",
    feature = "NSWindow"
))]
extern_conformance!(
    unsafe impl NSAccessibility for NSPanel {}
);

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSResponder",
    feature = "NSWindow"
))]
extern_conformance!(
    unsafe impl NSAccessibilityElementProtocol for NSPanel {}
);

#[cfg(all(feature = "NSAnimation", feature = "NSResponder", feature = "NSWindow"))]
extern_conformance!(
    unsafe impl NSAnimatablePropertyContainer for NSPanel {}
);

#[cfg(all(
    feature = "NSAppearance",
    feature = "NSResponder",
    feature = "NSWindow"
))]
extern_conformance!(
    unsafe impl NSAppearanceCustomization for NSPanel {}
);

#[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
extern_conformance!(
    unsafe impl NSCoding for NSPanel {}
);

#[cfg(all(feature = "NSMenu", feature = "NSResponder", feature = "NSWindow"))]
extern_conformance!(
    unsafe impl NSMenuItemValidation for NSPanel {}
);

#[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSPanel {}
);

#[cfg(all(
    feature = "NSResponder",
    feature = "NSUserInterfaceItemIdentification",
    feature = "NSWindow"
))]
extern_conformance!(
    unsafe impl NSUserInterfaceItemIdentification for NSPanel {}
);

#[cfg(all(
    feature = "NSResponder",
    feature = "NSUserInterfaceValidation",
    feature = "NSWindow"
))]
extern_conformance!(
    unsafe impl NSUserInterfaceValidations for NSPanel {}
);

#[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
impl NSPanel {
    extern_methods!(
        #[unsafe(method(isFloatingPanel))]
        #[unsafe(method_family = none)]
        pub fn isFloatingPanel(&self) -> bool;

        /// Setter for [`isFloatingPanel`][Self::isFloatingPanel].
        #[unsafe(method(setFloatingPanel:))]
        #[unsafe(method_family = none)]
        pub fn setFloatingPanel(&self, floating_panel: bool);

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

        /// Setter for [`becomesKeyOnlyIfNeeded`][Self::becomesKeyOnlyIfNeeded].
        #[unsafe(method(setBecomesKeyOnlyIfNeeded:))]
        #[unsafe(method_family = none)]
        pub fn setBecomesKeyOnlyIfNeeded(&self, becomes_key_only_if_needed: bool);

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

        /// Setter for [`worksWhenModal`][Self::worksWhenModal].
        #[unsafe(method(setWorksWhenModal:))]
        #[unsafe(method_family = none)]
        pub fn setWorksWhenModal(&self, works_when_modal: bool);
    );
}

/// Methods declared on superclass `NSWindow`.
#[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
impl NSPanel {
    extern_methods!(
        #[cfg(feature = "NSGraphics")]
        #[unsafe(method(initWithContentRect:styleMask:backing:defer:))]
        #[unsafe(method_family = init)]
        pub fn initWithContentRect_styleMask_backing_defer(
            this: Allocated<Self>,
            content_rect: NSRect,
            style: NSWindowStyleMask,
            backing_store_type: NSBackingStoreType,
            flag: bool,
        ) -> Retained<Self>;

        #[cfg(all(feature = "NSGraphics", feature = "NSScreen"))]
        #[unsafe(method(initWithContentRect:styleMask:backing:defer:screen:))]
        #[unsafe(method_family = init)]
        pub fn initWithContentRect_styleMask_backing_defer_screen(
            this: Allocated<Self>,
            content_rect: NSRect,
            style: NSWindowStyleMask,
            backing_store_type: NSBackingStoreType,
            flag: bool,
            screen: Option<&NSScreen>,
        ) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;

        #[cfg(feature = "NSViewController")]
        /// Convenience method for creating an autoreleased titled window with the given contentViewController. A basic NSWindow with the following attributes is made: titled, closable, resizable, miniaturizable. The window's title is automatically bound to the contentViewController's title. The size of the window can easily be controlled by utilizing autolayout and applying size constraints to the view (or its subviews). The window has isReleasedWhenClosed set to NO, and it must be explicitly retained to keep the window instance alive. To have it automatically be freed when it is closed, do the following: [window retain] and [window setReleasedWhenClosed:YES].
        #[unsafe(method(windowWithContentViewController:))]
        #[unsafe(method_family = none)]
        pub fn windowWithContentViewController(
            content_view_controller: &NSViewController,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSResponder`.
#[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
impl NSPanel {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
impl NSPanel {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

extern "C-unwind" {
    /// # Safety
    ///
    /// - `panel` should be of the correct type.
    /// - `panel` might not allow `None`.
    #[deprecated = "Use NSAlert instead"]
    pub fn NSReleaseAlertPanel(panel: Option<&AnyObject>);
}

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsalertdefaultreturn?language=objc)
#[deprecated = "Use NSAlertFirstButtonReturn with an NSAlert presentation instead"]
pub const NSAlertDefaultReturn: c_int = 1;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsalertalternatereturn?language=objc)
#[deprecated = "Use NSAlertFirstButtonReturn and other NSModalResponses with an NSAlert presentation instead"]
pub const NSAlertAlternateReturn: c_int = 0;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsalertotherreturn?language=objc)
#[deprecated = "Use NSAlertFirstButtonReturn and other NSModalResponses with an NSAlert presentation instead"]
pub const NSAlertOtherReturn: c_int = -1;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsalerterrorreturn?language=objc)
#[deprecated = "Use NSAlertFirstButtonReturn and other NSModalResponses with an NSAlert presentation instead"]
pub const NSAlertErrorReturn: c_int = -2;