objc2_application_services/generated/PrintCore/
PDEPluginInterface.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7#[cfg(feature = "objc2-foundation")]
8use objc2_foundation::*;
9
10use crate::*;
11
12#[cfg(feature = "objc2")]
13extern_protocol!(
14    /// An instance implementing methods in the PDEPlugIn protocol
15    /// acts as a factory for PDEPanels. The factory is provided with the type
16    /// of printer panel needed (page setup or print dialog) as well as
17    /// the current printer. It can use this information to determine which
18    /// PDEPanels should be created.
19    ///
20    /// See also [Apple's documentation](https://developer.apple.com/documentation/applicationservices/pdeplugin?language=objc)
21    #[cfg(feature = "objc2")]
22    pub unsafe trait PDEPlugIn: NSObjectProtocol {
23        #[cfg(feature = "objc2-foundation")]
24        /// Called to instantiate the principal class of the PDE plug-in.
25        ///
26        ///
27        /// Prior to macOS 13, PDE plug-ins were instantiated with -init, and after
28        /// that -initWithBundle: was called expecting a BOOL return. In macOS 13
29        /// and later, PDE plug-ins that conform to the PDEPlugIn protocol will be
30        /// instantiated with -initWithBundle: as the sole initializer method, returning
31        /// the usual instancetype. PDE plug-ins that do not conform to PDEPlugIn
32        /// will be instantiated in the old two step way.
33        ///
34        ///
35        /// Parameter `theBundle`: The plug-in's bundle.
36        ///
37        ///
38        /// Returns: Return a valid instance if initialization succeeded and nil otherwise.
39        #[unsafe(method(initWithBundle:))]
40        #[unsafe(method_family = init)]
41        unsafe fn initWithBundle(
42            this: Allocated<Self>,
43            the_bundle: &NSBundle,
44        ) -> Option<Retained<Self>>;
45
46        #[cfg(feature = "objc2-foundation")]
47        /// Returns an array of instances conforming to the PDEPanel protocol.
48        ///
49        ///
50        /// Parameter `pdeType`: The type of print panels that should be returned. These kinds are
51        /// defined in PMPrintingDialogExtensions.h and include:
52        /// kGeneralPageSetupDialogTypeIDStr
53        /// - Panels that should be shown in the page setup dialog.
54        /// kGeneralPrintDialogTypeIDStr
55        /// - Panels that should be shown in the print dialog.
56        ///
57        ///
58        /// Parameter `host`: A print system provided instance that implements methods from the protocol
59        /// PDEPlugInCallbackProtocol. The PDEPlugIn can use this parameter to
60        /// obtain the current printer or print setting in order to filter the
61        /// available panels if there are printer specific PDEPanels in the PDEPlugIn.
62        ///
63        ///
64        /// Returns: An array of instances implementing methods from the PDEPanel protocol.
65        /// Each instance represents a panel that will be shown in the printer dialog.
66        /// The method may return either nil or an empty array if no panels should be used.
67        #[unsafe(method(PDEPanelsForType:withHostInfo:))]
68        #[unsafe(method_family = none)]
69        unsafe fn PDEPanelsForType_withHostInfo(
70            &self,
71            pde_type: &NSString,
72            host: &ProtocolObject<dyn PDEPlugInCallbackProtocol>,
73        ) -> Option<Retained<NSArray<ProtocolObject<dyn PDEPanel>>>>;
74    }
75);
76
77#[cfg(feature = "objc2")]
78extern_protocol!(
79    /// A print dialog plugin should have an instance implementing methods
80    /// from the PDEPanel protocol. Each such instance handles a single
81    /// print dialog panel.
82    ///
83    /// See also [Apple's documentation](https://developer.apple.com/documentation/applicationservices/pdepanel?language=objc)
84    #[cfg(feature = "objc2")]
85    pub unsafe trait PDEPanel: NSObjectProtocol {
86        /// The panel should complete any final preperations it needs
87        /// before the panel is shown.
88        ///
89        ///
90        /// The panel may want to use this method to lazily prepare
91        /// its user interface.
92        #[unsafe(method(willShow))]
93        #[unsafe(method_family = none)]
94        unsafe fn willShow(&self);
95
96        /// Prepare the panel to be removed from the user's sight.
97        ///
98        ///
99        /// This method is invoked by the print system just before the panel is
100        /// removed fromthe user's sight. The panel can use this opportunity
101        /// for any final interaction with the user, perhaps to check the user's
102        /// input. A panel that needs more interaction with the user, perhaps
103        /// because some of the input values were invalid, should return NO.
104        /// Returning YES indicates that the panel can be hidden, probably to
105        /// show another panel or to dismiss the printing dialog.
106        ///
107        ///
108        /// Returns: Return YES if it is okay to hide panel and NO otherwise.
109        #[unsafe(method(shouldHide))]
110        #[unsafe(method_family = none)]
111        unsafe fn shouldHide(&self) -> bool;
112
113        #[cfg(feature = "objc2-foundation")]
114        /// Take the values from the panel's user interface and write them to
115        /// the appropriate settings.
116        ///
117        ///
118        /// This is the panel's chance to write the values from its user interface
119        /// controls to the permanent store. Depending upon the panel type the values may
120        /// be stored in the print settings or into the page format. Panels of type
121        /// kGeneralPageSetupDialogTypeIDStr will generally store values into the page
122        /// format while panels of type kGeneralPrintDialogTypeIDStr will write to
123        /// the print settings. The panel should use the provided PDEPlugInCallbackProtocol
124        /// to obtain the settings and tickets it needs to write into.
125        ///
126        /// A panel will usually be asked to write its values when the user dismisses
127        /// the dialog, other than via cancel, or when the user has asked that a preset
128        /// be saved.
129        #[unsafe(method(saveValuesAndReturnError:_))]
130        #[unsafe(method_family = none)]
131        unsafe fn saveValuesAndReturnError(&self) -> Result<(), Retained<NSError>>;
132
133        #[cfg(feature = "objc2-foundation")]
134        /// Set the panel's user interface elements based upon the appropriate settings.
135        ///
136        ///
137        /// The panel should refresh its user interface elements by reading values from
138        /// the page format or print settings. The panel should use the provided
139        /// PDEPlugInCallbackProtocol to obtain the settings and tickets it needs to read.
140        ///
141        /// A panel will usually be asked to read its setting just before it is first
142        /// shown and when the user selects a new preset.
143        #[unsafe(method(restoreValuesAndReturnError:_))]
144        #[unsafe(method_family = none)]
145        unsafe fn restoreValuesAndReturnError(&self) -> Result<(), Retained<NSError>>;
146
147        #[cfg(feature = "objc2-foundation")]
148        /// The panel takes responsability for displaying user interface elements for the
149        /// PPD option keys returned from this call.
150        ///
151        ///
152        /// Any PPD option keys not claimed by a PDEPanel are provided with a dynamically built
153        /// user interface in the Printer Features panel.
154        #[optional]
155        #[unsafe(method(supportedPPDOptionKeys))]
156        #[unsafe(method_family = none)]
157        unsafe fn supportedPPDOptionKeys(&self) -> Option<Retained<NSArray<NSString>>>;
158
159        #[cfg(feature = "objc2-foundation")]
160        /// Inform the panel that, external to the panel, the specified PPD
161        /// choice has been made.
162        ///
163        ///
164        /// During PPD conflict resolution the choice for a panel controlled PPD option
165        /// may need to be changed by another panel. This call informs the panel
166        /// that a setting has been changed. The panel should update any internal data it maintains
167        /// in regards to this PPD option key.
168        ///
169        /// The 'option' and 'choice' values are taken from the printer's PPD. For
170        /// example the PPD fragment:
171        ///
172        /// *OpenUI *TraySwitch/Tray Switch:    Boolean
173        /// *TraySwitch True/On: "1 dict dup /TraySwitch true put setpagedevice"
174        /// *TraySwitch False/Off: "1 dict dup /TraySwitch false put setpagedevice"
175        /// *CloseUI: *TraySwitch
176        ///
177        /// describes the option 'TraySwitch'. It has 2 choices: 'True' and 'False'.
178        /// If another panel caused the choice of the option key 'TraySwitch' to be
179        /// altered to 'True'then this method will be called with the 'option' parameter
180        /// set to
181        /// "
182        /// TraySwitch" and the 'choice parameter set to @"True".
183        #[unsafe(method(PPDOptionKeyValueDidChange:ppdChoice:))]
184        #[unsafe(method_family = none)]
185        unsafe fn PPDOptionKeyValueDidChange_ppdChoice(&self, option: &NSString, choice: &NSString);
186
187        #[cfg(feature = "objc2-foundation")]
188        /// Return the panel's name.
189        ///
190        ///
191        /// This is the localized name of the panel. It will be placed into
192        /// the panel menu.
193        #[unsafe(method(panelName))]
194        #[unsafe(method_family = none)]
195        unsafe fn panelName(&self) -> Retained<NSString>;
196
197        #[cfg(feature = "objc2-foundation")]
198        /// Return the panel's kind.
199        ///
200        ///
201        /// A panel's kind is used to allow a plugin to override a system panel.
202        /// PMPrintingDialogExtensions.h lists the kinds for the print system provided
203        /// panels. If a PDF panel is not supposed to override a print system provided
204        /// panel then it should return a unique string for its kind.
205        #[unsafe(method(panelKind))]
206        #[unsafe(method_family = none)]
207        unsafe fn panelKind(&self) -> Retained<NSString>;
208
209        #[cfg(feature = "objc2-foundation")]
210        /// Return localized, textual descriptions of the panel's settings.
211        ///
212        ///
213        /// Each key in the dictionary must be an NSString providing the name
214        /// of the setting. The value for the key must be an NSString describing
215        /// the value for the setting. The strings should be localized for the
216        /// current user. For example a key in the dictionary for the copies and
217        /// pages panel might have the key 'Page Range' and the value 'All'.
218        #[unsafe(method(summaryInfo))]
219        #[unsafe(method_family = none)]
220        unsafe fn summaryInfo(&self) -> Option<Retained<NSDictionary<NSString, NSString>>>;
221
222        /// The panel should show panel specific help if it is available.
223        ///
224        ///
225        /// Returns: Return YES if the default printing help should be shown and NO otherwise.
226        ///
227        ///
228        /// When a given panel is visible and the user clicks on the help
229        /// icon in a print dialog or sheet, the current panel's shouldShowHelp
230        /// method is invoked. If the panel implements custom help, the
231        /// panel should then present that help and return NO. If this method is not
232        /// implemented by a panel or the panel's shouldShowHelp method returns YES,
233        /// the default printing help will be presented.
234        ///
235        /// Invoked only in Mac OS X version 10.5 and later.
236        #[optional]
237        #[unsafe(method(shouldShowHelp))]
238        #[unsafe(method_family = none)]
239        unsafe fn shouldShowHelp(&self) -> bool;
240
241        /// The panel should indicate whether the user should be allowed to print.
242        ///
243        ///
244        /// Returns: Return YES unless the printing state for the panel does not allow printing.
245        ///
246        ///
247        /// When a user has performed an action in a print dialog or sheet
248        /// that will initiate printing, prior to dismissing the dialog, a panel's
249        /// shouldPrint method is invoked, allowing a panel to indicate that the
250        /// current state of the dialog should not allow printing. Prior to returning
251        /// NO, a panel should present information to the user as to why printing is not
252        /// allowed.
253        ///
254        /// Most panels have no need to implement a 'shouldPrint' method. Typically
255        /// a panel manages its state so that it is always valid for the user to
256        /// click the print button or otherwise initiate a printing action.
257        ///
258        /// Invoked only in Mac OS X version 10.5 and later.
259        #[optional]
260        #[unsafe(method(shouldPrint))]
261        #[unsafe(method_family = none)]
262        unsafe fn shouldPrint(&self) -> bool;
263
264        /// The print dialog or sheet is closing and a panel should perform
265        /// any special tasks that are needed before the window is closed.
266        ///
267        ///
268        /// This is the print panel's chance to peform any special tasks before
269        /// the print dialog or sheet goes away. The 'userCanceled' parameter
270        /// is true if the print window is being being dismissed because the user
271        /// canceled the dialog or sheet.
272        ///
273        /// One reason for implementing a printWindowWillClose is so that a panel
274        /// can remove any notification observers it has added.
275        ///
276        /// Invoked only in Mac OS X version 10.6 and later.
277        #[optional]
278        #[unsafe(method(printWindowWillClose:))]
279        #[unsafe(method_family = none)]
280        unsafe fn printWindowWillClose(&self, user_canceled: bool);
281    }
282);
283
284#[cfg(feature = "objc2")]
285extern_protocol!(
286    /// A protocol implemented by the print system so
287    /// that printing dialog extensions can obtain information
288    /// about the current printer and print job.
289    ///
290    ///
291    /// An print system created instance implementing the protocol,
292    /// PDEPlugInCallbackProtocol, is passed to PDEPlugin as part of the PDEPlugIn's
293    /// PDEPanelsForType:withHostInfo: message. The PDEPlugIn is expected to
294    /// hold on to the passed in instance and to use this PDEPlugInCallbackProtocol
295    /// to query the print system for relevant information. The PDEPlugin can
296    /// pass the instance implementing PDEPlugInCallbackProtocol to PDEPanels
297    /// as needed.
298    ///
299    /// See also [Apple's documentation](https://developer.apple.com/documentation/applicationservices/pdeplugincallbackprotocol?language=objc)
300    #[cfg(feature = "objc2")]
301    pub unsafe trait PDEPlugInCallbackProtocol {
302        #[cfg(feature = "PMDefinitions")]
303        /// Return a reference to the current print session.
304        #[unsafe(method(printSession))]
305        #[unsafe(method_family = none)]
306        unsafe fn printSession(&self) -> PMPrintSession;
307
308        #[cfg(feature = "PMDefinitions")]
309        /// Return a reference to the print settings object that is
310        /// being modified by the printer dialog.
311        ///
312        ///
313        /// This method will return nil if the current print dialog is
314        /// not operating on a print settings. The page setup dialog is
315        /// the most obvious case where this method will return nil.
316        #[unsafe(method(printSettings))]
317        #[unsafe(method_family = none)]
318        unsafe fn printSettings(&self) -> PMPrintSettings;
319
320        #[cfg(feature = "PMDefinitions")]
321        /// Return a reference to the page format that is being used
322        /// by the printer dialog.
323        ///
324        ///
325        /// The caller should be prepared for this method to return nil
326        /// if the current print dialog is operating without a page format
327        /// instance. Today both the print and page setup dialogs will return
328        /// a reference to a page format object.
329        #[unsafe(method(pageFormat))]
330        #[unsafe(method_family = none)]
331        unsafe fn pageFormat(&self) -> PMPageFormat;
332
333        #[cfg(feature = "PMDefinitions")]
334        /// Return a reference to the current printer instance.
335        ///
336        ///
337        /// When the page setup dialog is displayed this method will return
338        /// the user's default printer. When the print dialog is displayed this
339        /// method will return the printer currently selected in the print dialog.
340        #[unsafe(method(PMPrinter))]
341        #[unsafe(method_family = none)]
342        unsafe fn PMPrinter(&self) -> PMPrinter;
343
344        #[cfg(feature = "objc2-foundation")]
345        /// A PDEPlugIn makes this call to let the print system know that
346        /// the plugin intends to alter the choice for a PPD option.
347        ///
348        ///
349        /// When a print dialog plugin intends to change the choice for a
350        /// PPD option it notifies the print system with this call. If the
351        /// desired choice is in conflict with other currently selected PPD options
352        /// then the print system will try to do conflict resolution. This may
353        /// include presenting the user with a dialog explaining the conflict
354        /// and allowing the user to cancel the change.
355        ///
356        /// The 'option' parameter names a main key from the printer's PPD.
357        /// As an example take the following PPD fragment:
358        ///
359        /// *OpenUI *MediaType/Paper Type: PickOne
360        /// *MediaType Plain/Plain: ""
361        /// *MediaType Transparency/Transparency: ""
362        /// *CloseUI: *MediaType
363        ///
364        /// If a panel wishes to switch the value of the option key 'MediaType'
365        /// to the choice 'Transparency' then it should invoke this callback
366        /// passing
367        /// "
368        /// MediaType" and @"Transparency" as the 'option' and
369        /// 'choice' parameters. If that choice is allowed then YES will be
370        /// returned otherwise NO.
371        ///
372        ///
373        /// Returns: Returns YES if the plugin should make the change and returns NO if the
374        /// user or the print system would like the change not to occur.
375        #[unsafe(method(willChangePPDOptionKeyValue:ppdChoice:))]
376        #[unsafe(method_family = none)]
377        unsafe fn willChangePPDOptionKeyValue_ppdChoice(
378            &self,
379            option: &NSString,
380            choice: &NSString,
381        ) -> bool;
382    }
383);