qwt_panner.h 2.9 KB

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