1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QPICTURE_H
|
---|
43 | #define QPICTURE_H
|
---|
44 |
|
---|
45 | #include <QtGui/qpaintdevice.h>
|
---|
46 | #include <QtCore/qstringlist.h>
|
---|
47 |
|
---|
48 | QT_BEGIN_HEADER
|
---|
49 |
|
---|
50 | QT_BEGIN_NAMESPACE
|
---|
51 |
|
---|
52 | QT_MODULE(Gui)
|
---|
53 |
|
---|
54 | #ifndef QT_NO_PICTURE
|
---|
55 |
|
---|
56 | class QPicturePrivate;
|
---|
57 | class Q_GUI_EXPORT QPicture : public QPaintDevice
|
---|
58 | {
|
---|
59 | Q_DECLARE_PRIVATE(QPicture)
|
---|
60 | public:
|
---|
61 | explicit QPicture(int formatVersion = -1);
|
---|
62 | QPicture(const QPicture &);
|
---|
63 | ~QPicture();
|
---|
64 |
|
---|
65 | bool isNull() const;
|
---|
66 |
|
---|
67 | int devType() const;
|
---|
68 | uint size() const;
|
---|
69 | const char* data() const;
|
---|
70 | virtual void setData(const char* data, uint size);
|
---|
71 |
|
---|
72 | bool play(QPainter *p);
|
---|
73 |
|
---|
74 | bool load(QIODevice *dev, const char *format = 0);
|
---|
75 | bool load(const QString &fileName, const char *format = 0);
|
---|
76 | bool save(QIODevice *dev, const char *format = 0);
|
---|
77 | bool save(const QString &fileName, const char *format = 0);
|
---|
78 |
|
---|
79 | QRect boundingRect() const;
|
---|
80 | void setBoundingRect(const QRect &r);
|
---|
81 |
|
---|
82 | QPicture& operator=(const QPicture &p);
|
---|
83 | void detach();
|
---|
84 | bool isDetached() const;
|
---|
85 |
|
---|
86 | friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QPicture &p);
|
---|
87 | friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QPicture &p);
|
---|
88 |
|
---|
89 | static const char* pictureFormat(const QString &fileName);
|
---|
90 | static QList<QByteArray> inputFormats();
|
---|
91 | static QList<QByteArray> outputFormats();
|
---|
92 | static QStringList inputFormatList();
|
---|
93 | static QStringList outputFormatList();
|
---|
94 |
|
---|
95 | QPaintEngine *paintEngine() const;
|
---|
96 |
|
---|
97 | protected:
|
---|
98 | QPicture(QPicturePrivate &data);
|
---|
99 |
|
---|
100 | int metric(PaintDeviceMetric m) const;
|
---|
101 | #ifdef QT3_SUPPORT
|
---|
102 | inline QT3_SUPPORT QPicture copy() const { QPicture p(*this); p.detach(); return p; }
|
---|
103 | #endif
|
---|
104 |
|
---|
105 | private:
|
---|
106 | bool exec(QPainter *p, QDataStream &ds, int i);
|
---|
107 | void detach_helper();
|
---|
108 |
|
---|
109 | QPicturePrivate *d_ptr;
|
---|
110 | friend class QPicturePaintEngine;
|
---|
111 | friend class Q3Picture;
|
---|
112 | friend class QAlphaPaintEngine;
|
---|
113 | friend class QPreviewPaintEngine;
|
---|
114 |
|
---|
115 | public:
|
---|
116 | typedef QPicturePrivate* DataPtr;
|
---|
117 | inline DataPtr &data_ptr() { return d_ptr; }
|
---|
118 | };
|
---|
119 |
|
---|
120 | Q_DECLARE_SHARED(QPicture)
|
---|
121 |
|
---|
122 |
|
---|
123 | #ifndef QT_NO_PICTUREIO
|
---|
124 | class QIODevice;
|
---|
125 | class QPictureIO;
|
---|
126 | typedef void (*picture_io_handler)(QPictureIO *); // picture IO handler
|
---|
127 |
|
---|
128 | struct QPictureIOData;
|
---|
129 |
|
---|
130 | class Q_GUI_EXPORT QPictureIO
|
---|
131 | {
|
---|
132 | public:
|
---|
133 | QPictureIO();
|
---|
134 | QPictureIO(QIODevice *ioDevice, const char *format);
|
---|
135 | QPictureIO(const QString &fileName, const char *format);
|
---|
136 | ~QPictureIO();
|
---|
137 |
|
---|
138 | const QPicture &picture() const;
|
---|
139 | int status() const;
|
---|
140 | const char *format() const;
|
---|
141 | QIODevice *ioDevice() const;
|
---|
142 | QString fileName() const;
|
---|
143 | int quality() const;
|
---|
144 | QString description() const;
|
---|
145 | const char *parameters() const;
|
---|
146 | float gamma() const;
|
---|
147 |
|
---|
148 | void setPicture(const QPicture &);
|
---|
149 | void setStatus(int);
|
---|
150 | void setFormat(const char *);
|
---|
151 | void setIODevice(QIODevice *);
|
---|
152 | void setFileName(const QString &);
|
---|
153 | void setQuality(int);
|
---|
154 | void setDescription(const QString &);
|
---|
155 | void setParameters(const char *);
|
---|
156 | void setGamma(float);
|
---|
157 |
|
---|
158 | bool read();
|
---|
159 | bool write();
|
---|
160 |
|
---|
161 | static QByteArray pictureFormat(const QString &fileName);
|
---|
162 | static QByteArray pictureFormat(QIODevice *);
|
---|
163 | static QList<QByteArray> inputFormats();
|
---|
164 | static QList<QByteArray> outputFormats();
|
---|
165 |
|
---|
166 | static void defineIOHandler(const char *format,
|
---|
167 | const char *header,
|
---|
168 | const char *flags,
|
---|
169 | picture_io_handler read_picture,
|
---|
170 | picture_io_handler write_picture);
|
---|
171 |
|
---|
172 | private:
|
---|
173 | Q_DISABLE_COPY(QPictureIO)
|
---|
174 |
|
---|
175 | void init();
|
---|
176 |
|
---|
177 | QPictureIOData *d;
|
---|
178 | };
|
---|
179 |
|
---|
180 | #endif //QT_NO_PICTUREIO
|
---|
181 |
|
---|
182 |
|
---|
183 | /*****************************************************************************
|
---|
184 | QPicture stream functions
|
---|
185 | *****************************************************************************/
|
---|
186 |
|
---|
187 | Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPicture &);
|
---|
188 | Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPicture &);
|
---|
189 |
|
---|
190 | #endif // QT_NO_PICTURE
|
---|
191 |
|
---|
192 | QT_END_NAMESPACE
|
---|
193 |
|
---|
194 | QT_END_HEADER
|
---|
195 |
|
---|
196 | #endif // QPICTURE_H
|
---|