1 /** <title>NSPrintOperation</title>
2 
3    <abstract>Controls generation of EPS, PDF or PS print jobs.</abstract>
4 
5    Copyright (C) 1996,2001,2004 Free Software Foundation, Inc.
6 
7    Author:  Scott Christley <scottc@net-community.com>
8    Date: 1996
9    Author: Fred Kiefer <FredKiefer@gmx.de>
10    Date: November 2000
11    Updated to new specification
12    Author: Adam Fedor <fedor@gnu.org>
13    Date: Oct 2001
14    Modified for Printing Backend Support
15    Author: Chad Hardin <cehardin@mac.com>
16    Date: June 2004
17 
18    This file is part of the GNUstep GUI Library.
19 
20    This library is free software; you can redistribute it and/or
21    modify it under the terms of the GNU Lesser General Public
22    License as published by the Free Software Foundation; either
23    version 2 of the License, or (at your option) any later version.
24 
25    This library is distributed in the hope that it will be useful,
26    but WITHOUT ANY WARRANTY; without even the implied warranty of
27    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
28    Lesser General Public License for more details.
29 
30    You should have received a copy of the GNU Lesser General Public
31    License along with this library; see the file COPYING.LIB.
32    If not, see <http://www.gnu.org/licenses/> or write to the
33    Free Software Foundation, 51 Franklin Street, Fifth Floor,
34    Boston, MA 02110-1301, USA.
35 */
36 
37 #ifndef _GNUstep_H_NSPrintOperation
38 #define _GNUstep_H_NSPrintOperation
39 #import <GNUstepBase/GSVersionMacros.h>
40 
41 #import <Foundation/NSObject.h>
42 #import <Foundation/NSGeometry.h>
43 
44 @class NSString;
45 @class NSData;
46 @class NSMutableData;
47 
48 @class NSView;
49 @class NSWindow;
50 @class NSPrintInfo;
51 @class NSPrintPanel;
52 @class NSGraphicsContext;
53 
54 typedef enum _NSPrintingPageOrder {
55   NSDescendingPageOrder,
56   NSSpecialPageOrder,
57   NSAscendingPageOrder,
58   NSUnknownPageOrder
59 } NSPrintingPageOrder;
60 
61 @interface NSPrintOperation : NSObject
62 {
63   // Attributes
64   NSPrintInfo *_print_info;
65   NSView *_view;
66   NSRect _rect;
67   NSMutableData *_data;
68   NSString *_path;
69   NSGraphicsContext *_context;
70   NSPrintPanel *_print_panel;
71   NSView *_accessory_view;
72   NSString *_job_style_hint;
73   NSPrintingPageOrder _page_order;
74   struct __Flags {
75       unsigned int show_print_panel:1;
76       unsigned int show_progress_panel:1;
77       unsigned int can_spawn_separate_thread:1;
78       unsigned int RESERVED:29;
79   } _flags;
80   int  _currentPage;
81 }
82 
83 //
84 // Creating and Initializing an NSPrintOperation Object
85 //
86 + (NSPrintOperation *)EPSOperationWithView:(NSView *)aView
87                                 insideRect:(NSRect)rect
88                                     toData:(NSMutableData *)data;
89 + (NSPrintOperation *)EPSOperationWithView:(NSView *)aView
90                                 insideRect:(NSRect)rect
91                                     toData:(NSMutableData *)data
92                                  printInfo:(NSPrintInfo *)aPrintInfo;
93 + (NSPrintOperation *)EPSOperationWithView:(NSView *)aView
94                                 insideRect:(NSRect)rect
95                                     toPath:(NSString *)path
96                                  printInfo:(NSPrintInfo *)aPrintInfo;
97 
98 + (NSPrintOperation *)printOperationWithView:(NSView *)aView;
99 + (NSPrintOperation *)printOperationWithView:(NSView *)aView
100                                    printInfo:(NSPrintInfo *)aPrintInfo;
101 
102 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
103 + (NSPrintOperation *)PDFOperationWithView:(NSView *)aView
104                                 insideRect:(NSRect)rect
105                                     toData:(NSMutableData *)data;
106 + (NSPrintOperation *)PDFOperationWithView:(NSView *)aView
107                                 insideRect:(NSRect)rect
108                                     toData:(NSMutableData *)data
109                                  printInfo:(NSPrintInfo*)aPrintInfo;
110 + (NSPrintOperation *)PDFOperationWithView:(NSView *)aView
111                                 insideRect:(NSRect)rect
112                                     toPath:(NSString *)path
113                                  printInfo:(NSPrintInfo*)aPrintInfo;
114 #endif
115 
116 - (id)initEPSOperationWithView:(NSView *)aView
117                     insideRect:(NSRect)rect
118                         toData:(NSMutableData *)data
119                      printInfo:(NSPrintInfo *)aPrintInfo;
120 - (id)initWithView:(NSView *)aView
121          printInfo:(NSPrintInfo *)aPrintInfo;
122 
123 //
124 // Setting the Print Operation
125 //
126 + (NSPrintOperation *)currentOperation;
127 + (void)setCurrentOperation:(NSPrintOperation *)operation;
128 
129 //
130 // Determining the Type of Operation
131 //
132 - (BOOL)isEPSOperation;
133 
134 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
135 - (BOOL)isCopyingOperation;
136 #endif
137 
138 //
139 // Controlling the User Interface
140 //
141 - (NSPrintPanel *)printPanel;
142 - (BOOL)showPanels;
143 - (void)setPrintPanel:(NSPrintPanel *)panel;
144 - (void)setShowPanels:(BOOL)flag;
145 #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
146 - (BOOL)showsPrintPanel;
147 - (void)setShowsPrintPanel:(BOOL)flag;
148 - (BOOL)showsProgressPanel;
149 - (void)setShowsProgressPanel:(BOOL)flag;
150 #endif
151 
152 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
153 - (NSView *)accessoryView;
154 - (void)setAccessoryView:(NSView *)aView;
155 #endif
156 
157 //
158 // Managing the DPS Context
159 //
160 - (NSGraphicsContext *)createContext;
161 - (NSGraphicsContext *)context;
162 - (void)destroyContext;
163 
164 //
165 // Page Information
166 //
167 - (int)currentPage;
168 - (NSPrintingPageOrder)pageOrder;
169 - (void)setPageOrder:(NSPrintingPageOrder)order;
170 
171 //
172 // Running a Print Operation
173 //
174 - (void)cleanUpOperation;
175 - (BOOL)deliverResult;
176 - (BOOL)runOperation;
177 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
178 - (void)runOperationModalForWindow:(NSWindow *)docWindow
179                           delegate:(id)delegate
180                     didRunSelector:(SEL)didRunSelector
181                        contextInfo:(void *)contextInfo;
182 - (BOOL)canSpawnSeparateThread;
183 - (void)setCanSpawnSeparateThread:(BOOL)flag;
184 #endif
185 #if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
186 - (NSString *) jobStyleHint;
187 - (void)setJobStyleHint:(NSString *)hint;
188 #endif
189 
190 //
191 // Getting the NSPrintInfo Object
192 //
193 - (NSPrintInfo *)printInfo;
194 - (void)setPrintInfo:(NSPrintInfo *)aPrintInfo;
195 
196 //
197 // Getting the NSView Object
198 //
199 - (NSView *)view;
200 
201 @end
202 
203 
204 //
205 // Private method used by the NSPrintOperation subclasses
206 // such as GSEPSPrintOperation, GSPDFPrintOperation.  This
207 // also includes GSPrintOperation, which is used in the printing
208 // backend system.  Printing bundles subclass GSPrintOperation
209 // and use that to interface with the native printing system.
210 //
211 @interface NSPrintOperation (Private)
212 
213 - (id) initWithView:(NSView *)aView
214          insideRect:(NSRect)rect
215              toData:(NSMutableData *)data
216           printInfo:(NSPrintInfo *)aPrintInfo;
217 
218 @end
219 
220 
221 #endif // _GNUstep_H_NSPrintOperation
222