NSPrintPanel Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.0 and later. |
| Declared in | NSPrintPanel.h |
| Companion guides | |
Overview
An NSPrintPanel object creates the Print panel used to query the user for information about a print job. This panel may lets the user select the range of pages to print and the number of copies before executing the Print command.
Print panels can display a simplified interface when printing certain types of data. For example, the panel can display a list of print-setting presets, which lets the user enable print settings in groups as opposed to individually. The setJobStyleHint: method activates the simplified interface and identifies which presets to display.
Tasks
Creating an NSPrintPanel
Customizing the Panel
-
– jobStyleHint -
– setJobStyleHint: -
– options -
– setOptions: -
– defaultButtonTitle -
– setDefaultButtonTitle: -
– helpAnchor -
– setHelpAnchor:
Managing Accessory Views
Running the Panel
-
– beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo: -
– runModal -
– runModalWithPrintInfo:
Communicating with the NSPrintInfo Object
-
– printInfo -
– finalWritePrintInfoDeprecated in OS X v10.5 -
– updateFromPrintInfoDeprecated in OS X v10.5
Deprecated Methods
-
– pickedAllPages:Available in OS X v10.0 through OS X v10.4 -
– pickedButton:Available in OS X v10.0 through OS X v10.4 -
– pickedLayoutList:Available in OS X v10.0 through OS X v10.4 -
– accessoryViewDeprecated in OS X v10.5 -
– setAccessoryView:Deprecated in OS X v10.5
Class Methods
printPanel
Returns a new NSPrintPanel object.
Return Value
The print panel object.
Availability
- Available in OS X v10.0 and later.
Declared In
NSPrintPanel.hInstance Methods
accessoryControllers
Returns the array of controller objects used to manage the Print panel’s accessory views.
Return Value
An array of NSViewController objects, each of which manages an accessory view for the Print panel.
Discussion
This method returns the accessory views that were added using the addAccessoryController: method.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPrintPanel.haddAccessoryController:
Adds a custom controller to the Print panel to manage an accessory view.
Parameters
- accessoryController
The view controller that manages your custom accessory views.
Discussion
You can invoke this method multiple times to add multiple accessory views to the receiver’s Print panel.
The title for the accessory view is obtained from the title method of the view controller object.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPrintPanel.hbeginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:
Displays a Print panel sheet and runs it modally for the specified window.
Parameters
- printInfo
The printing information for the current job.
- docWindow
The window on which to display the sheet.
- modalDelegate
A modal delegate object assigned to handle the closing of the Print panel sheet.
- didEndSelector
The selector to call on the modal delegate object when the sheet is dismissed. The signature of this method is listed in the Discussion section.
- contextInfo
A pointer to context data the
didEndSelectormethod needs to process the sheet. This data is user-defined and may beNULL.
Discussion
When the modal session ends, if modalDelegate and didEndSelector contain non-nil values, the method specified by didEndSelector is invoked on the object in modalDelegate. The data you specify in contextInfo is passed as a parameter to the didEndSelector method. The object in modalDelegate is not the same as a delegate assigned to the panel. Modal delegates for sheets are temporary and the relationship lasts only until the sheet is dismissed.
The didEndSelector argument must have the following signature:
- (void)printPanelDidEnd:(NSPrintPanel *)printPanel returnCode:(NSInteger)returnCode contextInfo: (void *)contextInfo; |
The value passed as returnCode is either NSCancelButton or NSOKButton. The value NSOKButton is returned even if the user clicked the Preview button.
Availability
- Available in OS X v10.0 and later.
Declared In
NSPrintPanel.hdefaultButtonTitle
Returns the title of the Print panel’s default button.
Return Value
The title of the default button.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPrintPanel.hhelpAnchor
Returns the HTML help anchor associated with the Print panel.
Return Value
The current help anchor.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPrintPanel.hjobStyleHint
Returns the type of content that the Print panel is representing.
Return Value
A string containing the job style hint or nil if no hint has been set.
Availability
- Available in OS X v10.2 and later.
See Also
Declared In
NSPrintPanel.hoptions
Returns the current configuration options for the Print panel.
Return Value
One or more configuration constants added together. To determine if a particular option is set, AND the return value with the appropriate constants found in “NSPrintPanelOptions.”
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPrintPanel.hprintInfo
Returns the printing information associated with the running Print panel.
Return Value
The current printing information. May return nil if the Print panel is not currently running.
Discussion
This method is a convenience method that your delegate can use to get the printing information while the Print Panel is visible.
Availability
- Available in OS X v10.5 and later.
Declared In
NSPrintPanel.hremoveAccessoryController:
Removes the specified controller and accessory view from the Print panel.
Parameters
- accessoryController
The view controller to remove.
Discussion
You use this method to remove any view controllers responsible for displaying accessory views you do not want to include in the Print panel.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPrintPanel.hrunModal
Displays the receiver's Print panel and begins the modal loop.
Return Value
NSCancelButton if the user clicks the Cancel button; otherwise NSOKButton.
Discussion
This method uses the printing information associated with the current printing operation.
Availability
- Available in OS X v10.0 and later.
See Also
-
– printInfo(NSPrintOperation)
Declared In
NSPrintPanel.hrunModalWithPrintInfo:
Displays the receiver’s Print panel and runs the modal loop using the specified printing information.
Parameters
- printInfo
The printing information to use while displaying the Print panel.
Return Value
NSCancelButton if the user clicks the Cancel button; otherwise NSOKButton.
Availability
- Available in OS X v10.5 and later.
Declared In
NSPrintPanel.hsetDefaultButtonTitle:
Sets the title of the Print panel’s default button.
Parameters
- defaultButtonTitle
The string to use for the button title.
Discussion
You can use this method to change the default button title from "Print” to something more appropriate for your usage of the panel. For example, if you are using the Print panel to save a representation of the document to a file, you might change the title to “Save”.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPrintPanel.hsetHelpAnchor:
Sets the HTML help anchor for the print panel.
Parameters
- helpAnchor
The anchor name in your Apple Help file. This parameter should contain just the name portion of the HTML anchor element.
Discussion
For information on how to insert anchors into your Apple Help files, see Authoring User Help in Apple Help Programming Guide.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPrintPanel.hsetJobStyleHint:
Sets the type of content the Print panel is representing.
Parameters
- hint
For a list of supported job style hints, see “Job Style Hints.” Pass
nilto this method to deactivate the simplified Print panel interface and use the standard interface instead (the equivalent of Core Printing’skPMPresetGraphicsTypeGeneral).
Discussion
This method controls the set of items that appear in the Presets menu of the simplified Print panel interface.
Availability
- Available in OS X v10.2 and later.
See Also
Declared In
NSPrintPanel.hsetOptions:
Sets the configuration options for the Print panel.
Parameters
- options
The configuration options, which you specify by adding together the appropriate constant values found in “NSPrintPanelOptions.”
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPrintPanel.hConstants
Job Style Hints
This constant can be passed to the setJobStyleHint: method to activate the simplified Print panel interface and specify which presets to display.
NSString *const NSPrintPhotoJobStyleHint; NSString *const NSPrintAllPresetsJobStyleHint; NSString *const NSPrintNoPresetsJobStyleHint;
Constants
NSPrintPhotoJobStyleHintOutput contains photographic data.
Available in OS X v10.2 and later.
Declared in
NSPrintPanel.h.NSPrintAllPresetsJobStyleHintOutput appropriate to all graphics types. Equivalent to Core Printing’s
kPMPresetGraphicsTypeAll.Available in OS X v10.6 and later.
Declared in
NSPrintPanel.h.NSPrintNoPresetsJobStyleHintOutput excludes all graphics printing. Equivalent to Core Printing’s
kPMPresetGraphicsTypeNone.Available in OS X v10.6 and later.
Declared in
NSPrintPanel.h.
Declared In
NSPrintPanel.hNSPrintPanelOptions
These constants are used to configure the contents of the main Print panel.
enum {
NSPrintPanelShowsCopies = 0x01,
NSPrintPanelShowsPageRange = 0x02,
NSPrintPanelShowsPaperSize = 0x04,
NSPrintPanelShowsOrientation = 0x08,
NSPrintPanelShowsScaling = 0x10,
NSPrintPanelShowsPrintSelection = 1 << 5,
NSPrintPanelShowsPageSetupAccessory = 0x100,
NSPrintPanelShowsPreview = 0x20000
};
typedef NSInteger NSPrintPanelOptions;
Constants
NSPrintPanelShowsCopiesThe Print panel includes a field for manipulating the number of copies being printed. This field is separate from any accessory views.
Available in OS X v10.5 and later.
Declared in
NSPrintPanel.h.NSPrintPanelShowsPageRangeThe Print panel includes a set of fields for manipulating the range of pages being printed. These fields are separate from any accessory views.
Available in OS X v10.5 and later.
Declared in
NSPrintPanel.h.NSPrintPanelShowsPaperSizeThe Print panel includes a control for manipulating the paper size of the printer. This control is separate from any accessory views.
Available in OS X v10.5 and later.
Declared in
NSPrintPanel.h.NSPrintPanelShowsOrientationThe Print panel includes a control for manipulating the page orientation. This control is separate from any accessory views.
Available in OS X v10.5 and later.
Declared in
NSPrintPanel.h.NSPrintPanelShowsScalingThe Print panel includes a control for scaling the printed output. This control is separate from any accessory views.
Available in OS X v10.5 and later.
Declared in
NSPrintPanel.h.NSPrintPanelShowsPrintSelectionThe Print panel includes an additional selection option for paper range. This control is separate from any accessory views.
Available in OS X v10.6 and later.
Declared in
NSPrintPanel.h.NSPrintPanelShowsPageSetupAccessoryThe Print panel includes a separate accessory view for manipulating the paper size, orientation, and scaling attributes. Page setup fields that are already configured for display on the main portion of the Print panel appear there and not on this accessory panel.
Available in OS X v10.5 and later.
Declared in
NSPrintPanel.h.NSPrintPanelShowsPreviewThe Print panel displays a built-in preview of the document contents. This option is only appropriate when the Print panel is used in conjunction with an
NSPrintOperationobject to print a document.Available in OS X v10.5 and later.
Declared in
NSPrintPanel.h.
Declared In
NSPrintPanel.h© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-06-23)