Inherits from: NSPanel : NSObject
Package: com.apple.yellow.application
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 false
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 static 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 constructors 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
public NSPrintPanel(NSRect aNSRect, int anInt, int anInt, boolean aBoolean)
public NSPrintPanel(NSRect aNSRect, int anInt, int anInt, boolean aBoolean, NSScreen aNSScreen)
public static NSPrintPanel printPanel()
public NSView accessoryView()
See Also: setAccessoryView
public void finalWritePrintInfo()
See Also: updateFromPrintInfo, + currentOperation (NSPrintOperation)
public void pickedAllPages(Object sender)
See Also: pickedButton, pickedLayoutList
public void pickedButton(Object sender)
See Also: pickedAllPages, pickedLayoutList, runModal
public void pickedLayoutList(Object sender)
See Also: pickedAllPages, pickedButton
public int runModal()
NSPanel.CancelButton
if
the user clicks the Cancel button, otherwise returns NSPanel.OkButton
.See Also: pickedButton
public void setAccessoryView(NSView aView)
null
,
the receiver's current accessory view is removed.See Also: accessoryView
public void updateFromPrintInfo()
See Also: finalWritePrintInfo, + currentOperation (NSPrintOperation)