qwt_picker.h
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#ifndef QWT_PICKER
#define QWT_PICKER 1
#include "qwt_global.h"
#include "qwt_text.h"
#include "qwt_event_pattern.h"
#include <qobject.h>
#include <qpen.h>
#include <qfont.h>
#include <qrect.h>
#include <qpainterpath.h>
class QWidget;
class QMouseEvent;
class QWheelEvent;
class QKeyEvent;
class QwtPickerMachine;
class QwtWidgetOverlay;
class QWT_EXPORT QwtPicker: public QObject, public QwtEventPattern
{
Q_OBJECT
Q_ENUMS( RubberBand DisplayMode ResizeMode )
Q_PROPERTY( bool isEnabled READ isEnabled WRITE setEnabled )
Q_PROPERTY( ResizeMode resizeMode READ resizeMode WRITE setResizeMode )
Q_PROPERTY( DisplayMode trackerMode READ trackerMode WRITE setTrackerMode )
Q_PROPERTY( QPen trackerPen READ trackerPen WRITE setTrackerPen )
Q_PROPERTY( QFont trackerFont READ trackerFont WRITE setTrackerFont )
Q_PROPERTY( RubberBand rubberBand READ rubberBand WRITE setRubberBand )
Q_PROPERTY( QPen rubberBandPen READ rubberBandPen WRITE setRubberBandPen )
public:
enum RubberBand
{
NoRubberBand = 0,
HLineRubberBand,
VLineRubberBand,
CrossRubberBand,
RectRubberBand,
EllipseRubberBand,
PolygonRubberBand,
UserRubberBand = 100
};
enum DisplayMode
{
AlwaysOff,
AlwaysOn,
ActiveOnly
};
enum ResizeMode
{
Stretch,
KeepSize
};
explicit QwtPicker( QWidget *parent );
explicit QwtPicker( RubberBand rubberBand,
DisplayMode trackerMode, QWidget * );
virtual ~QwtPicker();
void setStateMachine( QwtPickerMachine * );
const QwtPickerMachine *stateMachine() const;
QwtPickerMachine *stateMachine();
void setRubberBand( RubberBand );
RubberBand rubberBand() const;
void setTrackerMode( DisplayMode );
DisplayMode trackerMode() const;
void setResizeMode( ResizeMode );
ResizeMode resizeMode() const;
void setRubberBandPen( const QPen & );
QPen rubberBandPen() const;
void setTrackerPen( const QPen & );
QPen trackerPen() const;
void setTrackerFont( const QFont & );
QFont trackerFont() const;
bool isEnabled() const;
bool isActive() const;
virtual bool eventFilter( QObject *, QEvent * );
QWidget *parentWidget();
const QWidget *parentWidget() const;
virtual QPainterPath pickArea() const;
virtual void drawRubberBand( QPainter * ) const;
virtual void drawTracker( QPainter * ) const;
virtual QRegion rubberBandMask() const;
virtual QwtText trackerText( const QPoint &pos ) const;
QPoint trackerPosition() const;
virtual QRect trackerRect( const QFont & ) const;
QPolygon selection() const;
public Q_SLOTS:
void setEnabled( bool );
Q_SIGNALS:
void activated( bool on );
void selected( const QPolygon &polygon );
void appended( const QPoint &pos );
void moved( const QPoint &pos );
void removed( const QPoint &pos );
void changed( const QPolygon &selection );
protected:
virtual QPolygon adjustedPoints( const QPolygon & ) const;
virtual void transition( const QEvent * );
virtual void begin();
virtual void append( const QPoint & );
virtual void move( const QPoint & );
virtual void remove();
virtual bool end( bool ok = true );
virtual bool accept( QPolygon & ) const;
virtual void reset();
virtual void widgetMousePressEvent( QMouseEvent * );
virtual void widgetMouseReleaseEvent( QMouseEvent * );
virtual void widgetMouseDoubleClickEvent( QMouseEvent * );
virtual void widgetMouseMoveEvent( QMouseEvent * );
virtual void widgetWheelEvent( QWheelEvent * );
virtual void widgetKeyPressEvent( QKeyEvent * );
virtual void widgetKeyReleaseEvent( QKeyEvent * );
virtual void widgetEnterEvent( QEvent * );
virtual void widgetLeaveEvent( QEvent * );
virtual void stretchSelection(
const QSize &oldSize, const QSize &newSize );
virtual void updateDisplay();
const QwtWidgetOverlay *rubberBandOverlay() const;
const QwtWidgetOverlay *trackerOverlay() const;
const QPolygon &pickedPoints() const;
private:
void init( QWidget *, RubberBand rubberBand, DisplayMode trackerMode );
void setMouseTracking( bool );
class PrivateData;
PrivateData *d_data;
};
#endif
QwtPicker::Stretch
All points are scaled according to the new size,.
Definition: qwt_picker.h:179
QwtPicker::HLineRubberBand
A horizontal line ( only for QwtPickerMachine::PointSelection )
Definition: qwt_picker.h:128
QwtText
A class representing a text.
Definition: qwt_text.h:51
QwtPickerMachine
A state machine for QwtPicker selections.
Definition: qwt_picker_machine.h:28
QwtPicker::ResizeMode
ResizeMode
Definition: qwt_picker.h:176
QwtPicker::DisplayMode
DisplayMode
Display mode.
Definition: qwt_picker.h:156
QwtPicker::RubberBand
RubberBand
Definition: qwt_picker.h:122
QwtPicker::PolygonRubberBand
A polygon ( only for QwtPickerMachine::PolygonSelection )
Definition: qwt_picker.h:143
QwtEventPattern
A collection of event patterns.
Definition: qwt_event_pattern.h:29
QwtWidgetOverlay
An overlay for a widget.
Definition: qwt_widget_overlay.h:40
QwtPicker::CrossRubberBand
A crosshair ( only for QwtPickerMachine::PointSelection )
Definition: qwt_picker.h:134
QwtPicker::AlwaysOff
Display never.
Definition: qwt_picker.h:159
QwtPicker::EllipseRubberBand
An ellipse ( only for QwtPickerMachine::RectSelection )
Definition: qwt_picker.h:140
QwtPicker::VLineRubberBand
A vertical line ( only for QwtPickerMachine::PointSelection )
Definition: qwt_picker.h:131
QwtPicker
QwtPicker provides selections on a widget.
Definition: qwt_picker.h:98
QwtPicker::AlwaysOn
Display always.
Definition: qwt_picker.h:162
QwtPicker::RectRubberBand
A rectangle ( only for QwtPickerMachine::RectSelection )
Definition: qwt_picker.h:137