Fixed pool update.
[tagua/yd.git] / src / chesstable.h
blob7a57012c65b9a34bbc0f51d6496ad639eafc64f7
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef CHESSTABLE_H
12 #define CHESSTABLE_H
14 #include <qwidget.h>
16 #include "kgamecanvas.h"
17 #include "positioninfo.h"
18 #include "board.h"
19 #include "common.h"
21 class PiecePool;
22 class Player;
23 class Clock;
24 class InfoDisplay;
25 namespace MoveList {
26 class Table;
28 namespace Canvas {
29 class TiledPixmap;
32 class ChessTable : public KGameCanvasWidget {
33 Q_OBJECT
34 KGameCanvasTiledPixmap* m_wallpaper;
36 Clock* m_clocks[2];
37 Board* m_board;
38 PiecePool* m_pools[2];
39 MoveList::Table* m_movelist;
40 InfoDisplay* m_info;
42 ClickableCanvas* m_current;
43 ClickableCanvas* m_mousegrab;
44 bool m_need_reload;
46 ClickableCanvas* eventItemAt(QPoint pos);
48 void layout(bool force_reload = false);
50 public:
51 ChessTable(QWidget* parent = 0);
52 ~ChessTable();
54 inline Board* board() const { return m_board; }
55 inline PiecePool* pool(int index) const { return m_pools[index]; }
56 inline MoveList::Table* moveListTable() const { return m_movelist; }
57 inline Clock* clock(int index) const { return m_clocks[index]; }
58 inline InfoDisplay* info() const { return m_info; }
60 void flip(bool);
61 void flip();
62 void run();
63 void stopClocks();
65 void setEntity(const boost::shared_ptr<UserEntity>& entity);
67 void displayMessage(const QString&);
69 virtual void resizeEvent(QResizeEvent*);
70 virtual void mouseReleaseEvent(QMouseEvent*);
71 virtual void mousePressEvent(QMouseEvent*);
72 virtual void mouseMoveEvent(QMouseEvent*);
73 virtual void enterEvent (QEvent * event);
74 virtual void leaveEvent (QEvent * event);
76 void settingsChanged(); //called by GraphicalInfo, for better theme change
78 public slots:
79 void updateTurn(int color);
80 void changeClock(int color);
81 void updateTime(int white, int black);
82 void setPlayers(const Player&, const Player&);
83 void resetClock();
85 signals:
86 void message(const QString&);
87 void error(ErrorCode);
90 #endif // CHESSTABLE_H