Qwt User's Guide 6.1.0

- Main Page
- Related Pages
- Classes

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
99 Q_ENUMS( RubberBand DisplayMode 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 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
276 void removed( const QPoint &pos );
284 void changed( const QPolygon &selection );
285
286 protected:
287 virtual QPolygon adjustedPoints( const QPolygon & ) const;
288
289 virtual void transition( const QEvent * );
290
291 virtual void begin();
292 virtual void append( const QPoint & );
293 virtual void move( const QPoint & );
294 virtual void remove();
295 virtual bool end( bool ok = true );
296
297 virtual bool accept( QPolygon & ) const;
298 virtual void reset();
299
300 virtual void widgetMousePressEvent( QMouseEvent * );
301 virtual void widgetMouseReleaseEvent( QMouseEvent * );
302 virtual void widgetMouseDoubleClickEvent( QMouseEvent * );
303 virtual void widgetMouseMoveEvent( QMouseEvent * );
304 virtual void widgetWheelEvent( QWheelEvent * );
305 virtual void widgetKeyPressEvent( QKeyEvent * );
306 virtual void widgetKeyReleaseEvent( QKeyEvent * );
307 virtual void widgetEnterEvent( QEvent * );
308 virtual void widgetLeaveEvent( QEvent * );
309
310 virtual void stretchSelection( const QSize &oldSize,
311 const QSize &newSize );
312
313 virtual void updateDisplay();
314
315 const QwtWidgetOverlay *rubberBandOverlay() const;
316 const QwtWidgetOverlay *trackerOverlay() const;
317
318 const QPolygon &pickedPoints() const;
319
320 private:
321 void init( QWidget *, RubberBand rubberBand, DisplayMode trackerMode );
322
323 void setMouseTracking( bool );
324
325 class PrivateData;
326 PrivateData *d_data;
327 };
328
329 #endif