00001 /********************************************************************** 00002 ** Copyright (C) 2000 Trolltech AS. All rights reserved. 00003 ** 00004 ** This file is part of Qtopia Environment. 00005 ** 00006 ** This file may be distributed and/or modified under the terms of the 00007 ** GNU General Public License version 2 as published by the Free Software 00008 ** Foundation and appearing in the file LICENSE.GPL included in the 00009 ** packaging of this file. 00010 ** 00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 ** 00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00015 ** 00016 ** Contact info@trolltech.com if any conditions of this licensing are 00017 ** not clear to you. 00018 ** 00019 **********************************************************************/ 00020 00021 #ifndef STYLUSNORMALIZER_H 00022 #define STYLUSNORMALIZER_H 00023 00024 #include <qdatetime.h> 00025 #include <qwidget.h> 00026 00027 class QTimer; 00028 00029 class _StylusEvent 00030 { 00031 public: 00032 _StylusEvent( const QPoint &pt = QPoint( 0, 0 ) ); 00033 ~_StylusEvent(); 00034 QPoint point( void ) const { return _pt; }; 00035 QTime time( void ) const { return _t; }; 00036 void setPoint( int x, int y) { _pt.setX( x ); _pt.setY( y ); }; 00037 void setPoint( const QPoint &newPt ) { _pt = newPt; }; 00038 void setTime( QTime newTime ) { _t = newTime; }; 00039 00040 private: 00041 QPoint _pt; 00042 QTime _t; 00043 }; 00044 00045 00046 class StylusNormalizer : public QWidget 00047 { 00048 Q_OBJECT 00049 public: 00050 StylusNormalizer( QWidget *parent = 0, const char* name = 0 ); 00051 ~StylusNormalizer(); 00052 void start(); 00053 void stop(); 00054 void addEvent( const QPoint &pt ); // add a new point in 00055 00056 signals: 00057 void signalNewPoint( const QPoint &p ); 00058 00059 private slots: 00060 void slotAveragePoint( void ); // return an averaged point 00061 00062 private: 00063 static const int SAMPLES = 10; 00064 _StylusEvent _ptList[SAMPLES]; 00065 int _next; 00066 QTimer *_tExpire; 00067 bool bFirst; // the first item added in... 00068 }; 00069 00070 #endif
1.4.2