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 unsigned long _xresolution; 33 unsigned long _yresolution; 34 unsigned char _paperType; 35 unsigned char _paperSource; 36 unsigned short _duplex; 37 38 unsigned char _compVersion; 39 40 long double _pageSizeX; 41 long double _pageSizeY; 42 long double _marginX; 43 long double _marginY; 44 long double _areaX; 45 long double _areaY; 46 47 char* _docHeaderValues; 48 49 protected: 50 long double _convertX(long double d) const; 51 long double _convertY(long double d) const; 52 char* _convertStr(const char *str) const; 53 54 public: 55 Printer(); 56 Printer(ppd_file_t* ppd); 57 ~Printer(); 58 59 void newJob(FILE *output); 60 void endJob(FILE *output); 61 62 public: setPageSizeX(long double f)63 void setPageSizeX(long double f) {_pageSizeX = f;} setPageSizeY(long double f)64 void setPageSizeY(long double f) {_pageSizeY = f;} setMarginX(long double f)65 void setMarginX(long double f) {_marginX = f;} setMarginY(long double f)66 void setMarginY(long double f) {_marginY = f;} setAreaX(long double f)67 void setAreaX(long double f) {_areaX = f;} setAreaY(long double f)68 void setAreaY(long double f) {_areaY = f;} setResolution(unsigned long xres,unsigned long yres)69 void setResolution(unsigned long xres, unsigned long 70 yres) 71 {_xresolution = xres; _yresolution = yres;} 72 pageSizeX()73 long double pageSizeX() const 74 {return _convertX(_pageSizeX);} pageSizeY()75 long double pageSizeY() const 76 {return _convertY(_pageSizeY);} marginX()77 long double marginX() const 78 {return _convertX(_marginX);}; marginY()79 long double marginY() const 80 {return _convertY(_marginY);}; areaX()81 long double areaX() const 82 {return _convertX(_areaX);} areaY()83 long double areaY() const 84 {return _convertY(_areaY);} resolutionX()85 unsigned long resolutionX() const {return _xresolution;} resolutionY()86 unsigned long resolutionY() const {return _yresolution;} bandHeight()87 unsigned long bandHeight() const {return 0x80;} 88 paperType()89 unsigned char paperType() const {return _paperType;} paperSource()90 unsigned char paperSource() const {return _paperSource;} duplex()91 unsigned short duplex() const {return _duplex;} compVersion()92 unsigned char compVersion() const {return _compVersion;} 93 docHeaderValues(unsigned long val)94 char docHeaderValues(unsigned long val) const 95 {return _docHeaderValues[val];} 96 }; 97 98 #endif /* PRINTER_H_ */ 99 100