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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
/*
Rosegarden
A MIDI and audio sequencer and musical notation editor.
This program is Copyright 2000-2008
Guillaume Laurent <[email protected]>,
Chris Cannam <[email protected]>,
Richard Bown <[email protected]>
The moral rights of Guillaume Laurent, Chris Cannam, and Richard
Bown to claim authorship of this work have been asserted.
Other copyrights also apply to some parts of this work. Please
see the AUTHORS file and individual file headers for details.
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 2 of the
License, or (at your option) any later version. See the file
COPYING included with this distribution for more information.
*/
#include "ClefDialog.h"
#include "base/NotationTypes.h"
#include "gui/editors/notation/NotePixmapFactory.h"
#include "gui/widgets/BigArrowButton.h"
#include <klocale.h>
#include <kdialogbase.h>
#include <tqbuttongroup.h>
#include <tqgroupbox.h>
#include <tqhbox.h>
#include <tqlabel.h>
#include <tqobject.h>
#include <tqpixmap.h>
#include <tqradiobutton.h>
#include <tqstring.h>
#include <tqtooltip.h>
#include <tqvbox.h>
#include <tqwidget.h>
namespace Rosegarden
{
ClefDialog::ClefDialog(TQWidget *parent,
NotePixmapFactory *npf,
Clef defaultClef,
bool showConversionOptions) :
KDialogBase(parent, 0, true, i18n("Clef"), Ok | Cancel | Help),
m_notePixmapFactory(npf),
m_clef(defaultClef)
{
setHelp("nv-signatures-clef");
TQVBox *vbox = makeVBoxMainWidget();
TQGroupBox *clefFrame = new TQGroupBox
(1, Qt::Horizontal, i18n("Clef"), vbox);
TQButtonGroup *conversionFrame = new TQButtonGroup
(1, Qt::Horizontal, i18n("Existing notes following clef change"), vbox);
TQHBox *clefBox = new TQHBox(clefFrame);
BigArrowButton *clefDown = new BigArrowButton(clefBox, Qt::LeftArrow);
TQToolTip::add
(clefDown, i18n("Lower clef"));
TQHBox *clefLabelBox = new TQVBox(clefBox);
m_octaveUp = new BigArrowButton(clefLabelBox, Qt::UpArrow);
TQToolTip::add
(m_octaveUp, i18n("Up an Octave"));
m_clefLabel = new TQLabel(i18n("Clef"), clefLabelBox);
m_clefLabel->setAlignment(AlignVCenter | AlignHCenter);
m_octaveDown = new BigArrowButton(clefLabelBox, Qt::DownArrow);
TQToolTip::add
(m_octaveDown, i18n("Down an Octave"));
BigArrowButton *clefUp = new BigArrowButton(clefBox, Qt::RightArrow);
TQToolTip::add
(clefUp, i18n("Higher clef"));
m_clefNameLabel = new TQLabel(i18n("Clef"), clefLabelBox);
m_clefNameLabel->setAlignment(AlignVCenter | AlignHCenter);
if (showConversionOptions) {
m_noConversionButton =
new TQRadioButton
(i18n("Maintain current pitches"), conversionFrame);
m_changeOctaveButton =
new TQRadioButton
(i18n("Transpose into appropriate octave"), conversionFrame);
m_transposeButton = 0;
//!!! why aren't we offering this option? does it not work? too difficult to describe?
// m_transposeButton =
// new TQRadioButton
// (i18n("Maintain current positions on the staff"), conversionFrame);
m_changeOctaveButton->setChecked(true);
} else {
m_noConversionButton = 0;
m_changeOctaveButton = 0;
m_transposeButton = 0;
conversionFrame->hide();
}
TQObject::connect(clefUp, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotClefUp()));
TQObject::connect(clefDown, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotClefDown()));
TQObject::connect(m_octaveUp, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotOctaveUp()));
TQObject::connect(m_octaveDown, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotOctaveDown()));
redrawClefPixmap();
}
Clef
ClefDialog::getClef() const
{
return m_clef;
}
ClefDialog::ConversionType
ClefDialog::getConversionType() const
{
if (m_noConversionButton && m_noConversionButton->isChecked()) {
return NoConversion;
} else if (m_changeOctaveButton && m_changeOctaveButton->isChecked()) {
return ChangeOctave;
} else if (m_transposeButton && m_transposeButton->isChecked()) {
return Transpose;
}
return NoConversion;
}
void
ClefDialog::slotClefUp()
{
int octaveOffset = m_clef.getOctaveOffset();
Clef::ClefList clefs(Clef::getClefs());
for (Clef::ClefList::iterator i = clefs.begin();
i != clefs.end(); ++i) {
if (m_clef.getClefType() == i->getClefType()) {
if (++i == clefs.end())
i = clefs.begin();
m_clef = Clef(i->getClefType(), octaveOffset);
break;
}
}
redrawClefPixmap();
}
void
ClefDialog::slotClefDown()
{
int octaveOffset = m_clef.getOctaveOffset();
Clef::ClefList clefs(Clef::getClefs());
for (Clef::ClefList::iterator i = clefs.begin();
i != clefs.end(); ++i) {
if (m_clef.getClefType() == i->getClefType()) {
if (i == clefs.begin())
i = clefs.end();
--i;
m_clef = Clef(i->getClefType(), octaveOffset);
break;
}
}
redrawClefPixmap();
}
void
ClefDialog::slotOctaveUp()
{
int octaveOffset = m_clef.getOctaveOffset();
if (octaveOffset == 2)
return ;
++octaveOffset;
m_octaveDown->setEnabled(true);
if (octaveOffset == 2) {
m_octaveUp->setEnabled(false);
}
m_clef = Clef(m_clef.getClefType(), octaveOffset);
redrawClefPixmap();
}
void
ClefDialog::slotOctaveDown()
{
int octaveOffset = m_clef.getOctaveOffset();
if (octaveOffset == -2)
return ;
--octaveOffset;
m_octaveUp->setEnabled(true);
if (octaveOffset == 2) {
m_octaveDown->setEnabled(false);
}
m_clef = Clef(m_clef.getClefType(), octaveOffset);
redrawClefPixmap();
}
void
ClefDialog::redrawClefPixmap()
{
TQPixmap pmap = NotePixmapFactory::toTQPixmap
(m_notePixmapFactory->makeClefDisplayPixmap(m_clef));
m_clefLabel->setPixmap(pmap);
TQString name;
int octave = m_clef.getOctaveOffset();
switch (octave) {
case - 1:
name = i18n("%1 down an octave");
break;
case - 2:
name = i18n("%1 down two octaves");
break;
case 1:
name = i18n("%1 up an octave");
break;
case 2:
name = i18n("%1 up two octaves");
break;
default:
name = "%1";
break;
}
std::string type = m_clef.getClefType();
if (type == Clef::Treble)
name = name.tqarg(i18n("Treble"));
else if (type == Clef::French)
name = name.tqarg(i18n("French violin"));
else if (type == Clef::Soprano)
name = name.tqarg(i18n("Soprano"));
else if (type == Clef::Mezzosoprano)
name = name.tqarg(i18n("Mezzo-soprano"));
else if (type == Clef::Alto)
name = name.tqarg(i18n("Alto"));
else if (type == Clef::Tenor)
name = name.tqarg(i18n("Tenor"));
else if (type == Clef::Baritone)
name = name.tqarg(i18n("C-baritone"));
else if (type == Clef::Varbaritone)
name = name.tqarg(i18n("F-baritone"));
else if (type == Clef::Bass)
name = name.tqarg(i18n("Bass"));
else if (type == Clef::Subbass)
name = name.tqarg(i18n("Sub-bass"));
m_clefNameLabel->setText(name);
}
}
#include "ClefDialog.moc"
|