objc2-car-play 0.3.2

Bindings to the CarPlay 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/carplay/cptextbuttonstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CPTextButtonStyle(pub NSInteger);
impl CPTextButtonStyle {
    /// A style that indicates a default action.
    #[doc(alias = "CPTextButtonStyleNormal")]
    pub const Normal: Self = Self(0);
    /// A style that indicates the action will cancel and leave data unchanged.
    #[doc(alias = "CPTextButtonStyleCancel")]
    pub const Cancel: Self = Self(1);
    /// A style that indicates the button will confirm an action.
    #[doc(alias = "CPTextButtonStyleConfirm")]
    pub const Confirm: Self = Self(2);
}

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

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cptextbutton?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CPTextButton;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for CPTextButton {}
);

impl CPTextButton {
    extern_methods!(
        #[cfg(feature = "block2")]
        /// Create a button with text and a style that, when tapped, calls your custom handler.
        ///
        ///
        /// Parameter `title`: A title that will appear in the button.
        ///
        /// Parameter `textStyle`: A style that will be applied by the system for this button.
        ///
        /// Parameter `handler`: A block that will be called when the user taps this button.
        #[unsafe(method(initWithTitle:textStyle:handler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithTitle_textStyle_handler(
            this: Allocated<Self>,
            title: &NSString,
            text_style: CPTextButtonStyle,
            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPTextButton>)>>,
        ) -> Retained<Self>;

        /// A custom title to display for this button, displayed only in templates that allow for custom titles.
        #[unsafe(method(title))]
        #[unsafe(method_family = none)]
        pub unsafe fn title(&self) -> Retained<NSString>;

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

        /// A
        /// `CPButtonTextStyle`value indicating the style for this button, when displayed in a template
        /// that supports button styling, like the Information template.
        ///
        ///
        /// This value defaults to
        /// `CPTextButtonStyleNormal.`
        #[unsafe(method(textStyle))]
        #[unsafe(method_family = none)]
        pub unsafe fn textStyle(&self) -> CPTextButtonStyle;

        /// Setter for [`textStyle`][Self::textStyle].
        #[unsafe(method(setTextStyle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTextStyle(&self, text_style: CPTextButtonStyle);

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

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