// pianoinstrument.cpp - A piano simulator
-// Written by James Bunton <james@delx.cjb.net>
+// Written by James Bunton <james@delx.net.au>
// Licensed under the GPL, see COPYING.txt for more details
#include "pianoinstrument.h"
-
+using namespace Qt;
PianoInstrument::PianoInstrument(QWidget *parent)
: Instrument(parent)
{
- // Set us up to look pretty
- setPaletteBackgroundPixmap(QPixmap("piano.png"));
- setFixedSize(184, 220);
- parentWidget()->setFixedSize(184, 220);
+ background.load("piano.png");
- for(int i = 0; i < 26; i++) {
- oldNotes[i] = false;
- notes[i] = false;
- }
+ memset(oldNotes, 0, sizeof(oldNotes));
+ memset(notes, 0, sizeof(notes));
noteStart = 48;
"Playing the keyboard:"
"<ul>"
-"<li>You can change the octave using the "Octave" box above. Middle C is the third octave</li>"
+"<li>You can change the octave using the "Base Octave" box above. Middle C is the third octave</li>"
"<li>The keys - qwertyui are the top row white keys</li>"
"<li>The keys - 23 567 9 are the top row black keys</li>"
"<li>The keys - zxcvbnm, are the bottom row white keys</li>"
"<li>The keys - sd ghj l are the bottom row black keys</li>"
+"<li>When you push a key, the note it corresponds to is highlighted</li>"
"</ul>"
"</html>"
void PianoInstrument::paintEvent(QPaintEvent *)
{
QPainter paint(this);
+
+ paint.drawPixmap(0, 0, background);
+
paint.setPen(Qt::red);
const int topBlackY = 38;
repaint();
}
-