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

« back to all changes in this revision

Viewing changes to noatun/noatun/modules/kaiman/style.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
// -*- C++ -*-
 
2
/*
 
3
   Copyright (c) 2000 Stefan Schimanski (1Stein@gmx.de)
 
4
                 1999-2000 Christian Esken (esken@kde.org)
 
5
 
 
6
   This program is free software; you can redistribute it and/or modify
 
7
   it under the terms of the GNU General Public License as published by
 
8
   the Free Software Foundation; either version 2, or (at your option)
 
9
   any later version.
 
10
 
 
11
   This program is distributed in the hope that it will be useful,
 
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
   GNU General Public License for more details.
 
15
 
 
16
   You should have received a copy of the GNU General Public License
 
17
   along with this program; if not, write to the Free Software
 
18
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
19
*/
 
20
 
 
21
#ifndef KaimanStyle_H
 
22
#define KaimanStyle_H
 
23
 
 
24
#include <qstring.h>
 
25
#include <qwidget.h>
 
26
#include <qpixmap.h>
 
27
#include <qbitmap.h>
 
28
#include <qimage.h>
 
29
#include <qevent.h>
 
30
#include <qvector.h>
 
31
 
 
32
class KaimanStyleElement : public QWidget
 
33
{
 
34
    Q_OBJECT
 
35
public:
 
36
    KaimanStyleElement(QWidget *parent, const char *name=0);
 
37
    ~KaimanStyleElement();
 
38
 
 
39
    virtual void loadPixmaps(QString &val_s_filename);
 
40
 
 
41
    QString     element;
 
42
    QString     filename;
 
43
    QPoint      upperLeft;
 
44
    QSize      dimension;
 
45
 
 
46
    bool options[3];
 
47
    int digits;
 
48
 
 
49
    bool optionPrelight;
 
50
    bool optionStatuslight;
 
51
 
 
52
    int pixmapLines;
 
53
    int pixmapColumns;
 
54
 
 
55
    QVector<QPixmap> pixmaps;
 
56
 
 
57
public slots:
 
58
    void setPixmap( int num );
 
59
 
 
60
protected:
 
61
    void paintEvent(QPaintEvent *qpe);
 
62
    void dropEvent( QDropEvent *event );
 
63
    void dragEnterEvent( QDragEnterEvent *event );
 
64
 
 
65
    int pixmapNum;
 
66
 
 
67
private:
 
68
    int _currentPixmap;
 
69
};
 
70
 
 
71
 
 
72
class KaimanStyleMasked : public KaimanStyleElement
 
73
{
 
74
 Q_OBJECT
 
75
public:
 
76
    KaimanStyleMasked(QWidget *parent, const char *name=0)
 
77
        : KaimanStyleElement( parent, name ) {};
 
78
 
 
79
    virtual void loadPixmaps(QString &val_s_filename)
 
80
        {
 
81
            KaimanStyleElement::loadPixmaps( val_s_filename );
 
82
            if(pixmaps[0]->mask())
 
83
                setMask(*pixmaps[0]->mask());
 
84
        };
 
85
};
 
86
 
 
87
 
 
88
class KaimanStyleButton : public KaimanStyleMasked
 
89
{
 
90
 Q_OBJECT
 
91
public:
 
92
    KaimanStyleButton(QWidget *parent, const char *name=0);
 
93
    ~KaimanStyleButton();
 
94
 
 
95
    // Button states.
 
96
    enum { NormalUp=0, NormalDown, LitUp, LitDown, PrelightUp, PrelightLitUp, StateListEND };
 
97
 
 
98
    QVector<int> I_pmIndex;
 
99
 
 
100
    void setLit(bool);
 
101
    void setPrelight(bool);
 
102
    void setDown(bool);
 
103
    bool lit();
 
104
    bool prelit();
 
105
    bool down();
 
106
    void updateButtonState();
 
107
 
 
108
signals:
 
109
    void clicked();
 
110
 
 
111
protected:
 
112
    void mousePressEvent(QMouseEvent *qme);
 
113
    void mouseReleaseEvent(QMouseEvent *qme);
 
114
    void enterEvent(QEvent * );
 
115
    void leaveEvent ( QEvent * );
 
116
 
 
117
private:
 
118
    int i_i_currentState;
 
119
    bool i_b_lit;
 
120
    bool i_b_prelit;
 
121
    bool i_b_down;
 
122
};
 
123
 
 
124
 
 
125
class KaimanStyleSlider : public KaimanStyleMasked
 
126
{
 
127
 Q_OBJECT
 
128
public:
 
129
    KaimanStyleSlider(int min, int max, QWidget *parent, const char *name=0);
 
130
    ~KaimanStyleSlider();
 
131
 
 
132
    int value() { return _value; };
 
133
 
 
134
    static const bool optionVertical = 1;
 
135
    static const bool optionReversed = 2;
 
136
 
 
137
public slots:
 
138
    void setValue( int value );
 
139
    void setValue( int value, int min, int max );
 
140
 
 
141
signals:
 
142
    void newValue( int value );
 
143
    void newValueDrag( int value );
 
144
    void newValueDrop( int value );
 
145
 
 
146
protected:
 
147
    void mouseMoveEvent(QMouseEvent *qme);
 
148
    void mousePressEvent(QMouseEvent *qme);
 
149
    void mouseReleaseEvent(QMouseEvent *qme);
 
150
    void paintEvent(QPaintEvent *qpe);
 
151
    void enterEvent(QEvent * );
 
152
    void leaveEvent ( QEvent * );
 
153
 
 
154
    int pos2value( int x, int y );
 
155
 
 
156
    bool _down;
 
157
    bool _lit;
 
158
    int _value;
 
159
    int _min, _max;
 
160
};
 
161
 
 
162
 
 
163
class KaimanStyleBackground : public KaimanStyleMasked
 
164
{
 
165
 Q_OBJECT
 
166
public:
 
167
    KaimanStyleBackground(QWidget *parent, const char *name=0);
 
168
    ~KaimanStyleBackground();
 
169
 
 
170
protected:
 
171
    void mousePressEvent(QMouseEvent *qme);
 
172
    void mouseReleaseEvent(QMouseEvent *qme);
 
173
    void mouseMoveEvent(QMouseEvent *qme);
 
174
 
 
175
private:
 
176
    bool i_b_move;
 
177
    QPoint i_point_dragStart;
 
178
    QPoint i_point_lastPos;
 
179
};
 
180
 
 
181
 
 
182
class KaimanStyleValue : public KaimanStyleMasked
 
183
{
 
184
 Q_OBJECT
 
185
public:
 
186
    KaimanStyleValue(int min, int max, QWidget *parent, const char *name=0);
 
187
    ~KaimanStyleValue();
 
188
 
 
189
    int value() { return _value; };
 
190
 
 
191
public slots:
 
192
    void setValue( int value );
 
193
    void setValue( int value, int min, int max );
 
194
 
 
195
private:
 
196
    int _min, _max, _value;
 
197
};
 
198
 
 
199
 
 
200
class KaimanStyleState : public KaimanStyleMasked
 
201
{
 
202
 Q_OBJECT
 
203
public:
 
204
    KaimanStyleState(QWidget *parent, const char *name=0);
 
205
    ~KaimanStyleState();
 
206
 
 
207
    int value() { return _value; };
 
208
 
 
209
public slots:
 
210
    void setValue( int value );
 
211
 
 
212
signals:
 
213
    void clicked();
 
214
 
 
215
protected:
 
216
    void mousePressEvent(QMouseEvent *qme);
 
217
 
 
218
private:
 
219
    int _value;
 
220
};
 
221
 
 
222
 
 
223
class KaimanStyleNumber : public KaimanStyleElement
 
224
{
 
225
 Q_OBJECT
 
226
public:
 
227
    KaimanStyleNumber(QWidget *parent, const char *name=0);
 
228
    ~KaimanStyleNumber();
 
229
 
 
230
    virtual void loadPixmaps(QString &val_s_filename);
 
231
 
 
232
    static const bool optionCentered = 1;
 
233
 
 
234
    int value() { return _value; };
 
235
 
 
236
public slots:
 
237
    void setValue( int value );
 
238
 
 
239
protected:
 
240
    void paintEvent(QPaintEvent *qpe);
 
241
 
 
242
private:
 
243
    int _value;
 
244
};
 
245
 
 
246
 
 
247
class KaimanStyleText : public KaimanStyleElement
 
248
{
 
249
 Q_OBJECT
 
250
public:
 
251
    KaimanStyleText(QWidget *parent, const char *name=0);
 
252
    ~KaimanStyleText();
 
253
 
 
254
    virtual void loadPixmaps(QString &val_s_filename);
 
255
 
 
256
    static const bool optionExtended = 1;
 
257
 
 
258
    QString value() { return _value; };
 
259
 
 
260
    void startAnimation( int delay );
 
261
    void stopAnimation();
 
262
 
 
263
public slots:
 
264
    void setValue( QString value );
 
265
 
 
266
protected:
 
267
    void paintEvent(QPaintEvent *qpe);
 
268
 
 
269
protected slots:
 
270
    void timeout();
 
271
 
 
272
private:
 
273
    QString _value;
 
274
    int _pos;
 
275
    int _direction;
 
276
    int _delay;
 
277
    QTimer *_timer;
 
278
};
 
279
 
 
280
 
 
281
class KaimanStyleAnimation : public KaimanStyleMasked
 
282
{
 
283
 Q_OBJECT
 
284
public:
 
285
    KaimanStyleAnimation(int delay, QWidget *parent, const char *name=0);
 
286
    ~KaimanStyleAnimation();
 
287
 
 
288
public slots:
 
289
    void start();
 
290
    void pause();
 
291
    void stop();
 
292
 
 
293
protected:
 
294
    void timeout();
 
295
 
 
296
private:
 
297
    int _delay,_frame;
 
298
    QTimer *_timer;
 
299
};
 
300
 
 
301
class KaimanStyle : public QWidget
 
302
{
 
303
 Q_OBJECT
 
304
public:
 
305
    KaimanStyle(QWidget *parent, const char *name=0);
 
306
    ~KaimanStyle();
 
307
 
 
308
    enum { background, mask, play_Button, stop_Button, pause_Button, prev_Button, next_Button,  repeat_Button, shuffle_Button, playlist_Button, mixer_Button, exit_Button, Iconify_Button, Config_Button, Alt_Skin_Button, Minute_Number, Second_Number, in_Rate_Number, in_Hz_Number, song_Number, status_Item, cPU_Number, digit_Large, digit_Small_Default, title, volume_Item, volume_Slider, position_Item, position_Slider };
 
309
 
 
310
    enum { ParsingError=1, FileNotFound };
 
311
 
 
312
    /// Finds a style element, according  to it's name. Returns 0 when element is not available.
 
313
    KaimanStyleElement* find(const char* val_s_elemName);
 
314
 
 
315
    /// Tries to load the given style and returns success (true) or failure (false)
 
316
    bool loadStyle(const QString &styleName, const QString &descFile="skindata" );
 
317
    QString skinName() { return i_skinName; };
 
318
 
 
319
    /// Returns the mask
 
320
    QBitmap* Mask();
 
321
 
 
322
    virtual bool eventFilter( QObject *o, QEvent *e );
 
323
 
 
324
private:
 
325
    // Parses the "skindata" file and returns success (true) or failure (false)
 
326
    int parseStyleFile(QString &l_s_tmpName);
 
327
    QString getToken(QString &val_s_string, char val_c_separator);
 
328
    void interpretTokens(QStringList& ref_s_tokens);
 
329
    bool loadPixmaps();
 
330
 
 
331
    /// The name of the style, e.g. "k9"
 
332
    QString     i_s_styleName;
 
333
    /// The base directory, where the style is found. For example
 
334
    /// "/opt/kde/share/apps/kaiman/Skins/k9/" or  "/opt/kde/share/apps/kaiman/Skins/k9.tgz"
 
335
    QString     i_s_styleBase;
 
336
 
 
337
 
 
338
    // The mask of the complete style. Used for doing shaped windows
 
339
    QBitmap     i_bitmap_Mask;
 
340
 
 
341
    /// All style elements are stored here.
 
342
    QVector<KaimanStyleElement> I_styleElem;
 
343
 
 
344
    // The parent window. In other words: The container that holds all the KaimanStyleElement's
 
345
    QWidget*            i_qw_parent;
 
346
 
 
347
    QList<QWidget> i_sliders;
 
348
    bool i_eventSemaphore;
 
349
 
 
350
    QString i_smallFont;
 
351
    QString i_largeFont;
 
352
    QString i_skinName;
 
353
};
 
354
 
 
355
 
 
356
#endif