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