Go to the documentation of this file.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 #include <qpainterpath.h>
00021
00022 class QWidget;
00023 class QMouseEvent;
00024 class QWheelEvent;
00025 class QKeyEvent;
00026 class QwtPickerMachine;
00027 class QwtWidgetOverlay;
00028
00095 class QWT_EXPORT QwtPicker: public QObject, public QwtEventPattern
00096 {
00097 Q_OBJECT
00098
00099 Q_ENUMS( RubberBand DisplayMode 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:
00119 enum RubberBand
00120 {
00122 NoRubberBand = 0,
00123
00125 HLineRubberBand,
00126
00128 VLineRubberBand,
00129
00131 CrossRubberBand,
00132
00134 RectRubberBand,
00135
00137 EllipseRubberBand,
00138
00140 PolygonRubberBand,
00141
00146 UserRubberBand = 100
00147 };
00148
00153 enum DisplayMode
00154 {
00156 AlwaysOff,
00157
00159 AlwaysOn,
00160
00162 ActiveOnly
00163 };
00164
00173 enum ResizeMode
00174 {
00176 Stretch,
00177
00179 KeepSize
00180 };
00181
00182 explicit QwtPicker( QWidget *parent );
00183 explicit QwtPicker( RubberBand rubberBand,
00184 DisplayMode trackerMode, QWidget * );
00185
00186 virtual ~QwtPicker();
00187
00188 void setStateMachine( QwtPickerMachine * );
00189 const QwtPickerMachine *stateMachine() const;
00190 QwtPickerMachine *stateMachine();
00191
00192 void setRubberBand( RubberBand );
00193 RubberBand rubberBand() const;
00194
00195 void setTrackerMode( DisplayMode );
00196 DisplayMode trackerMode() const;
00197
00198 void setResizeMode( ResizeMode );
00199 ResizeMode resizeMode() const;
00200
00201 void setRubberBandPen( const QPen & );
00202 QPen rubberBandPen() const;
00203
00204 void setTrackerPen( const QPen & );
00205 QPen trackerPen() const;
00206
00207 void setTrackerFont( const QFont & );
00208 QFont trackerFont() const;
00209
00210 bool isEnabled() const;
00211 bool isActive() const;
00212
00213 virtual bool eventFilter( QObject *, QEvent * );
00214
00215 QWidget *parentWidget();
00216 const QWidget *parentWidget() const;
00217
00218 virtual QPainterPath pickArea() const;
00219
00220 virtual void drawRubberBand( QPainter * ) const;
00221 virtual void drawTracker( QPainter * ) const;
00222
00223 virtual QRegion trackerMask() const;
00224 virtual QRegion rubberBandMask() const;
00225
00226 virtual QwtText trackerText( const QPoint &pos ) const;
00227 QPoint trackerPosition() const;
00228 virtual QRect trackerRect( const QFont & ) const;
00229
00230 QPolygon selection() const;
00231
00232 public Q_SLOTS:
00233 void setEnabled( bool );
00234
00235 Q_SIGNALS:
00243 void activated( bool on );
00244
00251 void selected( const QPolygon &polygon );
00252
00259 void appended( const QPoint &pos );
00260
00268 void moved( const QPoint &pos );
00269
00277 void removed( const QPoint &pos );
00285 void changed( const QPolygon &selection );
00286
00287 protected:
00288 virtual QPolygon adjustedPoints( const QPolygon & ) const;
00289
00290 virtual void transition( const QEvent * );
00291
00292 virtual void begin();
00293 virtual void append( const QPoint & );
00294 virtual void move( const QPoint & );
00295 virtual void remove();
00296 virtual bool end( bool ok = true );
00297
00298 virtual bool accept( QPolygon & ) const;
00299 virtual void reset();
00300
00301 virtual void widgetMousePressEvent( QMouseEvent * );
00302 virtual void widgetMouseReleaseEvent( QMouseEvent * );
00303 virtual void widgetMouseDoubleClickEvent( QMouseEvent * );
00304 virtual void widgetMouseMoveEvent( QMouseEvent * );
00305 virtual void widgetWheelEvent( QWheelEvent * );
00306 virtual void widgetKeyPressEvent( QKeyEvent * );
00307 virtual void widgetKeyReleaseEvent( QKeyEvent * );
00308 virtual void widgetEnterEvent( QEvent * );
00309 virtual void widgetLeaveEvent( QEvent * );
00310
00311 virtual void stretchSelection( const QSize &oldSize,
00312 const QSize &newSize );
00313
00314 virtual void updateDisplay();
00315
00316 const QwtWidgetOverlay *rubberBandOverlay() const;
00317 const QwtWidgetOverlay *trackerOverlay() const;
00318
00319 const QPolygon &pickedPoints() const;
00320
00321 private:
00322 void init( QWidget *, RubberBand rubberBand, DisplayMode trackerMode );
00323
00324 void setMouseTracking( bool );
00325
00326 class PrivateData;
00327 PrivateData *d_data;
00328 };
00329
00330 #endif