Qwt User's Guide 5.2.3

- 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 <qobject.h>
14 #include <qpen.h>
15 #include <qfont.h>
16 #include <qrect.h>
17 #include "qwt_global.h"
18 #include "qwt_text.h"
19 #include "qwt_polygon.h"
20 #include "qwt_event_pattern.h"
21
22 class QWidget;
23 class QMouseEvent;
24 class QWheelEvent;
25 class QKeyEvent;
26 class QwtPickerMachine;
27
80 class QWT_EXPORT QwtPicker: public QObject, public QwtEventPattern
81 {
82 Q_OBJECT
83
84 Q_ENUMS(RubberBand)
85 Q_ENUMS(DisplayMode)
86 Q_ENUMS(ResizeMode)
87
88 Q_PROPERTY(int selectionFlags READ selectionFlags WRITE setSelectionFlags)
89 Q_PROPERTY(DisplayMode trackerMode READ trackerMode WRITE setTrackerMode)
90 Q_PROPERTY(QFont trackerFont READ trackerFont WRITE setTrackerFont)
91 Q_PROPERTY(RubberBand rubberBand READ rubberBand WRITE setRubberBand)
92 Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
93 Q_PROPERTY(bool isEnabled READ isEnabled WRITE setEnabled)
94
95 Q_PROPERTY(QPen trackerPen READ trackerPen WRITE setTrackerPen)
96 Q_PROPERTY(QPen rubberBandPen READ rubberBandPen WRITE setRubberBandPen)
97
98 public:
117 enum SelectionType
118 {
119 NoSelection = 0,
120 PointSelection = 1,
121 RectSelection = 2,
122 PolygonSelection = 4
123 };
124
143 enum RectSelectionType
144 {
145 CornerToCorner = 64,
146 CenterToCorner = 128,
147 CenterToRadius = 256
148 };
149
157 enum SelectionMode
158 {
159 ClickSelection = 1024,
160 DragSelection = 2048
161 };
162
187 enum RubberBand
188 {
189 NoRubberBand = 0,
190
191 // Point
192 HLineRubberBand,
193 VLineRubberBand,
194 CrossRubberBand,
195
196 // Rect
197 RectRubberBand,
198 EllipseRubberBand,
199
200 // Polygon
201 PolygonRubberBand,
202
203 UserRubberBand = 100
204 };
205
217 enum DisplayMode
218 {
219 AlwaysOff,
220 AlwaysOn,
221 ActiveOnly
222 };
223
236 enum ResizeMode
237 {
238 Stretch,
239 KeepSize
240 };
241
242 explicit QwtPicker(QWidget *parent);
243 explicit QwtPicker(int selectionFlags, RubberBand rubberBand,
244 DisplayMode trackerMode, QWidget *);
245
246 virtual ~QwtPicker();
247
248 virtual void setSelectionFlags(int);
249 int selectionFlags() const;
250
251 virtual void setRubberBand(RubberBand);
252 RubberBand rubberBand() const;
253
254 virtual void setTrackerMode(DisplayMode);
255 DisplayMode trackerMode() const;
256
257 virtual void setResizeMode(ResizeMode);
258 ResizeMode resizeMode() const;
259
260 virtual void setRubberBandPen(const QPen &);
261 QPen rubberBandPen() const;
262
263 virtual void setTrackerPen(const QPen &);
264 QPen trackerPen() const;
265
266 virtual void setTrackerFont(const QFont &);
267 QFont trackerFont() const;
268
269 bool isEnabled() const;
270 virtual void setEnabled(bool);
271
272 bool isActive() const;
273
274 virtual bool eventFilter(QObject *, QEvent *);
275
276 QWidget *parentWidget();
277 const QWidget *parentWidget() const;
278
279 virtual QRect pickRect() const;
280 const QwtPolygon &selection() const;
281
282 virtual void drawRubberBand(QPainter *) const;
283 virtual void drawTracker(QPainter *) const;
284
285 virtual QwtText trackerText(const QPoint &pos) const;
286 QPoint trackerPosition() const;
287 QRect trackerRect(const QFont &) const;
288
289
290 signals:
297 void selected(const QwtPolygon &pa);
298
305 void appended(const QPoint &pos);
306
314 void moved(const QPoint &pos);
315
323 void changed(const QwtPolygon &pa);
324
325 protected:
334 virtual bool accept(QwtPolygon &selection) const;
335
336 virtual void transition(const QEvent *);
337
338 virtual void begin();
339 virtual void append(const QPoint &);
340 virtual void move(const QPoint &);
341 virtual bool end(bool ok = true);
342
343 virtual void reset();
344
345 virtual void widgetMousePressEvent(QMouseEvent *);
346 virtual void widgetMouseReleaseEvent(QMouseEvent *);
347 virtual void widgetMouseDoubleClickEvent(QMouseEvent *);
348 virtual void widgetMouseMoveEvent(QMouseEvent *);
349 virtual void widgetWheelEvent(QWheelEvent *);
350 virtual void widgetKeyPressEvent(QKeyEvent *);
351 virtual void widgetKeyReleaseEvent(QKeyEvent *);
352 virtual void widgetLeaveEvent(QEvent *);
353
354 virtual void stretchSelection(const QSize &oldSize,
355 const QSize &newSize);
356
357 virtual QwtPickerMachine *stateMachine(int) const;
358
359 virtual void updateDisplay();
360
361 const QWidget *rubberBandWidget() const;
362 const QWidget *trackerWidget() const;
363
364 private:
365 void init(QWidget *, int selectionFlags, RubberBand rubberBand,
366 DisplayMode trackerMode);
367
368 void setStateMachine(QwtPickerMachine *);
369 void setMouseTracking(bool);
370
371 class PickerWidget;
372 class PrivateData;
373 PrivateData *d_data;
374 };
375
376 #endif