Factor canBeCaptured() out of Shogi legal() check for east reuse.
[tagua/yd.git] / src / chesstable.h
blob50a3be561e88a159f7ee4972e9f1c8c7d7ec71db
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.h>
16 #include "kgamecanvas.h"
17 #include "positioninfo.h"
18 #include "board.h"
19 #include "common.h"
20 #include "animationfactory.h"
22 class PiecePool;
23 class Player;
24 class Clock;
25 class InfoDisplay;
26 namespace MoveList {
27 class Table;
29 namespace Canvas {
30 class TiledPixmap;
33 class ChessTable : public KGameCanvasWidget {
34 Q_OBJECT
35 KGameCanvasTiledPixmap* m_wallpaper;
37 Clock* m_clocks[2];
38 Board* m_board;
39 PiecePool* m_pools[2];
40 MoveList::Table* m_movelist;
41 InfoDisplay* m_info;
43 ClickableCanvas* m_current;
44 ClickableCanvas* m_mousegrab;
45 bool m_need_reload;
47 ClickableCanvas* eventItemAt(QPoint pos);
49 void layout(bool force_reload = false);
51 AnimationSettings m_anim_settings;
52 public:
53 ChessTable(QWidget* parent = 0);
54 ~ChessTable();
56 inline Board* board() const { return m_board; }
57 inline PiecePool* pool(int index) const { return m_pools[index]; }
58 inline MoveList::Table* moveListTable() const { return m_movelist; }
59 inline Clock* clock(int index) const { return m_clocks[index]; }
60 inline InfoDisplay* info() const { return m_info; }
62 void flip(bool);
63 void flip();
64 void run();
65 void stopClocks();
67 void setEntity(const boost::shared_ptr<UserEntity>& entity);
69 void displayMessage(const QString&);
71 virtual void resizeEvent(QResizeEvent*);
72 virtual void mouseReleaseEvent(QMouseEvent*);
73 virtual void mousePressEvent(QMouseEvent*);
74 virtual void mouseMoveEvent(QMouseEvent*);
75 virtual void enterEvent (QEvent * event);
76 virtual void leaveEvent (QEvent * event);
78 void settingsChanged(); //called by GraphicalInfo, for better theme change
79 const AnimationSettings& animationSettings() const;
80 public Q_SLOTS:
81 void updateTurn(int color);
82 void changeClock(int color);
83 void updateTime(int white, int black);
84 void setPlayers(const Player&, const Player&);
85 void resetClock();
87 Q_SIGNALS:
88 void message(const QString&);
89 void error(ErrorCode);
92 #endif // CHESSTABLE_H