Eneboo - Documentación para desarrolladores
src/qwt/src/qwt_picker.h
Ir a la documentación de este archivo.
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     virtual QwtText trackerText(const QPoint &pos) const;
00286     QPoint trackerPosition() const;
00287     QRect trackerRect(const QFont &) const;
00288 
00289 
00290 signals:
00297     void selected(const QwtPolygon &pa);
00298 
00305     void appended(const QPoint &pos);
00306 
00314     void moved(const QPoint &pos);
00315 
00323     void changed(const QwtPolygon &pa);
00324 
00325 protected:
00334     virtual bool accept(QwtPolygon &selection) const;
00335 
00336     virtual void transition(const QEvent *);
00337 
00338     virtual void begin();
00339     virtual void append(const QPoint &);
00340     virtual void move(const QPoint &);
00341     virtual bool end(bool ok = true);
00342 
00343     virtual void reset();
00344 
00345     virtual void widgetMousePressEvent(QMouseEvent *);
00346     virtual void widgetMouseReleaseEvent(QMouseEvent *);
00347     virtual void widgetMouseDoubleClickEvent(QMouseEvent *); 
00348     virtual void widgetMouseMoveEvent(QMouseEvent *); 
00349     virtual void widgetWheelEvent(QWheelEvent *);
00350     virtual void widgetKeyPressEvent(QKeyEvent *); 
00351     virtual void widgetKeyReleaseEvent(QKeyEvent *); 
00352     virtual void widgetLeaveEvent(QEvent *); 
00353 
00354     virtual void stretchSelection(const QSize &oldSize, 
00355         const QSize &newSize);
00356 
00357     virtual QwtPickerMachine *stateMachine(int) const;
00358 
00359     virtual void updateDisplay();
00360 
00361     const QWidget *rubberBandWidget() const;
00362     const QWidget *trackerWidget() const;
00363 
00364 private:
00365     void init(QWidget *, int selectionFlags, RubberBand rubberBand,
00366         DisplayMode trackerMode);
00367 
00368     void setStateMachine(QwtPickerMachine *);
00369     void setMouseTracking(bool);
00370 
00371     class PickerWidget;
00372     class PrivateData;
00373     PrivateData *d_data;
00374 };
00375             
00376 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'