src/analog/wallclock.h

changeset 316
dcd472be9ae8
equal deleted inserted replaced
315:cf4e83cecdb5 316:dcd472be9ae8
1 /***************************************************************************
2 * Copyright (C) 2006-2008 by Tomasz Ziobrowski *
3 * http://www.3electrons.com *
4 * e-mail: t.ziobrowski@3electrons.com *
5 * *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ***************************************************************************/
22
23 #ifndef WALLCLOCK_H
24 #define WALLCLOCK_H
25 #include <QDateTime>
26 #include <QTimer>
27
28 #include "widgetwithbackground.h"
29
30 class WallClock : public WidgetWithBackground
31 {
32 Q_OBJECT
33 Q_PROPERTY (QFont digitFont READ digitFont WRITE setDigitFont)
34 Q_PROPERTY (QFont dateFont READ dateFont WRITE setDateFont)
35 Q_PROPERTY (QFont timeFont READ timeFont WRITE setTimeFont)
36 Q_PROPERTY (QFont dayFont READ dayFont WRITE setDayFont)
37
38 Q_PROPERTY (int digitOffset READ digitOffset WRITE setDigitOffset) //RESET resetDigitOffset)
39 Q_PROPERTY (int dateOffset READ dateOffset WRITE setDateOffset ) //RESET resetDateOffset )
40 Q_PROPERTY (int timeOffset READ timeOffset WRITE setTimeOffset ) //RESET resetTimeOffset )
41 Q_PROPERTY (int dayOffset READ dayOffset WRITE setDayOffset ) //RESET resetDayOffset )
42
43 Q_PROPERTY (QColor digitColor READ digitColor WRITE setDigitColor)
44 Q_PROPERTY (QColor dateColor READ dateColor WRITE setDateColor)
45 Q_PROPERTY (QColor timeColor READ timeColor WRITE setTimeColor)
46 Q_PROPERTY (QColor dayColor READ dayColor WRITE setDayColor)
47 Q_PROPERTY (QDateTime dateTime READ dateTime WRITE setDateTime)
48 Q_PROPERTY (bool showCurrentDateTime READ showCurrentDateTime WRITE setShowCurrentDateTime)
49 public:
50 WallClock(QWidget *parent = 0);
51
52 QFont digitFont() const { return m_digitFont;}
53 QFont timeFont () const { return m_timeFont; }
54 QFont dateFont () const { return m_dateFont; }
55 QFont dayFont () const { return m_dayFont; }
56
57 void setDigitFont(QFont f) { m_digitFont = f; updateWithBackground();}
58 void setTimeFont (QFont f) { m_timeFont = f; updateWithBackground();}
59 void setDateFont (QFont f) { m_dateFont = f; updateWithBackground();}
60 void setDayFont (QFont f) { m_dayFont = f; updateWithBackground();}
61
62 int digitOffset () const { return m_digitOffset; }
63 int dateOffset () const { return m_dateOffset; }
64 int timeOffset () const { return m_timeOffset; }
65 int dayOffset () const { return m_dayOffset; }
66 void setDigitOffset(int i) { m_digitOffset = i; updateWithBackground();}
67 void setDateOffset (int i) { m_dateOffset = i; updateWithBackground();}
68 void setTimeOffset (int i) { m_timeOffset = i; updateWithBackground();}
69 void setDayOffset (int i) { m_dayOffset = i; updateWithBackground();}
70
71 QColor digitColor() const { return m_digitColor; }
72 QColor dateColor() const { return m_dateColor; }
73 QColor timeColor() const { return m_timeColor; }
74 QColor dayColor() const { return m_dayColor; }
75 QDateTime dateTime() const { return m_dateTime; }
76 QDate date() const { return m_dateTime.date(); }
77 QTime time() const { return m_dateTime.time(); }
78 bool showCurrentDateTime() const { return m_showCurrentDateTime; }
79
80 void setDigitColor(QColor c){ m_digitColor = c; updateWithBackground();}
81 void setDateColor(QColor c) { m_dateColor = c; updateWithBackground();}
82 void setTimeColor(QColor c) { m_timeColor = c; updateWithBackground();}
83 void setDayColor (QColor c) { m_dayColor = c; updateWithBackground();}
84
85 public slots:
86
87 void setTime ( const QTime & );
88 void setDate ( const QDate & );
89 void setDateTime( const QDateTime &);
90 void setShowCurrentDateTime(bool showCurrentDateTime);
91 protected slots:
92 void updateTime();
93
94 protected:
95
96
97 void paintEvent(QPaintEvent *event);
98 void paintBackground(QPainter & painter);
99 void initCoordinateSystem(QPainter & painter);
100
101
102 int resetDigitOffset() const { return 75; }
103 int resetDateOffset() const { return 0; }
104 int resetTimeOffset() const { return -12;}
105 int resetDayOffset() const { return 29; }
106
107
108 QFont m_digitFont;
109 QFont m_dateFont;
110 QFont m_timeFont;
111 QFont m_dayFont;
112
113 int m_digitOffset;
114 int m_dateOffset;
115 int m_timeOffset;
116 int m_dayOffset;
117
118 QColor m_digitColor;
119 QColor m_dateColor;
120 QColor m_timeColor;
121 QColor m_dayColor;
122 QDateTime m_dateTime;
123 bool m_showCurrentDateTime;
124 QTimer * m_timer;
125 };
126 #endif // WALLCLOCK_H

mercurial