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/cpinformationtemplatelayout?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CPInformationTemplateLayout(pub NSInteger);
impl CPInformationTemplateLayout {
    /// A layout that will align all items on the leading edge of the template.
    #[doc(alias = "CPInformationTemplateLayoutLeading")]
    pub const Leading: Self = Self(0);
    /// A layout that will split each item into two columns.
    #[doc(alias = "CPInformationTemplateLayoutTwoColumn")]
    pub const TwoColumn: Self = Self(1);
}

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

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpinformationtemplate?language=objc)
    #[unsafe(super(CPTemplate, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "CPTemplate")]
    pub struct CPInformationTemplate;
);

#[cfg(all(feature = "CPBarButtonProviding", feature = "CPTemplate"))]
extern_conformance!(
    unsafe impl CPBarButtonProviding for CPInformationTemplate {}
);

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

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

#[cfg(feature = "CPTemplate")]
extern_conformance!(
    unsafe impl NSSecureCoding for CPInformationTemplate {}
);

#[cfg(feature = "CPTemplate")]
impl CPInformationTemplate {
    extern_methods!(
        #[cfg(all(feature = "CPInformationItem", feature = "CPTextButton"))]
        /// Initialize a CPInformationTemplate with a title, optional labels, and optional action buttons.
        ///
        ///
        /// Parameter `layout`: Information template layout, either leading aligned or two columns
        ///
        /// Parameter `title`: Information template title, appears at the top of the template
        ///
        /// Parameter `items`: Information items that will appear in the template
        ///
        /// Parameter `actions`: Optional actions that appear at the bottom of the template
        ///
        ///
        /// Note: The maximum number of
        /// `CPInformationItem`is 10. If you specify more than 10 items, only the first 10 will be used.
        /// The maximum number of
        /// `CPTextButton`is 3. If you specify more than 3, only the first 3 will be used.
        #[unsafe(method(initWithTitle:layout:items:actions:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithTitle_layout_items_actions(
            this: Allocated<Self>,
            title: &NSString,
            layout: CPInformationTemplateLayout,
            items: &NSArray<CPInformationItem>,
            actions: &NSArray<CPTextButton>,
        ) -> Retained<Self>;

        /// Information template layout, either leading aligned or two columns.
        #[unsafe(method(layout))]
        #[unsafe(method_family = none)]
        pub unsafe fn layout(&self) -> CPInformationTemplateLayout;

        /// Title that will appear at the top of the template.
        #[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);

        #[cfg(feature = "CPInformationItem")]
        /// An array of
        /// `CPInformationItem.`To update the items appearing in this information template, assign a new array to this property.
        ///
        ///
        /// Note: The maximum number of items is 10. If you specify more than 10 items, only the first 10 will be used.
        #[unsafe(method(items))]
        #[unsafe(method_family = none)]
        pub unsafe fn items(&self) -> Retained<NSArray<CPInformationItem>>;

        #[cfg(feature = "CPInformationItem")]
        /// Setter for [`items`][Self::items].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setItems:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setItems(&self, items: &NSArray<CPInformationItem>);

        #[cfg(feature = "CPTextButton")]
        /// An array of actions that appear at the bottom of the template.
        ///
        /// To update the actions appearing in this information template, assign a new array to this property.
        ///
        ///
        /// Note: The maximum number of actions is 3. If you specify more than 3, only the first 3 will be used.
        #[unsafe(method(actions))]
        #[unsafe(method_family = none)]
        pub unsafe fn actions(&self) -> Retained<NSArray<CPTextButton>>;

        #[cfg(feature = "CPTextButton")]
        /// Setter for [`actions`][Self::actions].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setActions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setActions(&self, actions: &NSArray<CPTextButton>);

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

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