Qwt User's Guide  6.1.6
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 
98 class QWT_EXPORT QwtPicker: public QObject, public QwtEventPattern
99 {
100  Q_OBJECT
101 
103 
104  Q_PROPERTY( bool isEnabled READ isEnabled WRITE setEnabled )
105  Q_PROPERTY( ResizeMode resizeMode READ resizeMode WRITE setResizeMode )
106 
107  Q_PROPERTY( DisplayMode trackerMode READ trackerMode WRITE setTrackerMode )
108  Q_PROPERTY( QPen trackerPen READ trackerPen WRITE setTrackerPen )
109  Q_PROPERTY( QFont trackerFont READ trackerFont WRITE setTrackerFont )
110 
111  Q_PROPERTY( RubberBand rubberBand READ rubberBand WRITE setRubberBand )
112  Q_PROPERTY( QPen rubberBandPen READ rubberBandPen WRITE setRubberBandPen )
113 
114 public:
123  {
125  NoRubberBand = 0,
126 
129 
132 
135 
138 
141 
144 
149  UserRubberBand = 100
150  };
151 
157  {
160 
163 
165  ActiveOnly
166  };
167 
177  {
180 
182  KeepSize
183  };
184 
185  explicit QwtPicker( QWidget *parent );
186  explicit QwtPicker( RubberBand rubberBand,
187  DisplayMode trackerMode, QWidget * );
188 
189  virtual ~QwtPicker();
190 
191  void setStateMachine( QwtPickerMachine * );
192  const QwtPickerMachine *stateMachine() const;
193  QwtPickerMachine *stateMachine();
194 
195  void setRubberBand( RubberBand );
196  RubberBand rubberBand() const;
197 
198  void setTrackerMode( DisplayMode );
199  DisplayMode trackerMode() const;
200 
201  void setResizeMode( ResizeMode );
202  ResizeMode resizeMode() const;
203 
204  void setRubberBandPen( const QPen & );
205  QPen rubberBandPen() const;
206 
207  void setTrackerPen( const QPen & );
208  QPen trackerPen() const;
209 
210  void setTrackerFont( const QFont & );
211  QFont trackerFont() const;
212 
213  bool isEnabled() const;
214  bool isActive() const;
215 
216  virtual bool eventFilter( QObject *, QEvent * );
217 
218  QWidget *parentWidget();
219  const QWidget *parentWidget() const;
220 
221  virtual QPainterPath pickArea() const;
222 
223  virtual void drawRubberBand( QPainter * ) const;
224  virtual void drawTracker( QPainter * ) const;
225 
226  virtual QRegion rubberBandMask() const;
227 
228  virtual QwtText trackerText( const QPoint &pos ) const;
229  QPoint trackerPosition() const;
230  virtual QRect trackerRect( const QFont & ) const;
231 
232  QPolygon selection() const;
233 
234 public Q_SLOTS:
235  void setEnabled( bool );
236 
237 Q_SIGNALS:
245  void activated( bool on );
246 
253  void selected( const QPolygon &polygon );
254 
261  void appended( const QPoint &pos );
262 
270  void moved( const QPoint &pos );
271 
279  void removed( const QPoint &pos );
287  void changed( const QPolygon &selection );
288 
289 protected:
290  virtual QPolygon adjustedPoints( const QPolygon & ) const;
291 
292  virtual void transition( const QEvent * );
293 
294  virtual void begin();
295  virtual void append( const QPoint & );
296  virtual void move( const QPoint & );
297  virtual void remove();
298  virtual bool end( bool ok = true );
299 
300  virtual bool accept( QPolygon & ) const;
301  virtual void reset();
302 
303  virtual void widgetMousePressEvent( QMouseEvent * );
304  virtual void widgetMouseReleaseEvent( QMouseEvent * );
305  virtual void widgetMouseDoubleClickEvent( QMouseEvent * );
306  virtual void widgetMouseMoveEvent( QMouseEvent * );
307  virtual void widgetWheelEvent( QWheelEvent * );
308  virtual void widgetKeyPressEvent( QKeyEvent * );
309  virtual void widgetKeyReleaseEvent( QKeyEvent * );
310  virtual void widgetEnterEvent( QEvent * );
311  virtual void widgetLeaveEvent( QEvent * );
312 
313  virtual void stretchSelection(
314  const QSize &oldSize, const QSize &newSize );
315 
316  virtual void updateDisplay();
317 
318  const QwtWidgetOverlay *rubberBandOverlay() const;
319  const QwtWidgetOverlay *trackerOverlay() const;
320 
321  const QPolygon &pickedPoints() const;
322 
323 private:
324  void init( QWidget *, RubberBand rubberBand, DisplayMode trackerMode );
325 
326  void setMouseTracking( bool );
327 
328  class PrivateData;
329  PrivateData *d_data;
330 };
331 
332 #endif
QwtPicker::Stretch
@ Stretch
All points are scaled according to the new size,.
Definition: qwt_picker.h:179
QwtPicker::changed
void changed(const QPolygon &selection)
QwtPicker::moved
void moved(const QPoint &pos)
QwtPicker::selected
void selected(const QPolygon &polygon)
QwtPicker::HLineRubberBand
@ HLineRubberBand
A horizontal line ( only for QwtPickerMachine::PointSelection )
Definition: qwt_picker.h:128
QwtWidgetOverlay
An overlay for a widget.
Definition: qwt_widget_overlay.h:41
QwtPicker::ResizeMode
ResizeMode
Definition: qwt_picker.h:177
QwtPicker::PolygonRubberBand
@ PolygonRubberBand
A polygon ( only for QwtPickerMachine::PolygonSelection )
Definition: qwt_picker.h:143
QwtPicker::DisplayMode
DisplayMode
Display mode.
Definition: qwt_picker.h:157
QwtPicker
QwtPicker provides selections on a widget.
Definition: qwt_picker.h:99
QwtText
A class representing a text.
Definition: qwt_text.h:52
QwtPicker::removed
void removed(const QPoint &pos)
QwtPicker::AlwaysOff
@ AlwaysOff
Display never.
Definition: qwt_picker.h:159
QwtPicker::EllipseRubberBand
@ EllipseRubberBand
An ellipse ( only for QwtPickerMachine::RectSelection )
Definition: qwt_picker.h:140
QwtPicker::RubberBand
RubberBand
Definition: qwt_picker.h:123
QwtPicker::appended
void appended(const QPoint &pos)
QwtEventPattern
A collection of event patterns.
Definition: qwt_event_pattern.h:30
QwtPickerMachine
A state machine for QwtPicker selections.
Definition: qwt_picker_machine.h:29
QwtPicker::CrossRubberBand
@ CrossRubberBand
A crosshair ( only for QwtPickerMachine::PointSelection )
Definition: qwt_picker.h:134
QwtPicker::VLineRubberBand
@ VLineRubberBand
A vertical line ( only for QwtPickerMachine::PointSelection )
Definition: qwt_picker.h:131
QwtPicker::activated
void activated(bool on)
QwtPicker::AlwaysOn
@ AlwaysOn
Display always.
Definition: qwt_picker.h:162
QwtPicker::RectRubberBand
@ RectRubberBand
A rectangle ( only for QwtPickerMachine::RectSelection )
Definition: qwt_picker.h:137