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 | |
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 | ||||
-rw-r--r-- | libqtaux/oticker.h | 3 |
2 files changed, 5 insertions, 2 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 | ||
diff --git a/libqtaux/oticker.h b/libqtaux/oticker.h index a89d334..655c469 100644 --- a/libqtaux/oticker.h +++ b/libqtaux/oticker.h | |||
@@ -1,151 +1,152 @@ | |||
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. | ||
4 | =. | 5 | =. |
5 | .=l. | 6 | .=l. |
6 | .>+-= | 7 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 14 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 22 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
28 | 29 | ||
29 | */ | 30 | */ |
30 | 31 | ||
31 | #ifndef OTICKER_H | 32 | #ifndef OTICKER_H |
32 | #define OTICKER_H | 33 | #define OTICKER_H |
33 | 34 | ||
34 | #include <qwidget.h> | 35 | #include <qwidget.h> |
35 | #include <qpainter.h> | 36 | #include <qpainter.h> |
36 | #include <qdrawutil.h> | 37 | #include <qdrawutil.h> |
37 | #include <qpixmap.h> | 38 | #include <qpixmap.h> |
38 | #include <qstring.h> | 39 | #include <qstring.h> |
39 | #include <qslider.h> | 40 | #include <qslider.h> |
40 | #include <qlabel.h> | 41 | #include <qlabel.h> |
41 | #include <qframe.h> | 42 | #include <qframe.h> |
42 | #include <qcolor.h> | 43 | #include <qcolor.h> |
43 | 44 | ||
44 | 45 | ||
45 | namespace Opie { | 46 | namespace Opie { |
46 | namespace Ui { | 47 | namespace Ui { |
47 | /** | 48 | /** |
48 | * @class OTicker | 49 | * @class OTicker |
49 | * @brief The OTicker class provides a QLabel widget that scroll its contents | 50 | * @brief The OTicker class provides a QLabel widget that scroll its contents |
50 | * | 51 | * |
51 | */ | 52 | */ |
52 | class OTicker : public QLabel { | 53 | class OTicker : public QLabel { |
53 | Q_OBJECT | 54 | Q_OBJECT |
54 | 55 | ||
55 | public: | 56 | public: |
56 | 57 | ||
57 | /*! | 58 | /*! |
58 | * @fn OTicker( QWidget* parent = 0 ) | 59 | * @fn OTicker( QWidget* parent = 0 ) |
59 | * @brief Object constructor. | 60 | * @brief Object constructor. |
60 | * | 61 | * |
61 | * @param parent Pointer to parent of this control. | 62 | * @param parent Pointer to parent of this control. |
62 | 63 | ||
63 | * Constructs a new OTicker control with parent | 64 | * Constructs a new OTicker control with parent |
64 | */ | 65 | */ |
65 | OTicker( QWidget* parent=0 ); | 66 | OTicker( QWidget* parent=0 ); |
66 | /*! | 67 | /*! |
67 | * @fn ~OTicker() | 68 | * @fn ~OTicker() |
68 | * @brief Object destructor. | 69 | * @brief Object destructor. |
69 | */ | 70 | */ |
70 | ~OTicker(); | 71 | ~OTicker(); |
71 | /*! | 72 | /*! |
72 | * @fn setText(const QString& ) | 73 | * @fn setText(const QString& ) |
73 | * @brief sets text to be displayed | 74 | * @brief sets text to be displayed |
74 | * @param text QString text to be displayed. | 75 | * @param text QString text to be displayed. |
75 | * | 76 | * |
76 | */ | 77 | */ |
77 | void setText( const QString& text ) ; | 78 | void setText( const QString& text ) ; |
78 | /*! | 79 | /*! |
79 | * @fn setBackgroundColor(const QColor& color) | 80 | * @fn setBackgroundColor(const QColor& color) |
80 | * @brief sets color of the ticker's background | 81 | * @brief sets color of the ticker's background |
81 | * @param color QColor color to be set. | 82 | * @param color QColor color to be set. |
82 | * | 83 | * |
83 | */ | 84 | */ |
84 | void setBackgroundColor(const QColor& color); | 85 | void setBackgroundColor(const QColor& color); |
85 | /*! | 86 | /*! |
86 | * @fn setForegroundColor(const QColor& color) | 87 | * @fn setForegroundColor(const QColor& color) |
87 | * @brief sets color of text | 88 | * @brief sets color of text |
88 | * @param color QColor color of text | 89 | * @param color QColor color of text |
89 | * | 90 | * |
90 | */ | 91 | */ |
91 | void setForegroundColor(const QColor& color); | 92 | void setForegroundColor(const QColor& color); |
92 | /*! | 93 | /*! |
93 | * @fn setFrame(int style) | 94 | * @fn setFrame(int style) |
94 | * @brief sets frame style | 95 | * @brief sets frame style |
95 | * @param style int Frame style to be see. See Qt::WidgetFlags. | 96 | * @param style int Frame style to be see. See Qt::WidgetFlags. |
96 | * | 97 | * |
97 | */ | 98 | */ |
98 | void setFrame(int style); | 99 | void setFrame(int style); |
99 | /*! | 100 | /*! |
100 | * @fn setUpdateTime(int timeout) | 101 | * @fn setUpdateTime(int timeout) |
101 | * @brief sets time of update | 102 | * @brief sets time of update |
102 | * @param timeout int time in milliseconds between updates. | 103 | * @param timeout int time in milliseconds between updates. |
103 | * | 104 | * |
104 | */ | 105 | */ |
105 | void setUpdateTime(int timeout); | 106 | void setUpdateTime(int timeout); |
106 | /*! | 107 | /*! |
107 | * @fn setScrollLength(int length) | 108 | * @fn setScrollLength(int length) |
108 | * @brief sets amount of scrolling default is 1 | 109 | * @brief sets amount of scrolling default is 1 |
109 | * @param length int scroll length. | 110 | * @param length int scroll length. |
110 | * | 111 | * |
111 | */ | 112 | */ |
112 | void setScrollLength(int length); | 113 | void setScrollLength(int length); |
113 | signals: | 114 | signals: |
114 | /*! | 115 | /*! |
115 | * @fn mousePressed() | 116 | * @fn mousePressed() |
116 | * @brief signal mouse press event | 117 | * @brief signal mouse press event |
117 | * | 118 | * |
118 | */ | 119 | */ |
119 | void mousePressed(); | 120 | void mousePressed(); |
120 | protected: | 121 | protected: |
121 | /*! | 122 | /*! |
122 | * @fn timerEvent( QTimerEvent * e) | 123 | * @fn timerEvent( QTimerEvent * e) |
123 | * @brief timer timeout event | 124 | * @brief timer timeout event |
124 | * @param e QEvent see QEvent. | 125 | * @param e QEvent see QEvent. |
125 | * | 126 | * |
126 | */ | 127 | */ |
127 | void timerEvent( QTimerEvent * e); | 128 | void timerEvent( QTimerEvent * e); |
128 | /*! | 129 | /*! |
129 | * @fn drawContents( QPainter *p ) | 130 | * @fn drawContents( QPainter *p ) |
130 | * @brief draws widget contents | 131 | * @brief draws widget contents |
131 | * @param p QPainter. see QPainter | 132 | * @param p QPainter. see QPainter |
132 | * | 133 | * |
133 | */ | 134 | */ |
134 | void drawContents( QPainter *p ); | 135 | void drawContents( QPainter *p ); |
135 | /*! | 136 | /*! |
136 | * @fn mouseReleaseEvent( QMouseEvent *e) | 137 | * @fn mouseReleaseEvent( QMouseEvent *e) |
137 | * @brief mouse release event | 138 | * @brief mouse release event |
138 | * @param e QMouseEvent. see QMouseEvent. | 139 | * @param e QMouseEvent. see QMouseEvent. |
139 | * | 140 | * |
140 | */ | 141 | */ |
141 | void mouseReleaseEvent( QMouseEvent *e); | 142 | void mouseReleaseEvent( QMouseEvent *e); |
142 | private: | 143 | private: |
143 | QColor backgroundcolor, foregroundcolor; | 144 | QColor backgroundcolor, foregroundcolor; |
144 | QString scrollText; | 145 | QString scrollText; |
145 | QPixmap scrollTextPixmap; | 146 | QPixmap scrollTextPixmap; |
146 | int pos, updateTimerTime, scrollLength; | 147 | int pos, updateTimerTime, scrollLength; |
147 | }; | 148 | }; |
148 | 149 | ||
149 | } | 150 | } |
150 | } | 151 | } |
151 | #endif | 152 | #endif |