~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to noatun/noatun/modules/kjofol-skin/kjloader.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef USERINTERFACE_H
 
2
#define USERINTERFACE_H
 
3
 
 
4
#ifdef HAVE_CONFIG_H
 
5
#include <config.h>
 
6
#endif
 
7
 
 
8
#include <plugin.h>
 
9
#include <noatunapp.h>
 
10
#include <qwidget.h>
 
11
#include "parser.h"
 
12
#include <qbitmap.h>
 
13
#include <qlist.h>
 
14
#include <iostream.h>
 
15
#include <qcstring.h>
 
16
 
 
17
 
 
18
class KJWidget;
 
19
class KHelpMenu;
 
20
class KJSeeker;
 
21
class NoatunPreferences;
 
22
class KJToolTip;
 
23
 
 
24
class KJFont;
 
25
 
 
26
class KJLoader :  public QWidget, public UserInterface, public Parser
 
27
{
 
28
Q_OBJECT
 
29
NOATUNPLUGIND
 
30
 
 
31
        friend class KJWidget;
 
32
public:
 
33
        KJLoader();
 
34
        ~KJLoader();
 
35
 
 
36
public:
 
37
        void minimize();
 
38
        KHelpMenu *helpMenu() const { return mHelpMenu; }
 
39
        QStringList &item(const QString &key) { return *Parser::find(key); }
 
40
 
 
41
        QList<KJWidget> widgetsAt(const QPoint &pt) const;
 
42
 
 
43
        void removeChild(KJWidget *c);
 
44
        void addChild(KJWidget *c);
 
45
 
 
46
        static bool cleanSkin(const QString &dir);
 
47
 
 
48
        static QString guessRcFile(const QString &dir);
 
49
 
 
50
public slots:
 
51
        void loadSkin(const QString &file);
 
52
 
 
53
protected:
 
54
        void unloadSkin();
 
55
        
 
56
public slots:
 
57
        void timeUpdate();
 
58
        void newSong();
 
59
 
 
60
private slots:
 
61
        void loadSeeker();
 
62
        
 
63
protected:
 
64
        virtual void mouseMoveEvent(QMouseEvent *e);
 
65
        virtual void mousePressEvent(QMouseEvent *e);
 
66
        virtual void mouseReleaseEvent(QMouseEvent *e);
 
67
        virtual void paintEvent(QPaintEvent *e);
 
68
        virtual void closeEvent(QCloseEvent*e);
 
69
        virtual void wheelEvent(QWheelEvent *e);
 
70
 
 
71
        virtual void dragEnterEvent(QDragEnterEvent *event);
 
72
        virtual void dropEvent(QDropEvent *event);
 
73
 
 
74
public:
 
75
        static KJLoader* kjofol;
 
76
        
 
77
private:
 
78
        bool moving;
 
79
        QPoint mMousePoint;
 
80
        QList<KJWidget> subwidgets;
 
81
        KJWidget *mClickedIn;
 
82
        KHelpMenu *mHelpMenu;
 
83
        KJFont *mText, *mNumbers;
 
84
        KJToolTip *mTooltips;
 
85
        QString mCurrentSkin;
 
86
};
 
87
 
 
88
class KJWidget
 
89
{
 
90
public:
 
91
        KJWidget(KJLoader *);
 
92
        virtual ~KJWidget() {};
 
93
        // called when the widget should paint
 
94
        virtual void paint(QPainter *, const QRect &) {};
 
95
        // called to recieve the rect this widget is in
 
96
        virtual QRect rect() const { return mRect; }
 
97
        // called when pressed in this widget
 
98
        virtual bool mousePress(const QPoint &) {return false; }
 
99
        // called when the mouse is released after clicked in this widget
 
100
        virtual void mouseRelease(const QPoint &, bool){}
 
101
        virtual void mouseMove(const QPoint &, bool) {}
 
102
        // called with the current time (mille)
 
103
        virtual void timeUpdate(int) {}
 
104
        // called when a new song is playing, player() is ready with it too
 
105
        virtual void newFile() {}
 
106
        
 
107
        // called when the mouse is moved while clicked in this widget
 
108
        // repaint myself
 
109
        virtual void repaint(bool me=true, const QRect &rect=QRect(), bool clear=false);
 
110
 
 
111
        virtual QString tip() { return 0; }
 
112
 
 
113
public:
 
114
        static QBitmap getMask(const QImage &color, register QRgb=qRgb(255,0,255));
 
115
        
 
116
protected:
 
117
        QString backgroundPressed(const QString &bmp);
 
118
        KJLoader *parent() const {return mParent;}
 
119
        KJLoader &parser() const {return *mParent;}
 
120
 
 
121
        KJFont &textFont() const {return *mParent->mText;}
 
122
        KJFont &timeFont() const {return *mParent->mNumbers;}
 
123
        
 
124
        void setRect(const QRect& rect) {mRect=rect;}
 
125
        void setRect(int x, int y, int xs, int ys) {mRect=QRect(x,y,xs,ys);}
 
126
private:
 
127
        KJLoader *mParent;
 
128
        QRect mRect;
 
129
        
 
130
};
 
131
 
 
132
class Background : public KJWidget
 
133
{
 
134
public:
 
135
        Background(KJLoader *);
 
136
        virtual void paint(QPainter *, const QRect &rect);
 
137
        virtual bool mousePress(const QPoint &) {return false;}
 
138
        virtual void mouseRelease(const QPoint &, bool) {}
 
139
 
 
140
private:
 
141
        QPixmap mBackground;
 
142
};
 
143
 
 
144
 
 
145
class KJButton : public KJWidget
 
146
{
 
147
public:
 
148
        KJButton(const QStringList&, KJLoader *);
 
149
        virtual void paint(QPainter *, const QRect &rect);
 
150
        virtual bool mousePress(const QPoint &pos);
 
151
        virtual void mouseRelease(const QPoint &pos, bool);
 
152
        virtual void showPressed(bool b=true);
 
153
        
 
154
        virtual QString tip();
 
155
 
 
156
private:
 
157
        QPixmap mBackground;
 
158
        bool mPushedPixmap;
 
159
        QPixmap mPressed;
 
160
        QString mTitle;
 
161
        bool mShowPressed;
 
162
};
 
163
 
 
164
 
 
165
class KJSeeker : public KJWidget
 
166
{
 
167
public:
 
168
        KJSeeker(const QStringList &i, KJLoader *);
 
169
        ~KJSeeker();
 
170
        
 
171
        
 
172
        virtual void paint(QPainter *, const QRect &rect);
 
173
        virtual bool mousePress(const QPoint &pos);
 
174
        virtual void mouseRelease(const QPoint &pos, bool);
 
175
 
 
176
        void timeUpdate(int mille);
 
177
 
 
178
        void closest();
 
179
        
 
180
private:
 
181
        QImage mScale;
 
182
        QImage mActive;
 
183
        QPixmap *barmode[256];
 
184
        QBitmap barModeMask;
 
185
        int g;
 
186
};
 
187
 
 
188
class KJVolumeBMP : public KJWidget
 
189
{
 
190
public:
 
191
        KJVolumeBMP(const QStringList &, KJLoader *parent);
 
192
 
 
193
        virtual void paint(QPainter *, const QRect &rect);
 
194
        virtual bool mousePress(const QPoint &pos);
 
195
        virtual void mouseRelease(const QPoint &pos, bool);
 
196
        virtual void timeUpdate(int);
 
197
        virtual void mouseMove(const QPoint &pos, bool);
 
198
 
 
199
        virtual QString tip();
 
200
private:
 
201
        QPixmap mImages;
 
202
        QImage mPos;
 
203
        int mVolume;
 
204
        int mWidth, mCount;
 
205
};
 
206
 
 
207
class KJFont 
 
208
{
 
209
public:
 
210
        KJFont(const QString &prefix, KJLoader *parent);
 
211
        // draw the string str to dev at position pos, within rectangle limit in relation to pos
 
212
        QPixmap draw(const QCString &str, int wide, const QPoint &pt=QPoint(0,0)) const;
 
213
        QPixmap draw(const QString &str, int wide, const QPoint &pt=QPoint(0,0)) const
 
214
                { return draw(QCString(str.latin1()), wide, pt); }
 
215
 
 
216
protected:
 
217
        void drawCharacter(QPixmap *dev, const QPoint &to, char c) const;
 
218
 
 
219
        QPoint charSource(char c) const;
 
220
 
 
221
private:
 
222
        QPixmap mText;
 
223
        int mWidth, mHeight;
 
224
        int mSpacing;
 
225
        bool mTransparent;
 
226
 
 
227
        const char *mString[3];
 
228
        char mNullChar;
 
229
};
 
230
 
 
231
class KJFilename : public QObject, public KJWidget
 
232
{
 
233
Q_OBJECT
 
234
public:
 
235
        KJFilename(const QStringList &, KJLoader *parent);
 
236
 
 
237
        virtual void paint(QPainter *, const QRect &rect);
 
238
        virtual bool mousePress(const QPoint &pos);
 
239
        virtual void newFile();
 
240
        void prepareString(const QCString &str);
 
241
 
 
242
        virtual void timerEvent(QTimerEvent *);
 
243
 
 
244
private:
 
245
        int mDistance;
 
246
        int mWidth;
 
247
        int mTickerPos;
 
248
        QPixmap mView;
 
249
};
 
250
 
 
251
class KJTime : public KJWidget
 
252
{
 
253
public:
 
254
        KJTime(const QStringList &, KJLoader *parent);
 
255
 
 
256
        virtual void paint(QPainter *, const QRect &rect);
 
257
        virtual bool mousePress(const QPoint &pos);
 
258
        virtual void timeUpdate(int);
 
259
 
 
260
        void prepareString(const QCString &time);
 
261
private:
 
262
        QCString mCurrentStr;
 
263
        int mWidth;
 
264
        QPixmap mTime;
 
265
};
 
266
 
 
267
class KJVisScope : public KJWidget
 
268
{
 
269
public:
 
270
        KJVisScope(KJLoader *parent) : KJWidget(parent) {}
 
271
        enum Visuals { Null=0, FFT, Mono };
 
272
        void swapScope(Visuals newOne);
 
273
};
 
274
 
 
275
class KJNullScope : public KJVisScope
 
276
{
 
277
public:
 
278
        KJNullScope(const QStringList &, KJLoader *parent);
 
279
        virtual bool mousePress(const QPoint&);
 
280
};
 
281
 
 
282
class KJVis : public KJVisScope, public MonoFFTScope
 
283
{
 
284
public:
 
285
        KJVis(const QStringList &, KJLoader *parent);
 
286
        virtual void scopeEvent(float *d, int size);
 
287
        
 
288
        virtual bool mousePress(const QPoint&);
 
289
 
 
290
private:
 
291
        QColor mColor;
 
292
        int mMultiples;
 
293
};
 
294
 
 
295
class KJScope : public KJVisScope, public MonoScope
 
296
{
 
297
public:
 
298
        KJScope(const QStringList &, KJLoader *parent);
 
299
        virtual void scopeEvent(float *d, int size);
 
300
        
 
301
        virtual bool mousePress(const QPoint&);
 
302
 
 
303
private:
 
304
        QColor mColor;
 
305
        int mMultiples;
 
306
        int mWidth;
 
307
        int mHeight;
 
308
};
 
309
 
 
310
class KJEqualizer : public QObject, public KJWidget
 
311
{
 
312
Q_OBJECT
 
313
public:
 
314
        KJEqualizer(const QStringList &, KJLoader *parent);
 
315
        
 
316
        virtual void mouseMove(const QPoint &pos, bool);
 
317
        virtual bool mousePress(const QPoint&);
 
318
        virtual void paint(QPainter *, const QRect &rect);
 
319
        int barNum(const QPoint &pos) const;
 
320
        int level(const QPoint &pos) const;
 
321
 
 
322
public slots:
 
323
        void updateBuffer();
 
324
        
 
325
private:
 
326
        int mBands;
 
327
        int mXSpace;
 
328
 
 
329
        int mXSize;
 
330
        int mNumber;
 
331
        QPixmap mBars;
 
332
        QPixmap mBuffer;
 
333
};
 
334
 
 
335
 
 
336
#endif
 
337