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/nsslideraccessorywidth?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
#[cfg(feature = "objc2-core-foundation")]
pub type NSSliderAccessoryWidth = CGFloat;

extern "C" {
    /// The default width for slider accessories.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsslideraccessorywidthdefault?language=objc)
    #[cfg(feature = "objc2-core-foundation")]
    pub static NSSliderAccessoryWidthDefault: NSSliderAccessoryWidth;
}

extern "C" {
    /// The standard "wide" width for slider accessories.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsslideraccessorywidthwide?language=objc)
    #[cfg(feature = "objc2-core-foundation")]
    pub static NSSliderAccessoryWidthWide: NSSliderAccessoryWidth;
}

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

#[cfg(feature = "NSTouchBarItem")]
extern_conformance!(
    unsafe impl NSCoding for NSSliderTouchBarItem {}
);

#[cfg(feature = "NSTouchBarItem")]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSSliderTouchBarItem {}
);

#[cfg(feature = "NSTouchBarItem")]
impl NSSliderTouchBarItem {
    extern_methods!(
        #[cfg(all(
            feature = "NSResponder",
            feature = "NSUserInterfaceCompression",
            feature = "NSView"
        ))]
        #[unsafe(method(view))]
        #[unsafe(method_family = none)]
        pub fn view(&self) -> Retained<NSView>;

        #[cfg(all(
            feature = "NSControl",
            feature = "NSResponder",
            feature = "NSSlider",
            feature = "NSView"
        ))]
        /// The slider displayed by the bar item. It is automatically created, but can be set to a custom subclass. doubleValue, minValue, maxValue, etc can all be read and set through the slider.
        #[unsafe(method(slider))]
        #[unsafe(method_family = none)]
        pub fn slider(&self) -> Retained<NSSlider>;

        #[cfg(all(
            feature = "NSControl",
            feature = "NSResponder",
            feature = "NSSlider",
            feature = "NSView"
        ))]
        /// Setter for [`slider`][Self::slider].
        #[unsafe(method(setSlider:))]
        #[unsafe(method_family = none)]
        pub fn setSlider(&self, slider: &NSSlider);

        /// The double value of the control
        #[unsafe(method(doubleValue))]
        #[unsafe(method_family = none)]
        pub fn doubleValue(&self) -> c_double;

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

        #[cfg(feature = "objc2-core-foundation")]
        /// The width boundaries of the slider track of this item.
        /// The system defines the default minimum. The maximum defaults to MAXFLOAT
        #[unsafe(method(minimumSliderWidth))]
        #[unsafe(method_family = none)]
        pub fn minimumSliderWidth(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`minimumSliderWidth`][Self::minimumSliderWidth].
        #[unsafe(method(setMinimumSliderWidth:))]
        #[unsafe(method_family = none)]
        pub fn setMinimumSliderWidth(&self, minimum_slider_width: CGFloat);

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

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`maximumSliderWidth`][Self::maximumSliderWidth].
        #[unsafe(method(setMaximumSliderWidth:))]
        #[unsafe(method_family = none)]
        pub fn setMaximumSliderWidth(&self, maximum_slider_width: CGFloat);

        /// The text label displayed along with the slider. If set to nil, the label will not have space reserved in the item.
        #[unsafe(method(label))]
        #[unsafe(method_family = none)]
        pub fn label(&self) -> Option<Retained<NSString>>;

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

        #[cfg(feature = "NSSliderAccessory")]
        /// The accessory that appears on the end of the slider with the minimum value
        #[unsafe(method(minimumValueAccessory))]
        #[unsafe(method_family = none)]
        pub fn minimumValueAccessory(&self) -> Option<Retained<NSSliderAccessory>>;

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

        #[cfg(feature = "NSSliderAccessory")]
        /// The accessory that appears on the end of the slider with the maximum value
        #[unsafe(method(maximumValueAccessory))]
        #[unsafe(method_family = none)]
        pub fn maximumValueAccessory(&self) -> Option<Retained<NSSliderAccessory>>;

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

        #[cfg(feature = "objc2-core-foundation")]
        /// The width of the value accessories. Defaults to `.default`, but can be set to `.wide` or a custom value.
        #[unsafe(method(valueAccessoryWidth))]
        #[unsafe(method_family = none)]
        pub fn valueAccessoryWidth(&self) -> NSSliderAccessoryWidth;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`valueAccessoryWidth`][Self::valueAccessoryWidth].
        #[unsafe(method(setValueAccessoryWidth:))]
        #[unsafe(method_family = none)]
        pub fn setValueAccessoryWidth(&self, value_accessory_width: NSSliderAccessoryWidth);

        /// The target of the item, notified when the slider or accessories receive user interaction.
        #[unsafe(method(target))]
        #[unsafe(method_family = none)]
        pub fn target(&self) -> Option<Retained<AnyObject>>;

        /// Setter for [`target`][Self::target].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        ///
        /// # Safety
        ///
        /// `target` should be of the correct type.
        #[unsafe(method(setTarget:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTarget(&self, target: Option<&AnyObject>);

        /// The action of the item, called when the slider or accessories receive user interaction.
        #[unsafe(method(action))]
        #[unsafe(method_family = none)]
        pub fn action(&self) -> Option<Sel>;

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

        /// The localized string labelling this item during user customization. The default value is empty string.
        #[unsafe(method(customizationLabel))]
        #[unsafe(method_family = none)]
        pub fn customizationLabel(&self) -> Retained<NSString>;

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

/// Methods declared on superclass `NSTouchBarItem`.
#[cfg(feature = "NSTouchBarItem")]
impl NSSliderTouchBarItem {
    extern_methods!(
        #[unsafe(method(initWithIdentifier:))]
        #[unsafe(method_family = init)]
        pub fn initWithIdentifier(
            this: Allocated<Self>,
            identifier: &NSTouchBarItemIdentifier,
        ) -> Retained<Self>;

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

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

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