Removed 'image' test (superseeded by 'luaimage' test)
[tagua/yd.git] / src / clock.h
blob6ff04df81103b76c417c0ded291c11960b7fb279
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 CLOCK_H
12 #define CLOCK_H
14 #include <boost/array.hpp>
15 #include <QTimer>
16 #include <QTime>
17 #include "canvas/canvas.h"
18 #include "player.h"
19 #include "clickablecanvas.h"
21 class Clock : public QObject, public ClickableCanvas {
22 Q_OBJECT
23 /**
24 * Structure containing information for a player.
26 class Info : public Canvas::Group {
27 Player m_player;
28 QTime m_time;
29 bool m_running;
30 int m_total_time;
31 Canvas::Rectangle* m_background;
32 Canvas::Rectangle* m_frame[4];
33 Canvas::Text* m_caption;
34 Canvas::Text* m_time_label;
35 Canvas::Text* m_player_name;
36 Canvas::Text* m_decs;
37 QRect m_rect;
39 void computeTime() const;
40 void update();
41 public:
42 Info()
43 : m_player(QString(), 0)
44 , m_running(false)
45 , m_rect(0, 0, 0, 0) { }
47 void setup(const Player& player, const QRect& p,
48 const QString& caption, Canvas::Abstract* canvas);
49 void setTime(int);
50 void start();
51 void stop();
52 void activate(bool);
53 void tick();
55 QString playerString(const Player& player) const;
56 void setPlayer(const Player& player);
58 void resize(const QRect& rect);
59 void reload();
60 QRect eventRect() const;
62 /** changed settings handler */
63 virtual void settingsChanged();
66 Info m_info[2];
67 QTimer m_timer;
68 int m_running;
69 int m_active;
70 public:
71 Clock(Canvas::Abstract* parent);
73 void setTime(int index, int value);
74 void start(int index);
75 void stop();
76 void activate(int index);
78 void setPlayers(const Player& white, const Player& black);
80 bool running() const { return m_running != -1; }
81 void resize(QSize size);
82 void reload();
84 virtual void onMousePress(const QPoint& pos, int button);
85 virtual void onMouseRelease(const QPoint& /*pos*/, int /*button*/) { }
86 virtual void onMouseMove(const QPoint& /*pos*/, int /*button*/) { }
88 /** changed settings handler */
89 virtual void settingsChanged();
90 private slots:
91 void tick();
92 signals:
93 void labelClicked(int);
96 #endif // CLOCK_H