toruschess/src/testgame.h

96 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-06 16:02:15 +00:00
/**
@author Stefan Bühler <stbuehler@web.de>
*/
2009-01-06 13:52:03 +00:00
namespace toruschess {
2009-01-06 16:02:15 +00:00
class PieceLibrary : public QObject {
Q_OBJECT
public:
PieceLibrary(QObject *parent);
virtual ~PieceLibrary();
QSize pieceSize() const { return QSize(m_width, m_height); }
QSize minPieceSize() const { return QSize(20, 20); }
void setSize(int width, int height);
void paint(QPainter &pt, int piece) const;
private:
QSvgRenderer **m_pieces;
QImage **m_buffers;
int m_width, m_height;
};
2009-01-06 13:52:03 +00:00
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;
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;
};
class TestField : public QWidget {
2009-01-06 16:02:15 +00:00
Q_OBJECT
public:
TestField(QWidget *parent, PieceLibrary *lib, Game *m_game);
protected:
virtual void resizeEvent(QResizeEvent *event);
private:
PieceLibrary *m_lib;
Game *m_game;
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