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