xref: /haiku/src/add-ons/print/drivers/pcl6/PCL6Writer.h (revision 95bac3fda53a4cb21880712d7b43f8c21db32a2e)
1 /*
2 ** PCL6Writer.h
3 ** Copyright 2005, Michael Pfeiffer, laplace@users.sourceforge.net. All rights reserved.
4 ** Distributed under the terms of the OpenBeOS License.
5 */
6 #ifndef _PCL6_WRITER_H
7 #define _PCL6_WRITER_H
8 
9 #include <SupportDefs.h>
10 
11 class PCL6Driver;
12 
13 class PCL6Writer {
14 public:
15 	// DO NOT change this enumerations the order is important!!!
16 	enum Orientation {
17 		kPortrait,
18 		kLandscape,
19 		kReversePortrait,
20 		kReverseLandscape
21 	};
22 
23 	enum MediaSize {
24 		kLetterPaper,
25 		kLegalPaper,
26 		kA4Paper,
27 		kExecPaper,
28 		kLedgerPaper,
29 		kA3Paper,
30 		kCOM10Envelope,
31 		kMonarchEnvelope,
32 		kC5Envelope,
33 		kDLEnvelope,
34 		kJB4Paper,
35 		kJB5Paper,
36 		kB5Envelope,
37 		kB5Paper,
38 		kJPostcard,
39 		kJDoublePostcard,
40 		kA5Paper,
41 		kA6Paper,
42 		kJB6Paper,
43 		kJIS8KPaper,
44 		kJIS16KPaper,
45 		kJISExecPaper
46 	};
47 
48 	enum MediaSource {
49 		kDefaultSource,
50 		kAutoSelect,
51 		kManualFeed,
52 		kMultiPurposeTray,
53 		kUpperCassette,
54 		kLowerCassette,
55 		kEnvelopeTray,
56 		kThirdCassette
57 	};
58 
59 	enum Compression {
60 		kNoCompression,
61 		kRLECompression,
62 		kJPEGCompression,
63 		kDeltaRowCompression
64 	};
65 
66 	enum ColorSpace {
67 		kBiLevel,
68 		kGray,
69 		kRGB,
70 		kCMY,
71 		kCIELab,
72 		kCRGB,
73 		kSRGB
74 	};
75 
76 	enum ColorDepth {
77 		k1Bit,
78 		k4Bit,
79 		k8Bit
80 	};
81 
82 	enum ColorMapping {
83 		kDirectPixel,
84 		kIndexedPixel,
85 		kDirectPlane
86 	};
87 
88 	enum Transparency {
89 		kOpaque,
90 		kTransparent
91 	};
92 
93 	enum DuplexPageMode {
94 		kDuplexHorizontalBinding,
95 		kDuplexVerticalBinding
96 	};
97 
98 	enum MediaSide {
99 		kFrontMediaSide,
100 		kBackMediaSide
101 	};
102 
103 	enum SimplexPageMode {
104 		kSimplexFrontSide
105 	};
106 
107 	enum UnitOfMeasure {
108 		kInch,
109 		kMillimeter,
110 		kTenthsOfAMillimeter
111 	};
112 
113 	enum ErrorReporting {
114 		kNoReporting,
115 		kBackChannel,
116 		kErrorPage,
117 		kBackChAndErrPage,
118 		kNWBackChannel,
119 		kNWErrorPage,
120 		kNWBackChAndErrPage
121 	};
122 
123 	enum Enable {
124 		kOn,
125 		kOff
126 	};
127 
128 	enum Boolean {
129 		kFalse,
130 		kTrue
131 	};
132 
133 	PCL6Writer(PCL6Driver* driver, uint32 bufferSize = 16 * 1024);
134 	virtual ~PCL6Writer();
135 
136 	// these methods throw TransportException if data could not
137 	// be written
138 	void Flush();
139 
140 	void BeginSession(uint16 xres, uint16 yres, UnitOfMeasure unitOfMeasure, ErrorReporting errorReporting);
141 	void EndSession();
142 
143 	void OpenDataSource();
144 	void CloseDataSource();
145 
146 	void BeginPage(Orientation orientation, MediaSize mediaSize, MediaSource mediaSource);
147 	void BeginPage(Orientation orientation, MediaSize mediaSize, MediaSource mediaSource, DuplexPageMode duplexPageMode, MediaSide mediaSide);
148 	void EndPage(uint16 copies);
149 
150 	void SetPageOrigin(int16 x, int16 y);
151 	void SetColorSpace(ColorSpace colorSpace);
152 	void SetPaintTxMode(Transparency transparency);
153 	void SetSourceTxMode(Transparency transparency);
154 	void SetROP(uint8 rop);
155 	void SetCursor(int16 x, int16 y);
156 
157 	void BeginImage(ColorMapping colorMapping, ColorDepth colorDepth, uint16 sourceWidth, uint16 sourceHeight, uint16 destWidth, uint16 destHeight);
158 	void ReadImage(Compression compression, uint16 startLine, uint16 blockHeight, uint8 padBytes = 4);
159 	void EndImage();
160 	void EmbeddedDataPrefix(uint32 size);
161 	void EmbeddedDataPrefix32(uint32 size);
162 
163 	void Append(uint8 value);
164 	void Append(int16 value);
165 	void Append(uint16 value);
166 	void Append(int32 value);
167 	void Append(uint32 value);
168 	void Append(float value);
169 	void Append(const uint8* data, uint32 size);
170 
171 	void AppendData(uint8 value);
172 	void AppendData(int16 value);
173 	void AppendData(uint16 value);
174 	void AppendData(int32 value);
175 	void AppendData(uint32 value);
176 	void AppendData(float value);
177 
178 	void AppendDataXY(uint8 x, uint8 y);
179 	void AppendDataXY(int16 x, int16 y);
180 	void AppendDataXY(uint16 x, uint16 y);
181 	void AppendDataXY(int32 x, int32 y);
182 	void AppendDataXY(uint32 x, uint32 y);
183 	void AppendDataXY(float x, float y);
184 
185 private:
186 	enum Operator {
187 		kBeginSession = 0x41,
188 		kEndSession,
189 		kBeginPage,
190 		kEndPage,
191 
192 		kVendorUnique = 0x46,
193 		kComment,
194 		kOpenDataSource,
195 		kCloseDataSource,
196 		kEchoComment,
197 		kQuery,
198 		kDiagnostic3,
199 
200 		kBeginStream = 0x5b,
201 		kReadStream,
202 		kEndStream,
203 
204 		kSetColorSpace = 0x6a,
205 		kSetCursor,
206 
207 		kSetPageOrigin = 0x75,
208 		kSetPageRotation,
209 		kSetPageScale,
210 		kSetPaintTxMode,
211 		kSetPenSource,
212 		kSetPenWidth,
213 		kSetROP,
214 		kSetSourceTxMode,
215 
216 		kBeginImage = 0xb0,
217 		kReadImage,
218 		kEndImage,
219 	};
220 
221 	enum DataTag {
222 		kUByteData = 0xc0,
223 		kUInt16Data,
224 		kUInt32Data,
225 		kSInt16Data,
226 		kSInt32Data,
227 		kReal32Data,
228 
229 		kString = 0xc7,
230 		kUByteArray,
231 		kUInt16Array,
232 		kUInt32Array,
233 		kSInt16Array,
234 		kSInt32Array,
235 		kReal32Array,
236 
237 		kUByteXY = 0xd0,
238 		kUInt16XY,
239 		kUInt32XY,
240 		kSInt16XY,
241 		kSInt32XY,
242 		kReal32XY,
243 
244 		kUByteBox = 0xe0,
245 		kUInt16Box,
246 		kUInt32Box,
247 		kSInt16Box,
248 		kSInt32Box,
249 		kReal32Box,
250 
251 		k8BitAttrId = 0xf8,
252 
253 		kEmbeddedData = 0xfa,
254 		kEmbeddedDataByte,
255 	};
256 
257 	enum DataType {
258 		kUByte,
259 		kSByte,
260 		kUInt16,
261 		kSInt16,
262 		kReal32
263 	};
264 
265 	enum Attribute {
266 		kCMYColor = 1,
267 		kPaletteDepth,
268 		kColorSpace,
269 
270 		kRGBColor = 11,
271 
272 		kMediaDest = 36,
273 		kMediaSize,
274 		kMediaSource,
275 		kMediaType,
276 		kOrientation,
277 		kPageAngle,
278 		kPageOrigin,
279 		kPageScale,
280 		kROP3,
281 		kTxMode,
282 
283 		kCustomMediaSize = 47,
284 		kCustomMediaSizeUnits,
285 		kPageCopies,
286 		kDitherMatrixSize,
287 		kDitherMatrixDepth,
288 		kSimplexPageMode,
289 		kDuplexPageMode,
290 		kDuplexPageSide,
291 
292 		kPoint = 76,
293 
294 		kColorDepth = 98,
295 		kBlockHeight,
296 		kColorMapping,
297 		kCompressMode,
298 		kDestinationBox,
299 		kDestinationSize,
300 
301 		kSourceHeight = 107,
302 		kSourceWidth,
303 		kStartLine,
304 		kPadBytesMultiple,
305 		kBlockByteLength,
306 
307 		kNumberOfScanLines = 115,
308 
309 		kDataOrg = 130,
310 		kMeasure = 134,
311 
312 		kSourceType = 136,
313 		kUnitsPerMeasure,
314 		kQueryKey,
315 		kStreamName,
316 		kStreamDataLength,
317 
318 		kErrorReport = 143,
319 		kIOReadTimeOut,
320 
321 		kWritingMode = 173
322 	};
323 
324 	enum DataSource {
325 		kDefaultDataSource
326 	};
327 
328 	enum DataOrganization {
329 		kBinaryHighByteFirst,
330 		kBinaryLowByteFirst
331 	};
332 
333 	void AppendOperator(Operator op);
334 	void AppendAttribute(Attribute attr);
335 	void AppendDataTag(DataTag tag);
336 
337 	PCL6Driver  *fDriver; // the driver used for writing the generated PCL6 data
338 	uint8       *fBuffer; // the buffer
339 	uint32       fSize;   // the size of the buffer
340 	uint32       fIndex;  // the index of the next byte to be written
341 };
342 
343 #endif
344 
345