0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the QtGui module of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
#ifndef QPRINTENGINE_QWS_P_H
|
|
43 |
#define QPRINTENGINE_QWS_P_H
|
|
44 |
|
|
45 |
//
|
|
46 |
// W A R N I N G
|
|
47 |
// -------------
|
|
48 |
//
|
|
49 |
// This file is not part of the Qt API. It exists for the convenience
|
|
50 |
// of other Qt classes. This header file may change from version to
|
|
51 |
// version without notice, or even be removed.
|
|
52 |
//
|
|
53 |
// We mean it.
|
|
54 |
//
|
|
55 |
|
|
56 |
#include "QtGui/qprinter.h"
|
|
57 |
|
|
58 |
#ifndef QT_NO_PRINTER
|
|
59 |
|
|
60 |
#include "QtGui/qprintengine.h"
|
|
61 |
#include "QtCore/qbytearray.h"
|
|
62 |
#include "private/qpaintengine_p.h"
|
|
63 |
|
|
64 |
QT_BEGIN_NAMESPACE
|
|
65 |
|
|
66 |
class QtopiaPrintEnginePrivate;
|
|
67 |
class QRasterPaintEngine;
|
|
68 |
class QPrinterPrivate;
|
|
69 |
class QImage;
|
|
70 |
|
|
71 |
class QtopiaPrintEngine : public QPaintEngine, public QPrintEngine
|
|
72 |
{
|
|
73 |
Q_DECLARE_PRIVATE(QtopiaPrintEngine)
|
|
74 |
public:
|
|
75 |
QtopiaPrintEngine(QPrinter::PrinterMode mode);
|
|
76 |
|
|
77 |
// override QWSPaintEngine
|
|
78 |
bool begin(QPaintDevice *dev);
|
|
79 |
bool end();
|
|
80 |
void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
|
|
81 |
void drawTextItem(const QPointF &p, const QTextItem &ti);
|
|
82 |
QPaintEngine::Type type() const { return QPaintEngine::X11; }
|
|
83 |
|
|
84 |
QPaintEngine *paintEngine() const;
|
|
85 |
|
|
86 |
void updateState(const QPaintEngineState &state);
|
|
87 |
|
|
88 |
QRect paperRect() const;
|
|
89 |
QRect pageRect() const;
|
|
90 |
|
|
91 |
bool newPage();
|
|
92 |
bool abort();
|
|
93 |
|
|
94 |
QPrinter::PrinterState printerState() const;
|
|
95 |
|
|
96 |
int metric(QPaintDevice::PaintDeviceMetric metricType) const;
|
|
97 |
|
|
98 |
QVariant property(PrintEnginePropertyKey key) const;
|
|
99 |
void setProperty(PrintEnginePropertyKey key, const QVariant &value);
|
|
100 |
|
|
101 |
private:
|
|
102 |
friend class QPrintDialog;
|
|
103 |
friend class QPageSetupDialog;
|
|
104 |
|
|
105 |
void clearPage();
|
|
106 |
void flushPage();
|
|
107 |
};
|
|
108 |
|
|
109 |
class QtopiaPrintBuffer
|
|
110 |
{
|
|
111 |
public:
|
|
112 |
QtopiaPrintBuffer( bool bigEndian=FALSE ) { _bigEndian = bigEndian; }
|
|
113 |
~QtopiaPrintBuffer() {}
|
|
114 |
|
|
115 |
const QByteArray& data() const { return _data; }
|
|
116 |
|
|
117 |
int size() const { return _data.size(); }
|
|
118 |
|
|
119 |
void clear() { _data.clear(); }
|
|
120 |
|
|
121 |
void append( char value ) { _data.append( value ); }
|
|
122 |
void append( short value );
|
|
123 |
void append( int value );
|
|
124 |
void append( const QByteArray& array ) { _data.append( array ); }
|
|
125 |
|
|
126 |
void patch( int posn, int value );
|
|
127 |
|
|
128 |
void pad();
|
|
129 |
|
|
130 |
private:
|
|
131 |
QByteArray _data;
|
|
132 |
bool _bigEndian;
|
|
133 |
};
|
|
134 |
|
|
135 |
#define QT_QWS_PRINTER_DEFAULT_DPI 200
|
|
136 |
|
|
137 |
class QtopiaPrintEnginePrivate : public QPaintEnginePrivate
|
|
138 |
{
|
|
139 |
Q_DECLARE_PUBLIC(QtopiaPrintEngine)
|
|
140 |
public:
|
|
141 |
QtopiaPrintEnginePrivate(QPrinter::PrinterMode m) :
|
|
142 |
mode(m),
|
|
143 |
printerState(QPrinter::Idle),
|
|
144 |
orientation(QPrinter::Portrait),
|
|
145 |
paperSize(QPrinter::A4),
|
|
146 |
pageOrder(QPrinter::FirstPageFirst),
|
|
147 |
colorMode(QPrinter::GrayScale),
|
|
148 |
paperSource(QPrinter::OnlyOne),
|
|
149 |
resolution(QT_QWS_PRINTER_DEFAULT_DPI),
|
|
150 |
_paintEngine(0),
|
|
151 |
numCopies(1),
|
|
152 |
outputToFile(false),
|
|
153 |
fullPage(false),
|
|
154 |
collateCopies(false),
|
|
155 |
pageNumber(0),
|
|
156 |
pageImage(0),
|
|
157 |
partialByte(0),
|
|
158 |
partialBits(0)
|
|
159 |
{
|
|
160 |
}
|
|
161 |
~QtopiaPrintEnginePrivate();
|
|
162 |
|
|
163 |
void initialize();
|
|
164 |
QPaintEngine *paintEngine();
|
|
165 |
|
|
166 |
QPrinter::PrinterMode mode;
|
|
167 |
|
|
168 |
QString printerName;
|
|
169 |
QString outputFileName;
|
|
170 |
QString printProgram;
|
|
171 |
QString docName;
|
|
172 |
QString creator;
|
|
173 |
|
|
174 |
QPrinter::PrinterState printerState;
|
|
175 |
|
|
176 |
QPrinter::Orientation orientation;
|
|
177 |
QPrinter::PaperSize paperSize;
|
|
178 |
QPrinter::PageOrder pageOrder;
|
|
179 |
QPrinter::ColorMode colorMode;
|
|
180 |
QPrinter::PaperSource paperSource;
|
|
181 |
|
|
182 |
int resolution;
|
|
183 |
QPaintEngine *_paintEngine;
|
|
184 |
int numCopies;
|
|
185 |
|
|
186 |
bool outputToFile;
|
|
187 |
bool fullPage;
|
|
188 |
bool collateCopies;
|
|
189 |
|
|
190 |
int pageNumber;
|
|
191 |
|
|
192 |
QImage *pageImage;
|
|
193 |
|
|
194 |
QtopiaPrintBuffer buffer;
|
|
195 |
|
|
196 |
// Definitions that are only relevant to G3FAX output.
|
|
197 |
int ifdPatch;
|
|
198 |
int partialByte;
|
|
199 |
int partialBits;
|
|
200 |
void writeG3FaxHeader();
|
|
201 |
void writeG3FaxPage();
|
|
202 |
int writeG3IFDEntry( int tag, int type, int count, int value );
|
|
203 |
void writeG3Code( int code, int bits );
|
|
204 |
void writeG3WhiteRun( int len );
|
|
205 |
void writeG3BlackRun( int len );
|
|
206 |
void writeG3EOL();
|
|
207 |
};
|
|
208 |
|
|
209 |
QT_END_NAMESPACE
|
|
210 |
|
|
211 |
#endif // QT_NO_PRINTER
|
|
212 |
|
|
213 |
#endif // QPRINTENGINE_QWS_P_H
|