xref: /haiku/src/add-ons/print/drivers/gutenprint/GPJob.h (revision d6d2c9b16db8d2f996cc7b692badfa992de60b60)
19295cd64SMichael Pfeiffer /*
29295cd64SMichael Pfeiffer * Copyright 2010, Haiku. All rights reserved.
39295cd64SMichael Pfeiffer * Distributed under the terms of the MIT License.
49295cd64SMichael Pfeiffer *
59295cd64SMichael Pfeiffer * Authors:
69295cd64SMichael Pfeiffer *		Michael Pfeiffer
79295cd64SMichael Pfeiffer */
89295cd64SMichael Pfeiffer #ifndef GP_JOB_H
99295cd64SMichael Pfeiffer #define GP_JOB_H
109295cd64SMichael Pfeiffer 
119295cd64SMichael Pfeiffer #include<gutenprint/gutenprint.h>
129295cd64SMichael Pfeiffer 
139295cd64SMichael Pfeiffer #include<list>
149295cd64SMichael Pfeiffer 
159295cd64SMichael Pfeiffer #include<String.h>
169295cd64SMichael Pfeiffer 
179295cd64SMichael Pfeiffer #include "GPBand.h"
189295cd64SMichael Pfeiffer #include "GPJobConfiguration.h"
199295cd64SMichael Pfeiffer #include "OutputStream.h"
20*d6d2c9b1SMichael Pfeiffer #include "Rectangle.h"
219295cd64SMichael Pfeiffer 
229295cd64SMichael Pfeiffer 
239295cd64SMichael Pfeiffer class GPJob
249295cd64SMichael Pfeiffer {
259295cd64SMichael Pfeiffer public:
269295cd64SMichael Pfeiffer 			GPJob();
279295cd64SMichael Pfeiffer 			~GPJob();
289295cd64SMichael Pfeiffer 
299295cd64SMichael Pfeiffer 	void	SetApplicationName(const BString& applicationName);
309295cd64SMichael Pfeiffer 	void	SetConfiguration(GPJobConfiguration* configuration);
319295cd64SMichael Pfeiffer 	void	SetOutputStream(OutputStream* outputStream);
329295cd64SMichael Pfeiffer 
339295cd64SMichael Pfeiffer 	status_t	Begin();
349295cd64SMichael Pfeiffer 	void		End();
359295cd64SMichael Pfeiffer 
369295cd64SMichael Pfeiffer 	status_t	PrintPage(list<GPBand*>& bands);
379295cd64SMichael Pfeiffer 
38c0aa3379SMichael Pfeiffer 	void		GetErrorMessage(BString& message);
39c0aa3379SMichael Pfeiffer 
409295cd64SMichael Pfeiffer private:
41*d6d2c9b1SMichael Pfeiffer 	RectInt32	GetPrintRectangle(list<GPBand*>& bands);
429295cd64SMichael Pfeiffer 	GPBand*		FindBand(int line);
439295cd64SMichael Pfeiffer 	void		FillRow(GPBand* band, unsigned char* data, size_t size,
449295cd64SMichael Pfeiffer 		int line);
459295cd64SMichael Pfeiffer 	void		FillWhite(unsigned char* data, size_t size);
469295cd64SMichael Pfeiffer 
479295cd64SMichael Pfeiffer 	void				Init();
489295cd64SMichael Pfeiffer 	void				Reset();
499295cd64SMichael Pfeiffer 	int					Width();
509295cd64SMichael Pfeiffer 	int					Height();
519295cd64SMichael Pfeiffer 	stp_image_status_t	GetRow(unsigned char* data, size_t size, int row);
529295cd64SMichael Pfeiffer 	const char*			GetAppname();
539295cd64SMichael Pfeiffer 	void				Conclude();
549295cd64SMichael Pfeiffer 	void				Write(const char* data, size_t size);
559295cd64SMichael Pfeiffer 	void				ReportError(const char* data, size_t size);
569295cd64SMichael Pfeiffer 
579295cd64SMichael Pfeiffer 	static void			ImageInit(stp_image_t* image);
589295cd64SMichael Pfeiffer 	static void			ImageReset(stp_image_t* image);
599295cd64SMichael Pfeiffer 	static int			ImageWidth(stp_image_t* image);
609295cd64SMichael Pfeiffer 	static int			ImageHeight(stp_image_t *image);
619295cd64SMichael Pfeiffer 	static stp_image_status_t	ImageGetRow(stp_image_t* image,
629295cd64SMichael Pfeiffer 		unsigned char* data, size_t size, int row);
639295cd64SMichael Pfeiffer 	static const char*	ImageGetAppname(stp_image_t* image);
649295cd64SMichael Pfeiffer 	static void			ImageConclude(stp_image_t *image);
659295cd64SMichael Pfeiffer 	static void			OutputFunction(void *cookie, const char *data,
669295cd64SMichael Pfeiffer 		size_t size);
679295cd64SMichael Pfeiffer 	static void			ErrorFunction(void *cookie, const char *data,
689295cd64SMichael Pfeiffer 		size_t size);
699295cd64SMichael Pfeiffer 
709295cd64SMichael Pfeiffer 	BString				fApplicationName;
719295cd64SMichael Pfeiffer 	OutputStream*		fOutputStream;
729295cd64SMichael Pfeiffer 	GPJobConfiguration*	fConfiguration;
739295cd64SMichael Pfeiffer 
74fad05958SMichael Pfeiffer 	bool					fHasPages;
759295cd64SMichael Pfeiffer 	stp_image_t				fImage;
769295cd64SMichael Pfeiffer 	stp_vars_t*				fVariables;
779295cd64SMichael Pfeiffer 	const stp_printer_t*	fPrinter;
78*d6d2c9b1SMichael Pfeiffer 	RectInt32				fPrintRect;
799295cd64SMichael Pfeiffer 	list<GPBand*>*			fBands;
809295cd64SMichael Pfeiffer 	GPBand*					fCachedBand;
81c0aa3379SMichael Pfeiffer 	status_t				fStatus;
82c0aa3379SMichael Pfeiffer 	BString					fErrorMessage;
839295cd64SMichael Pfeiffer };
849295cd64SMichael Pfeiffer #endif
85