QtGui/qpicture.h Source File

qpicture.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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 
50 
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 
116  friend class QPicturePaintEngine;
117  friend class Q3Picture;
118  friend class QAlphaPaintEngine;
119  friend class QPreviewPaintEngine;
120 
121 public:
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 *header,
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 
201 
203 
204 #endif // QPICTURE_H
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
#define QT_END_NAMESPACE
Definition: qglobal.h:128
void(* picture_io_handler)(QPictureIO *)
Definition: qpicture.h:132
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
virtual QPaintEngine * paintEngine() const =0
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
Q_GUI_EXPORT QDataStream & operator<<(QDataStream &, const QPicture &)
GLXDrawable GLXDrawable read
Definition: GLee.h:10243
virtual int devType() const
Definition: qpaintdevice.h:167
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: GLee.h:880
GLenum GLsizei GLenum format
Definition: GLee.h:873
Q_INLINE_TEMPLATE void qSwap(QScopedPointer< T, Cleanup > &p1, QScopedPointer< T, Cleanup > &p2)
Definition: qrect.h:58
void swap(QPicture &other)
Definition: qpicture.h:88
GLfloat GLfloat p
Definition: GLee.h:5416
GLuint in
Definition: GLee.h:7188
QExplicitlySharedDataPointer< QPicturePrivate > DataPtr
Definition: qpicture.h:122
Q_GUI_EXPORT QDataStream & operator>>(QDataStream &, QPicture &)
void detach()
#define QT_END_HEADER
Definition: qglobal.h:142
GLsizeiptr size
Definition: GLee.h:1561
DataPtr & data_ptr()
Definition: qpicture.h:123
virtual int metric(PaintDeviceMetric metric) const