Prepare 1.0 alpha3 release.
[tagua/yd.git] / src / chesstable.h
blob34cfdd3d5848d15aba24c85c927a2a897a3fc658
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 <QWidget>
15 #include <QPixmap>
17 #include "kgamecanvas.h"
18 #include "positioninfo.h"
19 #include "board.h"
20 #include "common.h"
21 #include "animationfactory.h"
23 class PiecePool;
24 class Player;
25 class Clock;
26 class InfoDisplay;
27 namespace MoveList {
28 class Table;
30 namespace Canvas {
31 class TiledPixmap;
34 class ChessTable : public KGameCanvasWidget {
35 Q_OBJECT
36 KGameCanvasPixmap* m_wallpaper;
37 QPixmap m_background_pixmap;
39 Clock* m_clocks[2];
40 Board* m_board;
41 PiecePool* m_pools[2];
42 MoveList::Table* m_movelist;
43 InfoDisplay* m_info;
45 ClickableCanvas* m_current;
46 ClickableCanvas* m_mousegrab;
47 bool m_need_reload;
49 ClickableCanvas* eventItemAt(QPoint pos);
51 void layout(bool force_reload = false);
52 void renderWallpaper();
54 AnimationSettings m_anim_settings;
56 public:
57 ChessTable(QWidget* parent = 0);
58 ~ChessTable();
60 inline Board* board() const { return m_board; }
61 inline PiecePool* pool(int index) const { return m_pools[index]; }
62 inline MoveList::Table* moveListTable() const { return m_movelist; }
63 inline Clock* clock(int index) const { return m_clocks[index]; }
64 inline InfoDisplay* info() const { return m_info; }
66 void flip(bool);
67 void flip();
68 void run();
69 void stopClocks();
71 void setEntity(const boost::shared_ptr<UserEntity>& entity);
73 void displayMessage(const QString&);
75 virtual void resizeEvent(QResizeEvent*);
76 virtual void mouseReleaseEvent(QMouseEvent*);
77 virtual void mousePressEvent(QMouseEvent*);
78 virtual void mouseMoveEvent(QMouseEvent*);
79 virtual void enterEvent (QEvent * event);
80 virtual void leaveEvent (QEvent * event);
82 void settingsChanged(); //called by GraphicalInfo, for better theme change
83 const AnimationSettings& animationSettings() const;
84 public Q_SLOTS:
85 void updateTurn(int color);
86 void changeClock(int color);
87 void updateTime(int white, int black);
88 void setPlayers(const Player&, const Player&);
89 void resetClock();
91 Q_SIGNALS:
92 void message(const QString&);
93 void error(ErrorCode);
96 #endif // CHESSTABLE_H