summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-03 21:39:35 (UTC)
committer llornkcor <llornkcor>2002-11-03 21:39:35 (UTC)
commit5ba841a12e67b326833751ea502cf054e423114d (patch) (unidiff)
tree7fadf7e584b9298663328e2aa96ec207e3be4bda
parentfe933da66a39ae964f44d0f057fabece5bdf077b (diff)
downloadopie-5ba841a12e67b326833751ea502cf054e423114d.zip
opie-5ba841a12e67b326833751ea502cf054e423114d.tar.gz
opie-5ba841a12e67b326833751ea502cf054e423114d.tar.bz2
added public methods for background, foreground colors and framestyle
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/oticker.cpp32
-rw-r--r--libopie/oticker.h5
2 files changed, 29 insertions, 8 deletions
diff --git a/libopie/oticker.cpp b/libopie/oticker.cpp
index 774a49d..3fcef5d 100644
--- a/libopie/oticker.cpp
+++ b/libopie/oticker.cpp
@@ -23,72 +23,88 @@
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#include <qpe/resource.h> 32#include <qpe/resource.h>
33#include <qpe/config.h> 33#include <qpe/config.h>
34 34
35#include <qwidget.h> 35#include <qwidget.h>
36#include <qpixmap.h> 36#include <qpixmap.h>
37#include <qbutton.h> 37#include <qbutton.h>
38#include <qpainter.h> 38#include <qpainter.h>
39#include <qframe.h> 39#include <qframe.h>
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qdir.h> 41#include <qdir.h>
42#include <stdlib.h> 42#include <stdlib.h>
43#include <stdio.h> 43#include <stdio.h>
44 44
45#include "oticker.h" 45#include "oticker.h"
46 46
47OTicker::OTicker( QWidget* parent=0 ) : QFrame( parent ) { 47OTicker::OTicker( QWidget* parent=0 )
48 setFrameStyle( NoFrame/*WinPanel | Sunken */); 48 : QFrame( parent ) {
49
50// setFrameStyle( NoFrame/*WinPanel | Sunken */);
51
52 Config cfg("qpe");
53 cfg.setGroup("Appearance");
54 backgroundcolor = QColor( cfg.readEntry( "Background", "#E5E1D5" ) );
55 foregroundcolor= Qt::black;
49} 56}
50 57
51OTicker::~OTicker() { 58OTicker::~OTicker() {
52} 59}
53 60
61void OTicker::setBackgroundColor(QColor backcolor) {
62 backgroundcolor = backcolor;
63}
64
65void OTicker::setForegroundColor(QColor backcolor) {
66 foregroundcolor = backcolor;
67}
68
69void OTicker::setFrame(int frameStyle) {
70 setFrameStyle( frameStyle/*WinPanel | Sunken */);
71}
72
54void OTicker::setText( const QString& text ) { 73void OTicker::setText( const QString& text ) {
55 Config cfg("qpe");
56 cfg.setGroup("Appearance");
57
58 pos = 0; // reset it everytime the text is changed 74 pos = 0; // reset it everytime the text is changed
59 scrollText = text; 75 scrollText = text;
60 76
61 int pixelLen = fontMetrics().width( text ); 77 int pixelLen = fontMetrics().width( text );
62 QPixmap pm( pixelLen, contentsRect().height() ); 78 QPixmap pm( pixelLen, contentsRect().height() );
63// pm.fill( QColor( 167, 212, 167 )); 79// pm.fill( QColor( 167, 212, 167 ));
64 80
65 pm.fill( QColor( cfg.readEntry( "Background", "#E5E1D5" ) )); 81 pm.fill(backgroundcolor);
66 QPainter pmp( &pm ); 82 QPainter pmp( &pm );
67 pmp.setPen( Qt::black ); 83 pmp.setPen(foregroundcolor );
68 pmp.drawText( 0, 0, pixelLen, contentsRect().height(), AlignVCenter, scrollText ); 84 pmp.drawText( 0, 0, pixelLen, contentsRect().height(), AlignVCenter, scrollText );
69 pmp.end(); 85 pmp.end();
70 scrollTextPixmap = pm; 86 scrollTextPixmap = pm;
71 87
72 killTimers(); 88 killTimers();
73 if ( pixelLen > contentsRect().width() ) 89 if ( pixelLen > contentsRect().width() )
74 startTimer( 50 ); 90 startTimer( 50 );
75 update(); 91 update();
76} 92}
77 93
78 94
79void OTicker::timerEvent( QTimerEvent * ) { 95void OTicker::timerEvent( QTimerEvent * ) {
80 pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - 1; 96 pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - 1;
81 repaint( FALSE ); 97 repaint( FALSE );
82} 98}
83 99
84void OTicker::drawContents( QPainter *p ) { 100void OTicker::drawContents( QPainter *p ) {
85 int pixelLen = scrollTextPixmap.width(); 101 int pixelLen = scrollTextPixmap.width();
86 p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap ); 102 p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap );
87 if ( pixelLen > contentsRect().width() ) // Scrolling 103 if ( pixelLen > contentsRect().width() ) // Scrolling
88 p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap ); 104 p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap );
89} 105}
90 106
91void OTicker::mouseReleaseEvent( QMouseEvent * e) { 107void OTicker::mouseReleaseEvent( QMouseEvent * ) {
92// qDebug("<<<<<<<>>>>>>>>>"); 108// qDebug("<<<<<<<>>>>>>>>>");
93 emit mousePressed(); 109 emit mousePressed();
94} 110}
diff --git a/libopie/oticker.h b/libopie/oticker.h
index 4f0ed11..92a4be4 100644
--- a/libopie/oticker.h
+++ b/libopie/oticker.h
@@ -1,32 +1,37 @@
1#ifndef OTICKER_H 1#ifndef OTICKER_H
2#define OTICKER_H 2#define OTICKER_H
3 3
4#include <qwidget.h> 4#include <qwidget.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qdrawutil.h> 6#include <qdrawutil.h>
7#include <qpixmap.h> 7#include <qpixmap.h>
8#include <qstring.h> 8#include <qstring.h>
9#include <qslider.h> 9#include <qslider.h>
10#include <qframe.h> 10#include <qframe.h>
11#include <qlineedit.h> 11#include <qlineedit.h>
12#include <qcolor.h>
12 13
13class OTicker : public QFrame { 14class OTicker : public QFrame {
14 Q_OBJECT 15 Q_OBJECT
15 16
16public: 17public:
17 OTicker( QWidget* parent=0 ); 18 OTicker( QWidget* parent=0 );
18 ~OTicker(); 19 ~OTicker();
19 void setText( const QString& text ) ; 20 void setText( const QString& text ) ;
21 void setBackgroundColor(QColor color);
22 void setForegroundColor(QColor color);
23 void setFrame(int);
20signals: 24signals:
21 void mousePressed(); 25 void mousePressed();
22protected: 26protected:
23 void timerEvent( QTimerEvent * ); 27 void timerEvent( QTimerEvent * );
24 void drawContents( QPainter *p ); 28 void drawContents( QPainter *p );
25 void mouseReleaseEvent ( QMouseEvent *); 29 void mouseReleaseEvent ( QMouseEvent *);
26private: 30private:
31 QColor backgroundcolor, foregroundcolor;
27 QString scrollText; 32 QString scrollText;
28 QPixmap scrollTextPixmap; 33 QPixmap scrollTextPixmap;
29 int pos;//, pixelLen; 34 int pos;//, pixelLen;
30}; 35};
31 36
32#endif 37#endif