new 33c0e9569b8825f53d773343cc90e4377118edca
[tagua/yd.git] / src / chesstable.h
blobfa2924db1b21cb4c958451021d52a8c6f07dc094
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
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 <KGameCanvas>
15 #include "animationmanager.h"
16 #include "positioninfo.h"
17 #include "chessboard.h"
18 #include "common.h"
19 #include "components.h"
21 class PiecePool;
22 class Player;
23 class Clock;
24 class InfoDisplay;
25 class Variant;
26 namespace MoveList { class Table; }
28 class ChessTable : public KGameCanvasWidget {
29 Q_OBJECT
30 KGameCanvasTiledPixmap* m_wallpaper;
32 Clock* m_clocks[2];
33 ChessBoard* m_board;
34 PiecePool* m_pools[2];
35 MoveList::Table* m_movelist;
36 InfoDisplay* m_info;
38 ClickableCanvas* m_current;
39 ClickableCanvas* m_mousegrab;
40 bool m_need_reload;
42 ClickableCanvas* eventItemAt(QPoint pos);
44 void layout(bool force_reload = false);
46 AnimationManager m_anim_manager;
47 Components m_components;
48 public:
49 explicit ChessTable(Variant* variant, QWidget* parent = 0);
50 ~ChessTable();
52 inline ChessBoard* board() const { return m_board; }
53 inline PiecePool* pool(int index) const { return m_pools[index]; }
54 inline MoveList::Table* moveListTable() const { return m_movelist; }
55 inline Clock* clock(int index) const { return m_clocks[index]; }
56 inline InfoDisplay* info() const { return m_info; }
58 void flip(bool);
59 void flip();
60 void run();
61 void stopClocks();
63 void setEntity(const boost::shared_ptr<UserEntity>& entity);
65 void displayMessage(const QString&);
67 virtual void resizeEvent(QResizeEvent*);
68 virtual void mouseReleaseEvent(QMouseEvent*);
69 virtual void mousePressEvent(QMouseEvent*);
70 virtual void mouseMoveEvent(QMouseEvent*);
71 virtual void enterEvent (QEvent * event);
72 virtual void leaveEvent (QEvent * event);
74 void settingsChanged(); //called by GraphicalInfo, for better theme change
75 AnimationManager* animationManager();
76 const AnimationManager* animationManager() const;
77 Components* components();
78 void setVariant(Variant* variant);
79 public Q_SLOTS:
80 void updateTurn(int color);
81 void changeClock(int color);
82 void updateTime(int white, int black);
83 void setPlayers(const Player&, const Player&);
84 void resetClock();
86 Q_SIGNALS:
87 void message(const QString&);
88 void error(ErrorCode);
91 #endif // CHESSTABLE_H