Continued refactoring.
[tagua/yd.git] / src / chesstable.h
blob335e4c2431d0428e7869e56c486ad7cfb274f73c
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 "canvas/widget.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 Canvas::Widget {
33 Q_OBJECT
34 Canvas::TiledPixmap* m_background;
36 Clock* m_clock;
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() const { return m_clock; }
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