QWT 7.0.1
Loading...
Searching...
No Matches
Classes | Signals | Public Member Functions | Protected Member Functions | List of all members
QwtCachePanner Class Reference

QwtCachePanner provides panning of a widget. More...

#include <qwt_cache_panner.h>

Inheritance diagram for QwtCachePanner:
QwtPlotCachePanner QwtPolarCachePanner

Classes

class  PrivateData
 

Signals

void panned (int dx, int dy)
 Signal emitted, when panning is done.
 
void moved (int dx, int dy)
 Signal emitted, while the widget moved, but panning is not finished.
 

Public Member Functions

 QwtCachePanner (QWidget *parent)
 Creates an panner that is enabled for the left mouse button.
 
virtual ~QwtCachePanner ()
 Destructor.
 
void setEnabled (bool)
 En/disable the panner.
 
bool isEnabled () const
 
void setMouseButton (Qt::MouseButton, Qt::KeyboardModifiers=Qt::NoModifier)
 Change the mouse button and modifiers used for panning The defaults are Qt::LeftButton and Qt::NoModifier.
 
void getMouseButton (Qt::MouseButton &button, Qt::KeyboardModifiers &) const
 Get mouse button and modifiers used for panning.
 
void setAbortKey (int key, Qt::KeyboardModifiers=Qt::NoModifier)
 Change the abort key The defaults are Qt::Key_Escape and Qt::NoModifiers.
 
void getAbortKey (int &key, Qt::KeyboardModifiers &) const
 Get the abort key and modifiers.
 
void setCursor (const QCursor &)
 Change the cursor, that is active while panning The default is the cursor of the parent widget.
 
const QCursor cursor () const
 
void setOrientations (Qt::Orientations)
 Set the orientations, where panning is enabled The default value is in both directions: Qt::Horizontal | Qt::Vertical.
 
Qt::Orientations orientations () const
 Return the orientation, where panning is enabled.
 
bool isOrientationEnabled (Qt::Orientation) const
 
virtual bool eventFilter (QObject *, QEvent *) QWT_OVERRIDE
 Event filter.
 

Protected Member Functions

virtual void widgetMousePressEvent (QMouseEvent *)
 Handle a mouse press event for the observed widget.
 
virtual void widgetMouseReleaseEvent (QMouseEvent *)
 Handle a mouse release event for the observed widget.
 
virtual void widgetMouseMoveEvent (QMouseEvent *)
 Handle a mouse move event for the observed widget.
 
virtual void widgetKeyPressEvent (QKeyEvent *)
 Handle a key press event for the observed widget.
 
virtual void widgetKeyReleaseEvent (QKeyEvent *)
 Handle a key release event for the observed widget.
 
virtual void paintEvent (QPaintEvent *) QWT_OVERRIDE
 Paint event.
 
virtual QBitmap contentsMask () const
 Calculate a mask for the contents of the panned widget.
 
virtual QPixmap grab () const
 Grab the widget into a pixmap.
 

Detailed Description

QwtCachePanner provides panning of a widget.

QwtCachePanner 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.

QwtCachePanner 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.

Constructor & Destructor Documentation

◆ QwtCachePanner()

QwtCachePanner::QwtCachePanner ( QWidget *  parent)
explicit

Creates an panner that is enabled for the left mouse button.

Parameters
parentParent widget to be panned

Member Function Documentation

◆ contentsMask()

QBitmap QwtCachePanner::contentsMask ( ) const
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.

Returns
An empty bitmap, indicating no mask

Reimplemented in QwtPlotCachePanner.

◆ cursor()

const QCursor QwtCachePanner::cursor ( ) const
Returns
Cursor that is active while panning
See also
setCursor()

◆ eventFilter()

bool QwtCachePanner::eventFilter ( QObject *  object,
QEvent *  event 
)
virtual

Event filter.

When isEnabled() is true mouse events of the observed widget are filtered.

Parameters
objectObject to be filtered
eventEvent
Returns
Always false, beside for paint events for the parent widget.
See also
widgetMousePressEvent(), widgetMouseReleaseEvent(), widgetMouseMoveEvent()

◆ grab()

QPixmap QwtCachePanner::grab ( ) const
protectedvirtual

Grab the widget into a pixmap.

Returns
Grabbed pixmap

Reimplemented in QwtPlotCachePanner.

◆ isEnabled()

bool QwtCachePanner::isEnabled ( ) const
Returns
true when enabled, false otherwise
See also
setEnabled, eventFilter()

◆ isOrientationEnabled()

bool QwtCachePanner::isOrientationEnabled ( Qt::Orientation  o) const
Returns
True if an orientation is enabled
See also
orientations(), setOrientations()

◆ moved

void QwtCachePanner::moved ( int  dx,
int  dy 
)
signal

Signal emitted, while the widget moved, but panning is not finished.

Parameters
dxOffset in horizontal direction
dyOffset in vertical direction

◆ paintEvent()

void QwtCachePanner::paintEvent ( QPaintEvent *  event)
protectedvirtual

Paint event.

Repaint the grabbed pixmap on its current position and fill the empty spaces by the background of the parent widget.

Parameters
eventPaint event

◆ panned

void QwtCachePanner::panned ( int  dx,
int  dy 
)
signal

Signal emitted, when panning is done.

Parameters
dxOffset in horizontal direction
dyOffset in vertical direction

◆ setAbortKey()

void QwtCachePanner::setAbortKey ( int  key,
Qt::KeyboardModifiers  modifiers = Qt::NoModifier 
)

Change the abort key The defaults are Qt::Key_Escape and Qt::NoModifiers.

Parameters
keyKey ( See Qt::Keycode )
modifiersKeyboard modifiers

◆ setCursor()

void QwtCachePanner::setCursor ( const QCursor &  cursor)

Change the cursor, that is active while panning The default is the cursor of the parent widget.

Parameters
cursorNew cursor
See also
setCursor()

◆ setEnabled()

void QwtCachePanner::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.

Parameters
ontrue or false
See also
isEnabled(), eventFilter()

◆ setOrientations()

void QwtCachePanner::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

◆ widgetKeyPressEvent()

void QwtCachePanner::widgetKeyPressEvent ( QKeyEvent *  keyEvent)
protectedvirtual

Handle a key press event for the observed widget.

Parameters
keyEventKey event
See also
eventFilter(), widgetKeyReleaseEvent()

◆ widgetKeyReleaseEvent()

void QwtCachePanner::widgetKeyReleaseEvent ( QKeyEvent *  keyEvent)
protectedvirtual

Handle a key release event for the observed widget.

Parameters
keyEventKey event
See also
eventFilter(), widgetKeyReleaseEvent()

◆ widgetMouseMoveEvent()

void QwtCachePanner::widgetMouseMoveEvent ( QMouseEvent *  mouseEvent)
protectedvirtual

Handle a mouse move event for the observed widget.

Parameters
mouseEventMouse event
See also
eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent()

◆ widgetMousePressEvent()

void QwtCachePanner::widgetMousePressEvent ( QMouseEvent *  mouseEvent)
protectedvirtual

Handle a mouse press event for the observed widget.

Parameters
mouseEventMouse event
See also
eventFilter(), widgetMouseReleaseEvent(), widgetMouseMoveEvent(),

Reimplemented in QwtPolarCachePanner.

◆ widgetMouseReleaseEvent()

void QwtCachePanner::widgetMouseReleaseEvent ( QMouseEvent *  mouseEvent)
protectedvirtual

Handle a mouse release event for the observed widget.

Parameters
mouseEventMouse event
See also
eventFilter(), widgetMousePressEvent(), widgetMouseMoveEvent(),

The documentation for this class was generated from the following files: