set window title

This commit is contained in:
Stefan Bühler 2009-01-06 23:07:55 +01:00
parent 2b90964302
commit 910626b3c7
1 changed files with 32 additions and 31 deletions

View File

@ -65,9 +65,32 @@ namespace toruschess {
pt.drawImage(0, 0, *m_buffers[piece-1]);
}
TestGame::TestGame(QWidget *parent) : QMainWindow(parent), m_game(new Game()) {
PieceLibrary *lib = new PieceLibrary(this);
setCentralWidget(new TestField(this, lib, m_game));
TestPlace::TestPlace(QWidget *parent, const PieceLibrary *lib, const Field *field, const Pos &p)
: QWidget(parent), m_field(field), m_lib(lib), m_pos(p), m_mark(false) {
setMinimumSize(m_lib->minPieceSize());
}
QSize TestPlace::sizeHint() const {
return m_lib->pieceSize();
}
void TestPlace::paintEvent(QPaintEvent *) {
QPainter pt(this);
int pl = m_field->place(m_pos);
if ((m_pos.x() + m_pos.y()) % 2) {
// #D18B47
pt.fillRect(rect(), QBrush(QColor(0xD1, 0x8B, 0x47)));
} else {
// #FFCE9E
pt.fillRect(rect(), QBrush(QColor(0xFF, 0xCE, 0x9E)));
}
m_lib->paint(pt, pl);
if (m_mark) {
int r = qMax(1, (rect().width() + rect().height()) / 36);
pt.setBrush(pl != 0 ? Qt::green : Qt::white);
pt.setPen(Qt::red);
pt.drawEllipse(QPoint(rect().width() / 2, rect().height() / 2), r, r);
}
}
TestField::TestField(QWidget *parent, PieceLibrary *lib, Game *game) : QWidget(parent), m_lib(lib), m_game(game) {
@ -124,32 +147,10 @@ namespace toruschess {
}
}
TestPlace::TestPlace(QWidget *parent, const PieceLibrary *lib, const Field *field, const Pos &p)
: QWidget(parent), m_field(field), m_lib(lib), m_pos(p), m_mark(false) {
setMinimumSize(m_lib->minPieceSize());
}
QSize TestPlace::sizeHint() const {
return m_lib->pieceSize();
}
void TestPlace::paintEvent(QPaintEvent *) {
QPainter pt(this);
int pl = m_field->place(m_pos);
if ((m_pos.x() + m_pos.y()) % 2) {
// #D18B47
pt.fillRect(rect(), QBrush(QColor(0xD1, 0x8B, 0x47)));
} else {
// #FFCE9E
pt.fillRect(rect(), QBrush(QColor(0xFF, 0xCE, 0x9E)));
}
m_lib->paint(pt, pl);
if (m_mark) {
int r = qMax(1, (rect().width() + rect().height()) / 36);
pt.setBrush(pl != 0 ? Qt::green : Qt::white);
pt.setPen(Qt::red);
pt.drawEllipse(QPoint(rect().width() / 2, rect().height() / 2), r, r);
}
TestGame::TestGame(QWidget *parent) : QMainWindow(parent), m_game(new Game()) {
setWindowTitle("Torus Chess");
PieceLibrary *lib = new PieceLibrary(this);
setCentralWidget(new TestField(this, lib, m_game));
}
}