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::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstickmarkposition?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTickMarkPosition(pub NSUInteger);
impl NSTickMarkPosition {
    #[doc(alias = "NSTickMarkPositionBelow")]
    pub const Below: Self = Self(0);
    #[doc(alias = "NSTickMarkPositionAbove")]
    pub const Above: Self = Self(1);
    #[doc(alias = "NSTickMarkPositionLeading")]
    pub const Leading: Self = Self(NSTickMarkPosition::Above.0);
    #[doc(alias = "NSTickMarkPositionTrailing")]
    pub const Trailing: Self = Self(NSTickMarkPosition::Below.0);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

#[cfg(all(feature = "NSActionCell", feature = "NSCell"))]
impl NSSliderCell {
    extern_methods!(
        #[unsafe(method(prefersTrackingUntilMouseUp))]
        #[unsafe(method_family = none)]
        pub fn prefersTrackingUntilMouseUp(mtm: MainThreadMarker) -> bool;

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

        /// Setter for [`minValue`][Self::minValue].
        #[unsafe(method(setMinValue:))]
        #[unsafe(method_family = none)]
        pub fn setMinValue(&self, min_value: c_double);

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

        /// Setter for [`maxValue`][Self::maxValue].
        #[unsafe(method(setMaxValue:))]
        #[unsafe(method_family = none)]
        pub fn setMaxValue(&self, max_value: c_double);

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

        /// Setter for [`altIncrementValue`][Self::altIncrementValue].
        #[unsafe(method(setAltIncrementValue:))]
        #[unsafe(method_family = none)]
        pub fn setAltIncrementValue(&self, alt_increment_value: c_double);

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

        /// Setter for [`sliderType`][Self::sliderType].
        #[unsafe(method(setSliderType:))]
        #[unsafe(method_family = none)]
        pub fn setSliderType(&self, slider_type: NSSliderType);

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

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

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(knobThickness))]
        #[unsafe(method_family = none)]
        pub fn knobThickness(&self) -> CGFloat;

        #[unsafe(method(knobRectFlipped:))]
        #[unsafe(method_family = none)]
        pub fn knobRectFlipped(&self, flipped: bool) -> NSRect;

        #[unsafe(method(barRectFlipped:))]
        #[unsafe(method_family = none)]
        pub fn barRectFlipped(&self, flipped: bool) -> NSRect;

        #[unsafe(method(drawKnob:))]
        #[unsafe(method_family = none)]
        pub fn drawKnob_(&self, knob_rect: NSRect);

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

        #[unsafe(method(drawBarInside:flipped:))]
        #[unsafe(method_family = none)]
        pub fn drawBarInside_flipped(&self, rect: NSRect, flipped: bool);
    );
}

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

/// NSSliderCellVerticalGetter.
#[cfg(all(feature = "NSActionCell", feature = "NSCell"))]
impl NSSliderCell {
    extern_methods!();
}

/// NSTickMarkSupport.
#[cfg(all(feature = "NSActionCell", feature = "NSCell"))]
impl NSSliderCell {
    extern_methods!(
        #[unsafe(method(numberOfTickMarks))]
        #[unsafe(method_family = none)]
        pub fn numberOfTickMarks(&self) -> NSInteger;

        /// Setter for [`numberOfTickMarks`][Self::numberOfTickMarks].
        #[unsafe(method(setNumberOfTickMarks:))]
        #[unsafe(method_family = none)]
        pub fn setNumberOfTickMarks(&self, number_of_tick_marks: NSInteger);

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

        /// Setter for [`tickMarkPosition`][Self::tickMarkPosition].
        #[unsafe(method(setTickMarkPosition:))]
        #[unsafe(method_family = none)]
        pub fn setTickMarkPosition(&self, tick_mark_position: NSTickMarkPosition);

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

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

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

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

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

        #[unsafe(method(closestTickMarkValueToValue:))]
        #[unsafe(method_family = none)]
        pub fn closestTickMarkValueToValue(&self, value: c_double) -> c_double;

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

/// NSDeprecated.
#[cfg(all(feature = "NSActionCell", feature = "NSCell"))]
impl NSSliderCell {
    extern_methods!(
        /// # Safety
        ///
        /// `cell` might not allow `None`.
        #[deprecated = "-setTitleCell: had no effect since 10.0"]
        #[unsafe(method(setTitleCell:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTitleCell(&self, cell: Option<&NSCell>);

        #[deprecated = "-titleCell has returned nil since 10.0"]
        #[unsafe(method(titleCell))]
        #[unsafe(method_family = none)]
        pub fn titleCell(&self) -> Option<Retained<AnyObject>>;

        #[cfg(feature = "NSColor")]
        /// # Safety
        ///
        /// `new_color` might not allow `None`.
        #[deprecated = "-setTitleColor: had no effect since 10.0"]
        #[unsafe(method(setTitleColor:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTitleColor(&self, new_color: Option<&NSColor>);

        #[cfg(feature = "NSColor")]
        #[deprecated = "-titleColor has returned nil since 10.0"]
        #[unsafe(method(titleColor))]
        #[unsafe(method_family = none)]
        pub fn titleColor(&self) -> Option<Retained<NSColor>>;

        #[cfg(feature = "NSFont")]
        /// # Safety
        ///
        /// `font_obj` might not allow `None`.
        #[deprecated = "-setTitleFont: had no effect since 10.0"]
        #[unsafe(method(setTitleFont:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTitleFont(&self, font_obj: Option<&NSFont>);

        #[cfg(feature = "NSFont")]
        #[deprecated = "-titleFont has returned nil since 10.0"]
        #[unsafe(method(titleFont))]
        #[unsafe(method_family = none)]
        pub fn titleFont(&self) -> Option<Retained<NSFont>>;

        #[deprecated = "-title has returned nil since 10.0"]
        #[unsafe(method(title))]
        #[unsafe(method_family = none)]
        pub fn title(&self) -> Option<Retained<NSString>>;

        /// # Safety
        ///
        /// `string` might not allow `None`.
        #[deprecated = "-setTitle: had no effect since 10.0"]
        #[unsafe(method(setTitle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTitle(&self, string: Option<&NSString>);

        #[cfg(feature = "objc2-core-foundation")]
        #[deprecated = "-knobThickness has returned 0 since 10.0"]
        #[unsafe(method(setKnobThickness:))]
        #[unsafe(method_family = none)]
        pub fn setKnobThickness(&self, thickness: CGFloat);

        #[cfg(feature = "NSImage")]
        /// # Safety
        ///
        /// `background_image` might not allow `None`.
        #[deprecated = "-setImage: had no effect since 10.0"]
        #[unsafe(method(setImage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setImage(&self, background_image: Option<&NSImage>);

        #[cfg(feature = "NSImage")]
        #[deprecated = "-image has returned nil since 10.0"]
        #[unsafe(method(image))]
        #[unsafe(method_family = none)]
        pub fn image(&self) -> Option<Retained<NSImage>>;
    );
}

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstickmarkbelow?language=objc)
#[deprecated]
pub static NSTickMarkBelow: NSTickMarkPosition = NSTickMarkPosition(NSTickMarkPosition::Below.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstickmarkabove?language=objc)
#[deprecated]
pub static NSTickMarkAbove: NSTickMarkPosition = NSTickMarkPosition(NSTickMarkPosition::Above.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstickmarkleft?language=objc)
#[deprecated]
pub static NSTickMarkLeft: NSTickMarkPosition = NSTickMarkPosition(NSTickMarkPosition::Leading.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstickmarkright?language=objc)
#[deprecated]
pub static NSTickMarkRight: NSTickMarkPosition = NSTickMarkPosition(NSTickMarkPosition::Trailing.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nslinearslider?language=objc)
#[deprecated]
pub static NSLinearSlider: NSSliderType = NSSliderType(NSSliderType::Linear.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscircularslider?language=objc)
#[deprecated]
pub static NSCircularSlider: NSSliderType = NSSliderType(NSSliderType::Circular.0);