qwt_magnifier.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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_MAGNIFIER_H
  10. #define QWT_MAGNIFIER_H 1
  11. #include "qwt_global.h"
  12. #include <qobject.h>
  13. class QWidget;
  14. class QMouseEvent;
  15. class QWheelEvent;
  16. class QKeyEvent;
  17. /*!
  18. \brief QwtMagnifier provides zooming, by magnifying in steps.
  19. Using QwtMagnifier a plot can be zoomed in/out in steps using
  20. keys, the mouse wheel or moving a mouse button in vertical direction.
  21. */
  22. class QWT_EXPORT QwtMagnifier: public QObject
  23. {
  24. Q_OBJECT
  25. public:
  26. explicit QwtMagnifier( QWidget * );
  27. virtual ~QwtMagnifier();
  28. QWidget *parentWidget();
  29. const QWidget *parentWidget() const;
  30. void setEnabled( bool );
  31. bool isEnabled() const;
  32. // mouse
  33. void setMouseFactor( double );
  34. double mouseFactor() const;
  35. void setMouseButton( Qt::MouseButton, Qt::KeyboardModifiers = Qt::NoModifier );
  36. void getMouseButton( Qt::MouseButton &, Qt::KeyboardModifiers & ) const;
  37. // mouse wheel
  38. void setWheelFactor( double );
  39. double wheelFactor() const;
  40. void setWheelModifiers( Qt::KeyboardModifiers );
  41. Qt::KeyboardModifiers wheelModifiers() const;
  42. // keyboard
  43. void setKeyFactor( double );
  44. double keyFactor() const;
  45. void setZoomInKey( int key, Qt::KeyboardModifiers = Qt::NoModifier );
  46. void getZoomInKey( int &key, Qt::KeyboardModifiers & ) const;
  47. void setZoomOutKey( int key, Qt::KeyboardModifiers = Qt::NoModifier );
  48. void getZoomOutKey( int &key, Qt::KeyboardModifiers & ) const;
  49. virtual bool eventFilter( QObject *, QEvent * );
  50. protected:
  51. /*!
  52. Rescale the parent widget
  53. \param factor Scale factor
  54. */
  55. virtual void rescale( double factor ) = 0;
  56. virtual void widgetMousePressEvent( QMouseEvent * );
  57. virtual void widgetMouseReleaseEvent( QMouseEvent * );
  58. virtual void widgetMouseMoveEvent( QMouseEvent * );
  59. virtual void widgetWheelEvent( QWheelEvent * );
  60. virtual void widgetKeyPressEvent( QKeyEvent * );
  61. virtual void widgetKeyReleaseEvent( QKeyEvent * );
  62. private:
  63. class PrivateData;
  64. PrivateData *d_data;
  65. };
  66. #endif