summaryrefslogtreecommitdiff
path: root/libopie
authorllornkcor <llornkcor>2002-11-10 23:46:23 (UTC)
committer llornkcor <llornkcor>2002-11-10 23:46:23 (UTC)
commit41c15dff26825ba13233d84583080e6bceee470f (patch) (unidiff)
treeee2d9de09d5903e970d3260edfb0f0aa8bd1f1e6 /libopie
parent9337c912158da3ad2fcda7ee1120c9357faddf8b (diff)
downloadopie-41c15dff26825ba13233d84583080e6bceee470f.zip
opie-41c15dff26825ba13233d84583080e6bceee470f.tar.gz
opie-41c15dff26825ba13233d84583080e6bceee470f.tar.bz2
added scroll speed and scroll amount and changed to QLabel for richtext, but it doesnt work.. yet.. for whatever reason
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/oticker.cpp23
-rw-r--r--libopie/oticker.h46
2 files changed, 57 insertions, 12 deletions
diff --git a/libopie/oticker.cpp b/libopie/oticker.cpp
index b4afbf9..6cd0dc8 100644
--- a/libopie/oticker.cpp
+++ b/libopie/oticker.cpp
@@ -1,113 +1,124 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 3 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
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 ) 47OTicker::OTicker( QWidget* parent )
48 : QFrame( parent ) { 48 : QLabel( parent ) {
49 49 // : QFrame( parent ) {
50// setFrameStyle( NoFrame/*WinPanel | Sunken */); 50 setTextFormat(Qt::RichText);
51
52 Config cfg("qpe"); 51 Config cfg("qpe");
53 cfg.setGroup("Appearance"); 52 cfg.setGroup("Appearance");
54 backgroundcolor = QColor( cfg.readEntry( "Background", "#E5E1D5" ) ); 53 backgroundcolor = QColor( cfg.readEntry( "Background", "#E5E1D5" ) );
55 foregroundcolor= Qt::black; 54 foregroundcolor= Qt::black;
55 updateTimerTime = 50;
56 scrollLength = 1;
56} 57}
57 58
58OTicker::~OTicker() { 59OTicker::~OTicker() {
59} 60}
60 61
61void OTicker::setBackgroundColor(QColor backcolor) { 62void OTicker::setBackgroundColor(QColor backcolor) {
62 backgroundcolor = backcolor; 63 backgroundcolor = backcolor;
63 update(); 64 update();
64} 65}
65 66
66void OTicker::setForegroundColor(QColor backcolor) { 67void OTicker::setForegroundColor(QColor backcolor) {
67 foregroundcolor = backcolor; 68 foregroundcolor = backcolor;
68 update(); 69 update();
69} 70}
70 71
71void OTicker::setFrame(int frameStyle) { 72void OTicker::setFrame(int frameStyle) {
72 setFrameStyle( frameStyle/*WinPanel | Sunken */); 73 setFrameStyle( frameStyle/*WinPanel | Sunken */);
73 update(); 74 update();
74} 75}
75 76
76void OTicker::setText( const QString& text ) { 77void OTicker::setText( const QString& text ) {
77 pos = 0; // reset it everytime the text is changed 78 pos = 0; // reset it everytime the text is changed
78 scrollText = text; 79 scrollText = text;
79 80
80 int pixelLen = fontMetrics().width( text ); 81 int pixelLen = fontMetrics().width( text );
81 QPixmap pm( pixelLen, contentsRect().height() ); 82 QPixmap pm( pixelLen, contentsRect().height() );
82// pm.fill( QColor( 167, 212, 167 )); 83// pm.fill( QColor( 167, 212, 167 ));
83 84
84 pm.fill(backgroundcolor); 85 pm.fill(backgroundcolor);
85 QPainter pmp( &pm ); 86 QPainter pmp( &pm );
86 pmp.setPen(foregroundcolor ); 87 pmp.setPen(foregroundcolor );
87 pmp.drawText( 0, 0, pixelLen, contentsRect().height(), AlignVCenter, scrollText ); 88 pmp.drawText( 0, 0, pixelLen, contentsRect().height(), AlignVCenter, scrollText );
88 pmp.end(); 89 pmp.end();
89 scrollTextPixmap = pm; 90 scrollTextPixmap = pm;
90 91
91 killTimers(); 92 killTimers();
93 // qDebug("Scrollupdate %d", updateTimerTime);
92 if ( pixelLen > contentsRect().width() ) 94 if ( pixelLen > contentsRect().width() )
93 startTimer( 50 ); 95 startTimer( updateTimerTime);
94 update(); 96 update();
95} 97}
96 98
97 99
98void OTicker::timerEvent( QTimerEvent * ) { 100void OTicker::timerEvent( QTimerEvent * ) {
99 pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - 1; 101 pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - scrollLength;//1;
100 repaint( FALSE ); 102 repaint( FALSE );
101} 103}
102 104
103void OTicker::drawContents( QPainter *p ) { 105void OTicker::drawContents( QPainter *p ) {
104 int pixelLen = scrollTextPixmap.width(); 106 int pixelLen = scrollTextPixmap.width();
105 p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap ); 107 p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap );
106 if ( pixelLen > contentsRect().width() ) // Scrolling 108 if ( pixelLen > contentsRect().width() ) // Scrolling
107 p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap ); 109 p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap );
108} 110}
109 111
110void OTicker::mouseReleaseEvent( QMouseEvent * ) { 112void OTicker::mouseReleaseEvent( QMouseEvent * ) {
111// qDebug("<<<<<<<>>>>>>>>>"); 113// qDebug("<<<<<<<>>>>>>>>>");
112 emit mousePressed(); 114 emit mousePressed();
113} 115}
116
117void OTicker::setUpdateTime(int time) {
118 updateTimerTime=time;
119}
120
121void OTicker::setScrollLength(int len) {
122scrollLength=len;
123}
124
diff --git a/libopie/oticker.h b/libopie/oticker.h
index 92a4be4..b7499e3 100644
--- a/libopie/oticker.h
+++ b/libopie/oticker.h
@@ -1,37 +1,71 @@
1/*
2                This file is part of the Opie Project
3 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
4 =.
5 .=l.
6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28
29*/
30
1#ifndef OTICKER_H 31#ifndef OTICKER_H
2#define OTICKER_H 32#define OTICKER_H
3 33
4#include <qwidget.h> 34#include <qwidget.h>
5#include <qpainter.h> 35#include <qpainter.h>
6#include <qdrawutil.h> 36#include <qdrawutil.h>
7#include <qpixmap.h> 37#include <qpixmap.h>
8#include <qstring.h> 38#include <qstring.h>
9#include <qslider.h> 39#include <qslider.h>
40#include <qlabel.h>
10#include <qframe.h> 41#include <qframe.h>
11#include <qlineedit.h> 42#include <qlineedit.h>
12#include <qcolor.h> 43#include <qcolor.h>
13 44
14class OTicker : public QFrame { 45class OTicker : public QLabel {
46//class OTicker : public QFrame {
15 Q_OBJECT 47 Q_OBJECT
16 48
17public: 49public:
18 OTicker( QWidget* parent=0 ); 50 OTicker( QWidget* parent=0 );
19 ~OTicker(); 51 ~OTicker();
20 void setText( const QString& text ) ; 52 void setText( const QString& text ) ;
21 void setBackgroundColor(QColor color); 53 void setBackgroundColor(QColor color); //sets background
22 void setForegroundColor(QColor color); 54 void setForegroundColor(QColor color); //sets text color
23 void setFrame(int); 55 void setFrame(int); //sets frame style
56 void setUpdateTime(int); //sets timeout for redraws default is 50 ms
57 void setScrollLength(int); //sets amount of scrolling default is 1
24signals: 58signals:
25 void mousePressed(); 59 void mousePressed(); // for mouse press events
26protected: 60protected:
27 void timerEvent( QTimerEvent * ); 61 void timerEvent( QTimerEvent * );
28 void drawContents( QPainter *p ); 62 void drawContents( QPainter *p );
29 void mouseReleaseEvent ( QMouseEvent *); 63 void mouseReleaseEvent ( QMouseEvent *);
30private: 64private:
31 QColor backgroundcolor, foregroundcolor; 65 QColor backgroundcolor, foregroundcolor;
32 QString scrollText; 66 QString scrollText;
33 QPixmap scrollTextPixmap; 67 QPixmap scrollTextPixmap;
34 int pos;//, pixelLen; 68 int pos, updateTimerTime, scrollLength;
35}; 69};
36 70
37#endif 71#endif