[4271] | 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_PANNER_H
|
---|
| 11 | #define QWT_PANNER_H 1
|
---|
| 12 |
|
---|
| 13 | #include "qwt_global.h"
|
---|
| 14 | #include <qwidget.h>
|
---|
| 15 | #include <qpixmap.h>
|
---|
| 16 |
|
---|
| 17 | class QCursor;
|
---|
| 18 |
|
---|
| 19 | /*!
|
---|
| 20 | \brief QwtPanner provides panning of a widget
|
---|
| 21 |
|
---|
| 22 | QwtPanner grabs the contents of a widget, that can be dragged
|
---|
| 23 | in all directions. The offset between the start and the end position
|
---|
| 24 | is emitted by the panned signal.
|
---|
| 25 |
|
---|
| 26 | QwtPanner grabs the content of the widget into a pixmap and moves
|
---|
| 27 | the pixmap around, without initiating any repaint events for the widget.
|
---|
| 28 | Areas, that are not part of content are not painted while panning.
|
---|
| 29 | This makes panning fast enough for widgets, where
|
---|
| 30 | repaints are too slow for mouse movements.
|
---|
| 31 |
|
---|
| 32 | For widgets, where repaints are very fast it might be better to
|
---|
| 33 | implement panning manually by mapping mouse events into paint events.
|
---|
| 34 | */
|
---|
| 35 | class QWT_EXPORT QwtPanner: public QWidget
|
---|
| 36 | {
|
---|
| 37 | Q_OBJECT
|
---|
| 38 |
|
---|
| 39 | public:
|
---|
| 40 | QwtPanner( QWidget* parent );
|
---|
| 41 | virtual ~QwtPanner();
|
---|
| 42 |
|
---|
| 43 | void setEnabled( bool );
|
---|
| 44 | bool isEnabled() const;
|
---|
| 45 |
|
---|
[8127] | 46 | void setMouseButton( Qt::MouseButton,
|
---|
| 47 | Qt::KeyboardModifiers = Qt::NoModifier );
|
---|
| 48 | void getMouseButton( Qt::MouseButton &button,
|
---|
| 49 | Qt::KeyboardModifiers & ) const;
|
---|
[4271] | 50 |
|
---|
[8127] | 51 | void setAbortKey( int key, Qt::KeyboardModifiers = Qt::NoModifier );
|
---|
| 52 | void getAbortKey( int &key, Qt::KeyboardModifiers & ) const;
|
---|
| 53 |
|
---|
[4271] | 54 | void setCursor( const QCursor & );
|
---|
| 55 | const QCursor cursor() const;
|
---|
| 56 |
|
---|
| 57 | void setOrientations( Qt::Orientations );
|
---|
| 58 | Qt::Orientations orientations() const;
|
---|
| 59 |
|
---|
| 60 | bool isOrientationEnabled( Qt::Orientation ) const;
|
---|
| 61 |
|
---|
| 62 | virtual bool eventFilter( QObject *, QEvent * );
|
---|
| 63 |
|
---|
| 64 | Q_SIGNALS:
|
---|
| 65 | /*!
|
---|
| 66 | Signal emitted, when panning is done
|
---|
| 67 |
|
---|
| 68 | \param dx Offset in horizontal direction
|
---|
| 69 | \param dy Offset in vertical direction
|
---|
| 70 | */
|
---|
| 71 | void panned( int dx, int dy );
|
---|
| 72 |
|
---|
| 73 | /*!
|
---|
| 74 | Signal emitted, while the widget moved, but panning
|
---|
| 75 | is not finished.
|
---|
| 76 |
|
---|
| 77 | \param dx Offset in horizontal direction
|
---|
| 78 | \param dy Offset in vertical direction
|
---|
| 79 | */
|
---|
| 80 | void moved( int dx, int dy );
|
---|
| 81 |
|
---|
| 82 | protected:
|
---|
| 83 | virtual void widgetMousePressEvent( QMouseEvent * );
|
---|
| 84 | virtual void widgetMouseReleaseEvent( QMouseEvent * );
|
---|
| 85 | virtual void widgetMouseMoveEvent( QMouseEvent * );
|
---|
| 86 | virtual void widgetKeyPressEvent( QKeyEvent * );
|
---|
| 87 | virtual void widgetKeyReleaseEvent( QKeyEvent * );
|
---|
| 88 |
|
---|
| 89 | virtual void paintEvent( QPaintEvent * );
|
---|
| 90 |
|
---|
| 91 | virtual QBitmap contentsMask() const;
|
---|
| 92 | virtual QPixmap grab() const;
|
---|
| 93 |
|
---|
| 94 | private:
|
---|
| 95 | #ifndef QT_NO_CURSOR
|
---|
| 96 | void showCursor( bool );
|
---|
| 97 | #endif
|
---|
| 98 |
|
---|
| 99 | class PrivateData;
|
---|
| 100 | PrivateData *d_data;
|
---|
| 101 | };
|
---|
| 102 |
|
---|
| 103 | #endif
|
---|