objc2_app_kit/generated/
NSPrintPanel.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintpanelresult?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct NSPrintPanelResult(pub NSInteger);
15impl NSPrintPanelResult {
16    #[doc(alias = "NSPrintPanelResultCancelled")]
17    pub const Cancelled: Self = Self(0);
18    #[doc(alias = "NSPrintPanelResultPrinted")]
19    pub const Printed: Self = Self(1);
20}
21
22unsafe impl Encode for NSPrintPanelResult {
23    const ENCODING: Encoding = NSInteger::ENCODING;
24}
25
26unsafe impl RefEncode for NSPrintPanelResult {
27    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
28}
29
30/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintpaneloptions?language=objc)
31// NS_OPTIONS
32#[repr(transparent)]
33#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
34pub struct NSPrintPanelOptions(pub NSUInteger);
35bitflags::bitflags! {
36    impl NSPrintPanelOptions: NSUInteger {
37        #[doc(alias = "NSPrintPanelShowsCopies")]
38        const ShowsCopies = 1<<0;
39        #[doc(alias = "NSPrintPanelShowsPageRange")]
40        const ShowsPageRange = 1<<1;
41        #[doc(alias = "NSPrintPanelShowsPaperSize")]
42        const ShowsPaperSize = 1<<2;
43        #[doc(alias = "NSPrintPanelShowsOrientation")]
44        const ShowsOrientation = 1<<3;
45        #[doc(alias = "NSPrintPanelShowsScaling")]
46        const ShowsScaling = 1<<4;
47        #[doc(alias = "NSPrintPanelShowsPrintSelection")]
48        const ShowsPrintSelection = 1<<5;
49        #[doc(alias = "NSPrintPanelShowsPageSetupAccessory")]
50        const ShowsPageSetupAccessory = 1<<8;
51        #[doc(alias = "NSPrintPanelShowsPreview")]
52        const ShowsPreview = 1<<17;
53    }
54}
55
56unsafe impl Encode for NSPrintPanelOptions {
57    const ENCODING: Encoding = NSUInteger::ENCODING;
58}
59
60unsafe impl RefEncode for NSPrintPanelOptions {
61    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintpaneljobstylehint?language=objc)
65// NS_TYPED_ENUM
66pub type NSPrintPanelJobStyleHint = NSString;
67
68extern "C" {
69    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintphotojobstylehint?language=objc)
70    pub static NSPrintPhotoJobStyleHint: &'static NSPrintPanelJobStyleHint;
71}
72
73extern "C" {
74    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintallpresetsjobstylehint?language=objc)
75    pub static NSPrintAllPresetsJobStyleHint: &'static NSPrintPanelJobStyleHint;
76}
77
78extern "C" {
79    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintnopresetsjobstylehint?language=objc)
80    pub static NSPrintNoPresetsJobStyleHint: &'static NSPrintPanelJobStyleHint;
81}
82
83/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintpanelaccessorysummarykey?language=objc)
84// NS_TYPED_ENUM
85pub type NSPrintPanelAccessorySummaryKey = NSString;
86
87extern "C" {
88    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintpanelaccessorysummaryitemnamekey?language=objc)
89    pub static NSPrintPanelAccessorySummaryItemNameKey: &'static NSPrintPanelAccessorySummaryKey;
90}
91
92extern "C" {
93    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintpanelaccessorysummaryitemdescriptionkey?language=objc)
94    pub static NSPrintPanelAccessorySummaryItemDescriptionKey:
95        &'static NSPrintPanelAccessorySummaryKey;
96}
97
98extern_protocol!(
99    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintpanelaccessorizing?language=objc)
100    pub unsafe trait NSPrintPanelAccessorizing: MainThreadOnly {
101        #[unsafe(method(localizedSummaryItems))]
102        #[unsafe(method_family = none)]
103        fn localizedSummaryItems(
104            &self,
105        ) -> Retained<NSArray<NSDictionary<NSPrintPanelAccessorySummaryKey, NSString>>>;
106
107        #[optional]
108        #[unsafe(method(keyPathsForValuesAffectingPreview))]
109        #[unsafe(method_family = none)]
110        fn keyPathsForValuesAffectingPreview(&self) -> Retained<NSSet<NSString>>;
111    }
112);
113
114extern_class!(
115    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintpanel?language=objc)
116    #[unsafe(super(NSObject))]
117    #[thread_kind = MainThreadOnly]
118    #[derive(Debug, PartialEq, Eq, Hash)]
119    pub struct NSPrintPanel;
120);
121
122extern_conformance!(
123    unsafe impl NSObjectProtocol for NSPrintPanel {}
124);
125
126impl NSPrintPanel {
127    extern_methods!(
128        #[unsafe(method(printPanel))]
129        #[unsafe(method_family = none)]
130        pub fn printPanel(mtm: MainThreadMarker) -> Retained<NSPrintPanel>;
131
132        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
133        /// # Safety
134        ///
135        /// `accessory_controller` must implement NSPrintPanelAccessorizing.
136        #[unsafe(method(addAccessoryController:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn addAccessoryController(&self, accessory_controller: &NSViewController);
139
140        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
141        /// # Safety
142        ///
143        /// `accessory_controller` must implement NSPrintPanelAccessorizing.
144        #[unsafe(method(removeAccessoryController:))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn removeAccessoryController(&self, accessory_controller: &NSViewController);
147
148        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
149        #[unsafe(method(accessoryControllers))]
150        #[unsafe(method_family = none)]
151        pub fn accessoryControllers(&self) -> Retained<NSArray<NSViewController>>;
152
153        #[unsafe(method(options))]
154        #[unsafe(method_family = none)]
155        pub fn options(&self) -> NSPrintPanelOptions;
156
157        /// Setter for [`options`][Self::options].
158        #[unsafe(method(setOptions:))]
159        #[unsafe(method_family = none)]
160        pub fn setOptions(&self, options: NSPrintPanelOptions);
161
162        #[unsafe(method(setDefaultButtonTitle:))]
163        #[unsafe(method_family = none)]
164        pub fn setDefaultButtonTitle(&self, default_button_title: Option<&NSString>);
165
166        #[unsafe(method(defaultButtonTitle))]
167        #[unsafe(method_family = none)]
168        pub fn defaultButtonTitle(&self) -> Option<Retained<NSString>>;
169
170        #[cfg(feature = "NSHelpManager")]
171        #[unsafe(method(helpAnchor))]
172        #[unsafe(method_family = none)]
173        pub fn helpAnchor(&self) -> Option<Retained<NSHelpAnchorName>>;
174
175        #[cfg(feature = "NSHelpManager")]
176        /// Setter for [`helpAnchor`][Self::helpAnchor].
177        ///
178        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
179        #[unsafe(method(setHelpAnchor:))]
180        #[unsafe(method_family = none)]
181        pub fn setHelpAnchor(&self, help_anchor: Option<&NSHelpAnchorName>);
182
183        #[unsafe(method(jobStyleHint))]
184        #[unsafe(method_family = none)]
185        pub fn jobStyleHint(&self) -> Option<Retained<NSPrintPanelJobStyleHint>>;
186
187        /// Setter for [`jobStyleHint`][Self::jobStyleHint].
188        ///
189        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
190        #[unsafe(method(setJobStyleHint:))]
191        #[unsafe(method_family = none)]
192        pub fn setJobStyleHint(&self, job_style_hint: Option<&NSPrintPanelJobStyleHint>);
193
194        #[cfg(all(
195            feature = "NSPrintInfo",
196            feature = "NSResponder",
197            feature = "NSWindow",
198            feature = "block2"
199        ))]
200        #[unsafe(method(beginSheetUsingPrintInfo:onWindow:completionHandler:))]
201        #[unsafe(method_family = none)]
202        pub fn beginSheetUsingPrintInfo_onWindow_completionHandler(
203            &self,
204            print_info: &NSPrintInfo,
205            parent_window: &NSWindow,
206            handler: Option<&block2::DynBlock<dyn Fn(NSPrintPanelResult)>>,
207        );
208
209        #[cfg(all(feature = "NSPrintInfo", feature = "NSResponder", feature = "NSWindow"))]
210        /// # Safety
211        ///
212        /// - `delegate` should be of the correct type.
213        /// - `did_end_selector` must be a valid selector.
214        /// - `context_info` must be a valid pointer or null.
215        #[deprecated]
216        #[unsafe(method(beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn beginSheetWithPrintInfo_modalForWindow_delegate_didEndSelector_contextInfo(
219            &self,
220            print_info: &NSPrintInfo,
221            doc_window: &NSWindow,
222            delegate: Option<&AnyObject>,
223            did_end_selector: Option<Sel>,
224            context_info: *mut c_void,
225        );
226
227        #[cfg(feature = "NSPrintInfo")]
228        #[unsafe(method(runModalWithPrintInfo:))]
229        #[unsafe(method_family = none)]
230        pub fn runModalWithPrintInfo(&self, print_info: &NSPrintInfo) -> NSInteger;
231
232        #[unsafe(method(runModal))]
233        #[unsafe(method_family = none)]
234        pub fn runModal(&self) -> NSInteger;
235
236        #[cfg(feature = "NSPrintInfo")]
237        #[unsafe(method(printInfo))]
238        #[unsafe(method_family = none)]
239        pub fn printInfo(&self) -> Retained<NSPrintInfo>;
240    );
241}
242
243/// Methods declared on superclass `NSObject`.
244impl NSPrintPanel {
245    extern_methods!(
246        #[unsafe(method(init))]
247        #[unsafe(method_family = init)]
248        pub fn init(this: Allocated<Self>) -> Retained<Self>;
249
250        #[unsafe(method(new))]
251        #[unsafe(method_family = new)]
252        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
253    );
254}
255
256/// NSDeprecated.
257impl NSPrintPanel {
258    extern_methods!(
259        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
260        #[deprecated = "Use -addAccessoryController instead"]
261        #[unsafe(method(setAccessoryView:))]
262        #[unsafe(method_family = none)]
263        pub fn setAccessoryView(&self, accessory_view: Option<&NSView>);
264
265        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
266        #[deprecated = "Use -accessoryControllers instead. For compatibility this returns the view of the first accessory controller, or nil"]
267        #[unsafe(method(accessoryView))]
268        #[unsafe(method_family = none)]
269        pub fn accessoryView(&self) -> Option<Retained<NSView>>;
270
271        #[deprecated]
272        #[unsafe(method(updateFromPrintInfo))]
273        #[unsafe(method_family = none)]
274        pub fn updateFromPrintInfo(&self);
275
276        #[deprecated]
277        #[unsafe(method(finalWritePrintInfo))]
278        #[unsafe(method_family = none)]
279        pub fn finalWritePrintInfo(&self);
280    );
281}