annotate src/panned.h @ 628:5dc24f89b791

* "Use extension" check box now appears to the left of the button and label, and enables/disables the button and label depending on its state
author Sam Izzo <sam@humbug.net>
date Sun, 26 Aug 2012 02:39:08 +1000
parents 533519ebc0cb
children ae67ea0af696
rev   line source
Chris@57 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@45 2
cannam@45 3 /*
Chris@57 4 EasyMercurial
Chris@57 5
Chris@57 6 Based on HgExplorer by Jari Korhonen
Chris@57 7 Copyright (c) 2010 Jari Korhonen
Chris@560 8 Copyright (c) 2012 Chris Cannam
Chris@560 9 Copyright (c) 2012 Queen Mary, University of London
Chris@57 10
cannam@45 11 This program is free software; you can redistribute it and/or
cannam@45 12 modify it under the terms of the GNU General Public License as
cannam@45 13 published by the Free Software Foundation; either version 2 of the
cannam@45 14 License, or (at your option) any later version. See the file
cannam@45 15 COPYING included with this distribution for more information.
cannam@45 16 */
cannam@45 17
Chris@57 18 #ifndef _PANNED_H_
Chris@57 19 #define _PANNED_H_
cannam@45 20
cannam@45 21 #include <QGraphicsView>
cannam@45 22
cannam@45 23 class QWheelEvent;
cannam@45 24 class QEvent;
Chris@168 25 class QTimer;
cannam@45 26
cannam@45 27 class Panned : public QGraphicsView
cannam@45 28 {
cannam@45 29 Q_OBJECT
cannam@45 30
cannam@45 31 public:
cannam@45 32 Panned();
cannam@45 33 virtual ~Panned() { }
cannam@45 34
Chris@133 35 virtual void setScene(QGraphicsScene *s);
Chris@133 36
cannam@45 37 signals:
cannam@45 38 void pannedRectChanged(QRectF);
cannam@45 39 void wheelEventReceived(QWheelEvent *);
cannam@45 40 void pannedContentsScrolled();
cannam@45 41 void mouseLeaves();
cannam@45 42
cannam@45 43 public slots:
cannam@45 44 void slotSetPannedRect(QRectF);
cannam@45 45 void slotEmulateWheelEvent(QWheelEvent *ev);
cannam@45 46
Chris@53 47 void zoomIn();
Chris@53 48 void zoomOut();
Chris@53 49
Chris@168 50 private slots:
Chris@168 51 void dragTimerTimeout();
Chris@168 52
cannam@45 53 protected:
cannam@45 54 QRectF m_pannedRect;
cannam@45 55
Chris@168 56 QPoint m_lastDragPos;
Chris@403 57 QPoint m_lastDragStart;
Chris@168 58 QPoint m_lastOrigin;
Chris@168 59 QPointF m_velocity;
Chris@168 60 bool m_dragging;
Chris@168 61 int m_dragTimerMs;
Chris@168 62 QTimer *m_dragTimer;
Chris@168 63
Chris@403 64 enum DragDirection {
Chris@403 65 UnknownDrag,
Chris@403 66 HorizontalDrag,
Chris@403 67 VerticalDrag,
Chris@403 68 FreeDrag
Chris@403 69 };
Chris@403 70 DragDirection m_dragDirection;
Chris@403 71 void updateDragDirection(QPoint);
Chris@403 72
Chris@168 73 virtual void mousePressEvent(QMouseEvent *);
Chris@168 74 virtual void mouseMoveEvent(QMouseEvent *);
Chris@168 75 virtual void mouseReleaseEvent(QMouseEvent *);
Chris@168 76
cannam@45 77 virtual void paintEvent(QPaintEvent *);
cannam@45 78 virtual void resizeEvent(QResizeEvent *);
cannam@45 79 virtual void drawForeground(QPainter *, const QRectF &);
cannam@45 80 virtual void wheelEvent(QWheelEvent *);
cannam@45 81 virtual void leaveEvent(QEvent *);
cannam@45 82 };
cannam@45 83
cannam@45 84 #endif
cannam@45 85