-rw-r--r-- | libopie/oticker.cpp | 32 |
1 files changed, 24 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 | |||
@@ -41,33 +41,49 @@ | |||
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 | ||
47 | OTicker::OTicker( QWidget* parent=0 ) : QFrame( parent ) { | 47 | OTicker::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 | ||
51 | OTicker::~OTicker() { | 58 | OTicker::~OTicker() { |
52 | } | 59 | } |
53 | 60 | ||
61 | void OTicker::setBackgroundColor(QColor backcolor) { | ||
62 | backgroundcolor = backcolor; | ||
63 | } | ||
64 | |||
65 | void OTicker::setForegroundColor(QColor backcolor) { | ||
66 | foregroundcolor = backcolor; | ||
67 | } | ||
68 | |||
69 | void OTicker::setFrame(int frameStyle) { | ||
70 | setFrameStyle( frameStyle/*WinPanel | Sunken */); | ||
71 | } | ||
72 | |||
54 | void OTicker::setText( const QString& text ) { | 73 | void 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() ) |
@@ -85,10 +101,10 @@ void 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 | ||
91 | void OTicker::mouseReleaseEvent( QMouseEvent * e) { | 107 | void OTicker::mouseReleaseEvent( QMouseEvent * ) { |
92 | // qDebug("<<<<<<<>>>>>>>>>"); | 108 | // qDebug("<<<<<<<>>>>>>>>>"); |
93 | emit mousePressed(); | 109 | emit mousePressed(); |
94 | } | 110 | } |