summaryrefslogtreecommitdiff
path: root/libopie
Unidiff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/oticker.cpp4
-rw-r--r--libopie/oticker.h6
2 files changed, 4 insertions, 6 deletions
diff --git a/libopie/oticker.cpp b/libopie/oticker.cpp
index 9a7044d..4fb5945 100644
--- a/libopie/oticker.cpp
+++ b/libopie/oticker.cpp
@@ -1,139 +1,139 @@
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 : QLabel( parent ) { 48 : QLabel( parent ) {
49 // : QFrame( parent ) { 49 // : QFrame( parent ) {
50 setTextFormat(Qt::RichText); 50 setTextFormat(Qt::RichText);
51 Config cfg("qpe"); 51 Config cfg("qpe");
52 cfg.setGroup("Appearance"); 52 cfg.setGroup("Appearance");
53 backgroundcolor = QColor( cfg.readEntry( "Background", "#E5E1D5" ) ); 53 backgroundcolor = QColor( cfg.readEntry( "Background", "#E5E1D5" ) );
54 foregroundcolor= Qt::black; 54 foregroundcolor= Qt::black;
55 updateTimerTime = 50; 55 updateTimerTime = 50;
56 scrollLength = 1; 56 scrollLength = 1;
57} 57}
58 58
59OTicker::~OTicker() { 59OTicker::~OTicker() {
60} 60}
61 61
62void OTicker::setBackgroundColor(QColor backcolor) { 62void OTicker::setBackgroundColor(const QColor& backcolor) {
63 backgroundcolor = backcolor; 63 backgroundcolor = backcolor;
64 update(); 64 update();
65} 65}
66 66
67void OTicker::setForegroundColor(QColor backcolor) { 67void OTicker::setForegroundColor(const QColor& backcolor) {
68 foregroundcolor = backcolor; 68 foregroundcolor = backcolor;
69 update(); 69 update();
70} 70}
71 71
72void OTicker::setFrame(int frameStyle) { 72void OTicker::setFrame(int frameStyle) {
73 setFrameStyle( frameStyle/*WinPanel | Sunken */); 73 setFrameStyle( frameStyle/*WinPanel | Sunken */);
74 update(); 74 update();
75} 75}
76 76
77void OTicker::setText( const QString& text ) { 77void OTicker::setText( const QString& text ) {
78 pos = 0; // reset it everytime the text is changed 78 pos = 0; // reset it everytime the text is changed
79 scrollText = text; 79 scrollText = text;
80qDebug(scrollText); 80qDebug(scrollText);
81 81
82 int pixelLen = 0; 82 int pixelLen = 0;
83 bool bigger = false; 83 bool bigger = false;
84 int contWidth = contentsRect().width(); 84 int contWidth = contentsRect().width();
85 int contHeight = contentsRect().height(); 85 int contHeight = contentsRect().height();
86 int pixelTextLen = fontMetrics().width( text ); 86 int pixelTextLen = fontMetrics().width( text );
87 printf("<<<<<<<height %d, width %d, text width %d %d\n", contHeight, contWidth, pixelTextLen, scrollText.length()); 87 printf("<<<<<<<height %d, width %d, text width %d %d\n", contHeight, contWidth, pixelTextLen, scrollText.length());
88 if( pixelTextLen < contWidth) 88 if( pixelTextLen < contWidth)
89 { 89 {
90 pixelLen = contWidth; 90 pixelLen = contWidth;
91 } 91 }
92 else 92 else
93 { 93 {
94 bigger = true; 94 bigger = true;
95 pixelLen = pixelTextLen; 95 pixelLen = pixelTextLen;
96 } 96 }
97 QPixmap pm( pixelLen, contHeight); 97 QPixmap pm( pixelLen, contHeight);
98// pm.fill( QColor( 167, 212, 167 )); 98// pm.fill( QColor( 167, 212, 167 ));
99 99
100 pm.fill(backgroundcolor); 100 pm.fill(backgroundcolor);
101 QPainter pmp( &pm ); 101 QPainter pmp( &pm );
102 pmp.setPen(foregroundcolor ); 102 pmp.setPen(foregroundcolor );
103 pmp.drawText( 0, 0, pixelTextLen, contHeight, AlignVCenter, scrollText ); 103 pmp.drawText( 0, 0, pixelTextLen, contHeight, AlignVCenter, scrollText );
104 pmp.end(); 104 pmp.end();
105 scrollTextPixmap = pm; 105 scrollTextPixmap = pm;
106 106
107 killTimers(); 107 killTimers();
108 // qDebug("Scrollupdate %d", updateTimerTime); 108 // qDebug("Scrollupdate %d", updateTimerTime);
109 if ( bigger /*pixelTextLen > contWidth*/ ) 109 if ( bigger /*pixelTextLen > contWidth*/ )
110 startTimer( updateTimerTime); 110 startTimer( updateTimerTime);
111 update(); 111 update();
112} 112}
113 113
114 114
115void OTicker::timerEvent( QTimerEvent * ) { 115void OTicker::timerEvent( QTimerEvent * ) {
116 pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - scrollLength;//1; 116 pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - scrollLength;//1;
117 repaint( FALSE ); 117 repaint( FALSE );
118} 118}
119 119
120void OTicker::drawContents( QPainter *p ) { 120void OTicker::drawContents( QPainter *p ) {
121 int pixelLen = scrollTextPixmap.width(); 121 int pixelLen = scrollTextPixmap.width();
122 p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap ); 122 p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap );
123 if ( pixelLen > contentsRect().width() ) // Scrolling 123 if ( pixelLen > contentsRect().width() ) // Scrolling
124 p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap ); 124 p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap );
125} 125}
126 126
127void OTicker::mouseReleaseEvent( QMouseEvent * ) { 127void OTicker::mouseReleaseEvent( QMouseEvent * ) {
128// qDebug("<<<<<<<>>>>>>>>>"); 128// qDebug("<<<<<<<>>>>>>>>>");
129 emit mousePressed(); 129 emit mousePressed();
130} 130}
131 131
132void OTicker::setUpdateTime(int time) { 132void OTicker::setUpdateTime(int time) {
133 updateTimerTime=time; 133 updateTimerTime=time;
134} 134}
135 135
136void OTicker::setScrollLength(int len) { 136void OTicker::setScrollLength(int len) {
137scrollLength=len; 137scrollLength=len;
138} 138}
139 139
diff --git a/libopie/oticker.h b/libopie/oticker.h
index c52e317..0b88919 100644
--- a/libopie/oticker.h
+++ b/libopie/oticker.h
@@ -1,148 +1,146 @@
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#ifndef OTICKER_H 31#ifndef OTICKER_H
32#define OTICKER_H 32#define OTICKER_H
33 33
34#include <qwidget.h> 34#include <qwidget.h>
35#include <qpainter.h> 35#include <qpainter.h>
36#include <qdrawutil.h> 36#include <qdrawutil.h>
37#include <qpixmap.h> 37#include <qpixmap.h>
38#include <qstring.h> 38#include <qstring.h>
39#include <qslider.h> 39#include <qslider.h>
40#include <qlabel.h> 40#include <qlabel.h>
41#include <qframe.h> 41#include <qframe.h>
42#include <qcolor.h> 42#include <qcolor.h>
43 43
44/** 44/**
45 * @class OTicker 45 * @class OTicker
46 * @brief The OTicker class provides a QLabel widget that scroll its contents 46 * @brief The OTicker class provides a QLabel widget that scroll its contents
47 * 47 *
48 */ 48 */
49class OTicker : public QLabel { 49class OTicker : public QLabel {
50 Q_OBJECT 50 Q_OBJECT
51 51
52public: 52public:
53 53
54/*! 54/*!
55 * @fn OTicker( QWidget* parent = 0 ) 55 * @fn OTicker( QWidget* parent = 0 )
56 * @brief Object constructor. 56 * @brief Object constructor.
57 * 57 *
58 * @param parent Pointer to parent of this control. 58 * @param parent Pointer to parent of this control.
59 59
60 * Constructs a new OTicker control with parent 60 * Constructs a new OTicker control with parent
61 */ 61 */
62 OTicker( QWidget* parent=0 ); 62 OTicker( QWidget* parent=0 );
63/*! 63/*!
64 * @fn ~OTicker() 64 * @fn ~OTicker()
65 * @brief Object destructor. 65 * @brief Object destructor.
66 */ 66 */
67 ~OTicker(); 67 ~OTicker();
68/*! 68/*!
69 * @fn setText(const QString& ) 69 * @fn setText(const QString& )
70 * @brief sets text to be displayed 70 * @brief sets text to be displayed
71 * @param text QString text to be displayed. 71 * @param text QString text to be displayed.
72 * 72 *
73 */ 73 */
74 void setText( const QString& text ) ; 74 void setText( const QString& text ) ;
75/*! 75/*!
76 * @fn setBackgroundColor(QColor color) 76 * @fn setBackgroundColor(QColor color)
77 * @brief sets color of the ticker's background 77 * @brief sets color of the ticker's background
78 * @param color QColor color to be set. 78 * @param color QColor color to be set.
79 * 79 *
80 */ 80 */
81 //FIXME const QColor& please -zecke 81 void setBackgroundColor(const QColor& color);
82 void setBackgroundColor(QColor color);
83/*! 82/*!
84 * @fn setForegroundColor(QColor color) 83 * @fn setForegroundColor(QColor color)
85 * @brief sets color of text 84 * @brief sets color of text
86 * @param color QColor color of text 85 * @param color QColor color of text
87 * 86 *
88 */ 87 */
89 // FIXME const QColor& please -zecke 88 void setForegroundColor(const QColor& color);
90 void setForegroundColor(QColor color);
91/*! 89/*!
92 * @fn setFrame(int style) 90 * @fn setFrame(int style)
93 * @brief sets frame style 91 * @brief sets frame style
94 * @param style int Frame style to be see. See Qt::WidgetFlags. 92 * @param style int Frame style to be see. See Qt::WidgetFlags.
95 * 93 *
96 */ 94 */
97 void setFrame(int style); 95 void setFrame(int style);
98/*! 96/*!
99 * @fn setUpdateTime(int timeout) 97 * @fn setUpdateTime(int timeout)
100 * @brief sets time of update 98 * @brief sets time of update
101 * @param timeout int time in milliseconds between updates. 99 * @param timeout int time in milliseconds between updates.
102 * 100 *
103 */ 101 */
104 void setUpdateTime(int timeout); 102 void setUpdateTime(int timeout);
105/*! 103/*!
106 * @fn setScrollLength(int length) 104 * @fn setScrollLength(int length)
107 * @brief sets amount of scrolling default is 1 105 * @brief sets amount of scrolling default is 1
108 * @param length int scroll length. 106 * @param length int scroll length.
109 * 107 *
110 */ 108 */
111 void setScrollLength(int length); 109 void setScrollLength(int length);
112signals: 110signals:
113/*! 111/*!
114 * @fn mousePressed() 112 * @fn mousePressed()
115 * @brief signal mouse press event 113 * @brief signal mouse press event
116 * 114 *
117 */ 115 */
118 void mousePressed(); 116 void mousePressed();
119protected: 117protected:
120/*! 118/*!
121 * @fn timerEvent( QTimerEvent * e) 119 * @fn timerEvent( QTimerEvent * e)
122 * @brief timer timeout event 120 * @brief timer timeout event
123 * @param e QEvent see QEvent. 121 * @param e QEvent see QEvent.
124 * 122 *
125 */ 123 */
126 void timerEvent( QTimerEvent * e); 124 void timerEvent( QTimerEvent * e);
127/*! 125/*!
128 * @fn drawContents( QPainter *p ) 126 * @fn drawContents( QPainter *p )
129 * @brief draws widget contents 127 * @brief draws widget contents
130 * @param p QPainter. see QPainter 128 * @param p QPainter. see QPainter
131 * 129 *
132 */ 130 */
133 void drawContents( QPainter *p ); 131 void drawContents( QPainter *p );
134/*! 132/*!
135 * @fn mouseReleaseEvent( QMouseEvent *e) 133 * @fn mouseReleaseEvent( QMouseEvent *e)
136 * @brief mouse release event 134 * @brief mouse release event
137 * @param e QMouseEvent. see QMouseEvent. 135 * @param e QMouseEvent. see QMouseEvent.
138 * 136 *
139 */ 137 */
140 void mouseReleaseEvent( QMouseEvent *e); 138 void mouseReleaseEvent( QMouseEvent *e);
141private: 139private:
142 QColor backgroundcolor, foregroundcolor; 140 QColor backgroundcolor, foregroundcolor;
143 QString scrollText; 141 QString scrollText;
144 QPixmap scrollTextPixmap; 142 QPixmap scrollTextPixmap;
145 int pos, updateTimerTime, scrollLength; 143 int pos, updateTimerTime, scrollLength;
146}; 144};
147 145
148#endif 146#endif