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 char           _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         unsigned long           _packetSize;
57 
58     protected:
59         long double             _convertX(long double d) const;
60         long double             _convertY(long double d) const;
61         char*                   _convertStr(const char *str) const;
62 
63     public:
64         Printer(ppd_file_t* ppd);
65         virtual ~Printer();
66 
67         void                    newJob(FILE *output);
68         void                    endJob(FILE *output);
69 
70     public:
setPageSizeX(long double f)71         void                    setPageSizeX(long double f) {_pageSizeX = f;}
setPageSizeY(long double f)72         void                    setPageSizeY(long double f) {_pageSizeY = f;}
setMarginX(long double f)73         void                    setMarginX(long double f) {_marginX = f;}
setMarginY(long double f)74         void                    setMarginY(long double f) {_marginY = f;}
setAreaX(long double f)75         void                    setAreaX(long double f) {_areaX = f;}
setAreaY(long double f)76         void                    setAreaY(long double f) {_areaY = f;}
setResolution(unsigned long xres,unsigned long yres)77         void                    setResolution(unsigned long xres,
78                                     unsigned long yres)
79                                 {_xresolution = xres; _yresolution = yres;}
setPrintableX(long double f)80         void                    setPrintableX(long double f) {_printableX = f;}
setPrintableY(long double f)81         void                    setPrintableY(long double f) {_printableY = f;}
setCompVersion(unsigned char v)82         void                    setCompVersion(unsigned char v)
83                                 {_compVersion = v;}
setUsername(const char * user)84         void                    setUsername(const char *user)
85                                 {_username = user;}
setJobName(const char * job)86         void                    setJobName(const char *job) {_jobname = job;}
87 
pageSizeX()88         long double             pageSizeX() const
89                                 {return _convertX(_pageSizeX);}
pageSizeY()90         long double             pageSizeY() const
91                                 {return _convertY(_pageSizeY);}
marginX()92         long double             marginX() const
93                                 {return _convertX(_marginX);};
marginY()94         long double             marginY() const
95                                 {return _convertY(_marginY);};
areaX()96         long double             areaX() const
97                                 {return _convertX(_areaX);}
areaY()98         long double             areaY() const
99                                 {return _convertY(_areaY);}
printableX()100         unsigned long           printableX() const
101                                 {return (unsigned long)_convertX(_printableX);}
printableY()102         unsigned long           printableY() const
103                                 {return (unsigned long)_convertY(_printableY);}
resolutionX()104         unsigned long           resolutionX() const {return _xresolution;}
resolutionY()105         unsigned long           resolutionY() const {return _yresolution;}
bandHeight()106         unsigned long           bandHeight() const {return _bandHeight;}
107 
paperType()108         unsigned char           paperType() const {return _paperType;}
paperSource()109         unsigned char           paperSource() const {return _paperSource;}
duplex()110         unsigned short          duplex() const {return _duplex;}
compVersion()111         unsigned char           compVersion() const {return _compVersion;}
112 
docHeaderValues(unsigned long val)113         char                    docHeaderValues(unsigned long val) const
114                                 {return _docHeaderValues[val];}
115 
isColorPrinter()116         bool                    isColorPrinter() const {return _color;}
qpdlVersion()117         unsigned char           qpdlVersion() const {return _qpdlVersion;}
packetSize()118         unsigned long           packetSize() const {return _packetSize;}
119 };
120 
121 #endif /* PRINTER_H_ */
122 
123 /* vim: set expandtab tabstop=4 shiftwidth=4 smarttab tw=80 cin enc=utf8: */
124 
125