objc2-shared-with-you 0.3.2

Bindings to the SharedWithYou 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-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

/// The context for the content being displayed; influences future ranking of this view's SWHighlight
///
/// Set the appropriate display context on SWAttributionView before it is added to a window. This informs the system about how the user is consuming the attributed content, and influences future relevancy ranking of the SWHighlight for this view.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/sharedwithyou/swattributionviewdisplaycontext?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SWAttributionViewDisplayContext(pub NSInteger);
impl SWAttributionViewDisplayContext {
    /// The default context. Indicates that the attributed content shown along with this view is being offered to the user for consumption
    #[doc(alias = "SWAttributionViewDisplayContextSummary")]
    pub const Summary: Self = Self(0);
    /// Indicates that the attributed content shown along with this view is being actively consumed by the user
    #[doc(alias = "SWAttributionViewDisplayContextDetail")]
    pub const Detail: Self = Self(1);
}

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

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

/// The horizontal alignment of SWAttributionView's contents
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/sharedwithyou/swattributionviewhorizontalalignment?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SWAttributionViewHorizontalAlignment(pub NSInteger);
impl SWAttributionViewHorizontalAlignment {
    /// The default horizontal alignment, to be chosen by SWAttributionView
    #[doc(alias = "SWAttributionViewHorizontalAlignmentDefault")]
    pub const Default: Self = Self(0);
    /// Horizontally align with the leading edge of the view (depends on the user interface layout direction)
    #[doc(alias = "SWAttributionViewHorizontalAlignmentLeading")]
    pub const Leading: Self = Self(1);
    /// Horizontally align with the center of the view
    #[doc(alias = "SWAttributionViewHorizontalAlignmentCenter")]
    pub const Center: Self = Self(2);
    /// Horizontally align with the trailing edge of the view (depends on the user interface layout direction)
    #[doc(alias = "SWAttributionViewHorizontalAlignmentTrailing")]
    pub const Trailing: Self = Self(3);
}

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

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

/// The background styling of SWAttributionView's contents
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/sharedwithyou/swattributionviewbackgroundstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SWAttributionViewBackgroundStyle(pub NSInteger);
impl SWAttributionViewBackgroundStyle {
    /// The default background style, to be chosen by SWAttributionView
    #[doc(alias = "SWAttributionViewBackgroundStyleDefault")]
    pub const Default: Self = Self(0);
    /// A non-material background color for the view's contents, best when placed over monochrome backgrounds
    #[doc(alias = "SWAttributionViewBackgroundStyleColor")]
    pub const Color: Self = Self(1);
    /// A material background blur for the view's contents, best when placed over multicolored backgrounds
    #[doc(alias = "SWAttributionViewBackgroundStyleMaterial")]
    pub const Material: Self = Self(2);
}

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

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/sharedwithyou/swattributionview?language=objc)
    #[unsafe(super(NSView, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2-app-kit")]
    #[cfg(target_os = "macos")]
    pub struct SWAttributionView;
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSAccessibility for SWAttributionView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSAccessibilityElementProtocol for SWAttributionView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSAnimatablePropertyContainer for SWAttributionView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSAppearanceCustomization for SWAttributionView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSCoding for SWAttributionView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSDraggingDestination for SWAttributionView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSObjectProtocol for SWAttributionView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSUserInterfaceItemIdentification for SWAttributionView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl SWAttributionView {
    extern_methods!(
        #[cfg(feature = "SWHighlight")]
        /// The SWHighlight to use for displaying this attribution. When this property is set to a new highlight, the contents of the view will be reloaded.
        #[unsafe(method(highlight))]
        #[unsafe(method_family = none)]
        pub unsafe fn highlight(&self) -> Option<Retained<SWHighlight>>;

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

        /// The context for the content being displayed with this view. Set this prior to adding this view to your view hierarchy.
        #[unsafe(method(displayContext))]
        #[unsafe(method_family = none)]
        pub unsafe fn displayContext(&self) -> SWAttributionViewDisplayContext;

        /// Setter for [`displayContext`][Self::displayContext].
        #[unsafe(method(setDisplayContext:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDisplayContext(&self, display_context: SWAttributionViewDisplayContext);

        /// The horizontal alignment of the view. You should specify a value, in case the internal default ever changes.
        ///
        /// This value specifies the horizontal anchor for the view's contents. This only has an effect when the width of the contents are less than the available width.
        #[unsafe(method(horizontalAlignment))]
        #[unsafe(method_family = none)]
        pub unsafe fn horizontalAlignment(&self) -> SWAttributionViewHorizontalAlignment;

        /// Setter for [`horizontalAlignment`][Self::horizontalAlignment].
        #[unsafe(method(setHorizontalAlignment:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setHorizontalAlignment(
            &self,
            horizontal_alignment: SWAttributionViewHorizontalAlignment,
        );

        /// The background style of the inner view containing names and avatars.
        ///
        /// If you do not specify a background style, one will be chosen automatically. In general, .color looks best on monochrome backgrounds, while .material looks better on colored backgrounds.
        #[unsafe(method(backgroundStyle))]
        #[unsafe(method_family = none)]
        pub unsafe fn backgroundStyle(&self) -> SWAttributionViewBackgroundStyle;

        /// Setter for [`backgroundStyle`][Self::backgroundStyle].
        #[unsafe(method(setBackgroundStyle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setBackgroundStyle(&self, background_style: SWAttributionViewBackgroundStyle);

        #[cfg(feature = "objc2-core-foundation")]
        /// For use when embedding this view in a SwiftUI view representable.
        ///
        /// When using this view in SwiftUI, this view will constrain its contents to this width. If you are not using SwiftUI this property should not be necessary, as SWAttributionView otherwise derives the maximum width from the frame or constraints you set.
        #[unsafe(method(preferredMaxLayoutWidth))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredMaxLayoutWidth(&self) -> CGFloat;

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

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

        /// A custom localized string to be used as the title for the "Hide" menu item title. A nil value will result in the default title.
        ///
        /// SWAttributionView manages a context menu which includes the option for the user to hide the content for the SWHighlight represented by this view. Set a title to be used as the title for that context menu. An app that displays articles, for example, might set
        /// "
        /// Hide Article", localized to the current language. The string should include the word "Hide", localized correctly with the custom content type.
        #[unsafe(method(menuTitleForHideAction))]
        #[unsafe(method_family = none)]
        pub unsafe fn menuTitleForHideAction(&self) -> Option<Retained<NSString>>;

        /// Setter for [`menuTitleForHideAction`][Self::menuTitleForHideAction].
        #[unsafe(method(setMenuTitleForHideAction:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMenuTitleForHideAction(
            &self,
            menu_title_for_hide_action: Option<&NSString>,
        );

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

        /// Setter for [`supplementalMenu`][Self::supplementalMenu].
        #[unsafe(method(setSupplementalMenu:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSupplementalMenu(&self, supplemental_menu: Option<&NSMenuItem>);

        /// Automatically enables a marquee effect if the text contents extend past the bounds of the view (tvOS only)
        #[unsafe(method(enablesMarquee))]
        #[unsafe(method_family = none)]
        pub unsafe fn enablesMarquee(&self) -> bool;

        /// Setter for [`enablesMarquee`][Self::enablesMarquee].
        #[unsafe(method(setEnablesMarquee:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setEnablesMarquee(&self, enables_marquee: bool);
    );
}

/// Methods declared on superclass `NSView`.
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl SWAttributionView {
    extern_methods!(
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> 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>>;
    );
}

/// Methods declared on superclass `NSResponder`.
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl SWAttributionView {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

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