Inherits from: NSPanel : NSObject
Conforms to: NSObject
(NSObject)
Declared in: AppKit/NSPrintPanel.h
NSPrintPanel creates a Print panel used to query the user for information about a print job, such as which pages to print and how many copies, and execute the Print command.
When a print: message is sent to an NSView or NSWindow, an
NSPrintOperation object is created to control the print operation
(see the NSPrintOperation class description for details). By default
an NSPrintOperation object uses an NSPrintPanel unless it is sent
the setShowPanels: message passing NO
as
the argument. Also, if you subclass NSPrintPanel, send the setPrintPanel: message to
the NSPrintOperation object passing an instance of your subclass
to ensure that it is used as the Print panel for that operation.
However, you rarely need to subclass NSPrintPanel since you can augment its display by adding a custom NSView using the setAccessoryView: method. The accessory view is displayed when the user clicks the Options button. (On Mach platforms, the panel is resized to accommodate the NSView you add.) Note, however, that you don't have to create controls for special printer features. If a printer includes features in the "OpenUI" field of its PostScript Printer Description (PPD) table, these features will appear in the panel. For more information on a printer's PPD table, see the NSPrinter class description.
Typically, you get an NSPrintPanel by invoking the printPanel class method. When the class receives a printPanel message, it tries to reuse an existing panel rather than create a new one. When a panel is reused, its attributes are reset to the default values so that the effect is the same as returning a new panel. Because a Print panel may be reused, you shouldn't modify the instance returned by printPanel, except through the methods listed below. For example, you can set the accessory view, but not the arrangement of the buttons within the panel. If you must modify the Print panel substantially, create and manage your own instance using the alloc... and init... methods rather than the printPanel method.
An application stores printing information in an NSPrintInfo object. When an NSPrintOperation object is created it is given a specific NSPrintInfo object from the application or assigned a default. You can get the current operation by sending the currentOperation class method to NSPrintOperation.
Use the updateFromPrintInfo method to read the NSPrintInfo object's information into the Print panel. Conversely, the finalWritePrintInfo method updates the NSPrintInfo object if the user changes the information on the Print panel. The NSPrintOperation object creates a copy of the NSPrintInfo object, so finalWritePrintInfo actually writes to that copy, not the original.
- Creating an NSPrintPanel
- + printPanel
- Customizing the panel
- - accessoryView
- - setAccessoryView:
- Running the panel
- - runModal
- Communicating with the NSPrintInfo object
- - updateFromPrintInfo
- - finalWritePrintInfo
- Updating the panel's display
- - pickedButton:
- - pickedAllPages:
- - pickedLayoutList:
+ (NSPrintPanel *)printPanel
- (NSView *)accessoryView
See Also: - setAccessoryView:
- (void)finalWritePrintInfo
See Also: - updateFromPrintInfo, + currentOperation (NSPrintOperation)
- (void)pickedAllPages:(id)sender
See Also: - pickedButton:, - pickedLayoutList:
- (void)pickedButton:(id)sender
See Also: - pickedAllPages:, - pickedLayoutList:, - runModal
- (void)pickedLayoutList:(id)sender
See Also: - pickedAllPages:, - pickedButton:
- (int)runModal
NSCancelButton
if the
user clicks the Cancel button, otherwise returns NSOkButton
.See Also: - pickedButton:
- (void)setAccessoryView:(NSView
*)aView
nil
,
the receiver's current accessory view is removed.See Also: - accessoryView
- (void)updateFromPrintInfo
See Also: - finalWritePrintInfo, + currentOperation (NSPrintOperation)