From e1e4956ec7ffa9a07f98b03e831f0f9627556a6c Mon Sep 17 00:00:00 2001 From: harlekin Date: Wed, 03 Jul 2002 14:44:22 +0000 Subject: much more code cleanup, make if look more like c++ code --- (limited to 'noncore/multimedia/opieplayer2/audiowidget.cpp') diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 8d3963a..1b0de5d 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -15,11 +15,48 @@ extern MediaPlayerState *mediaPlayerState; - static const int xo = -2; // movable x offset static const int yo = 22; // movable y offset +Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { + setFrameStyle( WinPanel | Sunken ); + setText( "No Song" ); +} + +Ticker::~Ticker() { +} + +void Ticker::setText( const QString& text ) { + pos = 0; // reset it everytime the text is changed + scrollText = text; + pixelLen = fontMetrics().width( scrollText ); + killTimers(); + if ( pixelLen > width() ) { + startTimer( 50 ); + } + update(); +} + + +void Ticker::timerEvent( QTimerEvent * ) { + pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; + repaint( FALSE ); +} + +void Ticker::drawContents( QPainter *p ) { + QPixmap pm( width(), height() ); + pm.fill( colorGroup().base() ); + QPainter pmp( &pm ); + for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { + pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); + } + p->drawPixmap( 0, 0, pm ); +} + + + + struct MediaButton { int xPos, yPos; int color; @@ -27,6 +64,8 @@ struct MediaButton { }; + + // Layout information for the audioButtons (and if it is a toggle button or not) MediaButton audioButtons[] = { { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play @@ -40,7 +79,6 @@ MediaButton audioButtons[] = { { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist }; - static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); @@ -145,7 +183,6 @@ void AudioWidget::setView( char view ) { if ( view == 'a' ) { startTimer( 150 ); - // show(); showMaximized(); } else { killTimers(); -- cgit v0.9.0.2