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::*;

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspathstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPathStyle(pub NSInteger);
impl NSPathStyle {
    #[doc(alias = "NSPathStyleStandard")]
    pub const Standard: Self = Self(0);
    #[doc(alias = "NSPathStylePopUp")]
    pub const PopUp: Self = Self(2);
    #[doc(alias = "NSPathStyleNavigationBar")]
    #[deprecated]
    pub const NavigationBar: Self = Self(1);
}

unsafe impl Encode for NSPathStyle {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSPathStyle {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

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

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSActionCell",
    feature = "NSCell"
))]
extern_conformance!(
    unsafe impl NSAccessibility for NSPathCell {}
);

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSActionCell",
    feature = "NSCell"
))]
extern_conformance!(
    unsafe impl NSAccessibilityElementProtocol for NSPathCell {}
);

#[cfg(all(feature = "NSActionCell", feature = "NSCell"))]
extern_conformance!(
    unsafe impl NSCoding for NSPathCell {}
);

#[cfg(all(feature = "NSActionCell", feature = "NSCell"))]
extern_conformance!(
    unsafe impl NSCopying for NSPathCell {}
);

#[cfg(all(feature = "NSActionCell", feature = "NSCell"))]
unsafe impl CopyingHelper for NSPathCell {
    type Result = Self;
}

#[cfg(all(feature = "NSActionCell", feature = "NSCell", feature = "NSMenu"))]
extern_conformance!(
    unsafe impl NSMenuItemValidation for NSPathCell {}
);

#[cfg(all(feature = "NSActionCell", feature = "NSCell"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSPathCell {}
);

#[cfg(all(feature = "NSActionCell", feature = "NSCell", feature = "NSSavePanel"))]
extern_conformance!(
    unsafe impl NSOpenSavePanelDelegate for NSPathCell {}
);

#[cfg(all(
    feature = "NSActionCell",
    feature = "NSCell",
    feature = "NSUserInterfaceItemIdentification"
))]
extern_conformance!(
    unsafe impl NSUserInterfaceItemIdentification for NSPathCell {}
);

#[cfg(all(feature = "NSActionCell", feature = "NSCell"))]
impl NSPathCell {
    extern_methods!(
        #[unsafe(method(pathStyle))]
        #[unsafe(method_family = none)]
        pub fn pathStyle(&self) -> NSPathStyle;

        /// Setter for [`pathStyle`][Self::pathStyle].
        #[unsafe(method(setPathStyle:))]
        #[unsafe(method_family = none)]
        pub fn setPathStyle(&self, path_style: NSPathStyle);

        #[unsafe(method(URL))]
        #[unsafe(method_family = none)]
        pub fn URL(&self) -> Option<Retained<NSURL>>;

        /// Setter for [`URL`][Self::URL].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setURL:))]
        #[unsafe(method_family = none)]
        pub fn setURL(&self, url: Option<&NSURL>);

        /// # Safety
        ///
        /// `obj` should be of the correct type.
        #[unsafe(method(setObjectValue:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setObjectValue(&self, obj: Option<&ProtocolObject<dyn NSCopying>>);

        #[unsafe(method(allowedTypes))]
        #[unsafe(method_family = none)]
        pub fn allowedTypes(&self) -> Option<Retained<NSArray<NSString>>>;

        /// Setter for [`allowedTypes`][Self::allowedTypes].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setAllowedTypes:))]
        #[unsafe(method_family = none)]
        pub fn setAllowedTypes(&self, allowed_types: Option<&NSArray<NSString>>);

        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSPathCellDelegate>>>;

        /// 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 NSPathCellDelegate>>);

        #[unsafe(method(pathComponentCellClass))]
        #[unsafe(method_family = none)]
        pub fn pathComponentCellClass(mtm: MainThreadMarker) -> &'static AnyClass;

        #[cfg(all(feature = "NSPathComponentCell", feature = "NSTextFieldCell"))]
        #[unsafe(method(pathComponentCells))]
        #[unsafe(method_family = none)]
        pub fn pathComponentCells(&self) -> Retained<NSArray<NSPathComponentCell>>;

        #[cfg(all(feature = "NSPathComponentCell", feature = "NSTextFieldCell"))]
        /// Setter for [`pathComponentCells`][Self::pathComponentCells].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setPathComponentCells:))]
        #[unsafe(method_family = none)]
        pub fn setPathComponentCells(&self, path_component_cells: &NSArray<NSPathComponentCell>);

        #[cfg(all(
            feature = "NSPathComponentCell",
            feature = "NSResponder",
            feature = "NSTextFieldCell",
            feature = "NSView"
        ))]
        #[unsafe(method(rectOfPathComponentCell:withFrame:inView:))]
        #[unsafe(method_family = none)]
        pub fn rectOfPathComponentCell_withFrame_inView(
            &self,
            cell: &NSPathComponentCell,
            frame: NSRect,
            view: &NSView,
        ) -> NSRect;

        #[cfg(all(
            feature = "NSPathComponentCell",
            feature = "NSResponder",
            feature = "NSTextFieldCell",
            feature = "NSView"
        ))]
        #[unsafe(method(pathComponentCellAtPoint:withFrame:inView:))]
        #[unsafe(method_family = none)]
        pub fn pathComponentCellAtPoint_withFrame_inView(
            &self,
            point: NSPoint,
            frame: NSRect,
            view: &NSView,
        ) -> Option<Retained<NSPathComponentCell>>;

        #[cfg(all(feature = "NSPathComponentCell", feature = "NSTextFieldCell"))]
        #[unsafe(method(clickedPathComponentCell))]
        #[unsafe(method_family = none)]
        pub fn clickedPathComponentCell(&self) -> Option<Retained<NSPathComponentCell>>;

        #[cfg(all(feature = "NSEvent", feature = "NSResponder", feature = "NSView"))]
        #[unsafe(method(mouseEntered:withFrame:inView:))]
        #[unsafe(method_family = none)]
        pub fn mouseEntered_withFrame_inView(&self, event: &NSEvent, frame: NSRect, view: &NSView);

        #[cfg(all(feature = "NSEvent", feature = "NSResponder", feature = "NSView"))]
        #[unsafe(method(mouseExited:withFrame:inView:))]
        #[unsafe(method_family = none)]
        pub fn mouseExited_withFrame_inView(&self, event: &NSEvent, frame: NSRect, view: &NSView);

        #[unsafe(method(doubleAction))]
        #[unsafe(method_family = none)]
        pub fn doubleAction(&self) -> Option<Sel>;

        /// Setter for [`doubleAction`][Self::doubleAction].
        ///
        /// # Safety
        ///
        /// `double_action` must be a valid selector.
        #[unsafe(method(setDoubleAction:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDoubleAction(&self, double_action: Option<Sel>);

        #[cfg(feature = "NSColor")]
        #[unsafe(method(backgroundColor))]
        #[unsafe(method_family = none)]
        pub fn backgroundColor(&self) -> Option<Retained<NSColor>>;

        #[cfg(feature = "NSColor")]
        /// Setter for [`backgroundColor`][Self::backgroundColor].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setBackgroundColor:))]
        #[unsafe(method_family = none)]
        pub fn setBackgroundColor(&self, background_color: Option<&NSColor>);

        #[unsafe(method(placeholderString))]
        #[unsafe(method_family = none)]
        pub fn placeholderString(&self) -> Option<Retained<NSString>>;

        /// Setter for [`placeholderString`][Self::placeholderString].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setPlaceholderString:))]
        #[unsafe(method_family = none)]
        pub fn setPlaceholderString(&self, placeholder_string: Option<&NSString>);

        #[unsafe(method(placeholderAttributedString))]
        #[unsafe(method_family = none)]
        pub fn placeholderAttributedString(&self) -> Option<Retained<NSAttributedString>>;

        /// Setter for [`placeholderAttributedString`][Self::placeholderAttributedString].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setPlaceholderAttributedString:))]
        #[unsafe(method_family = none)]
        pub fn setPlaceholderAttributedString(
            &self,
            placeholder_attributed_string: Option<&NSAttributedString>,
        );
    );
}

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

        #[unsafe(method(initTextCell:))]
        #[unsafe(method_family = init)]
        pub fn initTextCell(this: Allocated<Self>, string: &NSString) -> Retained<Self>;

        #[cfg(feature = "NSImage")]
        #[unsafe(method(initImageCell:))]
        #[unsafe(method_family = init)]
        pub fn initImageCell(this: Allocated<Self>, image: Option<&NSImage>) -> 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>;
    );
}

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

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspathcelldelegate?language=objc)
    pub unsafe trait NSPathCellDelegate: NSObjectProtocol + MainThreadOnly {
        #[cfg(all(
            feature = "NSActionCell",
            feature = "NSCell",
            feature = "NSOpenPanel",
            feature = "NSPanel",
            feature = "NSResponder",
            feature = "NSSavePanel",
            feature = "NSWindow"
        ))]
        #[optional]
        #[unsafe(method(pathCell:willDisplayOpenPanel:))]
        #[unsafe(method_family = none)]
        fn pathCell_willDisplayOpenPanel(&self, path_cell: &NSPathCell, open_panel: &NSOpenPanel);

        #[cfg(all(feature = "NSActionCell", feature = "NSCell", feature = "NSMenu"))]
        #[optional]
        #[unsafe(method(pathCell:willPopUpMenu:))]
        #[unsafe(method_family = none)]
        fn pathCell_willPopUpMenu(&self, path_cell: &NSPathCell, menu: &NSMenu);
    }
);