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        unsafe fn localizedSummaryItems(
104            &self,
105        ) -> Retained<NSArray<NSDictionary<NSPrintPanelAccessorySummaryKey, NSString>>>;
106
107        #[optional]
108        #[unsafe(method(keyPathsForValuesAffectingPreview))]
109        #[unsafe(method_family = none)]
110        unsafe 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
122unsafe impl NSObjectProtocol for NSPrintPanel {}
123
124impl NSPrintPanel {
125    extern_methods!(
126        #[unsafe(method(printPanel))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn printPanel(mtm: MainThreadMarker) -> Retained<NSPrintPanel>;
129
130        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
131        #[unsafe(method(addAccessoryController:))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn addAccessoryController(&self, accessory_controller: &NSViewController);
134
135        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
136        #[unsafe(method(removeAccessoryController:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn removeAccessoryController(&self, accessory_controller: &NSViewController);
139
140        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
141        #[unsafe(method(accessoryControllers))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn accessoryControllers(&self) -> Retained<NSArray<NSViewController>>;
144
145        #[unsafe(method(options))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn options(&self) -> NSPrintPanelOptions;
148
149        /// Setter for [`options`][Self::options].
150        #[unsafe(method(setOptions:))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn setOptions(&self, options: NSPrintPanelOptions);
153
154        #[unsafe(method(setDefaultButtonTitle:))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn setDefaultButtonTitle(&self, default_button_title: Option<&NSString>);
157
158        #[unsafe(method(defaultButtonTitle))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn defaultButtonTitle(&self) -> Option<Retained<NSString>>;
161
162        #[cfg(feature = "NSHelpManager")]
163        #[unsafe(method(helpAnchor))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn helpAnchor(&self) -> Option<Retained<NSHelpAnchorName>>;
166
167        #[cfg(feature = "NSHelpManager")]
168        /// Setter for [`helpAnchor`][Self::helpAnchor].
169        #[unsafe(method(setHelpAnchor:))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn setHelpAnchor(&self, help_anchor: Option<&NSHelpAnchorName>);
172
173        #[unsafe(method(jobStyleHint))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn jobStyleHint(&self) -> Option<Retained<NSPrintPanelJobStyleHint>>;
176
177        /// Setter for [`jobStyleHint`][Self::jobStyleHint].
178        #[unsafe(method(setJobStyleHint:))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn setJobStyleHint(&self, job_style_hint: Option<&NSPrintPanelJobStyleHint>);
181
182        #[cfg(all(
183            feature = "NSPrintInfo",
184            feature = "NSResponder",
185            feature = "NSWindow",
186            feature = "block2"
187        ))]
188        #[unsafe(method(beginSheetUsingPrintInfo:onWindow:completionHandler:))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn beginSheetUsingPrintInfo_onWindow_completionHandler(
191            &self,
192            print_info: &NSPrintInfo,
193            parent_window: &NSWindow,
194            handler: Option<&block2::Block<dyn Fn(NSPrintPanelResult)>>,
195        );
196
197        #[cfg(all(feature = "NSPrintInfo", feature = "NSResponder", feature = "NSWindow"))]
198        #[deprecated]
199        #[unsafe(method(beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn beginSheetWithPrintInfo_modalForWindow_delegate_didEndSelector_contextInfo(
202            &self,
203            print_info: &NSPrintInfo,
204            doc_window: &NSWindow,
205            delegate: Option<&AnyObject>,
206            did_end_selector: Option<Sel>,
207            context_info: *mut c_void,
208        );
209
210        #[cfg(feature = "NSPrintInfo")]
211        #[unsafe(method(runModalWithPrintInfo:))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn runModalWithPrintInfo(&self, print_info: &NSPrintInfo) -> NSInteger;
214
215        #[unsafe(method(runModal))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn runModal(&self) -> NSInteger;
218
219        #[cfg(feature = "NSPrintInfo")]
220        #[unsafe(method(printInfo))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn printInfo(&self) -> Retained<NSPrintInfo>;
223    );
224}
225
226/// Methods declared on superclass `NSObject`.
227impl NSPrintPanel {
228    extern_methods!(
229        #[unsafe(method(init))]
230        #[unsafe(method_family = init)]
231        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
232
233        #[unsafe(method(new))]
234        #[unsafe(method_family = new)]
235        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
236    );
237}
238
239/// NSDeprecated.
240impl NSPrintPanel {
241    extern_methods!(
242        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
243        #[deprecated = "Use -addAccessoryController instead"]
244        #[unsafe(method(setAccessoryView:))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn setAccessoryView(&self, accessory_view: Option<&NSView>);
247
248        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
249        #[deprecated = "Use -accessoryControllers instead. For compatibility this returns the view of the first accessory controller, or nil"]
250        #[unsafe(method(accessoryView))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn accessoryView(&self) -> Option<Retained<NSView>>;
253
254        #[deprecated]
255        #[unsafe(method(updateFromPrintInfo))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn updateFromPrintInfo(&self);
258
259        #[deprecated]
260        #[unsafe(method(finalWritePrintInfo))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn finalWritePrintInfo(&self);
263    );
264}