Initial porting to the new component API.
[tagua/yd.git] / src / chesstable.h
blobc74ed3cb1f33177be4abdd7ce984510ba0311302
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 "animationsettings.h"
16 #include "positioninfo.h"
17 #include "chessboard.h"
18 #include "common.h"
20 class PiecePool;
21 class Player;
22 class Clock;
23 class InfoDisplay;
24 namespace MoveList {
25 class Table;
27 namespace Canvas {
28 class TiledPixmap;
31 class ChessTable : public KGameCanvasWidget {
32 Q_OBJECT
33 KGameCanvasTiledPixmap* m_wallpaper;
35 Clock* m_clocks[2];
36 ChessBoard* m_board;
37 PiecePool* m_pools[2];
38 MoveList::Table* m_movelist;
39 InfoDisplay* m_info;
41 ClickableCanvas* m_current;
42 ClickableCanvas* m_mousegrab;
43 bool m_need_reload;
45 ClickableCanvas* eventItemAt(QPoint pos);
47 void layout(bool force_reload = false);
49 AnimationSettings m_anim_settings;
50 public:
51 explicit ChessTable(Variant* variant, QWidget* parent = 0);
52 ~ChessTable();
54 inline ChessBoard* 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
77 const AnimationSettings& animationSettings() const;
78 public Q_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 Q_SIGNALS:
86 void message(const QString&);
87 void error(ErrorCode);
90 #endif // CHESSTABLE_H