~ubuntu-branches/ubuntu/oneiric/psi/oneiric

« back to all changes in this revision

Viewing changes to libpsi/iconset/iconset.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2005-01-10 17:41:43 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050110174143-ltocv5zapl6blf5d
Tags: 0.9.3-1
* New upstream release
* Cleaned up debian/rules (some things are done by upstream Makefiles now)
* Fixed some lintian warnings:
  - removed executable bit from some .png files
  - moved psi.desktop to /usr/share/applications
* Updated menu files

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
        virtual int framenumber() const;
 
107
 
 
108
        virtual const QString &name() const;
 
109
        void setName(const QString &);
 
110
        void setName(const char *);
 
111
 
 
112
        const QRegExp &regExp() const;
 
113
        void setRegExp(const QRegExp &);
 
114
 
 
115
        const QDict<QString> &text() const;
 
116
        void setText(const QDict<QString> &);
 
117
 
 
118
        const QString &sound() const;
 
119
        void setSound(const QString &);
 
120
 
 
121
        bool loadFromData(const QByteArray &, bool isAnimation);
 
122
 
 
123
        void stripFirstAnimFrame();
 
124
 
 
125
        Icon copy() const;
 
126
        void detach();
 
127
 
 
128
signals:
 
129
        void pixmapChanged(const QPixmap &);
 
130
        void iconModified(const QPixmap &);
 
131
 
 
132
public slots:
 
133
        virtual void activated(bool playSound = true);  // it just has been inserted in the text, or now it's being displayed by
 
134
                                                        // some widget. icon should play sound and start animation
 
135
 
 
136
        virtual void stop();    // this icon is no more displaying. stop animation
 
137
 
 
138
public:
 
139
        class Private;
 
140
private:
 
141
        Private *d;
 
142
};
 
143
 
 
144
class Iconset
 
145
{
 
146
public:
 
147
        Iconset();
 
148
        Iconset(const Iconset &);
 
149
        ~Iconset();
 
150
 
 
151
        Iconset &operator=(const Iconset &);
 
152
        Iconset &operator+=(const Iconset &);
 
153
 
 
154
        void clear();
 
155
        uint count() const;
 
156
 
 
157
        bool load(const QString &dir);
 
158
 
 
159
        const Icon *icon(const QString &) const;
 
160
        void setIcon(const QString &, const Icon &);
 
161
        void removeIcon(const QString &);
 
162
 
 
163
        const QString &name() const;
 
164
        const QString &version() const;
 
165
        const QString &description() const;
 
166
        const QStringList &authors() const;
 
167
        const QString &creation() const;
 
168
        const QString &homeUrl() const;
 
169
 
 
170
        const QString &fileName() const;
 
171
        void setFileName(const QString &);
 
172
 
 
173
        const QDict<QString> info() const;
 
174
        void setInfo(const QDict<QString> &);
 
175
 
 
176
        QPtrListIterator<Icon> iterator() const;
 
177
 
 
178
        QMimeSourceFactory *createMimeSourceFactory() const;
 
179
 
 
180
        void addToFactory() const;
 
181
        void removeFromFactory() const;
 
182
 
 
183
        static void setSoundPrefs(QString unpackPath, QObject *receiver, const char *slot);
 
184
 
 
185
        Iconset copy() const;
 
186
        void detach();
 
187
 
 
188
private:
 
189
        class Private;
 
190
        Private *d;
 
191
};
 
192
 
 
193
class IconsetFactory
 
194
{
 
195
public:
 
196
        static Icon icon(const QString &name);
 
197
        static const QPixmap &iconPixmap(const QString &name);
 
198
 
 
199
        static const Icon *iconPtr(const QString &name);
 
200
        static const QStringList icons();
 
201
};
 
202
 
 
203
#endif