//! 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/nspopuparrowposition?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPopUpArrowPosition(pub NSUInteger);
impl NSPopUpArrowPosition {
    #[doc(alias = "NSPopUpNoArrow")]
    pub const NoArrow: Self = Self(0);
    #[doc(alias = "NSPopUpArrowAtCenter")]
    pub const ArrowAtCenter: Self = Self(1);
    #[doc(alias = "NSPopUpArrowAtBottom")]
    pub const ArrowAtBottom: Self = Self(2);
}

unsafe impl Encode for NSPopUpArrowPosition {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

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

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

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

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

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

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

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

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

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

#[cfg(all(
    feature = "NSActionCell",
    feature = "NSButtonCell",
    feature = "NSCell",
    feature = "NSMenuItemCell"
))]
impl NSPopUpButtonCell {
    extern_methods!(
        #[unsafe(method(initTextCell:pullsDown:))]
        #[unsafe(method_family = init)]
        pub fn initTextCell_pullsDown(
            this: Allocated<Self>,
            string_value: &NSString,
            pull_down: bool,
        ) -> 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 = "NSMenu")]
        #[unsafe(method(menu))]
        #[unsafe(method_family = none)]
        pub fn menu(&self) -> Option<Retained<NSMenu>>;

        #[cfg(feature = "NSMenu")]
        /// Setter for [`menu`][Self::menu].
        #[unsafe(method(setMenu:))]
        #[unsafe(method_family = none)]
        pub fn setMenu(&self, menu: Option<&NSMenu>);

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

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

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

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

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

        /// Setter for [`preferredEdge`][Self::preferredEdge].
        #[unsafe(method(setPreferredEdge:))]
        #[unsafe(method_family = none)]
        pub fn setPreferredEdge(&self, preferred_edge: NSRectEdge);

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

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

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

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

        #[unsafe(method(addItemWithTitle:))]
        #[unsafe(method_family = none)]
        pub fn addItemWithTitle(&self, title: &NSString);

        #[unsafe(method(addItemsWithTitles:))]
        #[unsafe(method_family = none)]
        pub fn addItemsWithTitles(&self, item_titles: &NSArray<NSString>);

        #[unsafe(method(insertItemWithTitle:atIndex:))]
        #[unsafe(method_family = none)]
        pub fn insertItemWithTitle_atIndex(&self, title: &NSString, index: NSInteger);

        #[unsafe(method(removeItemWithTitle:))]
        #[unsafe(method_family = none)]
        pub fn removeItemWithTitle(&self, title: &NSString);

        #[unsafe(method(removeItemAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn removeItemAtIndex(&self, index: NSInteger);

        #[unsafe(method(removeAllItems))]
        #[unsafe(method_family = none)]
        pub fn removeAllItems(&self);

        #[cfg(feature = "NSMenuItem")]
        #[unsafe(method(itemArray))]
        #[unsafe(method_family = none)]
        pub fn itemArray(&self) -> Retained<NSArray<NSMenuItem>>;

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

        #[cfg(feature = "NSMenuItem")]
        #[unsafe(method(indexOfItem:))]
        #[unsafe(method_family = none)]
        pub fn indexOfItem(&self, item: &NSMenuItem) -> NSInteger;

        #[unsafe(method(indexOfItemWithTitle:))]
        #[unsafe(method_family = none)]
        pub fn indexOfItemWithTitle(&self, title: &NSString) -> NSInteger;

        #[unsafe(method(indexOfItemWithTag:))]
        #[unsafe(method_family = none)]
        pub fn indexOfItemWithTag(&self, tag: NSInteger) -> NSInteger;

        /// # Safety
        ///
        /// `obj` should be of the correct type.
        #[unsafe(method(indexOfItemWithRepresentedObject:))]
        #[unsafe(method_family = none)]
        pub unsafe fn indexOfItemWithRepresentedObject(&self, obj: Option<&AnyObject>)
            -> NSInteger;

        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `action_selector` must be a valid selector.
        #[unsafe(method(indexOfItemWithTarget:andAction:))]
        #[unsafe(method_family = none)]
        pub unsafe fn indexOfItemWithTarget_andAction(
            &self,
            target: Option<&AnyObject>,
            action_selector: Option<Sel>,
        ) -> NSInteger;

        #[cfg(feature = "NSMenuItem")]
        #[unsafe(method(itemAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn itemAtIndex(&self, index: NSInteger) -> Option<Retained<NSMenuItem>>;

        #[cfg(feature = "NSMenuItem")]
        #[unsafe(method(itemWithTitle:))]
        #[unsafe(method_family = none)]
        pub fn itemWithTitle(&self, title: &NSString) -> Option<Retained<NSMenuItem>>;

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

        #[cfg(feature = "NSMenuItem")]
        #[unsafe(method(selectItem:))]
        #[unsafe(method_family = none)]
        pub fn selectItem(&self, item: Option<&NSMenuItem>);

        #[unsafe(method(selectItemAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn selectItemAtIndex(&self, index: NSInteger);

        #[unsafe(method(selectItemWithTitle:))]
        #[unsafe(method_family = none)]
        pub fn selectItemWithTitle(&self, title: &NSString);

        #[unsafe(method(selectItemWithTag:))]
        #[unsafe(method_family = none)]
        pub fn selectItemWithTag(&self, tag: NSInteger) -> bool;

        #[unsafe(method(setTitle:))]
        #[unsafe(method_family = none)]
        pub fn setTitle(&self, string: Option<&NSString>);

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

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

        #[unsafe(method(synchronizeTitleAndSelectedItem))]
        #[unsafe(method_family = none)]
        pub fn synchronizeTitleAndSelectedItem(&self);

        #[unsafe(method(itemTitleAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn itemTitleAtIndex(&self, index: NSInteger) -> Retained<NSString>;

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

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

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[unsafe(method(attachPopUpWithFrame:inView:))]
        #[unsafe(method_family = none)]
        pub fn attachPopUpWithFrame_inView(&self, cell_frame: NSRect, control_view: &NSView);

        #[unsafe(method(dismissPopUp))]
        #[unsafe(method_family = none)]
        pub fn dismissPopUp(&self);

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[unsafe(method(performClickWithFrame:inView:))]
        #[unsafe(method_family = none)]
        pub fn performClickWithFrame_inView(&self, frame: NSRect, control_view: &NSView);

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

        /// Setter for [`arrowPosition`][Self::arrowPosition].
        #[unsafe(method(setArrowPosition:))]
        #[unsafe(method_family = none)]
        pub fn setArrowPosition(&self, arrow_position: NSPopUpArrowPosition);
    );
}

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

/// Methods declared on superclass `NSButtonCell`.
#[cfg(all(
    feature = "NSActionCell",
    feature = "NSButtonCell",
    feature = "NSCell",
    feature = "NSMenuItemCell"
))]
impl NSPopUpButtonCell {
    extern_methods!(
        #[cfg(feature = "NSImage")]
        #[unsafe(method(initImageCell:))]
        #[unsafe(method_family = init)]
        pub fn initImageCell(this: Allocated<Self>, image: Option<&NSImage>) -> Retained<Self>;
    );
}

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

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspopupbuttoncellwillpopupnotification?language=objc)
    pub static NSPopUpButtonCellWillPopUpNotification: &'static NSNotificationName;
}
