summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-03 19:44:54 (UTC)
committer llornkcor <llornkcor>2002-11-03 19:44:54 (UTC)
commit88539c74ca4a6b6699df2b050a498a81d22a0793 (patch) (unidiff)
treec3ce1f6fc5107d16513e0009d41e64494a280d6e
parent7d282e8e721d4c7c71a6d308d082da7138139484 (diff)
downloadopie-88539c74ca4a6b6699df2b050a498a81d22a0793.zip
opie-88539c74ca4a6b6699df2b050a498a81d22a0793.tar.gz
opie-88539c74ca4a6b6699df2b050a498a81d22a0793.tar.bz2
add oticker
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie/libopie.pro6
-rw-r--r--libopie/oticker.cpp94
-rw-r--r--libopie/oticker.h32
3 files changed, 130 insertions, 2 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro
index f46a0b2..1787039 100644
--- a/libopie/libopie.pro
+++ b/libopie/libopie.pro
@@ -27,7 +27,8 @@ HEADERS = ofontmenu.h \
27 pim/otodoaccessvcal.h \ 27 pim/otodoaccessvcal.h \
28 pim/orecur.h \ 28 pim/orecur.h \
29 pim/opimstate.h \ 29 pim/opimstate.h \
30 orecurrancewidget.h 30 orecurrancewidget.h \
31 oticker.h
31# pim/otodoaccesssql.h \ 32# pim/otodoaccesssql.h \
32 33
33SOURCES = ofontmenu.cc \ 34SOURCES = ofontmenu.cc \
@@ -51,7 +52,8 @@ SOURCES = ofontmenu.cc \
51 pim/otodoaccessvcal.cpp \ 52 pim/otodoaccessvcal.cpp \
52 pim/orecur.cpp \ 53 pim/orecur.cpp \
53 pim/opimstate.cpp \ 54 pim/opimstate.cpp \
54 orecurrancewidget.cpp 55 orecurrancewidget.cpp \
56 oticker.cpp
55# pim/otodoaccesssql.cpp \ 57# pim/otodoaccesssql.cpp \
56 58
57TARGET = opie 59TARGET = opie
diff --git a/libopie/oticker.cpp b/libopie/oticker.cpp
new file mode 100644
index 0000000..774a49d
--- a/dev/null
+++ b/libopie/oticker.cpp
@@ -0,0 +1,94 @@
1/*
2                This file is part of the Opie Project
3 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
4 =.
5 .=l.
6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28
29*/
30
31#include <qpe/qpeapplication.h>
32#include <qpe/resource.h>
33#include <qpe/config.h>
34
35#include <qwidget.h>
36#include <qpixmap.h>
37#include <qbutton.h>
38#include <qpainter.h>
39#include <qframe.h>
40#include <qlayout.h>
41#include <qdir.h>
42#include <stdlib.h>
43#include <stdio.h>
44
45#include "oticker.h"
46
47OTicker::OTicker( QWidget* parent=0 ) : QFrame( parent ) {
48 setFrameStyle( NoFrame/*WinPanel | Sunken */);
49}
50
51OTicker::~OTicker() {
52}
53
54void OTicker::setText( const QString& text ) {
55 Config cfg("qpe");
56 cfg.setGroup("Appearance");
57
58 pos = 0; // reset it everytime the text is changed
59 scrollText = text;
60
61 int pixelLen = fontMetrics().width( text );
62 QPixmap pm( pixelLen, contentsRect().height() );
63// pm.fill( QColor( 167, 212, 167 ));
64
65 pm.fill( QColor( cfg.readEntry( "Background", "#E5E1D5" ) ));
66 QPainter pmp( &pm );
67 pmp.setPen( Qt::black );
68 pmp.drawText( 0, 0, pixelLen, contentsRect().height(), AlignVCenter, scrollText );
69 pmp.end();
70 scrollTextPixmap = pm;
71
72 killTimers();
73 if ( pixelLen > contentsRect().width() )
74 startTimer( 50 );
75 update();
76}
77
78
79void OTicker::timerEvent( QTimerEvent * ) {
80 pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - 1;
81 repaint( FALSE );
82}
83
84void OTicker::drawContents( QPainter *p ) {
85 int pixelLen = scrollTextPixmap.width();
86 p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap );
87 if ( pixelLen > contentsRect().width() ) // Scrolling
88 p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap );
89}
90
91void OTicker::mouseReleaseEvent( QMouseEvent * e) {
92// qDebug("<<<<<<<>>>>>>>>>");
93 emit mousePressed();
94}
diff --git a/libopie/oticker.h b/libopie/oticker.h
new file mode 100644
index 0000000..4f0ed11
--- a/dev/null
+++ b/libopie/oticker.h
@@ -0,0 +1,32 @@
1#ifndef OTICKER_H
2#define OTICKER_H
3
4#include <qwidget.h>
5#include <qpainter.h>
6#include <qdrawutil.h>
7#include <qpixmap.h>
8#include <qstring.h>
9#include <qslider.h>
10#include <qframe.h>
11#include <qlineedit.h>
12
13class OTicker : public QFrame {
14 Q_OBJECT
15
16public:
17 OTicker( QWidget* parent=0 );
18 ~OTicker();
19 void setText( const QString& text ) ;
20signals:
21 void mousePressed();
22protected:
23 void timerEvent( QTimerEvent * );
24 void drawContents( QPainter *p );
25 void mouseReleaseEvent ( QMouseEvent *);
26private:
27 QString scrollText;
28 QPixmap scrollTextPixmap;
29 int pos;//, pixelLen;
30};
31
32#endif