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