File: printer.h

package info (click to toggle)
splix 2.0.0-2.2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,912 kB
  • ctags: 653
  • sloc: cpp: 4,514; makefile: 332; sh: 86; ansic: 42
file content (161 lines) | stat: -rw-r--r-- 5,401 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
 * 	    printer.h                 (C) 2006-2008, Aurélien Croc (AP²C)
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; version 2 of the License.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the
 *  Free Software Foundation, Inc.,
 *  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 *  $Id: printer.h 242 2008-11-24 00:12:22Z ap2c $
 * 
 */
#ifndef _PRINTER_H_
#define _PRINTER_H_

class Request;

/**
  * @brief This class contains all the needed information about the printer.
  *
  * This class is mainly used by the QPDL render.
  */
class Printer 
{
    protected:
        char*                   _manufacturer;
        char*                   _model;
        char*                   _beginPJL;
        char*                   _endPJL;

        bool                    _color;
        unsigned long           _qpdlVersion;
        unsigned long           _bandHeight;
        unsigned long           _packetSize;

        unsigned char           _paperType;
        unsigned char           _paperSource;

        float                   _paperWidth;
        float                   _paperHeight;
        
        unsigned char           _unknownByte1;
        unsigned char           _unknownByte2;
        unsigned char           _unknownByte3;

        float                   _pageWidth;
        float                   _pageHeight;

        float                   _hardMarginX;
        float                   _hardMarginY;

    public:
        /**
          * Initialize a new instance.
          */
        Printer();
        /**
          * Destroy the instance and free the internal memory used.
          */
        virtual ~Printer();

    public:
        /**
          * Load the printer configuration requested.
          * @return TRUE if the information have been successfully loaded.
          *         Otherwise it returns FALSE.
          */
        bool                    loadInformation(const Request& request);

        /**
          * Send the PJL header.
          * The PJL header will be sent to STDOUT. Like the other methods which
          * send data to the printer, if you need to redirect the data to
          * somewhere else, use the freopen function to redirect STDOUT.
          * @return TRUE if it succeed. Otherwise it returns FALSE.
          */
        bool                    sendPJLHeader(const Request& request) const;
        /**
          * Send the PJL footer.
          * The PJL footer will be sent to STDOUT.
          * @return TRUE if it succeed. Otherwise it returns FALSE.
          */
        bool                    sendPJLFooter(const Request& request) const;

    public:
        /**
          * @return the manufacturer name.
          */
        const char*             manufacturer() const {return _manufacturer;}
        /**
          * @return the model name.
          */
        const char*             model() const {return _model;}
        /**
          * @return the height of a band.
          */ 
        unsigned long           bandHeight() const {return _bandHeight;}
        /**
          * @return the maximum size of a packet.
          */ 
        unsigned long           packetSize() const {return _packetSize;}
        /**
          * @return the QPDL version.
          */
        unsigned long           qpdlVersion() const {return _qpdlVersion;}
        /**
         * @return TRUE if this printer is a color printer. Otherwise it returns
         *         FALSE.
         */
        bool                    color() const {return _color;}
        /**
         * @return the paper source.
         */
        unsigned char           paperSource() const {return _paperSource;}
        /**
         * @return the page width.
         */
        float                   pageWidth() const {return _pageWidth;}
        /**
         * @return the page height.
         */
        float                   pageHeight() const {return _pageHeight;}
        /**
         * @return the paper type.
         */
        unsigned char           paperType() const {return _paperType;}
        /**
         * @return the unknown byte 1
         */
        unsigned char           unknownByte1() const {return _unknownByte1;}
        /**
         * @return the unknown byte 2
         */
        unsigned char           unknownByte2() const {return _unknownByte2;}
        /**
         * @return the unknown byte 3
         */
        unsigned char           unknownByte3() const {return _unknownByte3;}
        /**
         * @return the hard margin of the printer in the X direction.
         */
        float                   hardMarginX() const {return _hardMarginX;}
        /**
         * @return the hard margin of the printer in the Y direction.
         */
        float                   hardMarginY() const {return _hardMarginY;}

};

#endif /* _PRINTER_H_ */

/* vim: set expandtab tabstop=4 shiftwidth=4 smarttab tw=80 cin enc=utf8: */