1 //============================================================================= 2 // MusE Score 3 // Linux Music Score Editor 4 // 5 // Copyright (C) 2009 Werner Schweer and others 6 // 7 // This program is free software; you can redistribute it and/or modify 8 // it under the terms of the GNU General Public License version 2. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 //============================================================================= 19 20 #ifndef __RULER_H__ 21 #define __RULER_H__ 22 23 #include "libmscore/pos.h" 24 25 namespace Ms { 26 27 class Score; 28 29 static const int rulerHeight = 28; 30 31 //--------------------------------------------------------- 32 // Ruler 33 //--------------------------------------------------------- 34 35 class Ruler : public QWidget { 36 Q_OBJECT 37 38 Score* _score; 39 Pos _cursor; 40 Pos* _locator; 41 42 int magStep; 43 double _xmag; 44 int _xpos; 45 TType _timeType; 46 QFont _font1, _font2; 47 48 static QPixmap* markIcon[3]; 49 50 virtual void paintEvent(QPaintEvent*); 51 virtual void mousePressEvent(QMouseEvent*); 52 virtual void mouseMoveEvent(QMouseEvent* event); 53 virtual void leaveEvent(QEvent*); 54 55 Pos pix2pos(int x) const; 56 int pos2pix(const Pos& p) const; 57 void moveLocator(QMouseEvent*); 58 59 signals: 60 void posChanged(const Pos&); 61 void locatorMoved(int idx, const Pos&); 62 63 public slots: 64 void setXpos(int); 65 void setMag(double xmag, double ymag); 66 void setPos(const Pos&); 67 68 public: 69 Ruler(QWidget* parent = 0); 70 void setScore(Score*, Pos* locator); xmag()71 double xmag() const { return _xmag; } xpos()72 int xpos() const { return _xpos; } 73 }; 74 75 76 } // namespace Ms 77 #endif 78 79