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