QwtPanner provides panning of a widget. More...
#include <qwt_panner.h>
Classes | |
class | PrivateData |
Signals | |
void | moved (int dx, int dy) |
void | panned (int dx, int dy) |
Public Member Functions | |
const QCursor | cursor () const |
virtual bool | eventFilter (QObject *, QEvent *) |
Event filter. More... | |
void | getAbortKey (int &key, Qt::KeyboardModifiers &) const |
Get the abort key and modifiers. More... | |
void | getMouseButton (Qt::MouseButton &button, Qt::KeyboardModifiers &) const |
Get mouse button and modifiers used for panning. More... | |
bool | isEnabled () const |
bool | isOrientationEnabled (Qt::Orientation) const |
Qt::Orientations | orientations () const |
Return the orientation, where paning is enabled. More... | |
QwtPanner (QWidget *parent) | |
void | setAbortKey (int key, Qt::KeyboardModifiers=Qt::NoModifier) |
void | setCursor (const QCursor &) |
void | setEnabled (bool) |
En/disable the panner. More... | |
void | setMouseButton (Qt::MouseButton, Qt::KeyboardModifiers=Qt::NoModifier) |
void | setOrientations (Qt::Orientations) |
virtual | ~QwtPanner () |
Destructor. More... | |
Protected Member Functions | |
virtual QBitmap | contentsMask () const |
Calculate a mask for the contents of the panned widget. More... | |
virtual QPixmap | grab () const |
virtual void | paintEvent (QPaintEvent *) |
Paint event. More... | |
virtual void | widgetKeyPressEvent (QKeyEvent *) |
virtual void | widgetKeyReleaseEvent (QKeyEvent *) |
virtual void | widgetMouseMoveEvent (QMouseEvent *) |
virtual void | widgetMousePressEvent (QMouseEvent *) |
virtual void | widgetMouseReleaseEvent (QMouseEvent *) |
Private Member Functions | |
void | showCursor (bool) |
Private Attributes | |
PrivateData * | d_data |
QwtPanner provides panning of a widget.
QwtPanner grabs the contents of a widget, that can be dragged in all directions. The offset between the start and the end position is emitted by the panned signal.
QwtPanner grabs the content of the widget into a pixmap and moves the pixmap around, without initiating any repaint events for the widget. Areas, that are not part of content are not painted while panning. This makes panning fast enough for widgets, where repaints are too slow for mouse movements.
For widgets, where repaints are very fast it might be better to implement panning manually by mapping mouse events into paint events.
Definition at line 35 of file qwt_panner.h.
|
explicit |
Creates an panner that is enabled for the left mouse button.
parent | Parent widget to be panned |
Definition at line 86 of file qwt_panner.cpp.
|
virtual |
Destructor.
Definition at line 100 of file qwt_panner.cpp.
|
protectedvirtual |
Calculate a mask for the contents of the panned widget.
Sometimes only parts of the contents of a widget should be panned. F.e. for a widget with a styled background with rounded borders only the area inside of the border should be panned.
Reimplemented in QwtPlotPanner.
Definition at line 295 of file qwt_panner.cpp.
const QCursor QwtPanner::cursor | ( | ) | const |
Definition at line 166 of file qwt_panner.cpp.
|
virtual |
Event filter.
When isEnabled() is true mouse events of the observed widget are filtered.
object | Object to be filtered |
event | Event |
Definition at line 328 of file qwt_panner.cpp.
void QwtPanner::getAbortKey | ( | int & | key, |
Qt::KeyboardModifiers & | modifiers | ||
) | const |
Get the abort key and modifiers.
Definition at line 139 of file qwt_panner.cpp.
void QwtPanner::getMouseButton | ( | Qt::MouseButton & | button, |
Qt::KeyboardModifiers & | modifiers | ||
) | const |
Get mouse button and modifiers used for panning.
Definition at line 117 of file qwt_panner.cpp.
|
protectedvirtual |
Grab the widget into a pixmap.
Reimplemented in QwtPlotPanner.
Definition at line 304 of file qwt_panner.cpp.
bool QwtPanner::isEnabled | ( | ) | const |
Definition at line 239 of file qwt_panner.cpp.
bool QwtPanner::isOrientationEnabled | ( | Qt::Orientation | o | ) | const |
Definition at line 230 of file qwt_panner.cpp.
|
signal |
Signal emitted, while the widget moved, but panning is not finished.
dx | Offset in horizontal direction |
dy | Offset in vertical direction |
Qt::Orientations QwtPanner::orientations | ( | ) | const |
Return the orientation, where paning is enabled.
Definition at line 221 of file qwt_panner.cpp.
|
protectedvirtual |
Paint event.
Repaint the grabbed pixmap on its current position and fill the empty spaces by the background of the parent widget.
pe | Paint event |
Definition at line 252 of file qwt_panner.cpp.
|
signal |
Signal emitted, when panning is done
dx | Offset in horizontal direction |
dy | Offset in vertical direction |
void QwtPanner::setAbortKey | ( | int | key, |
Qt::KeyboardModifiers | modifiers = Qt::NoModifier |
||
) |
Change the abort key The defaults are Qt::Key_Escape and Qt::NoModifiers
key | Key ( See Qt::Keycode ) |
modifiers | Keyboard modifiers |
Definition at line 131 of file qwt_panner.cpp.
void QwtPanner::setCursor | ( | const QCursor & | cursor | ) |
Change the cursor, that is active while panning The default is the cursor of the parent widget.
cursor | New cursor |
Definition at line 155 of file qwt_panner.cpp.
void QwtPanner::setEnabled | ( | bool | on | ) |
En/disable the panner.
When enabled is true an event filter is installed for the observed widget, otherwise the event filter is removed.
on | true or false |
Definition at line 187 of file qwt_panner.cpp.
void QwtPanner::setMouseButton | ( | Qt::MouseButton | button, |
Qt::KeyboardModifiers | modifiers = Qt::NoModifier |
||
) |
Change the mouse button and modifiers used for panning The defaults are Qt::LeftButton and Qt::NoModifier
Definition at line 109 of file qwt_panner.cpp.
void QwtPanner::setOrientations | ( | Qt::Orientations | o | ) |
Set the orientations, where panning is enabled The default value is in both directions: Qt::Horizontal | Qt::Vertical
/param o Orientation
Definition at line 215 of file qwt_panner.cpp.
|
private |
Definition at line 506 of file qwt_panner.cpp.
|
protectedvirtual |
Handle a key press event for the observed widget.
keyEvent | Key event |
Definition at line 480 of file qwt_panner.cpp.
|
protectedvirtual |
Handle a key release event for the observed widget.
keyEvent | Key event |
Definition at line 500 of file qwt_panner.cpp.
|
protectedvirtual |
Handle a mouse move event for the observed widget.
mouseEvent | Mouse event |
Definition at line 419 of file qwt_panner.cpp.
|
protectedvirtual |
Handle a mouse press event for the observed widget.
mouseEvent | Mouse event |
Definition at line 379 of file qwt_panner.cpp.
|
protectedvirtual |
Handle a mouse release event for the observed widget.
mouseEvent | Mouse event |
Definition at line 447 of file qwt_panner.cpp.
|
private |
Definition at line 99 of file qwt_panner.h.