toruschess/src/testgame.h

89 lines
2.8 KiB
C
Raw Normal View History

2009-01-06 13:52:03 +00:00
/***************************************************************************
* Copyright (C) 2009 by Stefan Bühler *
* stbuehler@web.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; either 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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef TORUSCHESSTESTGAME_H
#define TORUSCHESSTESTGAME_H
#include <QWidget>
2009-01-06 16:02:15 +00:00
#include <QSvgRenderer>
#include <QMainWindow>
#include <QSize>
2009-01-06 13:52:03 +00:00
#include "toruschess.h"
2009-01-09 11:44:39 +00:00
#include "piecelibrary.h"
2009-01-06 13:52:03 +00:00
2009-01-06 16:02:15 +00:00
/**
@author Stefan Bühler <stbuehler@web.de>
*/
2009-01-06 13:52:03 +00:00
namespace toruschess {
class TestPlace : public QWidget {
2009-01-06 16:02:15 +00:00
Q_OBJECT
2009-01-06 13:52:03 +00:00
public:
2009-01-06 16:02:15 +00:00
TestPlace(QWidget *parent, const PieceLibrary *lib, const Field *field, const Pos &p);
2009-01-06 13:52:03 +00:00
const Pos& pos() const { return m_pos; }
const Field* field() const { return m_field; }
2009-01-06 16:02:15 +00:00
virtual QSize sizeHint() const;
void showMark() { m_mark = true; update(); }
void hideMark() { m_mark = false; update(); }
2009-01-06 16:02:15 +00:00
protected:
virtual void paintEvent(QPaintEvent *event);
2009-01-06 13:52:03 +00:00
private:
const Field *m_field;
2009-01-06 16:02:15 +00:00
const PieceLibrary *m_lib;
2009-01-06 13:52:03 +00:00
Pos m_pos;
bool m_mark;
2009-01-06 13:52:03 +00:00
};
class TestField : public QWidget {
2009-01-06 16:02:15 +00:00
Q_OBJECT
public:
TestField(QWidget *parent, PieceLibrary *lib, Game *m_game);
void markMoves(const QList<Move> &moves);
2009-01-06 16:02:15 +00:00
protected:
virtual void resizeEvent(QResizeEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
2009-01-06 16:02:15 +00:00
private:
PieceLibrary *m_lib;
Game *m_game;
TestPlace* m_places[8][8];
QList<Move> m_marked;
2009-01-06 13:52:03 +00:00
};
2009-01-06 16:02:15 +00:00
class TestGame : public QMainWindow {
Q_OBJECT
2009-01-06 13:52:03 +00:00
public:
2009-01-06 16:02:15 +00:00
TestGame(QWidget *parent = 0);
2009-01-06 13:52:03 +00:00
2009-01-06 16:02:15 +00:00
private:
Game *m_game;
2009-01-06 13:52:03 +00:00
};
}
#endif