1 /*
2  * 	printer.h		(C) 2006, Aurélien Croc (AP²C)
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; version 2 of the License.
7  *
8  *  This program is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  *  GNU General Public License for more details.
12  *
13  *  You should have received a copy of the GNU General Public License
14  *  along with this program; if not, write to the
15  *  Free Software Foundation, Inc.,
16  *  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  *
18  *  $Id$
19  *
20  */
21 #ifndef PRINTER_H_
22 #define PRINTER_H_
23 
24 #include <cups/ppd.h>
25 #include <stdlib.h>
26 
27 class Printer
28 {
29 	protected:
30 		ppd_file_t*	_ppd;
31 
32 		const char*	_username;
33 		const char*	_jobname;
34 
35 		unsigned long	_xresolution;
36 		unsigned long	_yresolution;
37 		unsigned char	_paperType;
38 		unsigned char	_paperSource;
39 		unsigned short	_duplex;
40 
41 		unsigned char	_compVersion;
42 
43 		unsigned short	_bandHeight;
44 		long double	_printableX;
45 		long double	_printableY;
46 		long double	_pageSizeX;
47 		long double	_pageSizeY;
48 		long double	_marginX;
49 		long double	_marginY;
50 		long double	_areaX;
51 		long double	_areaY;
52 
53 		char*		_docHeaderValues;
54 		bool		_color;
55 		unsigned char	_qpdlVersion;
56 
57 	protected:
58 		long double	_convertX(long double d) const;
59 		long double	_convertY(long double d) const;
60 		char*		_convertStr(const char *str) const;
61 
62 	public:
63 		Printer(ppd_file_t* ppd);
64 		~Printer();
65 
66 		void		newJob(FILE *output);
67 		void		endJob(FILE *output);
68 
69 	public:
setPageSizeX(long double f)70 		void		setPageSizeX(long double f) {_pageSizeX = f;}
setPageSizeY(long double f)71 		void		setPageSizeY(long double f) {_pageSizeY = f;}
setMarginX(long double f)72 		void		setMarginX(long double f) {_marginX = f;}
setMarginY(long double f)73 		void		setMarginY(long double f) {_marginY = f;}
setAreaX(long double f)74 		void		setAreaX(long double f) {_areaX = f;}
setAreaY(long double f)75 		void		setAreaY(long double f) {_areaY = f;}
setResolution(unsigned long xres,unsigned long yres)76 		void		setResolution(unsigned long xres, unsigned long
77 					yres)
78 				{_xresolution = xres; _yresolution = yres;}
setPrintableX(long double f)79 		void		setPrintableX(long double f) {_printableX = f;}
setPrintableY(long double f)80 		void		setPrintableY(long double f) {_printableY = f;}
setCompVersion(unsigned char v)81 		void		setCompVersion(unsigned char v)
82 				{_compVersion = v;}
setUsername(const char * user)83 		void		setUsername(const char *user)
84 				{_username = user;}
setJobName(const char * job)85 		void		setJobName(const char *job) {_jobname = job;}
86 
pageSizeX()87 		long double	pageSizeX() const
88 				{return _convertX(_pageSizeX);}
pageSizeY()89 		long double	pageSizeY() const
90 				{return _convertY(_pageSizeY);}
marginX()91 		long double	marginX() const
92 				{return _convertX(_marginX);};
marginY()93 		long double	marginY() const
94 				{return _convertY(_marginY);};
areaX()95 		long double	areaX() const
96 				{return _convertX(_areaX);}
areaY()97 		long double	areaY() const
98 				{return _convertY(_areaY);}
printableX()99 		unsigned long	printableX() const
100 				{return (unsigned long)_convertX(_printableX);}
printableY()101 		unsigned long 	printableY() const
102 				{return (unsigned long)_convertY(_printableY);}
resolutionX()103 		unsigned long	resolutionX() const {return _xresolution;}
resolutionY()104 		unsigned long	resolutionY() const {return _yresolution;}
bandHeight()105 		unsigned long 	bandHeight() const {return _bandHeight;}
106 
paperType()107 		unsigned char	paperType() const {return _paperType;}
paperSource()108 		unsigned char	paperSource() const {return _paperSource;}
duplex()109 		unsigned short	duplex() const {return _duplex;}
compVersion()110 		unsigned char	compVersion() const {return _compVersion;}
111 
docHeaderValues(unsigned long val)112 		char		docHeaderValues(unsigned long val) const
113 				{return _docHeaderValues[val];}
114 
isColorPrinter()115 		bool		isColorPrinter() const {return _color;}
qpdlVersion()116 		unsigned char	qpdlVersion() const {return _qpdlVersion;}
117 };
118 
119 #endif /* PRINTER_H_ */
120 
121