Qwt User's Guide: qwt_picker.h Source File

- Main Page
- Classes
- Files
- Related Pages

# qwt_picker.h

    00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
    00002  * Qwt Widget Library
    00003  * Copyright (C) 1997   Josef Wilgen
    00004  * Copyright (C) 2002   Uwe Rathmann
    00005  *
    00006  * This library is free software; you can redistribute it and/or
    00007  * modify it under the terms of the Qwt License, Version 1.0
    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
    00080 class QWT_EXPORT QwtPicker: public QObject, public QwtEventPattern
    00081 {
    00082     Q_OBJECT
    00083
    00084     Q_ENUMS(RubberBand)
    00085     Q_ENUMS(DisplayMode)
    00086     Q_ENUMS(ResizeMode)
    00087
    00088     Q_PROPERTY(int selectionFlags READ selectionFlags WRITE setSelectionFlags)
    00089     Q_PROPERTY(DisplayMode trackerMode READ trackerMode WRITE setTrackerMode)
    00090     Q_PROPERTY(QFont trackerFont READ trackerFont WRITE setTrackerFont)
    00091     Q_PROPERTY(RubberBand rubberBand READ rubberBand WRITE setRubberBand)
    00092     Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
    00093     Q_PROPERTY(bool isEnabled READ isEnabled WRITE setEnabled)
    00094
    00095     Q_PROPERTY(QPen trackerPen READ trackerPen WRITE setTrackerPen)
    00096     Q_PROPERTY(QPen rubberBandPen READ rubberBandPen WRITE setRubberBandPen)
    00097
    00098 public:
    00117     enum SelectionType
    00118     {
    00119         NoSelection = 0,
    00120         PointSelection = 1,
    00121         RectSelection = 2,
    00122         PolygonSelection = 4
    00123     };
    00124
    00143     enum RectSelectionType
    00144     {
    00145         CornerToCorner = 64,
    00146         CenterToCorner = 128,
    00147         CenterToRadius = 256
    00148     };
    00149
    00157     enum SelectionMode
    00158     {
    00159         ClickSelection = 1024,
    00160         DragSelection = 2048
    00161     };
    00162
    00187     enum RubberBand
    00188     {
    00189         NoRubberBand = 0,
    00190
    00191         // Point
    00192         HLineRubberBand,
    00193         VLineRubberBand,
    00194         CrossRubberBand,
    00195
    00196         // Rect
    00197         RectRubberBand,
    00198         EllipseRubberBand,
    00199
    00200         // Polygon
    00201         PolygonRubberBand,
    00202
    00203         UserRubberBand = 100
    00204     };
    00205
    00217     enum DisplayMode
    00218     {
    00219         AlwaysOff,
    00220         AlwaysOn,
    00221         ActiveOnly
    00222     };
    00223
    00236     enum ResizeMode
    00237     {
    00238         Stretch,
    00239         KeepSize
    00240     };
    00241
    00242     explicit QwtPicker(QWidget *parent);
    00243     explicit QwtPicker(int selectionFlags, RubberBand rubberBand,
    00244         DisplayMode trackerMode, QWidget *);
    00245
    00246     virtual ~QwtPicker();
    00247
    00248     virtual void setSelectionFlags(int);
    00249     int selectionFlags() const;
    00250
    00251     virtual void setRubberBand(RubberBand);
    00252     RubberBand rubberBand() const;
    00253
    00254     virtual void setTrackerMode(DisplayMode);
    00255     DisplayMode trackerMode() const;
    00256
    00257     virtual void setResizeMode(ResizeMode);
    00258     ResizeMode resizeMode() const;
    00259
    00260     virtual void setRubberBandPen(const QPen &);
    00261     QPen rubberBandPen() const;
    00262
    00263     virtual void setTrackerPen(const QPen &);
    00264     QPen trackerPen() const;
    00265
    00266     virtual void setTrackerFont(const QFont &);
    00267     QFont trackerFont() const;
    00268
    00269     bool isEnabled() const;
    00270     virtual void setEnabled(bool);
    00271
    00272     bool isActive() const;
    00273
    00274     virtual bool eventFilter(QObject *, QEvent *);
    00275
    00276     QWidget *parentWidget();
    00277     const QWidget *parentWidget() const;
    00278
    00279     virtual QRect pickRect() const;
    00280     const QwtPolygon &selection() const;
    00281
    00282     virtual void drawRubberBand(QPainter *) const;
    00283     virtual void drawTracker(QPainter *) const;
    00284
    00285 signals:
    00292     void selected(const QwtPolygon &pa);
    00293
    00300     void appended(const QPoint &pos);
    00301
    00309     void moved(const QPoint &pos);
    00310
    00318     void changed(const QwtPolygon &pa);
    00319
    00320 protected:
    00329     virtual bool accept(QwtPolygon &selection) const;
    00330
    00331     virtual void transition(const QEvent *);
    00332
    00333     virtual void begin();
    00334     virtual void append(const QPoint &);
    00335     virtual void move(const QPoint &);
    00336     virtual bool end(bool ok = true);
    00337
    00338     virtual void widgetMousePressEvent(QMouseEvent *);
    00339     virtual void widgetMouseReleaseEvent(QMouseEvent *);
    00340     virtual void widgetMouseDoubleClickEvent(QMouseEvent *);
    00341     virtual void widgetMouseMoveEvent(QMouseEvent *);
    00342     virtual void widgetWheelEvent(QWheelEvent *);
    00343     virtual void widgetKeyPressEvent(QKeyEvent *);
    00344     virtual void widgetKeyReleaseEvent(QKeyEvent *);
    00345     virtual void widgetLeaveEvent(QEvent *);
    00346
    00347     QRect trackerRect(QPainter *painter) const;
    00348
    00349     virtual void stretchSelection(const QSize &oldSize,
    00350         const QSize &newSize);
    00351
    00352     virtual QwtText trackerText(const QPoint &pos) const;
    00353
    00354     virtual QwtPickerMachine *stateMachine(int) const;
    00355
    00356     virtual void updateDisplay();
    00357
    00358     const QWidget *rubberBandWidget() const;
    00359     const QWidget *trackerWidget() const;
    00360
    00361 private:
    00362     void init(QWidget *, int selectionFlags, RubberBand rubberBand,
    00363         DisplayMode trackerMode);
    00364
    00365     void setStateMachine(QwtPickerMachine *);
    00366     void setMouseTracking(bool);
    00367
    00368     class PrivateData;
    00369     PrivateData *d_data;
    00370 };
    00371
    00372 #endif