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 "pixmaploader.h"
20 #include "clickablecanvas.h"
23 class ConstrainedText
;
25 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 /** the @a PixmapLoader used for controls */
52 PixmapLoader m_controls_loader
;
56 static QString
playerString(const Player
& player
);
59 Clock(int col
, KGameCanvasAbstract
* canvas
);
62 /** returns a reference to the loader used to load controls pixmaps */
63 PixmapLoader
* controlsLoader() { return &m_controls_loader
; }
65 bool running() { return m_running
; }
68 bool active() { return m_active
; }
71 void setPlayer(const Player
& p
);
74 virtual void onMousePress(const QPoint
& pos
, int button
);
75 virtual void onMouseRelease(const QPoint
& /*pos*/, int /*button*/) { }
76 virtual void onMouseMove(const QPoint
& /*pos*/, int /*button*/) { }
78 void resize(int size
);
79 int height() { return m_height
; }
80 void settingsChanged();
86 void labelClicked(int);
92 class Clock
: public QObject
, public ClickableCanvas
{
96 * Structure containing information for a player.
98 class Info
: public KGameCanvasGroup
{
103 KGameCanvasRectangle
* m_background
;
104 KGameCanvasRectangle
* m_frame
[4];
105 KGameCanvasText
* m_caption
;
106 KGameCanvasText
* m_time_label
;
107 KGameCanvasText
* m_player_name
;
108 KGameCanvasText
* m_decs
;
111 void computeTime() const;
115 : m_player(QString(), 0)
117 , m_rect(0, 0, 0, 0) { }
119 void setup(const Player
& player
, const QRect
& p
,
120 const QString
& caption
, KGameCanvasAbstract
* canvas
);
127 QString
playerString(const Player
& player
) const;
128 void setPlayer(const Player
& player
);
130 void resize(const QRect
& rect
);
132 QRect
eventRect() const;
134 /** changed settings handler */
135 virtual void settingsChanged();
143 Clock(KGameCanvasAbstract
* parent
);
145 void setTime(int index
, int value
);
146 void start(int index
);
148 void activate(int index
);
150 void setPlayers(const Player
& white
, const Player
& black
);
152 bool running() const { return m_running
!= -1; }
153 void resize(QSize size
);
156 virtual void onMousePress(const QPoint
& pos
, int button
);
157 virtual void onMouseRelease(const QPoint
& /*pos*/, int /*button*/) { }
158 virtual void onMouseMove(const QPoint
& /*pos*/, int /*button*/) { }
160 /** changed settings handler */
161 virtual void settingsChanged();
165 void labelClicked(int);