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,11 +65,34 @@ namespace toruschess {
pt.drawImage(0, 0, *m_buffers[piece-1]); pt.drawImage(0, 0, *m_buffers[piece-1]);
} }
TestGame::TestGame(QWidget *parent) : QMainWindow(parent), m_game(new Game()) { TestPlace::TestPlace(QWidget *parent, const PieceLibrary *lib, const Field *field, const Pos &p)
PieceLibrary *lib = new PieceLibrary(this); : QWidget(parent), m_field(field), m_lib(lib), m_pos(p), m_mark(false) {
setCentralWidget(new TestField(this, lib, m_game)); 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) { TestField::TestField(QWidget *parent, PieceLibrary *lib, Game *game) : QWidget(parent), m_lib(lib), m_game(game) {
QGridLayout *layout = new QGridLayout(); QGridLayout *layout = new QGridLayout();
for (int y = 0; y < 8; y++) { for (int y = 0; y < 8; y++) {
@ -124,32 +147,10 @@ namespace toruschess {
} }
} }
TestPlace::TestPlace(QWidget *parent, const PieceLibrary *lib, const Field *field, const Pos &p) TestGame::TestGame(QWidget *parent) : QMainWindow(parent), m_game(new Game()) {
: QWidget(parent), m_field(field), m_lib(lib), m_pos(p), m_mark(false) { setWindowTitle("Torus Chess");
setMinimumSize(m_lib->minPieceSize()); PieceLibrary *lib = new PieceLibrary(this);
setCentralWidget(new TestField(this, lib, m_game));
} }
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);
}
}
} }