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