Prepare 1.0 alpha3 release.
[tagua/yd.git] / src / clock.h
blob00c52f84e59abc9593b767665274eed8672a512e
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 CLOCK_H
12 #define CLOCK_H
14 #include <QPixmap>
15 #include <QTimer>
16 #include <QTime>
17 #include "kgamecanvas.h"
18 #include "player.h"
19 #include "pixmaploader.h"
20 #include "clickablecanvas.h"
23 class ConstrainedText;
25 class Clock : public QObject, public ClickableCanvas {
26 Q_OBJECT
28 int m_color;
29 QTimer m_timer;
30 QTime m_time;
31 int m_total_time;
33 bool m_running;
34 bool m_active;
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;
45 QColor m_active_text;
46 QColor m_inactive_text;
48 int m_height;
51 /** the @a PixmapLoader used for controls */
52 PixmapLoader m_controls_loader;
55 void computeTime();
56 static QString playerString(const Player& player);
58 public:
59 Clock(int col, KGameCanvasAbstract* canvas);
60 ~Clock();
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; }
66 void start();
67 void stop();
68 bool active() { return m_active; }
69 void activate(bool);
71 void setPlayer(const Player& p);
72 void setTime(int t);
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();
82 private Q_SLOTS:
83 void tick();
85 Q_SIGNALS:
86 void labelClicked(int);
89 #endif // CLOCK_H