1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
//=========================================================
// MusE
// Linux Music Editor
// $Id: tscale.cpp,v 1.2 2003/12/17 11:04:14 wschweer Exp $
// (C) Copyright 1999 Werner Schweer (ws@seh.de)
//
// 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; version 2 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, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//=========================================================
#include <stdio.h>
#include "tscale.h"
#include "globals.h"
#include "gconfig.h"
#include <QMouseEvent>
#include <QPainter>
namespace MusEGui {
//---------------------------------------------------------
// TScale
//---------------------------------------------------------
TScale::TScale(QWidget* parent, int ymag)
: View(parent, 1, ymag)
{
setFont(MusEGlobal::config.fonts[5]);
//int w = 4 * QFontMetrics(MusEGlobal::config.fonts[4]).width('0');
int w = 4 * fontMetrics().width('0');
setFixedWidth(w);
setMouseTracking(true);
}
//---------------------------------------------------------
// draw
//---------------------------------------------------------
void TScale::pdraw(QPainter& p, const QRect& r)
{
int y = r.y();
int h = r.height();
//p.setFont(MusEGlobal::config.fonts[4]);
QString s;
for (int i = 30000; i <= 250000; i += 10000) {
int yy = mapy(280000 - i);
if (yy < y)
break;
if (yy-15 > y+h)
continue;
p.drawLine(0, yy, width(), yy);
s.setNum(i/1000);
//QFontMetrics fm(MusEGlobal::config.fonts[4]);
//p.drawText(width() - fm.width(s) - 1, yy-2, s);
p.drawText(width() - fontMetrics().width(s) - 1, yy-2, s); // Use the window font. Tim p4.0.31
}
}
void TScale::viewMouseMoveEvent(QMouseEvent* event)
{
emit tempoChanged(280000 - event->y());
}
void TScale::leaveEvent(QEvent*)
{
emit tempoChanged(-1);
}
} // namespace MusEGui
|