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/nsdatepickerstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSDatePickerStyle(pub NSUInteger);
impl NSDatePickerStyle {
    #[doc(alias = "NSDatePickerStyleTextFieldAndStepper")]
    pub const TextFieldAndStepper: Self = Self(0);
    #[doc(alias = "NSDatePickerStyleClockAndCalendar")]
    pub const ClockAndCalendar: Self = Self(1);
    #[doc(alias = "NSDatePickerStyleTextField")]
    pub const TextField: Self = Self(2);
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsdatepickermode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSDatePickerMode(pub NSUInteger);
impl NSDatePickerMode {
    #[doc(alias = "NSDatePickerModeSingle")]
    pub const Single: Self = Self(0);
    #[doc(alias = "NSDatePickerModeRange")]
    pub const Range: Self = Self(1);
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsdatepickerelementflags?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSDatePickerElementFlags(pub NSUInteger);
bitflags::bitflags! {
    impl NSDatePickerElementFlags: NSUInteger {
        #[doc(alias = "NSDatePickerElementFlagHourMinute")]
        const HourMinute = 0x000c;
        #[doc(alias = "NSDatePickerElementFlagHourMinuteSecond")]
        const HourMinuteSecond = 0x000e;
        #[doc(alias = "NSDatePickerElementFlagTimeZone")]
        const TimeZone = 0x0010;
        #[doc(alias = "NSDatePickerElementFlagYearMonth")]
        const YearMonth = 0x00c0;
        #[doc(alias = "NSDatePickerElementFlagYearMonthDay")]
        const YearMonthDay = 0x00e0;
        #[doc(alias = "NSDatePickerElementFlagEra")]
        const Era = 0x0100;
    }
}

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

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

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

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

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

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

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

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

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

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

#[cfg(all(feature = "NSActionCell", feature = "NSCell"))]
impl NSDatePickerCell {
    extern_methods!(
        #[unsafe(method(initTextCell:))]
        #[unsafe(method_family = init)]
        pub fn initTextCell(this: Allocated<Self>, string: &NSString) -> 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 = "NSImage")]
        #[unsafe(method(initImageCell:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initImageCell(
            this: Allocated<Self>,
            image: Option<&NSImage>,
        ) -> Retained<Self>;

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

        /// Setter for [`datePickerStyle`][Self::datePickerStyle].
        #[unsafe(method(setDatePickerStyle:))]
        #[unsafe(method_family = none)]
        pub fn setDatePickerStyle(&self, date_picker_style: NSDatePickerStyle);

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

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

        #[cfg(feature = "NSColor")]
        #[unsafe(method(backgroundColor))]
        #[unsafe(method_family = none)]
        pub fn backgroundColor(&self) -> 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: &NSColor);

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

        #[cfg(feature = "NSColor")]
        /// Setter for [`textColor`][Self::textColor].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setTextColor:))]
        #[unsafe(method_family = none)]
        pub fn setTextColor(&self, text_color: &NSColor);

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

        /// Setter for [`datePickerMode`][Self::datePickerMode].
        #[unsafe(method(setDatePickerMode:))]
        #[unsafe(method_family = none)]
        pub fn setDatePickerMode(&self, date_picker_mode: NSDatePickerMode);

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

        /// Setter for [`datePickerElements`][Self::datePickerElements].
        #[unsafe(method(setDatePickerElements:))]
        #[unsafe(method_family = none)]
        pub fn setDatePickerElements(&self, date_picker_elements: NSDatePickerElementFlags);

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

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

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

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

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

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

        #[unsafe(method(dateValue))]
        #[unsafe(method_family = none)]
        pub fn dateValue(&self) -> Retained<NSDate>;

        /// Setter for [`dateValue`][Self::dateValue].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setDateValue:))]
        #[unsafe(method_family = none)]
        pub fn setDateValue(&self, date_value: &NSDate);

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

        /// Setter for [`timeInterval`][Self::timeInterval].
        #[unsafe(method(setTimeInterval:))]
        #[unsafe(method_family = none)]
        pub fn setTimeInterval(&self, time_interval: NSTimeInterval);

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

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

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

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

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

        /// 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 NSDatePickerCellDelegate>>);
    );
}

/// Methods declared on superclass `NSCell`.
#[cfg(all(feature = "NSActionCell", feature = "NSCell"))]
impl NSDatePickerCell {
    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 = "NSCell"))]
impl NSDatePickerCell {
    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/nsdatepickercelldelegate?language=objc)
    pub unsafe trait NSDatePickerCellDelegate: NSObjectProtocol + MainThreadOnly {
        #[cfg(all(feature = "NSActionCell", feature = "NSCell"))]
        /// # Safety
        ///
        /// `proposed_time_interval` must be a valid pointer or null.
        #[optional]
        #[unsafe(method(datePickerCell:validateProposedDateValue:timeInterval:))]
        #[unsafe(method_family = none)]
        unsafe fn datePickerCell_validateProposedDateValue_timeInterval(
            &self,
            date_picker_cell: &NSDatePickerCell,
            proposed_date_value: &mut Retained<NSDate>,
            proposed_time_interval: *mut NSTimeInterval,
        );
    }
);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextfieldandstepperdatepickerstyle?language=objc)
#[deprecated]
pub static NSTextFieldAndStepperDatePickerStyle: NSDatePickerStyle =
    NSDatePickerStyle(NSDatePickerStyle::TextFieldAndStepper.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsclockandcalendardatepickerstyle?language=objc)
#[deprecated]
pub static NSClockAndCalendarDatePickerStyle: NSDatePickerStyle =
    NSDatePickerStyle(NSDatePickerStyle::ClockAndCalendar.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextfielddatepickerstyle?language=objc)
#[deprecated]
pub static NSTextFieldDatePickerStyle: NSDatePickerStyle =
    NSDatePickerStyle(NSDatePickerStyle::TextField.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssingledatemode?language=objc)
#[deprecated]
pub static NSSingleDateMode: NSDatePickerMode = NSDatePickerMode(NSDatePickerMode::Single.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrangedatemode?language=objc)
#[deprecated]
pub static NSRangeDateMode: NSDatePickerMode = NSDatePickerMode(NSDatePickerMode::Range.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nshourminutedatepickerelementflag?language=objc)
#[deprecated]
pub static NSHourMinuteDatePickerElementFlag: NSDatePickerElementFlags =
    NSDatePickerElementFlags(NSDatePickerElementFlags::HourMinute.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nshourminuteseconddatepickerelementflag?language=objc)
#[deprecated]
pub static NSHourMinuteSecondDatePickerElementFlag: NSDatePickerElementFlags =
    NSDatePickerElementFlags(NSDatePickerElementFlags::HourMinuteSecond.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstimezonedatepickerelementflag?language=objc)
#[deprecated]
pub static NSTimeZoneDatePickerElementFlag: NSDatePickerElementFlags =
    NSDatePickerElementFlags(NSDatePickerElementFlags::TimeZone.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsyearmonthdatepickerelementflag?language=objc)
#[deprecated]
pub static NSYearMonthDatePickerElementFlag: NSDatePickerElementFlags =
    NSDatePickerElementFlags(NSDatePickerElementFlags::YearMonth.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsyearmonthdaydatepickerelementflag?language=objc)
#[deprecated]
pub static NSYearMonthDayDatePickerElementFlag: NSDatePickerElementFlags =
    NSDatePickerElementFlags(NSDatePickerElementFlags::YearMonthDay.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nseradatepickerelementflag?language=objc)
#[deprecated]
pub static NSEraDatePickerElementFlag: NSDatePickerElementFlags =
    NSDatePickerElementFlags(NSDatePickerElementFlags::Era.0);