summaryrefslogtreecommitdiff
path: root/noncore/games/chess/chess.h
Unidiff
Diffstat (limited to 'noncore/games/chess/chess.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/chess/chess.h128
1 files changed, 128 insertions, 0 deletions
diff --git a/noncore/games/chess/chess.h b/noncore/games/chess/chess.h
new file mode 100644
index 0000000..067b2f8
--- a/dev/null
+++ b/noncore/games/chess/chess.h
@@ -0,0 +1,128 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19** $Id$
20**
21**********************************************************************/
22#ifndef CHESS_H
23#define CHESS_H
24
25#include <qwidget.h>
26#include <qcanvas.h>
27#include <qmainwindow.h>
28#include <qpixmap.h>
29#include <qimage.h>
30#include <qstack.h>
31#include <qvector.h>
32#include <qpe/process.h>
33
34#define wPawn 'P'
35 #definewKnight 'N'
36#define wBishop 'B'
37#define wRook 'R'
38#define wQueen 'Q'
39#define wKing 'K'
40#define bPawn 'p'
41#define bKnight 'n'
42#define bBishop 'b'
43#define bRook 'r'
44#define bQueen 'q'
45#define bKing 'k'
46#define NONE N
47
48#define sideWhite 0
49#define sideBlack 1
50
51
52class Piece:public QCanvasRectangle {
53 public:
54 Piece(QCanvas *, int);
55 ~Piece() {
56 };
57
58 char type;
59
60 protected:
61 void drawShape(QPainter &);
62};
63
64
65class CraftyProcess : public Process {
66 public:
67 CraftyProcess(QObject *parent) : Process( parent ) { qDebug("CraftyProcess functions not implemented"); }
68 ~CraftyProcess() { }
69 bool start() { qDebug("CraftyProcess functions not implemented"); return FALSE; }
70 const char *readStdout() { qDebug("CraftyProcess functions not implemented"); return "Blah"; }
71 void writeToStdin(const char *) { qDebug("CraftyProcess functions not implemented"); }
72};
73
74
75class BoardView:public QCanvasView {
76 Q_OBJECT public:
77 BoardView(QCanvas *, QWidget *, const char *);
78 ~BoardView() {
79 };
80
81 protected:
82 void contentsMousePressEvent(QMouseEvent *);
83
84 signals:
85 void showMessage(const QString &);
86
87 public slots:void readStdout();
88 void craftyDied() {
89 qFatal("Crafty died unexpectedly\n");
90 };
91 void newGame();
92 void setTheme(QString);
93 void swapSides();
94 void undo();
95 void annotateGame();
96
97 private:
98 CraftyProcess * crafty;
99 QList < Piece > list;
100 Piece *activePiece;
101
102 void revertLastMove();
103 void emitErrorMessage();
104 void drawBackgroundImage(QPoint activeSquare);
105
106 void buildImages(QImage);
107
108 char convertToFile(int);
109 int convertToRank(int);
110 int convertFromFile(char);
111 int convertFromRank(int);
112
113 void decodePosition(const QString & t);
114
115 Piece *findPiece(char f, int r);
116 Piece *newPiece(int, char, int);
117 void deletePiece(Piece *);
118
119 int pieceSize;
120 QPixmap bg;
121 QImage whiteSquare, blackSquare, activeWhiteSquare, activeBlackSquare;
122
123 bool humanSide;
124 bool activeSide;
125 bool playingGame;
126};
127
128#endif