summaryrefslogtreecommitdiffstats
path: root/tdescreensaver/kdesavers/kclock.h
blob: 159adeaf272469ffd98c6dbf2a81aa295a921cbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// $Id$
//
// kclock - Clock screen saver for TDE
// Copyright (c) 2003   Melchior FRANZ
//
// License:		GPL v2
// Author:		Melchior FRANZ  <mfranz@kde.org>
// Dependencies:	libart_lgpl_2   http://www.levien.com/libart/
//
#ifndef __KCLOCK_H__
#define __KCLOCK_H__

#include <tqtimer.h>
#include <kdialogbase.h>
#include <tdescreensaver.h>


class KClockPainter
{
	int m_width;
	int m_height;
	TQ_UINT8 *m_buf;
	double m_matrix[6];
	TQ_UINT32 m_color;
	TQ_UINT32 m_shadow;

    public:
	KClockPainter(int width, int height);
	~KClockPainter();
	void copy(KClockPainter *p);
	void drawToImage(TQImage *q, int x, int y);
	inline int width() { return m_width; }
	inline int height() { return m_height; }
	inline void *image() { return (void *)m_buf; }
	void setColor(const TQColor &color);
	void setShadowColor(const TQColor &color);
	void fill(const TQColor &color);
	void drawRadial(double alpha, double r0, double r1, double width);
	void drawDisc(double radius);
	void drawHand(const TQColor &color, double angle, double length,
			double width, bool disc);
};


class KClockSaver : public KScreenSaver
{
    Q_OBJECT
  
    public:
	KClockSaver(WId id);
	virtual ~KClockSaver();
	inline void setBgndColor(const TQColor &c) { m_bgndColor = c; drawScale(); setBackgroundColor(c); };
	inline void setScaleColor(const TQColor &c) { m_scaleColor = c; drawScale(); };
	inline void setHourColor(const TQColor &c) { m_hourColor = c; forceRedraw(); };
	inline void setMinColor(const TQColor &c) { m_minColor = c; forceRedraw(); };
	inline void setSecColor(const TQColor &c) { m_secColor = c; forceRedraw(); };
	void setKeepCentered(bool b);
	void restart(int siz);
	inline void forceRedraw() { m_second = -1; }

    private:
	void readSettings();
	void drawScale();
	void drawClock();
	void start(int size);
	void stop();

    protected slots:
	void slotTimeout();

    protected:
	TQTimer m_timer;
	TQImage *m_image;
	KClockPainter *m_scale;
	KClockPainter *m_clock;

	int m_x;
	int m_y;
	int m_diameter;
	int m_size;
	bool m_showSecond;
	bool m_keepCentered;
	int m_hour;
	int m_minute;
	int m_second;

	TQColor m_bgndColor;
	TQColor m_scaleColor;
	TQColor m_hourColor;
	TQColor m_minColor;
	TQColor m_secColor;
};


class KClockSetup : public KDialogBase
{
    Q_OBJECT
  
    public:
	 KClockSetup(TQWidget *parent = 0, const char *name = 0);
    ~KClockSetup();
    protected:
	void readSettings();

    private slots:
	void slotOk();
	void slotHelp();

	void slotBgndColor(const TQColor &);
	void slotScaleColor(const TQColor &);
	void slotHourColor(const TQColor &);
	void slotMinColor(const TQColor &);
	void slotSecColor(const TQColor &);
	void slotSliderMoved(int);
	void slotKeepCenteredChanged(int);

    private:
	KClockSaver *m_saver;

	TQColor m_bgndColor;
	TQColor m_scaleColor;
	TQColor m_hourColor;
	TQColor m_minColor;
	TQColor m_secColor;

	int m_size;
	bool m_keepCentered;
};

#endif