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