Qwt User's Guide 6.0.2

- Main Page
- Related Pages
- Classes

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
21 class QWidget;
22 class QMouseEvent;
23 class QWheelEvent;
24 class QKeyEvent;
25 class QwtPickerMachine;
26
93 class QWT_EXPORT QwtPicker: public QObject, public QwtEventPattern
94 {
95 Q_OBJECT
96
97 Q_ENUMS( RubberBand )
98 Q_ENUMS( DisplayMode )
99 Q_ENUMS( ResizeMode )
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:
119 enum RubberBand
120 {
122 NoRubberBand = 0,
123
125 HLineRubberBand,
126
128 VLineRubberBand,
129
131 CrossRubberBand,
132
134 RectRubberBand,
135
137 EllipseRubberBand,
138
140 PolygonRubberBand,
141
146 UserRubberBand = 100
147 };
148
153 enum DisplayMode
154 {
156 AlwaysOff,
157
159 AlwaysOn,
160
162 ActiveOnly
163 };
164
173 enum ResizeMode
174 {
176 Stretch,
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 QRect pickRect() const;
219
220 virtual void drawRubberBand( QPainter * ) const;
221 virtual void drawTracker( QPainter * ) const;
222
223 virtual QwtText trackerText( const QPoint &pos ) const;
224 QPoint trackerPosition() const;
225 virtual QRect trackerRect( const QFont & ) const;
226
227 QPolygon selection() const;
228
229 public Q_SLOTS:
230 void setEnabled( bool );
231
232 Q_SIGNALS:
240 void activated( bool on );
241
248 void selected( const QPolygon &polygon );
249
256 void appended( const QPoint &pos );
257
265 void moved( const QPoint &pos );
266
273 void removed( const QPoint &pos );
281 void changed( const QPolygon &selection );
282
283 protected:
284 virtual QPolygon adjustedPoints( const QPolygon & ) const;
285
286 virtual void transition( const QEvent * );
287
288 virtual void begin();
289 virtual void append( const QPoint & );
290 virtual void move( const QPoint & );
291 virtual void remove();
292 virtual bool end( bool ok = true );
293
294 virtual bool accept( QPolygon & ) const;
295 virtual void reset();
296
297 virtual void widgetMousePressEvent( QMouseEvent * );
298 virtual void widgetMouseReleaseEvent( QMouseEvent * );
299 virtual void widgetMouseDoubleClickEvent( QMouseEvent * );
300 virtual void widgetMouseMoveEvent( QMouseEvent * );
301 virtual void widgetWheelEvent( QWheelEvent * );
302 virtual void widgetKeyPressEvent( QKeyEvent * );
303 virtual void widgetKeyReleaseEvent( QKeyEvent * );
304 virtual void widgetEnterEvent( QEvent * );
305 virtual void widgetLeaveEvent( QEvent * );
306
307 virtual void stretchSelection( const QSize &oldSize,
308 const QSize &newSize );
309
310 virtual void updateDisplay();
311
312 const QWidget *rubberBandWidget() const;
313 const QWidget *trackerWidget() const;
314
315 const QPolygon &pickedPoints() const;
316
317 private:
318 void init( QWidget *, RubberBand rubberBand, DisplayMode trackerMode );
319
320 void setMouseTracking( bool );
321
322 class PickerWidget;
323 class PrivateData;
324 PrivateData *d_data;
325 };
326
327 #endif