UBMagnifer.h 2.33 KB
Newer Older
Claudio Valerio's avatar
Claudio Valerio committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
15

16 17
#ifndef UBMAGNIFIER_H
#define UBMAGNIFIER_H
18

19
#include <QtGui>
20

21 22 23 24 25 26 27 28
class UBMagnifierParams
{
public :
    int x;
    int y;
    qreal zoom;
    qreal sizePercentFromScene;
};
29

30
class UBMagnifier : public QWidget
31 32 33 34
{
    Q_OBJECT

public:
35 36
    UBMagnifier(QWidget *parent = 0, bool isInteractive = false);
    ~UBMagnifier();
37

38 39
    void setSize(qreal percentFromScene);
    void setZoom(qreal zoom);
40

41 42
    void setGrabView(QWidget *view);
    void setMoveView(QWidget *view) {mView = view;}
43

44
    void grabPoint();
45
    void grabPoint(const QPoint &point);
46 47 48 49 50 51 52 53 54 55
    void grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab = true, bool needMove = true);

    UBMagnifierParams params;

signals:
    void magnifierMoved_Signal(QPoint newPos);
    void magnifierClose_Signal();
    void magnifierZoomIn_Signal();
    void magnifierZoomOut_Signal();
    void magnifierResized_Signal(qreal newPercentSize);
56 57 58 59 60

protected:
    void paintEvent(QPaintEvent *);
    void timerEvent(QTimerEvent *);

61 62 63 64 65 66 67 68 69 70 71 72 73 74
    virtual void mousePressEvent ( QMouseEvent * event );
    virtual void mouseMoveEvent ( QMouseEvent * event );
    virtual void mouseReleaseEvent ( QMouseEvent * event );

    QPoint mMousePressPos;
    qreal mMousePressDelta;
    bool mShouldMoveWidget;
    bool mShouldResizeWidget;


    QPixmap *sClosePixmap;
    QPixmap *sIncreasePixmap;
    QPixmap *sDecreasePixmap;
    QPixmap *mResizeItem;
75

76 77 78
    bool isCusrsorAlreadyStored;
    QCursor mOldCursor;
    QCursor mResizeCursor;
79 80 81

private:
    bool inTimer;
82
    bool m_isInteractive;
83 84

    int timerUpdate;
85 86
    QPoint updPointGrab;
    QPoint updPointMove;
87 88 89 90 91
    
    QPixmap pMap;
    QBitmap bmpMask;
    QPen borderPen;

92 93
    QWidget *gView;
    QWidget *mView;
94 95
};

96
#endif // UBMAGNIFIER_H