aboutsummaryrefslogtreecommitdiff
path: root/src/ClockTool.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/ClockTool.cc')
-rw-r--r--src/ClockTool.cc19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/ClockTool.cc b/src/ClockTool.cc
index 3b56be1..84ff7b3 100644
--- a/src/ClockTool.cc
+++ b/src/ClockTool.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: ClockTool.cc,v 1.1 2003/08/11 14:32:39 fluxgen Exp $ 23// $Id: ClockTool.cc,v 1.2 2003/08/11 20:29:30 fluxgen Exp $
24 24
25#include "ClockTool.hh" 25#include "ClockTool.hh"
26 26
@@ -36,9 +36,6 @@
36 36
37#include <ctime> 37#include <ctime>
38 38
39#include <iostream>
40using namespace std;
41
42ClockTool::ClockTool(const FbTk::FbWindow &parent, 39ClockTool::ClockTool(const FbTk::FbWindow &parent,
43 ToolTheme &theme, BScreen &screen): 40 ToolTheme &theme, BScreen &screen):
44 ToolbarItem(ToolbarItem::FIXED), 41 ToolbarItem(ToolbarItem::FIXED),
@@ -48,10 +45,8 @@ ClockTool::ClockTool(const FbTk::FbWindow &parent,
48 m_pixmap(0), 45 m_pixmap(0),
49 m_timeformat(screen.resourceManager(), std::string("%k:%M"), 46 m_timeformat(screen.resourceManager(), std::string("%k:%M"),
50 screen.name() + ".strftimeFormat", screen.altName() + ".StrftimeFormat") { 47 screen.name() + ".strftimeFormat", screen.altName() + ".StrftimeFormat") {
51 48 // attach signals
52 theme.reconfigSig().attach(this); 49 theme.reconfigSig().attach(this);
53 m_button.setGC(theme.textGC());
54 m_button.clear();
55 50
56 // setup timer to update the graphics each second 51 // setup timer to update the graphics each second
57 timeval delay; 52 timeval delay;
@@ -63,6 +58,8 @@ ClockTool::ClockTool(const FbTk::FbWindow &parent,
63 m_timer.setCommand(update_graphic); 58 m_timer.setCommand(update_graphic);
64 m_timer.start(); 59 m_timer.start();
65 60
61 m_button.setGC(m_theme.textGC());
62
66 update(0); 63 update(0);
67} 64}
68 65
@@ -84,6 +81,7 @@ void ClockTool::resize(unsigned int width, unsigned int height) {
84void ClockTool::moveResize(int x, int y, 81void ClockTool::moveResize(int x, int y,
85 unsigned int width, unsigned int height) { 82 unsigned int width, unsigned int height) {
86 m_button.moveResize(x, y, width, height); 83 m_button.moveResize(x, y, width, height);
84 renderTheme();
87} 85}
88 86
89void ClockTool::show() { 87void ClockTool::show() {
@@ -96,11 +94,12 @@ void ClockTool::hide() {
96 94
97void ClockTool::update(FbTk::Subject *subj) { 95void ClockTool::update(FbTk::Subject *subj) {
98 updateTime(); 96 updateTime();
99 resize(m_button.textWidth(), m_button.height()); 97 // + 3 to make the entire text fit inside
98 resize(m_button.textWidth() + 3, m_button.height());
100} 99}
101 100
102unsigned int ClockTool::width() const { 101unsigned int ClockTool::width() const {
103 return m_theme.font().textWidth(m_button.text().c_str(), m_button.text().size()); 102 return m_button.width();
104} 103}
105 104
106unsigned int ClockTool::height() const { 105unsigned int ClockTool::height() const {
@@ -127,7 +126,6 @@ void ClockTool::updateTime() {
127#endif // HAVE_STRFTIME 126#endif // HAVE_STRFTIME
128 } 127 }
129 128
130
131 m_button.clear(); 129 m_button.clear();
132} 130}
133 131
@@ -144,5 +142,6 @@ void ClockTool::renderTheme() {
144 if (old_pm) 142 if (old_pm)
145 m_screen.imageControl().removeImage(old_pm); 143 m_screen.imageControl().removeImage(old_pm);
146 144
145 m_button.setJustify(m_theme.justify());
147 m_button.clear(); 146 m_button.clear();
148} 147}