Qt 4.8
qicon_p.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 QICON_P_H
43 #define QICON_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include <QtCore/qglobal.h>
57 #include <QtCore/qsize.h>
58 #include <QtCore/qlist.h>
59 #include <QtGui/qpixmap.h>
60 #include <QtGui/qicon.h>
61 #include <QtGui/qiconengine.h>
62 
63 #ifndef QT_NO_ICON
65 
67 {
68 public:
69  QIconPrivate();
70 
72  if (engine_version == 1) {
73  if (!v1RefCount->deref()) {
74  delete engine;
75  delete v1RefCount;
76  }
77  } else if (engine_version == 2) {
78  delete engine;
79  }
80  }
81 
83 
85  int serialNum;
86  int detach_no;
88 
90 };
91 
92 
94 {
95  QPixmapIconEngineEntry():mode(QIcon::Normal), state(QIcon::Off){}
97  :pixmap(pm), size(pm.size()), mode(m), state(s){}
99  :fileName(file), size(sz), mode(m), state(s){}
105  bool isNull() const {return (fileName.isEmpty() && pixmap.isNull()); }
106 };
107 
108 
109 
111 public:
115  void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state);
116  QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
117  QPixmapIconEngineEntry *bestMatch(const QSize &size, QIcon::Mode mode, QIcon::State state, bool sizeOnly);
118  QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state);
119  void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state);
120  void addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state);
121 
122  // v2 functions
123  QString key() const;
124  QIconEngineV2 *clone() const;
125  bool read(QDataStream &in);
126  bool write(QDataStream &out) const;
127  void virtual_hook(int id, void *data);
128 
129 private:
130  QPixmapIconEngineEntry *tryMatch(const QSize &size, QIcon::Mode mode, QIcon::State state);
132 
133  friend QDataStream &operator<<(QDataStream &s, const QIcon &icon);
134  friend class QIconThemeEngine;
135 };
136 
138 #endif //QT_NO_ICON
139 #endif // QICON_P_H
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
int serialNum
Definition: qicon_p.h:85
QVector< QPixmapIconEngineEntry > pixmaps
Definition: qicon_p.h:131
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QAtomicInt class provides platform-independent atomic operations on integers. ...
Definition: qatomic.h:55
QAtomicInt * v1RefCount
Definition: qicon_p.h:89
State
This enum describes the state for which a pixmap is intended to be used.
Definition: qicon.h:64
QAtomicInt ref
Definition: qicon_p.h:84
QPixmapIconEngineEntry(const QString &file, const QSize &sz=QSize(), QIcon::Mode m=QIcon::Normal, QIcon::State s=QIcon::Off)
Definition: qicon_p.h:98
The QString class provides a Unicode character string.
Definition: qstring.h:83
QPixmapIconEngineEntry(const QPixmap &pm, QIcon::Mode m=QIcon::Normal, QIcon::State s=QIcon::Off)
Definition: qicon_p.h:96
int engine_version
Definition: qicon_p.h:87
QIcon::State state
Definition: qicon_p.h:104
QIcon::Mode mode
Definition: qicon_p.h:103
bool isNull() const
Definition: qicon_p.h:105
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition: qicon.h:63
bool deref()
Atomically decrements the value of this QAtomicInt.
static const char * data(const QByteArray &arr)
The QIconEngineV2 class provides an abstract base class for QIcon renderers.
Definition: qiconengine.h:73
~QIconPrivate()
Definition: qicon_p.h:71
int key
The QIconEngine class provides an abstract base class for QIcon renderers.
Definition: qiconengine.h:55
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QDataStream & operator<<(QDataStream &s, const QAxBase &c)
Definition: qaxbase.h:203
int detach_no
Definition: qicon_p.h:86
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
QIconEngine * engine
Definition: qicon_p.h:82
QIconPrivate()
Definition: qicon.cpp:124
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
static QString fileName(const QString &fileUrl)
static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo, const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd)
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60