Skip to content
qwt_panner.h 2.87 KiB
Newer Older
pixhawk's avatar
pixhawk committed
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 * Qwt Widget Library
 * Copyright (C) 1997   Josef Wilgen
 * Copyright (C) 2002   Uwe Rathmann
pixhawk's avatar
pixhawk committed
 * 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_PANNER_H
#define QWT_PANNER_H 1

#include "qwt_global.h"
Bryant's avatar
Bryant committed
#include <qwidget.h>
#include <qpixmap.h>
pixhawk's avatar
pixhawk committed

class QCursor;

/*!
  \brief 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.
pixhawk's avatar
pixhawk committed
  QwtPanner grabs the content of the widget into a pixmap and moves
  the pixmap around, without initiating any repaint events for the widget.
Bryant's avatar
Bryant committed
  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.
pixhawk's avatar
pixhawk committed

  For widgets, where repaints are very fast it might be better to
  implement panning manually by mapping mouse events into paint events.
*/
class QWT_EXPORT QwtPanner: public QWidget
{
    Q_OBJECT

public:
Bryant's avatar
Bryant committed
    QwtPanner( QWidget* parent );
pixhawk's avatar
pixhawk committed
    virtual ~QwtPanner();

Bryant's avatar
Bryant committed
    void setEnabled( bool );
pixhawk's avatar
pixhawk committed
    bool isEnabled() const;

Bryant's avatar
Bryant committed
    void setMouseButton( Qt::MouseButton, 
        Qt::KeyboardModifiers = Qt::NoModifier );
    void getMouseButton( Qt::MouseButton &button, 
        Qt::KeyboardModifiers & ) const;

    void setAbortKey( int key, Qt::KeyboardModifiers = Qt::NoModifier );
    void getAbortKey( int &key, Qt::KeyboardModifiers & ) const;
pixhawk's avatar
pixhawk committed

Bryant's avatar
Bryant committed
    void setCursor( const QCursor & );
pixhawk's avatar
pixhawk committed
    const QCursor cursor() const;

Bryant's avatar
Bryant committed
    void setOrientations( Qt::Orientations );
pixhawk's avatar
pixhawk committed
    Qt::Orientations orientations() const;

Bryant's avatar
Bryant committed
    bool isOrientationEnabled( Qt::Orientation ) const;
pixhawk's avatar
pixhawk committed

Bryant's avatar
Bryant committed
    virtual bool eventFilter( QObject *, QEvent * );
pixhawk's avatar
pixhawk committed

Bryant's avatar
Bryant committed
Q_SIGNALS:
pixhawk's avatar
pixhawk committed
    /*!
      Signal emitted, when panning is done

      \param dx Offset in horizontal direction
      \param dy Offset in vertical direction
    */
Bryant's avatar
Bryant committed
    void panned( int dx, int dy );
pixhawk's avatar
pixhawk committed

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

      \param dx Offset in horizontal direction
      \param dy Offset in vertical direction
    */
Bryant's avatar
Bryant committed
    void moved( int dx, int dy );
pixhawk's avatar
pixhawk committed

protected:
Bryant's avatar
Bryant committed
    virtual void widgetMousePressEvent( QMouseEvent * );
    virtual void widgetMouseReleaseEvent( QMouseEvent * );
    virtual void widgetMouseMoveEvent( QMouseEvent * );
    virtual void widgetKeyPressEvent( QKeyEvent * );
    virtual void widgetKeyReleaseEvent( QKeyEvent * );

    virtual void paintEvent( QPaintEvent * );
pixhawk's avatar
pixhawk committed

Bryant's avatar
Bryant committed
    virtual QBitmap contentsMask() const;
    virtual QPixmap grab() const;
pixhawk's avatar
pixhawk committed

private:
#ifndef QT_NO_CURSOR
Bryant's avatar
Bryant committed
    void showCursor( bool );
pixhawk's avatar
pixhawk committed
#endif

    class PrivateData;
    PrivateData *d_data;
};

#endif