00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_PICKER
00011 #define QWT_PICKER 1
00012
00013 #include "qwt_global.h"
00014 #include "qwt_text.h"
00015 #include "qwt_event_pattern.h"
00016 #include <qobject.h>
00017 #include <qpen.h>
00018 #include <qfont.h>
00019 #include <qrect.h>
00020
00021 class QWidget;
00022 class QMouseEvent;
00023 class QWheelEvent;
00024 class QKeyEvent;
00025 class QwtPickerMachine;
00026
00093 class QWT_EXPORT QwtPicker: public QObject, public QwtEventPattern
00094 {
00095 Q_OBJECT
00096
00097 Q_ENUMS( RubberBand )
00098 Q_ENUMS( DisplayMode )
00099 Q_ENUMS( ResizeMode )
00100
00101 Q_PROPERTY( bool isEnabled READ isEnabled WRITE setEnabled )
00102 Q_PROPERTY( ResizeMode resizeMode READ resizeMode WRITE setResizeMode )
00103
00104 Q_PROPERTY( DisplayMode trackerMode READ trackerMode WRITE setTrackerMode )
00105 Q_PROPERTY( QPen trackerPen READ trackerPen WRITE setTrackerPen )
00106 Q_PROPERTY( QFont trackerFont READ trackerFont WRITE setTrackerFont )
00107
00108 Q_PROPERTY( RubberBand rubberBand READ rubberBand WRITE setRubberBand )
00109 Q_PROPERTY( QPen rubberBandPen READ rubberBandPen WRITE setRubberBandPen )
00110
00111 public:
00136 enum RubberBand
00137 {
00138 NoRubberBand = 0,
00139
00140
00141 HLineRubberBand,
00142 VLineRubberBand,
00143 CrossRubberBand,
00144
00145
00146 RectRubberBand,
00147 EllipseRubberBand,
00148
00149
00150 PolygonRubberBand,
00151
00152 UserRubberBand = 100
00153 };
00154
00166 enum DisplayMode
00167 {
00168 AlwaysOff,
00169 AlwaysOn,
00170 ActiveOnly
00171 };
00172
00185 enum ResizeMode
00186 {
00187 Stretch,
00188 KeepSize
00189 };
00190
00191 explicit QwtPicker( QWidget *parent );
00192 explicit QwtPicker( RubberBand rubberBand,
00193 DisplayMode trackerMode, QWidget * );
00194
00195 virtual ~QwtPicker();
00196
00197 void setStateMachine( QwtPickerMachine * );
00198 const QwtPickerMachine *stateMachine() const;
00199 QwtPickerMachine *stateMachine();
00200
00201 void setRubberBand( RubberBand );
00202 RubberBand rubberBand() const;
00203
00204 void setTrackerMode( DisplayMode );
00205 DisplayMode trackerMode() const;
00206
00207 void setResizeMode( ResizeMode );
00208 ResizeMode resizeMode() const;
00209
00210 void setRubberBandPen( const QPen & );
00211 QPen rubberBandPen() const;
00212
00213 void setTrackerPen( const QPen & );
00214 QPen trackerPen() const;
00215
00216 void setTrackerFont( const QFont & );
00217 QFont trackerFont() const;
00218
00219 bool isEnabled() const;
00220 bool isActive() const;
00221
00222 virtual bool eventFilter( QObject *, QEvent * );
00223
00224 QWidget *parentWidget();
00225 const QWidget *parentWidget() const;
00226
00227 virtual QRect pickRect() const;
00228
00229 virtual void drawRubberBand( QPainter * ) const;
00230 virtual void drawTracker( QPainter * ) const;
00231
00232 virtual QwtText trackerText( const QPoint &pos ) const;
00233 QPoint trackerPosition() const;
00234 QRect trackerRect( const QFont & ) const;
00235
00236 QPolygon selection() const;
00237
00238 public Q_SLOTS:
00239 void setEnabled( bool );
00240
00241 Q_SIGNALS:
00249 void activated( bool on );
00250
00257 void selected( const QPolygon &polygon );
00258
00265 void appended( const QPoint &pos );
00266
00274 void moved( const QPoint &pos );
00275
00282 void removed( const QPoint &pos );
00290 void changed( const QPolygon &selection );
00291
00292 protected:
00293 virtual QPolygon adjustedPoints( const QPolygon & ) const;
00294
00295 virtual void transition( const QEvent * );
00296
00297 virtual void begin();
00298 virtual void append( const QPoint & );
00299 virtual void move( const QPoint & );
00300 virtual void remove();
00301 virtual bool end( bool ok = true );
00302
00303 virtual bool accept( QPolygon & ) const;
00304 virtual void reset();
00305
00306 virtual void widgetMousePressEvent( QMouseEvent * );
00307 virtual void widgetMouseReleaseEvent( QMouseEvent * );
00308 virtual void widgetMouseDoubleClickEvent( QMouseEvent * );
00309 virtual void widgetMouseMoveEvent( QMouseEvent * );
00310 virtual void widgetWheelEvent( QWheelEvent * );
00311 virtual void widgetKeyPressEvent( QKeyEvent * );
00312 virtual void widgetKeyReleaseEvent( QKeyEvent * );
00313 virtual void widgetEnterEvent( QEvent * );
00314 virtual void widgetLeaveEvent( QEvent * );
00315
00316 virtual void stretchSelection( const QSize &oldSize,
00317 const QSize &newSize );
00318
00319 virtual void updateDisplay();
00320
00321 const QWidget *rubberBandWidget() const;
00322 const QWidget *trackerWidget() const;
00323
00324 const QPolygon &pickedPoints() const;
00325
00326 private:
00327 void init( QWidget *, RubberBand rubberBand, DisplayMode trackerMode );
00328
00329 void setMouseTracking( bool );
00330
00331 class PickerWidget;
00332 class PrivateData;
00333 PrivateData *d_data;
00334 };
00335
00336 #endif