summaryrefslogtreecommitdiff
path: root/libqtaux
Unidiff
Diffstat (limited to 'libqtaux') (more/less context) (ignore whitespace changes)
-rw-r--r--libqtaux/oticker.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/libqtaux/oticker.cpp b/libqtaux/oticker.cpp
index e954cc8..29478fd 100644
--- a/libqtaux/oticker.cpp
+++ b/libqtaux/oticker.cpp
@@ -1,139 +1,141 @@
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 <opie2/odebug.h>
35
34#include <qpe/config.h> 36#include <qpe/config.h>
35 37
36using namespace Opie::Ui; 38using namespace Opie::Ui;
37 39
38OTicker::OTicker( QWidget* parent ) 40OTicker::OTicker( QWidget* parent )
39 : QLabel( parent ) 41 : QLabel( parent )
40{ 42{
41 setTextFormat( Qt::RichText ); 43 setTextFormat( Qt::RichText );
42 Config cfg( "qpe" ); 44 Config cfg( "qpe" );
43 cfg.setGroup( "Appearance" ); 45 cfg.setGroup( "Appearance" );
44 backgroundcolor = QColor( cfg.readEntry( "Background", "#E5E1D5" ) ); 46 backgroundcolor = QColor( cfg.readEntry( "Background", "#E5E1D5" ) );
45 foregroundcolor = Qt::black; 47 foregroundcolor = Qt::black;
46 updateTimerTime = 50; 48 updateTimerTime = 50;
47 scrollLength = 1; 49 scrollLength = 1;
48} 50}
49 51
50OTicker::~OTicker() 52OTicker::~OTicker()
51{} 53{}
52 54
53void OTicker::setBackgroundColor( const QColor& backcolor ) 55void OTicker::setBackgroundColor( const QColor& backcolor )
54{ 56{
55 backgroundcolor = backcolor; 57 backgroundcolor = backcolor;
56 update(); 58 update();
57} 59}
58 60
59void OTicker::setForegroundColor( const QColor& backcolor ) 61void OTicker::setForegroundColor( const QColor& backcolor )
60{ 62{
61 foregroundcolor = backcolor; 63 foregroundcolor = backcolor;
62 update(); 64 update();
63} 65}
64 66
65void OTicker::setFrame( int frameStyle ) 67void OTicker::setFrame( int frameStyle )
66{ 68{
67 setFrameStyle( frameStyle /*WinPanel | Sunken */ ); 69 setFrameStyle( frameStyle /*WinPanel | Sunken */ );
68 update(); 70 update();
69} 71}
70 72
71void OTicker::setText( const QString& text ) 73void OTicker::setText( const QString& text )
72{ 74{
73 pos = 0; // reset it everytime the text is changed 75 pos = 0; // reset it everytime the text is changed
74 scrollText = text; 76 scrollText = text;
75 qDebug( scrollText ); 77 odebug << scrollText << oendl;
76 78
77 int pixelLen = 0; 79 int pixelLen = 0;
78 bool bigger = false; 80 bool bigger = false;
79 int contWidth = contentsRect().width(); 81 int contWidth = contentsRect().width();
80 int contHeight = contentsRect().height(); 82 int contHeight = contentsRect().height();
81 int pixelTextLen = fontMetrics().width( text ); 83 int pixelTextLen = fontMetrics().width( text );
82 qDebug( "<<<<<<<height %d, width %d, text width %d %d\n", contHeight, contWidth, pixelTextLen, scrollText.length() ); 84 odebug << "<<<<<<<height " << contHeight << ", width " << contWidth << ", text width " << pixelTextLen << " " << scrollText.length() << "\n" << oendl;
83 if ( pixelTextLen < contWidth ) 85 if ( pixelTextLen < contWidth )
84 { 86 {
85 pixelLen = contWidth; 87 pixelLen = contWidth;
86 } 88 }
87 else 89 else
88 { 90 {
89 bigger = true; 91 bigger = true;
90 pixelLen = pixelTextLen; 92 pixelLen = pixelTextLen;
91 } 93 }
92 QPixmap pm( pixelLen, contHeight ); 94 QPixmap pm( pixelLen, contHeight );
93 // pm.fill( QColor( 167, 212, 167 )); 95 // pm.fill( QColor( 167, 212, 167 ));
94 96
95 pm.fill( backgroundcolor ); 97 pm.fill( backgroundcolor );
96 QPainter pmp( &pm ); 98 QPainter pmp( &pm );
97 pmp.setPen( foregroundcolor ); 99 pmp.setPen( foregroundcolor );
98 pmp.drawText( 0, 0, pixelTextLen, contHeight, AlignVCenter, scrollText ); 100 pmp.drawText( 0, 0, pixelTextLen, contHeight, AlignVCenter, scrollText );
99 pmp.end(); 101 pmp.end();
100 scrollTextPixmap = pm; 102 scrollTextPixmap = pm;
101 103
102 killTimers(); 104 killTimers();
103 // qDebug("Scrollupdate %d", updateTimerTime); 105 // odebug << "Scrollupdate " << updateTimerTime << "" << oendl;
104 if ( bigger /*pixelTextLen > contWidth*/ ) 106 if ( bigger /*pixelTextLen > contWidth*/ )
105 startTimer( updateTimerTime ); 107 startTimer( updateTimerTime );
106 update(); 108 update();
107} 109}
108 110
109 111
110void OTicker::timerEvent( QTimerEvent * ) 112void OTicker::timerEvent( QTimerEvent * )
111{ 113{
112 pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - scrollLength; //1; 114 pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - scrollLength; //1;
113 repaint( FALSE ); 115 repaint( FALSE );
114} 116}
115 117
116void OTicker::drawContents( QPainter *p ) 118void OTicker::drawContents( QPainter *p )
117{ 119{
118 int pixelLen = scrollTextPixmap.width(); 120 int pixelLen = scrollTextPixmap.width();
119 p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap ); 121 p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap );
120 if ( pixelLen > contentsRect().width() ) // Scrolling 122 if ( pixelLen > contentsRect().width() ) // Scrolling
121 p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap ); 123 p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap );
122} 124}
123 125
124void OTicker::mouseReleaseEvent( QMouseEvent * ) 126void OTicker::mouseReleaseEvent( QMouseEvent * )
125{ 127{
126 // qDebug("<<<<<<<>>>>>>>>>"); 128 // odebug << "<<<<<<<>>>>>>>>>" << oendl;
127 emit mousePressed(); 129 emit mousePressed();
128} 130}
129 131
130void OTicker::setUpdateTime( int time ) 132void OTicker::setUpdateTime( int time )
131{ 133{
132 updateTimerTime = time; 134 updateTimerTime = time;
133} 135}
134 136
135void OTicker::setScrollLength( int len ) 137void OTicker::setScrollLength( int len )
136{ 138{
137 scrollLength = len; 139 scrollLength = len;
138} 140}
139 141