~ubuntu-branches/ubuntu/hoary/psi/hoary

« back to all changes in this revision

Viewing changes to libpsi/iconset/iconset.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2004-06-15 00:10:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040615001041-enywb6pcpe4sjsw6
Tags: 0.9.2-1
* New upstream release
* Set KDEDIR for ./configure so kde specific files get installed
* Don't install libpsiwidgets.so. It got installed in /usr/share
  where it doesn't belong. May be included (at a better location)
  later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * iconset.h - various graphics handling classes
 
3
 * Copyright (C) 2001-2003  Justin Karneges, Michail Pishchagin
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Lesser General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2.1 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * Lesser General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Lesser General Public
 
16
 * License along with this library; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 *
 
19
 */
 
20
 
 
21
#ifndef ICONSET_H
 
22
#define ICONSET_H
 
23
 
 
24
#include <qobject.h>
 
25
#include <qdict.h>
 
26
#include <qptrlist.h>
 
27
#include <qregexp.h>
 
28
#include <qstring.h>
 
29
#include <qstringlist.h>
 
30
#include <qvaluevector.h>
 
31
 
 
32
class QImage;
 
33
class QPixmap;
 
34
class QIconSet;
 
35
class QMimeSourceFactory;
 
36
class Anim;
 
37
 
 
38
class Impix
 
39
{
 
40
public:
 
41
        Impix();
 
42
        Impix(const QPixmap &);
 
43
        Impix(const QImage &);
 
44
        Impix(const Impix &);
 
45
        Impix & operator=(const Impix &from);
 
46
        ~Impix();
 
47
 
 
48
        void unload();
 
49
        bool isNull() const;
 
50
 
 
51
        const QPixmap & pixmap() const;
 
52
        const QImage & image() const;
 
53
        void setPixmap(const QPixmap &);
 
54
        void setImage(const QImage &);
 
55
 
 
56
        operator const QPixmap &() const { return pixmap(); }
 
57
        operator const QImage &() const { return image(); }
 
58
        Impix & operator=(const QPixmap &from) { setPixmap(from); return *this; }
 
59
        Impix & operator=(const QImage &from) { setImage(from); return *this; }
 
60
 
 
61
        bool loadFromData(const QByteArray &);
 
62
 
 
63
        Impix copy() const;
 
64
        void detach();
 
65
 
 
66
private:
 
67
        class Private;
 
68
        Private *d;
 
69
};
 
70
 
 
71
class Icon : public QObject
 
72
{
 
73
        Q_OBJECT
 
74
public:
 
75
        Icon();
 
76
        Icon(const Icon &);
 
77
        ~Icon();
 
78
 
 
79
        Icon & operator= (const Icon &);
 
80
 
 
81
        //!
 
82
        //! Returns impix().pixmap().
 
83
        operator const QPixmap &() const { return impix().pixmap(); }
 
84
 
 
85
        //!
 
86
        //! Returns impix().image().
 
87
        operator const QImage &() const { return impix().image(); }
 
88
 
 
89
        //!
 
90
        //! see iconSet().
 
91
        operator const QIconSet &() const { return iconSet(); }
 
92
 
 
93
        virtual bool isAnimated() const;
 
94
        virtual const QPixmap &pixmap() const;
 
95
        virtual const QImage &image() const;
 
96
        virtual const QIconSet & iconSet() const;
 
97
 
 
98
        virtual const Impix &impix() const;
 
99
        virtual const Impix &frameImpix() const;
 
100
        void setImpix(const Impix &, bool doDetach = true);
 
101
 
 
102
        const Anim *anim() const;
 
103
        void setAnim(const Anim &, bool doDetach = true);
 
104
        void removeAnim(bool doDetach = true);
 
105
 
 
106
        const QString &name() const;
 
107
        void setName(const QString &);
 
108
        void setName(const char *);
 
109
 
 
110
        const QRegExp &regExp() const;
 
111
        void setRegExp(const QRegExp &);
 
112
 
 
113
        const QDict<QString> &text() const;
 
114
        void setText(const QDict<QString> &);
 
115
 
 
116
        const QString &sound() const;
 
117
        void setSound(const QString &);
 
118
 
 
119
        bool loadFromData(const QByteArray &, bool isAnimation);
 
120
 
 
121
        void stripFirstAnimFrame();
 
122
 
 
123
        Icon copy() const;
 
124
        void detach();
 
125
 
 
126
signals:
 
127
        void pixmapChanged(const QPixmap &);
 
128
        void iconModified(const QPixmap &);
 
129
 
 
130
public slots:
 
131
        virtual void activated(bool playSound = true);  // it just has been inserted in the text, or now it's being displayed by
 
132
                                                        // some widget. icon should play sound and start animation
 
133
 
 
134
        virtual void stop();    // this icon is no more displaying. stop animation
 
135
 
 
136
public:
 
137
        class Private;
 
138
private:
 
139
        Private *d;
 
140
};
 
141
 
 
142
class Iconset
 
143
{
 
144
public:
 
145
        Iconset();
 
146
        Iconset(const Iconset &);
 
147
        ~Iconset();
 
148
 
 
149
        Iconset &operator=(const Iconset &);
 
150
        Iconset &operator+=(const Iconset &);
 
151
 
 
152
        void clear();
 
153
        uint count() const;
 
154
 
 
155
        bool load(const QString &dir);
 
156
 
 
157
        const Icon *icon(const QString &) const;
 
158
        void setIcon(const QString &, const Icon &);
 
159
        void removeIcon(const QString &);
 
160
 
 
161
        const QString &name() const;
 
162
        const QString &version() const;
 
163
        const QString &description() const;
 
164
        const QStringList &authors() const;
 
165
        const QString &creation() const;
 
166
        const QString &homeUrl() const;
 
167
 
 
168
        const QString &fileName() const;
 
169
        void setFileName(const QString &);
 
170
 
 
171
        const QDict<QString> info() const;
 
172
        void setInfo(const QDict<QString> &);
 
173
 
 
174
        QPtrListIterator<Icon> iterator() const;
 
175
 
 
176
        QMimeSourceFactory *createMimeSourceFactory() const;
 
177
 
 
178
        void addToFactory() const;
 
179
        void removeFromFactory() const;
 
180
 
 
181
        static void setSoundPrefs(QString unpackPath, QObject *receiver, const char *slot);
 
182
 
 
183
        Iconset copy() const;
 
184
        void detach();
 
185
 
 
186
private:
 
187
        class Private;
 
188
        Private *d;
 
189
};
 
190
 
 
191
class IconsetFactory
 
192
{
 
193
public:
 
194
        static Icon icon(const QString &name);
 
195
        static const Icon *iconPtr(const QString &name);
 
196
        static const QStringList icons();
 
197
};
 
198
 
 
199
#endif