~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/image/qiconengine.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the painting module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#include "qiconengine.h"
 
30
#include "qpainter.h"
 
31
 
 
32
/*!
 
33
  \class QIconEngine
 
34
 
 
35
  \brief The QIconEngine class provides an abstract base class for QIcon renderers.
 
36
 
 
37
  \ingroup multimedia
 
38
 
 
39
  An icon engine provides the rendering functions for a QIcon. Each icon has a
 
40
  corresponding icon engine that is responsible for drawing the icon with a
 
41
  requested size, mode and state.
 
42
 
 
43
  The icon is rendered by the paint() function, and the icon can additionally be
 
44
  obtained as a pixmap with the pixmap() function (the default implementation
 
45
  simply uses paint() to achieve this). The addPixmap() function can be used to
 
46
  add new pixmaps to the icon engine, and is used by QIcon to add specialized
 
47
  custom pixmaps.
 
48
 
 
49
  The paint(), pixmap(), and addPixmap() functions are all virtual, and can
 
50
  therefore be reimplemented in subclasses of QIconEngine.
 
51
 
 
52
  \sa QIconEnginePlugin
 
53
 
 
54
*/
 
55
 
 
56
/*!
 
57
  \fn virtual void QIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) = 0;
 
58
 
 
59
  Uses the given \a painter to paint the icon with the required \a mode and
 
60
  \a state into the rectangle \a rect.
 
61
*/
 
62
 
 
63
/*!  Returns the actual size of the icon the engine provides for the
 
64
  requested \a size, \a mode and \a state. The default implementation
 
65
  returns the given \a size.
 
66
 */
 
67
QSize QIconEngine::actualSize(const QSize &size, QIcon::Mode /*mode*/, QIcon::State /*state*/)
 
68
{
 
69
    return size;
 
70
}
 
71
 
 
72
 
 
73
/*!
 
74
  Destroys the icon engine.
 
75
 */
 
76
QIconEngine::~QIconEngine()
 
77
{
 
78
}
 
79
 
 
80
 
 
81
/*!
 
82
  Returns the icon as a pixmap with the required \a size, \a mode,
 
83
  and \a state. The default implementation creates a new pixmap and
 
84
  calls paint() to fill it.
 
85
*/
 
86
QPixmap QIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
 
87
{
 
88
    QPixmap pm(size);
 
89
    {
 
90
        QPainter p(&pm);
 
91
        paint(&p, QRect(QPoint(0,0),size), mode, state);
 
92
    }
 
93
    return pm;
 
94
}
 
95
 
 
96
/*!
 
97
  Called by QIcon::addPixmap(). Adds a specialized \a pixmap for the given
 
98
  \a mode and \a state. The default pixmap-based engine stores any supplied
 
99
  pixmaps, and it uses them instead of scaled pixmaps if the size of a pixmap
 
100
  matches the size of icon requested. Custom icon engines that implement
 
101
  scalable vector formats are free to ignores any extra pixmaps.
 
102
 */
 
103
void QIconEngine::addPixmap(const QPixmap &/*pixmap*/, QIcon::Mode /*mode*/, QIcon::State /*state*/)
 
104
{
 
105
}
 
106
 
 
107
 
 
108
/*!  Called by QIcon::addFile(). Adds a specialized pixmap from the
 
109
  file with the given \a fileName, \a size, \a mode and \a state. The
 
110
  default pixmap-based engine stores any supplied file names, and it
 
111
  loads the pixmaps on demand instead of using scaled pixmaps if the
 
112
  size of a pixmap matches the size of icon requested. Custom icon
 
113
  engines that implement scalable vector formats are free to ignores
 
114
  any extra files.
 
115
 */
 
116
void QIconEngine::addFile(const QString &/*fileName*/, const QSize &/*size*/, QIcon::Mode /*mode*/, QIcon::State /*state*/)
 
117
{
 
118
}