Qt 4.8
qiconengine.cpp
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 #include "qiconengine.h"
43 #include "qpainter.h"
44 
46 
87 QSize QIconEngine::actualSize(const QSize &size, QIcon::Mode /*mode*/, QIcon::State /*state*/)
88 {
89  return size;
90 }
91 
92 
97 {
98 }
99 
100 
107 {
108  QPixmap pm(size);
109  {
110  QPainter p(&pm);
111  paint(&p, QRect(QPoint(0,0),size), mode, state);
112  }
113  return pm;
114 }
115 
123 void QIconEngine::addPixmap(const QPixmap &/*pixmap*/, QIcon::Mode /*mode*/, QIcon::State /*state*/)
124 {
125 }
126 
127 
136 void QIconEngine::addFile(const QString &/*fileName*/, const QSize &/*size*/, QIcon::Mode /*mode*/, QIcon::State /*state*/)
137 {
138 }
139 
140 
141 
142 // version 2 functions
143 
144 
252 {
253  return QString();
254 }
255 
260 {
261  return 0;
262 }
263 
271 {
272  return false;
273 }
274 
282 {
283  return false;
284 }
285 
300 {
301  switch (id) {
304  *reinterpret_cast<QIconEngineV2::AvailableSizesArgument*>(data);
305  arg.sizes.clear();
306  break;
307  }
308  default:
309  break;
310  }
311 }
312 
327 {
329  arg.mode = mode;
330  arg.state = state;
331  virtual_hook(QIconEngineV2::AvailableSizesHook, reinterpret_cast<void*>(&arg));
332  return arg.sizes;
333 }
334 
348 {
349  QString name;
350  virtual_hook(QIconEngineV2::IconNameHook, reinterpret_cast<void*>(&name));
351  return name;
352 }
353 
virtual QString key() const
Returns a key that identifies this icon engine.
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QString iconName()
Returns the name used to create the engine, if available.
virtual QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state)
Returns the actual size of the icon the engine provides for the requested size, mode and state...
Definition: qiconengine.cpp:87
virtual QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
Returns the icon as a pixmap with the required size, mode, and state.
State
This enum describes the state for which a pixmap is intended to be used.
Definition: qicon.h:64
The QString class provides a Unicode character string.
Definition: qstring.h:83
QIcon::Mode mode
the requested mode of an image.
Definition: qiconengine.h:87
QList< QSize > availableSizes(QIcon::Mode mode=QIcon::Normal, QIcon::State state=QIcon::Off)
Returns sizes of all images that are contained in the engine for the specific mode and state...
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
This struct represents arguments to virtual_hook() function when id parameter is QIconEngineV2::Avail...
Definition: qiconengine.h:85
const char * name
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition: qicon.h:63
virtual void virtual_hook(int id, void *data)
Additional method to allow extending QIconEngineV2 without adding new virtual methods (and without br...
virtual void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state)
Called by QIcon::addPixmap().
QList< QSize > sizes
image sizes that are available with specified mode and
Definition: qiconengine.h:89
static const char * data(const QByteArray &arr)
virtual bool read(QDataStream &in)
Reads icon engine contents from the QDataStream in.
void clear()
Removes all items from the list.
Definition: qlist.h:764
virtual QIconEngineV2 * clone() const
Returns a clone of this icon engine.
The QIconEngineV2 class provides an abstract base class for QIcon renderers.
Definition: qiconengine.h:73
virtual bool write(QDataStream &out) const
Writes the contents of this engine to the QDataStream out.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
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
virtual ~QIconEngine()
Destroys the icon engine.
Definition: qiconengine.cpp:96
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
QIcon::State state
the requested state of an image.
Definition: qiconengine.h:88
virtual void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)=0
Uses the given painter to paint the icon with the required mode and state into the rectangle rect...
virtual void addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state)
Called by QIcon::addFile().