author | llornkcor <llornkcor> | 2004-08-05 10:00:11 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-08-05 10:00:11 (UTC) |
commit | de7547111c8ee5b2424a405ba9d4454d753f465e (patch) (unidiff) | |
tree | 8d72d8c209072bce07e8a4ecb14772e1d4cf3fd4 /libqtaux/oticker.cpp | |
parent | cc6e3dc07d3e4baeba76b2651a2cfe118bba433c (diff) | |
download | opie-de7547111c8ee5b2424a405ba9d4454d753f465e.zip opie-de7547111c8ee5b2424a405ba9d4454d753f465e.tar.gz opie-de7547111c8ee5b2424a405ba9d4454d753f465e.tar.bz2 |
proper copyright header
-rw-r--r-- | libqtaux/oticker.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libqtaux/oticker.cpp b/libqtaux/oticker.cpp index 29478fd..aa6aa9b 100644 --- a/libqtaux/oticker.cpp +++ b/libqtaux/oticker.cpp | |||
@@ -1,141 +1,143 @@ | |||
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 | and Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
5 | |||
4 | =. | 6 | =. |
5 | .=l. | 7 | .=l. |
6 | .>+-= | 8 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 9 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 10 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 11 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 12 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 13 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 14 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 15 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 16 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 18 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 21 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 22 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 23 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 24 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 25 | -_. . . )=. = General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 26 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 27 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 28 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 29 | Boston, MA 02111-1307, USA. |
28 | 30 | ||
29 | */ | 31 | */ |
30 | 32 | ||
31 | #include "oticker.h" | 33 | #include "oticker.h" |
32 | 34 | ||
33 | /* OPIE */ | 35 | /* OPIE */ |
34 | #include <opie2/odebug.h> | 36 | #include <opie2/odebug.h> |
35 | 37 | ||
36 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
37 | 39 | ||
38 | using namespace Opie::Ui; | 40 | using namespace Opie::Ui; |
39 | 41 | ||
40 | OTicker::OTicker( QWidget* parent ) | 42 | OTicker::OTicker( QWidget* parent ) |
41 | : QLabel( parent ) | 43 | : QLabel( parent ) |
42 | { | 44 | { |
43 | setTextFormat( Qt::RichText ); | 45 | setTextFormat( Qt::RichText ); |
44 | Config cfg( "qpe" ); | 46 | Config cfg( "qpe" ); |
45 | cfg.setGroup( "Appearance" ); | 47 | cfg.setGroup( "Appearance" ); |
46 | backgroundcolor = QColor( cfg.readEntry( "Background", "#E5E1D5" ) ); | 48 | backgroundcolor = QColor( cfg.readEntry( "Background", "#E5E1D5" ) ); |
47 | foregroundcolor = Qt::black; | 49 | foregroundcolor = Qt::black; |
48 | updateTimerTime = 50; | 50 | updateTimerTime = 50; |
49 | scrollLength = 1; | 51 | scrollLength = 1; |
50 | } | 52 | } |
51 | 53 | ||
52 | OTicker::~OTicker() | 54 | OTicker::~OTicker() |
53 | {} | 55 | {} |
54 | 56 | ||
55 | void OTicker::setBackgroundColor( const QColor& backcolor ) | 57 | void OTicker::setBackgroundColor( const QColor& backcolor ) |
56 | { | 58 | { |
57 | backgroundcolor = backcolor; | 59 | backgroundcolor = backcolor; |
58 | update(); | 60 | update(); |
59 | } | 61 | } |
60 | 62 | ||
61 | void OTicker::setForegroundColor( const QColor& backcolor ) | 63 | void OTicker::setForegroundColor( const QColor& backcolor ) |
62 | { | 64 | { |
63 | foregroundcolor = backcolor; | 65 | foregroundcolor = backcolor; |
64 | update(); | 66 | update(); |
65 | } | 67 | } |
66 | 68 | ||
67 | void OTicker::setFrame( int frameStyle ) | 69 | void OTicker::setFrame( int frameStyle ) |
68 | { | 70 | { |
69 | setFrameStyle( frameStyle /*WinPanel | Sunken */ ); | 71 | setFrameStyle( frameStyle /*WinPanel | Sunken */ ); |
70 | update(); | 72 | update(); |
71 | } | 73 | } |
72 | 74 | ||
73 | void OTicker::setText( const QString& text ) | 75 | void OTicker::setText( const QString& text ) |
74 | { | 76 | { |
75 | pos = 0; // reset it everytime the text is changed | 77 | pos = 0; // reset it everytime the text is changed |
76 | scrollText = text; | 78 | scrollText = text; |
77 | odebug << scrollText << oendl; | 79 | odebug << scrollText << oendl; |
78 | 80 | ||
79 | int pixelLen = 0; | 81 | int pixelLen = 0; |
80 | bool bigger = false; | 82 | bool bigger = false; |
81 | int contWidth = contentsRect().width(); | 83 | int contWidth = contentsRect().width(); |
82 | int contHeight = contentsRect().height(); | 84 | int contHeight = contentsRect().height(); |
83 | int pixelTextLen = fontMetrics().width( text ); | 85 | int pixelTextLen = fontMetrics().width( text ); |
84 | odebug << "<<<<<<<height " << contHeight << ", width " << contWidth << ", text width " << pixelTextLen << " " << scrollText.length() << "\n" << oendl; | 86 | odebug << "<<<<<<<height " << contHeight << ", width " << contWidth << ", text width " << pixelTextLen << " " << scrollText.length() << "\n" << oendl; |
85 | if ( pixelTextLen < contWidth ) | 87 | if ( pixelTextLen < contWidth ) |
86 | { | 88 | { |
87 | pixelLen = contWidth; | 89 | pixelLen = contWidth; |
88 | } | 90 | } |
89 | else | 91 | else |
90 | { | 92 | { |
91 | bigger = true; | 93 | bigger = true; |
92 | pixelLen = pixelTextLen; | 94 | pixelLen = pixelTextLen; |
93 | } | 95 | } |
94 | QPixmap pm( pixelLen, contHeight ); | 96 | QPixmap pm( pixelLen, contHeight ); |
95 | // pm.fill( QColor( 167, 212, 167 )); | 97 | // pm.fill( QColor( 167, 212, 167 )); |
96 | 98 | ||
97 | pm.fill( backgroundcolor ); | 99 | pm.fill( backgroundcolor ); |
98 | QPainter pmp( &pm ); | 100 | QPainter pmp( &pm ); |
99 | pmp.setPen( foregroundcolor ); | 101 | pmp.setPen( foregroundcolor ); |
100 | pmp.drawText( 0, 0, pixelTextLen, contHeight, AlignVCenter, scrollText ); | 102 | pmp.drawText( 0, 0, pixelTextLen, contHeight, AlignVCenter, scrollText ); |
101 | pmp.end(); | 103 | pmp.end(); |
102 | scrollTextPixmap = pm; | 104 | scrollTextPixmap = pm; |
103 | 105 | ||
104 | killTimers(); | 106 | killTimers(); |
105 | // odebug << "Scrollupdate " << updateTimerTime << "" << oendl; | 107 | // odebug << "Scrollupdate " << updateTimerTime << "" << oendl; |
106 | if ( bigger /*pixelTextLen > contWidth*/ ) | 108 | if ( bigger /*pixelTextLen > contWidth*/ ) |
107 | startTimer( updateTimerTime ); | 109 | startTimer( updateTimerTime ); |
108 | update(); | 110 | update(); |
109 | } | 111 | } |
110 | 112 | ||
111 | 113 | ||
112 | void OTicker::timerEvent( QTimerEvent * ) | 114 | void OTicker::timerEvent( QTimerEvent * ) |
113 | { | 115 | { |
114 | pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - scrollLength; //1; | 116 | pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - scrollLength; //1; |
115 | repaint( FALSE ); | 117 | repaint( FALSE ); |
116 | } | 118 | } |
117 | 119 | ||
118 | void OTicker::drawContents( QPainter *p ) | 120 | void OTicker::drawContents( QPainter *p ) |
119 | { | 121 | { |
120 | int pixelLen = scrollTextPixmap.width(); | 122 | int pixelLen = scrollTextPixmap.width(); |
121 | p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap ); | 123 | p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap ); |
122 | if ( pixelLen > contentsRect().width() ) // Scrolling | 124 | if ( pixelLen > contentsRect().width() ) // Scrolling |
123 | p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap ); | 125 | p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap ); |
124 | } | 126 | } |
125 | 127 | ||
126 | void OTicker::mouseReleaseEvent( QMouseEvent * ) | 128 | void OTicker::mouseReleaseEvent( QMouseEvent * ) |
127 | { | 129 | { |
128 | // odebug << "<<<<<<<>>>>>>>>>" << oendl; | 130 | // odebug << "<<<<<<<>>>>>>>>>" << oendl; |
129 | emit mousePressed(); | 131 | emit mousePressed(); |
130 | } | 132 | } |
131 | 133 | ||
132 | void OTicker::setUpdateTime( int time ) | 134 | void OTicker::setUpdateTime( int time ) |
133 | { | 135 | { |
134 | updateTimerTime = time; | 136 | updateTimerTime = time; |
135 | } | 137 | } |
136 | 138 | ||
137 | void OTicker::setScrollLength( int len ) | 139 | void OTicker::setScrollLength( int len ) |
138 | { | 140 | { |
139 | scrollLength = len; | 141 | scrollLength = len; |
140 | } | 142 | } |
141 | 143 | ||