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.
17 #include "kgamecanvas.h"
19 #include "clickablecanvas.h"
22 class ConstrainedText
;
24 class Clock
: public QObject
, public ClickableCanvas
{
36 KGameCanvasPixmap
* m_background
;
37 ConstrainedText
* m_caption
;
38 ConstrainedText
* m_time_label
;
39 ConstrainedText
* m_player_name
;
40 ConstrainedText
* m_decs
;
42 QPixmap m_active_pixmap
;
43 QPixmap m_inactive_pixmap
;
46 QColor m_inactive_text
;
51 static QString
playerString(const Player
& player
);
54 Clock(int col
, Board
* b
, KGameCanvasAbstract
* canvas
);
57 bool running() { return m_running
; }
60 bool active() { return m_active
; }
63 void setPlayer(const Player
& p
);
66 virtual void onMousePress(const QPoint
& pos
, int button
);
67 virtual void onMouseRelease(const QPoint
& /*pos*/, int /*button*/) { }
68 virtual void onMouseMove(const QPoint
& /*pos*/, int /*button*/) { }
71 int height() { return m_height
; }
72 void settingsChanged() { }
78 void labelClicked(int);
84 class Clock
: public QObject
, public ClickableCanvas
{
88 * Structure containing information for a player.
90 class Info
: public KGameCanvasGroup
{
95 KGameCanvasRectangle
* m_background
;
96 KGameCanvasRectangle
* m_frame
[4];
97 KGameCanvasText
* m_caption
;
98 KGameCanvasText
* m_time_label
;
99 KGameCanvasText
* m_player_name
;
100 KGameCanvasText
* m_decs
;
103 void computeTime() const;
107 : m_player(QString(), 0)
109 , m_rect(0, 0, 0, 0) { }
111 void setup(const Player
& player
, const QRect
& p
,
112 const QString
& caption
, KGameCanvasAbstract
* canvas
);
119 QString
playerString(const Player
& player
) const;
120 void setPlayer(const Player
& player
);
122 void resize(const QRect
& rect
);
124 QRect
eventRect() const;
126 /** changed settings handler */
127 virtual void settingsChanged();
135 Clock(KGameCanvasAbstract
* parent
);
137 void setTime(int index
, int value
);
138 void start(int index
);
140 void activate(int index
);
142 void setPlayers(const Player
& white
, const Player
& black
);
144 bool running() const { return m_running
!= -1; }
145 void resize(QSize size
);
148 virtual void onMousePress(const QPoint
& pos
, int button
);
149 virtual void onMouseRelease(const QPoint
& /*pos*/, int /*button*/) { }
150 virtual void onMouseMove(const QPoint
& /*pos*/, int /*button*/) { }
152 /** changed settings handler */
153 virtual void settingsChanged();
157 void labelClicked(int);