objc2_shared_with_you/generated/
SWAttributionView.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9#[cfg(feature = "objc2-core-foundation")]
10use objc2_core_foundation::*;
11use objc2_foundation::*;
12
13use crate::*;
14
15/// The context for the content being displayed; influences future ranking of this view's SWHighlight
16///
17/// 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.
18///
19/// See also [Apple's documentation](https://developer.apple.com/documentation/sharedwithyou/swattributionviewdisplaycontext?language=objc)
20// NS_ENUM
21#[repr(transparent)]
22#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
23pub struct SWAttributionViewDisplayContext(pub NSInteger);
24impl SWAttributionViewDisplayContext {
25    /// The default context. Indicates that the attributed content shown along with this view is being offered to the user for consumption
26    #[doc(alias = "SWAttributionViewDisplayContextSummary")]
27    pub const Summary: Self = Self(0);
28    /// Indicates that the attributed content shown along with this view is being actively consumed by the user
29    #[doc(alias = "SWAttributionViewDisplayContextDetail")]
30    pub const Detail: Self = Self(1);
31}
32
33unsafe impl Encode for SWAttributionViewDisplayContext {
34    const ENCODING: Encoding = NSInteger::ENCODING;
35}
36
37unsafe impl RefEncode for SWAttributionViewDisplayContext {
38    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
39}
40
41/// The horizontal alignment of SWAttributionView's contents
42///
43/// See also [Apple's documentation](https://developer.apple.com/documentation/sharedwithyou/swattributionviewhorizontalalignment?language=objc)
44// NS_ENUM
45#[repr(transparent)]
46#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
47pub struct SWAttributionViewHorizontalAlignment(pub NSInteger);
48impl SWAttributionViewHorizontalAlignment {
49    /// The default horizontal alignment, to be chosen by SWAttributionView
50    #[doc(alias = "SWAttributionViewHorizontalAlignmentDefault")]
51    pub const Default: Self = Self(0);
52    /// Horizontally align with the leading edge of the view (depends on the user interface layout direction)
53    #[doc(alias = "SWAttributionViewHorizontalAlignmentLeading")]
54    pub const Leading: Self = Self(1);
55    /// Horizontally align with the center of the view
56    #[doc(alias = "SWAttributionViewHorizontalAlignmentCenter")]
57    pub const Center: Self = Self(2);
58    /// Horizontally align with the trailing edge of the view (depends on the user interface layout direction)
59    #[doc(alias = "SWAttributionViewHorizontalAlignmentTrailing")]
60    pub const Trailing: Self = Self(3);
61}
62
63unsafe impl Encode for SWAttributionViewHorizontalAlignment {
64    const ENCODING: Encoding = NSInteger::ENCODING;
65}
66
67unsafe impl RefEncode for SWAttributionViewHorizontalAlignment {
68    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
69}
70
71/// The background styling of SWAttributionView's contents
72///
73/// See also [Apple's documentation](https://developer.apple.com/documentation/sharedwithyou/swattributionviewbackgroundstyle?language=objc)
74// NS_ENUM
75#[repr(transparent)]
76#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
77pub struct SWAttributionViewBackgroundStyle(pub NSInteger);
78impl SWAttributionViewBackgroundStyle {
79    /// The default background style, to be chosen by SWAttributionView
80    #[doc(alias = "SWAttributionViewBackgroundStyleDefault")]
81    pub const Default: Self = Self(0);
82    /// A non-material background color for the view's contents, best when placed over monochrome backgrounds
83    #[doc(alias = "SWAttributionViewBackgroundStyleColor")]
84    pub const Color: Self = Self(1);
85    /// A material background blur for the view's contents, best when placed over multicolored backgrounds
86    #[doc(alias = "SWAttributionViewBackgroundStyleMaterial")]
87    pub const Material: Self = Self(2);
88}
89
90unsafe impl Encode for SWAttributionViewBackgroundStyle {
91    const ENCODING: Encoding = NSInteger::ENCODING;
92}
93
94unsafe impl RefEncode for SWAttributionViewBackgroundStyle {
95    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
96}
97
98extern_class!(
99    /// [Apple's documentation](https://developer.apple.com/documentation/sharedwithyou/swattributionview?language=objc)
100    #[unsafe(super(NSView, NSResponder, NSObject))]
101    #[derive(Debug, PartialEq, Eq, Hash)]
102    #[cfg(feature = "objc2-app-kit")]
103    #[cfg(target_os = "macos")]
104    pub struct SWAttributionView;
105);
106
107#[cfg(feature = "objc2-app-kit")]
108#[cfg(target_os = "macos")]
109extern_conformance!(
110    unsafe impl NSAccessibility for SWAttributionView {}
111);
112
113#[cfg(feature = "objc2-app-kit")]
114#[cfg(target_os = "macos")]
115extern_conformance!(
116    unsafe impl NSAccessibilityElementProtocol for SWAttributionView {}
117);
118
119#[cfg(feature = "objc2-app-kit")]
120#[cfg(target_os = "macos")]
121extern_conformance!(
122    unsafe impl NSAnimatablePropertyContainer for SWAttributionView {}
123);
124
125#[cfg(feature = "objc2-app-kit")]
126#[cfg(target_os = "macos")]
127extern_conformance!(
128    unsafe impl NSAppearanceCustomization for SWAttributionView {}
129);
130
131#[cfg(feature = "objc2-app-kit")]
132#[cfg(target_os = "macos")]
133extern_conformance!(
134    unsafe impl NSCoding for SWAttributionView {}
135);
136
137#[cfg(feature = "objc2-app-kit")]
138#[cfg(target_os = "macos")]
139extern_conformance!(
140    unsafe impl NSDraggingDestination for SWAttributionView {}
141);
142
143#[cfg(feature = "objc2-app-kit")]
144#[cfg(target_os = "macos")]
145extern_conformance!(
146    unsafe impl NSObjectProtocol for SWAttributionView {}
147);
148
149#[cfg(feature = "objc2-app-kit")]
150#[cfg(target_os = "macos")]
151extern_conformance!(
152    unsafe impl NSUserInterfaceItemIdentification for SWAttributionView {}
153);
154
155#[cfg(feature = "objc2-app-kit")]
156#[cfg(target_os = "macos")]
157impl SWAttributionView {
158    extern_methods!(
159        #[cfg(feature = "SWHighlight")]
160        /// 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.
161        #[unsafe(method(highlight))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn highlight(&self) -> Option<Retained<SWHighlight>>;
164
165        #[cfg(feature = "SWHighlight")]
166        /// Setter for [`highlight`][Self::highlight].
167        #[unsafe(method(setHighlight:))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn setHighlight(&self, highlight: Option<&SWHighlight>);
170
171        /// The context for the content being displayed with this view. Set this prior to adding this view to your view hierarchy.
172        #[unsafe(method(displayContext))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn displayContext(&self) -> SWAttributionViewDisplayContext;
175
176        /// Setter for [`displayContext`][Self::displayContext].
177        #[unsafe(method(setDisplayContext:))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn setDisplayContext(&self, display_context: SWAttributionViewDisplayContext);
180
181        /// The horizontal alignment of the view. You should specify a value, in case the internal default ever changes.
182        ///
183        /// 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.
184        #[unsafe(method(horizontalAlignment))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn horizontalAlignment(&self) -> SWAttributionViewHorizontalAlignment;
187
188        /// Setter for [`horizontalAlignment`][Self::horizontalAlignment].
189        #[unsafe(method(setHorizontalAlignment:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn setHorizontalAlignment(
192            &self,
193            horizontal_alignment: SWAttributionViewHorizontalAlignment,
194        );
195
196        /// The background style of the inner view containing names and avatars.
197        ///
198        /// 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.
199        #[unsafe(method(backgroundStyle))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn backgroundStyle(&self) -> SWAttributionViewBackgroundStyle;
202
203        /// Setter for [`backgroundStyle`][Self::backgroundStyle].
204        #[unsafe(method(setBackgroundStyle:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn setBackgroundStyle(&self, background_style: SWAttributionViewBackgroundStyle);
207
208        #[cfg(feature = "objc2-core-foundation")]
209        /// For use when embedding this view in a SwiftUI view representable.
210        ///
211        /// 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.
212        #[unsafe(method(preferredMaxLayoutWidth))]
213        #[unsafe(method_family = none)]
214        pub unsafe fn preferredMaxLayoutWidth(&self) -> CGFloat;
215
216        #[cfg(feature = "objc2-core-foundation")]
217        /// Setter for [`preferredMaxLayoutWidth`][Self::preferredMaxLayoutWidth].
218        #[unsafe(method(setPreferredMaxLayoutWidth:))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn setPreferredMaxLayoutWidth(&self, preferred_max_layout_width: CGFloat);
221
222        #[unsafe(method(highlightMenu))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn highlightMenu(&self) -> Retained<NSMenu>;
225
226        /// 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.
227        ///
228        /// 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
229        /// "
230        /// Hide Article", localized to the current language. The string should include the word "Hide", localized correctly with the custom content type.
231        #[unsafe(method(menuTitleForHideAction))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn menuTitleForHideAction(&self) -> Option<Retained<NSString>>;
234
235        /// Setter for [`menuTitleForHideAction`][Self::menuTitleForHideAction].
236        #[unsafe(method(setMenuTitleForHideAction:))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn setMenuTitleForHideAction(
239            &self,
240            menu_title_for_hide_action: Option<&NSString>,
241        );
242
243        #[unsafe(method(supplementalMenu))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn supplementalMenu(&self) -> Option<Retained<NSMenuItem>>;
246
247        /// Setter for [`supplementalMenu`][Self::supplementalMenu].
248        #[unsafe(method(setSupplementalMenu:))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn setSupplementalMenu(&self, supplemental_menu: Option<&NSMenuItem>);
251
252        /// Automatically enables a marquee effect if the text contents extend past the bounds of the view (tvOS only)
253        #[unsafe(method(enablesMarquee))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn enablesMarquee(&self) -> bool;
256
257        /// Setter for [`enablesMarquee`][Self::enablesMarquee].
258        #[unsafe(method(setEnablesMarquee:))]
259        #[unsafe(method_family = none)]
260        pub unsafe fn setEnablesMarquee(&self, enables_marquee: bool);
261    );
262}
263
264/// Methods declared on superclass `NSView`.
265#[cfg(feature = "objc2-app-kit")]
266#[cfg(target_os = "macos")]
267impl SWAttributionView {
268    extern_methods!(
269        #[unsafe(method(initWithFrame:))]
270        #[unsafe(method_family = init)]
271        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
272
273        /// # Safety
274        ///
275        /// `coder` possibly has further requirements.
276        #[unsafe(method(initWithCoder:))]
277        #[unsafe(method_family = init)]
278        pub unsafe fn initWithCoder(
279            this: Allocated<Self>,
280            coder: &NSCoder,
281        ) -> Option<Retained<Self>>;
282    );
283}
284
285/// Methods declared on superclass `NSResponder`.
286#[cfg(feature = "objc2-app-kit")]
287#[cfg(target_os = "macos")]
288impl SWAttributionView {
289    extern_methods!(
290        #[unsafe(method(init))]
291        #[unsafe(method_family = init)]
292        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
293    );
294}
295
296/// Methods declared on superclass `NSObject`.
297#[cfg(feature = "objc2-app-kit")]
298#[cfg(target_os = "macos")]
299impl SWAttributionView {
300    extern_methods!(
301        #[unsafe(method(new))]
302        #[unsafe(method_family = new)]
303        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
304    );
305}