summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/audiowidget.h
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/audiowidget.h') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.h144
1 files changed, 144 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h
new file mode 100644
index 0000000..4b82a91
--- a/dev/null
+++ b/core/multimedia/opieplayer/audiowidget.h
@@ -0,0 +1,144 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef AUDIO_WIDGET_H
21#define AUDIO_WIDGET_H
22
23
24#include <qwidget.h>
25#include <qpainter.h>
26#include <qdrawutil.h>
27#include <qpixmap.h>
28#include <qstring.h>
29#include <qslider.h>
30#include <qframe.h>
31
32
33class QPixmap;
34
35
36enum AudioButtons {
37 AudioPlay,
38 AudioStop,
39 AudioPause,
40 AudioNext,
41 AudioPrevious,
42 AudioVolumeUp,
43 AudioVolumeDown,
44 AudioLoop,
45 AudioPlayList
46};
47
48
49#define USE_DBLBUF
50
51
52class Ticker : public QFrame {
53 Q_OBJECT
54public:
55 Ticker( QWidget* parent=0 ) : QFrame( parent ) {
56 setFrameStyle( WinPanel | Sunken );
57 setText( "No Song" );
58 }
59 ~Ticker() { }
60 void setText( const QString& text ) {
61 pos = 0; // reset it everytime the text is changed
62 scrollText = text;
63 pixelLen = fontMetrics().width( scrollText );
64 killTimers();
65 if ( pixelLen > width() )
66 startTimer( 50 );
67 update();
68 }
69protected:
70 void timerEvent( QTimerEvent * ) {
71 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
72#ifndef USE_DBLBUF
73 scroll( -1, 0, contentsRect() );
74#else
75 repaint( FALSE );
76#endif
77 }
78 void drawContents( QPainter *p ) {
79#ifndef USE_DBLBUF
80 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
81 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
82#else
83 // Double buffering code.
84 // Looks like qvfb makes it look like it flickers but I don't think it really is
85 QPixmap pm( width(), height() );
86 pm.fill( colorGroup().base() );
87 QPainter pmp( &pm );
88 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
89 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
90 p->drawPixmap( 0, 0, pm );
91#endif
92 }
93private:
94 QString scrollText;
95 int pos, pixelLen;
96};
97
98
99class AudioWidget : public QWidget {
100 Q_OBJECT
101public:
102 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
103 ~AudioWidget();
104 void setTickerText( const QString &text ) { songInfo->setText( text ); }
105
106public slots:
107 void updateSlider( long, long );
108 void sliderPressed( );
109 void sliderReleased( );
110 void setPaused( bool b) { setToggleButton( AudioPause, b ); }
111 void setLooping( bool b) { setToggleButton( AudioLoop, b ); }
112 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); }
113 void setPosition( long );
114 void setLength( long );
115 void setView( char );
116
117signals:
118 void moreClicked();
119 void lessClicked();
120 void moreReleased();
121 void lessReleased();
122 void sliderMoved(long);
123
124protected:
125 void paintEvent( QPaintEvent *pe );
126 void showEvent( QShowEvent *se );
127 void mouseMoveEvent( QMouseEvent *event );
128 void mousePressEvent( QMouseEvent *event );
129 void mouseReleaseEvent( QMouseEvent *event );
130 void timerEvent( QTimerEvent *event );
131 void closeEvent( QCloseEvent *event );
132
133private:
134 void toggleButton( int );
135 void setToggleButton( int, bool );
136 void paintButton( QPainter *p, int i );
137 QPixmap *pixmaps[4];
138 Ticker *songInfo;
139 QSlider *slider;
140};
141
142
143#endif // AUDIO_WIDGET_H
144