Classes | Signals | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
QwtPanner Class Reference

QwtPanner provides panning of a widget. More...

#include <qwt_panner.h>

Inheritance diagram for QwtPanner:
Inheritance graph
[legend]

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 *) QWT_OVERRIDE
 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 panning 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 *) QWT_OVERRIDE
 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

PrivateDatam_data
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ QwtPanner()

QwtPanner::QwtPanner ( QWidget *  parent)
explicit

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

Parameters
parentParent widget to be panned

Definition at line 87 of file qwt_panner.cpp.

◆ ~QwtPanner()

QwtPanner::~QwtPanner ( )
virtual

Destructor.

Definition at line 101 of file qwt_panner.cpp.

Member Function Documentation

◆ contentsMask()

QBitmap QwtPanner::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 QwtPlotPanner.

Definition at line 297 of file qwt_panner.cpp.

◆ cursor()

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

Definition at line 167 of file qwt_panner.cpp.

◆ eventFilter()

bool QwtPanner::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()

Definition at line 330 of file qwt_panner.cpp.

◆ getAbortKey()

void QwtPanner::getAbortKey ( int &  key,
Qt::KeyboardModifiers &  modifiers 
) const

Get the abort key and modifiers.

Definition at line 140 of file qwt_panner.cpp.

◆ getMouseButton()

void QwtPanner::getMouseButton ( Qt::MouseButton &  button,
Qt::KeyboardModifiers &  modifiers 
) const

Get mouse button and modifiers used for panning.

Definition at line 118 of file qwt_panner.cpp.

◆ grab()

QPixmap QwtPanner::grab ( ) const
protectedvirtual

Grab the widget into a pixmap.

Returns
Grabbed pixmap

Reimplemented in QwtPlotPanner.

Definition at line 306 of file qwt_panner.cpp.

◆ isEnabled()

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

Definition at line 240 of file qwt_panner.cpp.

◆ isOrientationEnabled()

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

Definition at line 231 of file qwt_panner.cpp.

◆ moved

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

◆ orientations()

Qt::Orientations QwtPanner::orientations ( ) const

Return the orientation, where panning is enabled.

Definition at line 222 of file qwt_panner.cpp.

◆ paintEvent()

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

Definition at line 253 of file qwt_panner.cpp.

◆ panned

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

Signal emitted, when panning is done

Parameters
dxOffset in horizontal direction
dyOffset in vertical direction

◆ setAbortKey()

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

Definition at line 132 of file qwt_panner.cpp.

◆ setCursor()

void QwtPanner::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()

Definition at line 156 of file qwt_panner.cpp.

◆ setEnabled()

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.

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

Definition at line 188 of file qwt_panner.cpp.

◆ setMouseButton()

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 110 of file qwt_panner.cpp.

◆ setOrientations()

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 216 of file qwt_panner.cpp.

◆ showCursor()

void QwtPanner::showCursor ( bool  on)
private

Definition at line 508 of file qwt_panner.cpp.

◆ widgetKeyPressEvent()

void QwtPanner::widgetKeyPressEvent ( QKeyEvent *  keyEvent)
protectedvirtual

Handle a key press event for the observed widget.

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

Definition at line 482 of file qwt_panner.cpp.

◆ widgetKeyReleaseEvent()

void QwtPanner::widgetKeyReleaseEvent ( QKeyEvent *  keyEvent)
protectedvirtual

Handle a key release event for the observed widget.

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

Definition at line 502 of file qwt_panner.cpp.

◆ widgetMouseMoveEvent()

void QwtPanner::widgetMouseMoveEvent ( QMouseEvent *  mouseEvent)
protectedvirtual

Handle a mouse move event for the observed widget.

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

Definition at line 421 of file qwt_panner.cpp.

◆ widgetMousePressEvent()

void QwtPanner::widgetMousePressEvent ( QMouseEvent *  mouseEvent)
protectedvirtual

Handle a mouse press event for the observed widget.

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

Reimplemented in QwtPolarPanner.

Definition at line 381 of file qwt_panner.cpp.

◆ widgetMouseReleaseEvent()

void QwtPanner::widgetMouseReleaseEvent ( QMouseEvent *  mouseEvent)
protectedvirtual

Handle a mouse release event for the observed widget.

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

Definition at line 449 of file qwt_panner.cpp.

Member Data Documentation

◆ m_data

PrivateData* QwtPanner::m_data
private

Definition at line 99 of file qwt_panner.h.


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


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:50