Qwt User's Guide  6.1-rc3
 All Classes Functions Variables Typedefs Enumerations Enumerator Pages
qwt_picker.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the Qwt License, Version 1.0
8  *****************************************************************************/
9 
10 #ifndef QWT_PICKER
11 #define QWT_PICKER 1
12 
13 #include "qwt_global.h"
14 #include "qwt_text.h"
15 #include "qwt_event_pattern.h"
16 #include <qobject.h>
17 #include <qpen.h>
18 #include <qfont.h>
19 #include <qrect.h>
20 #include <qpainterpath.h>
21 
22 class QWidget;
23 class QMouseEvent;
24 class QWheelEvent;
25 class QKeyEvent;
26 class QwtPickerMachine;
27 class QwtWidgetOverlay;
28 
95 class QWT_EXPORT QwtPicker: public QObject, public QwtEventPattern
96 {
97  Q_OBJECT
98 
100 
101  Q_PROPERTY( bool isEnabled READ isEnabled WRITE setEnabled )
102  Q_PROPERTY( ResizeMode resizeMode READ resizeMode WRITE setResizeMode )
103 
104  Q_PROPERTY( DisplayMode trackerMode READ trackerMode WRITE setTrackerMode )
105  Q_PROPERTY( QPen trackerPen READ trackerPen WRITE setTrackerPen )
106  Q_PROPERTY( QFont trackerFont READ trackerFont WRITE setTrackerFont )
107 
108  Q_PROPERTY( RubberBand rubberBand READ rubberBand WRITE setRubberBand )
109  Q_PROPERTY( QPen rubberBandPen READ rubberBandPen WRITE setRubberBandPen )
110 
111 public:
120  {
122  NoRubberBand = 0,
123 
126 
129 
132 
135 
138 
141 
146  UserRubberBand = 100
147  };
148 
154  {
157 
160 
162  ActiveOnly
163  };
164 
173  enum ResizeMode
174  {
177 
179  KeepSize
180  };
181 
182  explicit QwtPicker( QWidget *parent );
183  explicit QwtPicker( RubberBand rubberBand,
184  DisplayMode trackerMode, QWidget * );
185 
186  virtual ~QwtPicker();
187 
188  void setStateMachine( QwtPickerMachine * );
189  const QwtPickerMachine *stateMachine() const;
190  QwtPickerMachine *stateMachine();
191 
192  void setRubberBand( RubberBand );
193  RubberBand rubberBand() const;
194 
195  void setTrackerMode( DisplayMode );
196  DisplayMode trackerMode() const;
197 
198  void setResizeMode( ResizeMode );
199  ResizeMode resizeMode() const;
200 
201  void setRubberBandPen( const QPen & );
202  QPen rubberBandPen() const;
203 
204  void setTrackerPen( const QPen & );
205  QPen trackerPen() const;
206 
207  void setTrackerFont( const QFont & );
208  QFont trackerFont() const;
209 
210  bool isEnabled() const;
211  bool isActive() const;
212 
213  virtual bool eventFilter( QObject *, QEvent * );
214 
215  QWidget *parentWidget();
216  const QWidget *parentWidget() const;
217 
218  virtual QPainterPath pickArea() const;
219 
220  virtual void drawRubberBand( QPainter * ) const;
221  virtual void drawTracker( QPainter * ) const;
222 
223  virtual QRegion rubberBandMask() const;
224 
225  virtual QwtText trackerText( const QPoint &pos ) const;
226  QPoint trackerPosition() const;
227  virtual QRect trackerRect( const QFont & ) const;
228 
229  QPolygon selection() const;
230 
231 public Q_SLOTS:
232  void setEnabled( bool );
233 
234 Q_SIGNALS:
242  void activated( bool on );
243 
250  void selected( const QPolygon &polygon );
251 
258  void appended( const QPoint &pos );
259 
267  void moved( const QPoint &pos );
268 
275  void removed( const QPoint &pos );
283  void changed( const QPolygon &selection );
284 
285 protected:
286  virtual QPolygon adjustedPoints( const QPolygon & ) const;
287 
288  virtual void transition( const QEvent * );
289 
290  virtual void begin();
291  virtual void append( const QPoint & );
292  virtual void move( const QPoint & );
293  virtual void remove();
294  virtual bool end( bool ok = true );
295 
296  virtual bool accept( QPolygon & ) const;
297  virtual void reset();
298 
299  virtual void widgetMousePressEvent( QMouseEvent * );
300  virtual void widgetMouseReleaseEvent( QMouseEvent * );
301  virtual void widgetMouseDoubleClickEvent( QMouseEvent * );
302  virtual void widgetMouseMoveEvent( QMouseEvent * );
303  virtual void widgetWheelEvent( QWheelEvent * );
304  virtual void widgetKeyPressEvent( QKeyEvent * );
305  virtual void widgetKeyReleaseEvent( QKeyEvent * );
306  virtual void widgetEnterEvent( QEvent * );
307  virtual void widgetLeaveEvent( QEvent * );
308 
309  virtual void stretchSelection( const QSize &oldSize,
310  const QSize &newSize );
311 
312  virtual void updateDisplay();
313 
314  const QwtWidgetOverlay *rubberBandOverlay() const;
315  const QwtWidgetOverlay *trackerOverlay() const;
316 
317  const QPolygon &pickedPoints() const;
318 
319 private:
320  void init( QWidget *, RubberBand rubberBand, DisplayMode trackerMode );
321 
322  void setMouseTracking( bool );
323 
324  class PrivateData;
325  PrivateData *d_data;
326 };
327 
328 #endif