Important: The information in this document is obsolete and should not be used for new development.
Inherits from | |
Package | com.apple.cocoa.application |
Companion guide |
An NSPrintOperation object controls operations that generate Encapsulated PostScript (EPS) code, Portable Document Format (PDF) code, or print jobs. NSPrintOperation works in conjunction with two other objects: an NSPrintInfo object, which specifies how the code should be generated, and an NSView object, which generates the actual code.
It is important to note that the majority of methods in NSPrintOperation copy the instance of NSPrintInfo passed into them. Future changes to that print info are not reflected in the print info retained by NSPrintOperation. All changes should be made to the print info before passing to NSPrintOperation methods. The only method in NSPrintOperation which does not copy the NSPrintInfo instance is setPrintInfo
.
showPanels
setShowPanels
showsPrintPanel
showsProgressPanel
setShowsPrintPanel
setShowsProgressPanel
accessoryView
setAccessoryView
jobStyleHint
setJobStyleHint
printPanel
setPrintPanel
Returns the current print operation for this thread.
public static NSPrintOperation currentOperation
()
Returns null
if there isn’t a current operation.
Returns a new NSPrintOperation object that controls the copying of EPS graphics from the area specified by rect in aView.
public static NSPrintOperation EPSOperationWithViewInsideRect
(NSView aView, NSRect rect, NSMutableData data)
The new NSPrintOperation object uses the default NSPrintInfo object. The EPS code is written to data. Throws an exception if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
Returns a new NSPrintOperation object that controls the copying of EPS graphics from the area specified by rect in aView.
public static NSPrintOperation EPSOperationWithViewInsideRect
(NSView aView, NSRect rect, NSMutableData data, NSPrintInfo aPrintInfo)
The new NSPrintOperation object uses the settings stored in aPrintInfo. The code is written to data. Throws an exception if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
Creates and returns a new NSPrintOperation object that controls the copying of EPS graphics from the area specified by rect in aView.
public static NSPrintOperation EPSOperationWithViewInsideRect
(NSView aView, NSRect rect, String path, NSPrintInfo aPrintInfo)
The new NSPrintOperation object uses the settings stored in aPrintInfo. The code is written to path. Throws an exception if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
Returns a new NSPrintOperation object that controls the copying of PDF graphics from the area specified by rect in aView.
public static NSPrintOperation PDFOperationWithViewInsideRect
(NSView aView, NSRect rect, NSMutableData data)
The new NSPrintOperation object uses the default NSPrintInfo object. The PDF is written to data. Throws an exception if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
Returns a new NSPrintOperation object that controls the copying of PDF graphics from the area specified by rect in aView.
public static NSPrintOperation PDFOperationWithViewInsideRect
(NSView aView, NSRect rect, NSMutableData data, NSPrintInfo aPrintInfo)
The new NSPrintOperation object uses the settings stored in aPrintInfo. The PDF is written to data. Throws an exception if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
Creates and returns a new NSPrintOperation object that controls the copying of PDF graphics from the area specified by rect in aView.
public static NSPrintOperation PDFOperationWithViewInsideRect
(NSView aView, NSRect rect, String path, NSPrintInfo aPrintInfo)
The new NSPrintOperation object uses the settings stored in aPrintInfo. The PDF is written to path. Throws an exception if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
Returns a new NSPrintOperation that controls the printing of aView.
public static NSPrintOperation printOperationWithView
(NSView aView)
The new NSPrintOperation object uses the settings stored in the shared NSPrintInfo object. Throws an exception if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
Returns a new NSPrintOperation that controls the printing of aView.
public static NSPrintOperation printOperationWithView
(NSView aView, NSPrintInfo aPrintInfo)
The new NSPrintOperation object uses the settings stored in aPrintInfo. Throws an exception if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
Sets the current print operation for this thread to operation.
public static void setCurrentOperation
(NSPrintOperation operation)
If operation is null
, then there is no current print operation.
Returns the accessory view used by the receiver’s NSPrintPanel object.
public NSView accessoryView
()
You use setAccessoryView
to customize the default NSPrintPanel object without having to subclass NSPrintPanel or specify your own NSPrintPanel object.
Returns whether the receiver is allowed to spawn a separate printing thread.
public boolean canSpawnSeparateThread
()
Invoked by runOperation
at the end of an operation to remove the receiver as the current operation.
public void cleanUpOperation
()
You typically do not invoke this method directly.
Returns the receiver’s display context used for generating output.
public NSGraphicsContext context
()
Creates the display context for output generation, using the receiver’s NSPrintInfo settings.
public NSGraphicsContext createContext
()
Do not invoke this method directly—it is invoked before any output is generated.
Returns the page number of the page currently being printed.
public int currentPage
()
Delivers the results generated by runOperation
to the intended destination (for example, the printer spool or preview application).
public boolean deliverResult
()
Returns true
if the operation was successful, false
otherwise. Do not invoke this method directly—it is invoked automatically when the operation is done generating the output.
Destroys the receiver’s display context.
public void destroyContext
()
Do not invoke this method directly—it is invoked at the end of a print operation.
Returns true
if the receiver is an EPS or PDF copy operation.
public boolean isCopyingOperation
()
Returns true
if the receiver controls an EPS operation (initiated by a copy command), and false
if the receiver controls a printing operation (initiated by a print command).
public boolean isEPSOperation
()
Returns the type of content that the print job is printing.
public String jobStyleHint
()
Returns null
if no job style hint has been set.
Returns the order in which pages will be printed.
public int pageOrder
()
See “Constants” for possible return values.
Returns the receiver’s NSPrintInfo object.
public NSPrintInfo printInfo
()
Returns the NSPrintPanel object used when running the operation.
public NSPrintPanel printPanel
()
Runs the print operation, with document-modal sheets attached to docWindow. When the modal session ends, if neither delegate or didRunSelector are null
, didRunSelector is sent to delegate with contextInfo as an argument. The
public void runModalOperation
(NSWindow docWindow, Object delegate, NSSelector didRunSelector, Object contextInfo)
didRunSelector argument must have the following signature:
public void printOperationDidRun(NSPrintOperation printOperation, boolean success, void contextInfo) |
The value of success is true
if the print operation ran to completion without cancellation or error, and false
otherwise.
If you send setCanSpawnSeparateThread
to an NSPrintOperation object with an argument of true
, then the delegate specified in a subsequent invocation of runModalOperation
may be messaged in that spawned, non-main thread.
Runs the operation, either copying an EPS or PDF graphic or printing a job.
public boolean runOperation
()
Returns true
if successful, false
otherwise. The operation runs to completion in the current thread, blocking the application. A separate thread is not spawned, even if canSpawnSeparateThread
is true
. Use runModalOperation
to use document-modal sheets and to allow a separate thread to perform the operation.
Sets the custom accessory view aView, to be used by the receiver’s NSPrintPanel object.
public void setAccessoryView
(NSView aView)
By using this method you do not need to subclass NSPrintPanel or specify your own NSPrintPanel object. The NSPrintPanel is automatically resized to accommodate the new accessory view aView.
Sets whether the receiver is allowed to spawn a separate printing thread.
public void setCanSpawnSeparateThread
(boolean canSpawnSeparateThread)
If canSpawnSeparateThread is true
, an NSThread is detached when the print panel is dismissed (or immediately, if the panel is not to be displayed). The new thread performs the print operation, so that control can return to your application. A thread is detached only if the print operation is run using runModalOperation
. If canSpawnSeparateThread is false
, the operation runs on the current thread, blocking the application until the operation completes.
If you send setCanSpawnSeparateThread
to an NSPrintOperation object with an argument of true
, then the delegate specified in a subsequent invocation of runModalOperation
may be messaged in that spawned, non-main thread.
Sets the type of content that the print job is printing.
public void setJobStyleHint
(String hint)
This controls the set of items that appear in the Presets menu of the simplified Print panel interface presented by this operation, if it presents one. The supported job style hints are described in the “Constants” section of NSPrintPanel. If hint is null
, the standard interface is used.
Sets the order in which pages will be printed to order.
public void setPageOrder
(int order)
order is one of the values described in “Constants.”
Sets the receiver’s NSPrintInfo object to aPrintInfo.
public void setPrintInfo
(NSPrintInfo aPrintInfo)
Sets the receiver’s NSPrintPanel used in the operation to panel.
public void setPrintPanel
(NSPrintPanel panel)
public void setShowPanels
(boolean flag)
If flag is true
then the receiver’s NSPrintPanel will be used in the operation; otherwise it will not. This method also affects whether a progress panel is presented while the operation runs. If an EPS or PDF copy operation is being performed, neither panel is displayed, regardless of the value of flag.
If flag is true,
then the receiver’s NSPrintPanel is used in the operation; otherwise, it is not.
public void setShowsPrintPanel
(boolean flag)
This method does not affect the display of a progress panel; that operation is now controlled by setShowsProgressPanel
.
If an EPS or PDF copy operation is being performed, an NSPrintPanel is not displayed, regardless of the value of flag.
If flag is true
, then the receiver’s progress panel is used in the operation; otherwise, it is not.
public void setShowsProgressPanel
(boolean flag)
This method does not affect the display of a print panel; that operation is now controlled by setShowsPrintPanel
. This method replaces the setShowPanels
method.
Returns true
if the NSPrintPanel will be used in the operation, otherwise false
.
public boolean showPanels
()
Returns true
if the NSPrintPanel will be used in the operation, otherwise false
.
public boolean showsPrintPanel
()
Returns true
if a progress panel will be used in the operation, otherwise false
.
public boolean showsProgressPanel
()
Returns the NSView object that generates the actual PostScript or PDF code controlled by the receiver.
public NSView view
()
These constants specify the page order. They’re used by pageOrder
and setPageOrder
.
© 1997, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-01)