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 test suite 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 |
#ifndef QENGINES_H
|
|
42 |
#define QENGINES_H
|
|
43 |
|
|
44 |
#if defined(BUILD_OPENGL)
|
|
45 |
#include <QGLPixelBuffer>
|
|
46 |
#endif
|
|
47 |
#include <QPrinter>
|
|
48 |
#include <QPixmap>
|
|
49 |
#include <QImage>
|
|
50 |
#include <QMap>
|
|
51 |
#include <QList>
|
|
52 |
#include <QColor>
|
|
53 |
|
|
54 |
QT_FORWARD_DECLARE_CLASS(QSvgRenderer)
|
|
55 |
QT_FORWARD_DECLARE_CLASS(QGLWidget)
|
|
56 |
|
|
57 |
class QEngine
|
|
58 |
{
|
|
59 |
public:
|
|
60 |
virtual ~QEngine();
|
|
61 |
virtual QString name() const =0;
|
|
62 |
virtual void prepare(const QSize &size, const QColor &fillColor = Qt::white) =0;
|
|
63 |
virtual void render(QSvgRenderer *r, const QString &) =0;
|
|
64 |
virtual void render(const QStringList &qpsScript,
|
|
65 |
const QString &absFilePath) =0;
|
|
66 |
virtual bool drawOnPainter(QPainter *p) =0;
|
|
67 |
virtual void save(const QString &file) =0;
|
|
68 |
virtual void cleanup();
|
|
69 |
};
|
|
70 |
|
|
71 |
class QtEngines
|
|
72 |
{
|
|
73 |
public:
|
|
74 |
static QtEngines *self();
|
|
75 |
QtEngines();
|
|
76 |
|
|
77 |
QList<QEngine*> engines() const;
|
|
78 |
QList<QEngine*> foreignEngines() const;
|
|
79 |
|
|
80 |
QEngine *defaultEngine() const;
|
|
81 |
private:
|
|
82 |
void init();
|
|
83 |
private:
|
|
84 |
QList<QEngine*> m_engines;
|
|
85 |
QList<QEngine*> m_foreignEngines;
|
|
86 |
QEngine *m_defaultEngine;
|
|
87 |
};
|
|
88 |
|
|
89 |
class RasterEngine : public QEngine
|
|
90 |
{
|
|
91 |
public:
|
|
92 |
RasterEngine();
|
|
93 |
|
|
94 |
virtual QString name() const;
|
|
95 |
virtual void prepare(const QSize &size, const QColor &fillColor = Qt::white);
|
|
96 |
virtual void render(QSvgRenderer *r, const QString &);
|
|
97 |
virtual void render(const QStringList &qpsScript,
|
|
98 |
const QString &absFilePath);
|
|
99 |
virtual bool drawOnPainter(QPainter *p);
|
|
100 |
virtual void save(const QString &file);
|
|
101 |
private:
|
|
102 |
QImage image;
|
|
103 |
};
|
|
104 |
|
|
105 |
class NativeEngine : public QEngine
|
|
106 |
{
|
|
107 |
public:
|
|
108 |
NativeEngine();
|
|
109 |
|
|
110 |
virtual QString name() const;
|
|
111 |
virtual void prepare(const QSize &size, const QColor &fillColor = Qt::white);
|
|
112 |
virtual void render(QSvgRenderer *r, const QString &);
|
|
113 |
virtual void render(const QStringList &qpsScript,
|
|
114 |
const QString &absFilePath);
|
|
115 |
virtual bool drawOnPainter(QPainter *p);
|
|
116 |
virtual void save(const QString &file);
|
|
117 |
private:
|
|
118 |
QPixmap pixmap;
|
|
119 |
};
|
|
120 |
|
|
121 |
|
|
122 |
#if defined(BUILD_OPENGL)
|
|
123 |
class GLEngine : public QEngine
|
|
124 |
{
|
|
125 |
public:
|
|
126 |
GLEngine();
|
|
127 |
virtual QString name() const;
|
|
128 |
virtual void prepare(const QSize &_size, const QColor &fillColor = Qt::white);
|
|
129 |
virtual void render(QSvgRenderer *r, const QString &);
|
|
130 |
virtual void render(const QStringList &qpsScript,
|
|
131 |
const QString &absFilePath);
|
|
132 |
virtual bool drawOnPainter(QPainter *p);
|
|
133 |
virtual void save(const QString &file);
|
|
134 |
virtual void cleanup();
|
|
135 |
private:
|
|
136 |
QGLPixelBuffer *pbuffer;
|
|
137 |
QGLWidget *widget;
|
|
138 |
bool usePixelBuffers;
|
|
139 |
QSize size;
|
|
140 |
QColor fillColor;
|
|
141 |
};
|
|
142 |
#endif
|
|
143 |
|
|
144 |
class WidgetEngineWidget;
|
|
145 |
class WidgetEngine : public QEngine
|
|
146 |
{
|
|
147 |
public:
|
|
148 |
WidgetEngine();
|
|
149 |
virtual QString name() const;
|
|
150 |
virtual void prepare(const QSize &_size, const QColor &fillColor = Qt::white);
|
|
151 |
virtual void render(QSvgRenderer *r, const QString &);
|
|
152 |
virtual void render(const QStringList &qpsScript,
|
|
153 |
const QString &absFilePath);
|
|
154 |
virtual bool drawOnPainter(QPainter *p);
|
|
155 |
virtual void save(const QString &file);
|
|
156 |
virtual void cleanup();
|
|
157 |
private:
|
|
158 |
WidgetEngineWidget *m_widget;
|
|
159 |
};
|
|
160 |
|
|
161 |
#ifndef QT_NO_PRINTER
|
|
162 |
class PDFEngine : public QEngine
|
|
163 |
{
|
|
164 |
public:
|
|
165 |
PDFEngine();
|
|
166 |
|
|
167 |
virtual QString name() const;
|
|
168 |
virtual void prepare(const QSize &size, const QColor &fillColor = Qt::white);
|
|
169 |
virtual void render(QSvgRenderer *r, const QString &);
|
|
170 |
virtual void render(const QStringList &qpsScript,
|
|
171 |
const QString &absFilePath);
|
|
172 |
virtual bool drawOnPainter(QPainter *p);
|
|
173 |
virtual void save(const QString &file);
|
|
174 |
virtual void cleanup();
|
|
175 |
private:
|
|
176 |
QPrinter *printer;
|
|
177 |
QSize m_size;
|
|
178 |
QString m_tempFile;
|
|
179 |
};
|
|
180 |
|
|
181 |
#ifdef Q_WS_X11
|
|
182 |
class PSEngine : public QEngine
|
|
183 |
{
|
|
184 |
public:
|
|
185 |
PSEngine();
|
|
186 |
|
|
187 |
virtual QString name() const;
|
|
188 |
virtual void prepare(const QSize &size, const QColor &fillColor = Qt::white);
|
|
189 |
virtual void render(QSvgRenderer *r, const QString &);
|
|
190 |
virtual void render(const QStringList &qpsScript,
|
|
191 |
const QString &absFilePath);
|
|
192 |
virtual bool drawOnPainter(QPainter *p);
|
|
193 |
virtual void save(const QString &file);
|
|
194 |
virtual void cleanup();
|
|
195 |
private:
|
|
196 |
QPrinter *printer;
|
|
197 |
QSize m_size;
|
|
198 |
QString m_tempFile;
|
|
199 |
};
|
|
200 |
#endif
|
|
201 |
|
|
202 |
#ifdef Q_WS_WIN
|
|
203 |
class WinPrintEngine : public QEngine
|
|
204 |
{
|
|
205 |
public:
|
|
206 |
WinPrintEngine();
|
|
207 |
|
|
208 |
virtual QString name() const;
|
|
209 |
virtual void prepare(const QSize &size, const QColor &fillColor = Qt::white);
|
|
210 |
virtual void render(QSvgRenderer *r, const QString &);
|
|
211 |
virtual void render(const QStringList &qpsScript,
|
|
212 |
const QString &absFilePath);
|
|
213 |
virtual bool drawOnPainter(QPainter *p);
|
|
214 |
virtual void save(const QString &file);
|
|
215 |
virtual void cleanup();
|
|
216 |
private:
|
|
217 |
QPrinter *printer;
|
|
218 |
QSize m_size;
|
|
219 |
QString m_tempFile;
|
|
220 |
};
|
|
221 |
#endif
|
|
222 |
#endif //QT_NO_PRINTER
|
|
223 |
|
|
224 |
class RSVGEngine : public QEngine
|
|
225 |
{
|
|
226 |
public:
|
|
227 |
RSVGEngine();
|
|
228 |
|
|
229 |
virtual QString name() const;
|
|
230 |
virtual void prepare(const QSize &size, const QColor &fillColor = Qt::white);
|
|
231 |
virtual void render(QSvgRenderer *r, const QString &);
|
|
232 |
virtual void render(const QStringList &qpsScript,
|
|
233 |
const QString &absFilePath);
|
|
234 |
virtual bool drawOnPainter(QPainter *p);
|
|
235 |
virtual void save(const QString &file);
|
|
236 |
private:
|
|
237 |
QString m_fileName;
|
|
238 |
QSize m_size;
|
|
239 |
};
|
|
240 |
|
|
241 |
#endif
|