1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtGui module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QPRINTENGINE_QWS_P_H
43 #define QPRINTENGINE_QWS_P_H
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.
56 #include "QtGui/qprinter.h"
60 #include "QtGui/qprintengine.h"
61 #include "QtCore/qbytearray.h"
62 #include "private/qpaintengine_p.h"
66 class QtopiaPrintEnginePrivate;
67 class QRasterPaintEngine;
68 class QPrinterPrivate;
71 class QtopiaPrintEngine : public QPaintEngine, public QPrintEngine
73 Q_DECLARE_PRIVATE(QtopiaPrintEngine)
75 QtopiaPrintEngine(QPrinter::PrinterMode mode);
77 // override QWSPaintEngine
78 bool begin(QPaintDevice *dev);
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; }
84 QPaintEngine *paintEngine() const;
86 void updateState(const QPaintEngineState &state);
88 QRect paperRect() const;
89 QRect pageRect() const;
94 QPrinter::PrinterState printerState() const;
96 int metric(QPaintDevice::PaintDeviceMetric metricType) const;
98 QVariant property(PrintEnginePropertyKey key) const;
99 void setProperty(PrintEnginePropertyKey key, const QVariant &value);
102 friend class QPrintDialog;
103 friend class QPageSetupDialog;
109 class QtopiaPrintBuffer
112 QtopiaPrintBuffer( bool bigEndian=FALSE ) { _bigEndian = bigEndian; }
113 ~QtopiaPrintBuffer() {}
115 const QByteArray& data() const { return _data; }
117 int size() const { return _data.size(); }
119 void clear() { _data.clear(); }
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 ); }
126 void patch( int posn, int value );
135 #define QT_QWS_PRINTER_DEFAULT_DPI 200
137 class QtopiaPrintEnginePrivate : public QPaintEnginePrivate
139 Q_DECLARE_PUBLIC(QtopiaPrintEngine)
141 QtopiaPrintEnginePrivate(QPrinter::PrinterMode 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),
154 collateCopies(false),
161 ~QtopiaPrintEnginePrivate();
164 QPaintEngine *paintEngine();
166 QPrinter::PrinterMode mode;
169 QString outputFileName;
170 QString printProgram;
174 QPrinter::PrinterState printerState;
176 QPrinter::Orientation orientation;
177 QPrinter::PaperSize paperSize;
178 QPrinter::PageOrder pageOrder;
179 QPrinter::ColorMode colorMode;
180 QPrinter::PaperSource paperSource;
183 QPaintEngine *_paintEngine;
194 QtopiaPrintBuffer buffer;
196 // Definitions that are only relevant to G3FAX output.
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 );
211 #endif // QT_NO_PRINTER
213 #endif // QPRINTENGINE_QWS_P_H