DigestGuiCore/strokeseditor.h

Go to the documentation of this file.
00001 /*  -*- c++ -*-  (for Emacs)
00002  *
00003  *  strokeseditor.h
00004  *  Digest
00005  * 
00006  *  Created by Aidan Lane on Mon Jun 27 2005.
00007  *  Copyright (c) 2005-2006 Optimisation and Constraint Solving Group,
00008  *  Monash University. All rights reserved.
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00023  */
00024 
00025 #ifndef STROKESEDITOR_H
00026 #define STROKESEDITOR_H
00027 
00028 
00029 #include "strokesviewer.h"
00030 
00031 #include <QTime>
00032 #include <QTimer>
00033 
00034 
00035 class StrokesEditor : public StrokesViewer {
00036 
00037   Q_OBJECT
00038   Q_PROPERTY( bool autoClear READ autoClear WRITE setAutoClear )
00039   Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
00040   Q_PROPERTY( bool recordHiRes READ recordHiRes WRITE setRecordHiRes )
00041   Q_PROPERTY( double multiStrokeTimeout READ multiStrokeTimeout \
00042               WRITE setMultiStrokeTimeout )
00043 
00044 public:
00045   enum State { EmptyState, StartedState, FinishedState };
00046 
00047   StrokesEditor( QWidget* parent = 0 );
00048   StrokesEditor( const StrokeList& strokes, QWidget* parent = 0,
00049                  bool readOnly = false );
00050 
00051   State  state() const;
00052   bool   autoClear() const;
00053   bool   isModified() const;
00054   bool   isReadOnly() const;
00055   bool   isStrokeBeginDrawn() const;
00056   bool   recordHiRes() const;
00057   double multiStrokeTimeout() const;
00058 
00059 
00060 signals:
00061   void recordHiResToggled( bool enabled );
00062   void multiStrokeTimeoutChanged( double timeout );
00063   void strokingAboutToStart();
00064   void strokingStarted();
00065   void strokingFinished( const StrokeList& strokes );
00066 
00067 
00068 public slots:
00069   virtual void setAutoClear( bool autoClear );
00070   virtual void setModified( bool modified );
00071   virtual void setReadOnly( bool readOnly );
00072   virtual void setRecordHiRes( bool enable );
00073   virtual void setStrokes( const StrokeList& strokes, bool updateWidget = true );
00074   virtual void setMultiStrokeTimeout( double timeout );
00075 
00076   void stopMultiStrokeTimoutTimer();
00077 
00078 
00079 private slots:
00080   virtual void onMultiStrokeTimedout();
00081 
00082 
00083 protected:
00084   virtual void beginNewStroke( StrokePoint pt );
00085   virtual void addPointToStroke( const StrokePoint& pt );
00086   virtual void endStroke();
00087 
00088   virtual void mousePressEvent( QMouseEvent* event );
00089   virtual void mouseMoveEvent( QMouseEvent* event );
00090   virtual void mouseReleaseEvent( QMouseEvent* event );
00091   virtual void tabletEvent( QTabletEvent* event );
00092 
00093 
00094 private:
00095   void init();
00096   void restartMultiStrokeTimoutTimer();
00097 
00098   State   m_state;
00099   bool    m_autoClear;
00100   bool    m_modified;
00101   bool    m_readOnly;
00102   bool    m_strokeBeginDrawn;
00103   bool    m_recordHiRes;
00104   Stroke  m_currentStroke;
00105   QTime   m_currentMultiStrokeTime;
00106   double  m_multiStrokeTimeout;
00107   QTimer* m_multiStrokeTimeoutTimer;
00108 };
00109 
00110 
00111 #endif  // ! STROKESEDITOR_H

Generated on Mon Jul 30 09:46:50 2007 for Digest by  doxygen 1.5.2