toruschess/src/field2d.h

76 lines
2.5 KiB
C
Raw Normal View History

2009-01-09 11:44:39 +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 TORUSCHESSFIELD2D_H
#define TORUSCHESSFIELD2D_H
#include "toruschess.h"
#include "piecelibrary.h"
#include <QWidget>
#include <QList>
/**
@author Stefan Bühler <stbuehler@web.de>
*/
namespace toruschess {
class Field2D : public QWidget {
Q_OBJECT
public:
Field2D(Game *game, QWidget *parent = 0);
2009-01-21 15:45:17 +00:00
virtual ~Field2D();
2009-01-09 11:44:39 +00:00
void markMoves(const QList<Move> &moves);
virtual QSize sizeHint() const;
protected:
virtual void paintEvent(QPaintEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual void wheelEvent(QWheelEvent *event);
void checkSizes();
2009-01-21 15:45:17 +00:00
void updateFieldBuffer();
2009-01-09 11:44:39 +00:00
Pos findPos(int x, int y);
2009-01-21 15:45:17 +00:00
protected slots:
void fieldUpdated();
2009-01-09 11:44:39 +00:00
private:
PieceLibrary *m_lib;
Game *m_game;
bool m_marked[8][8];
QList<Move> m_markedMoves;
int m_fieldWidth, m_fieldHeight;
int m_originX, m_originY;
int m_mouseLastX, m_mouseLastY;
2009-01-21 15:45:17 +00:00
QImage *m_fieldBuffer;
2009-01-09 11:44:39 +00:00
};
}
#endif