diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ClockTool.cc | 19 |
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> | ||
40 | using namespace std; | ||
41 | |||
42 | ClockTool::ClockTool(const FbTk::FbWindow &parent, | 39 | ClockTool::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) { | |||
84 | void ClockTool::moveResize(int x, int y, | 81 | void 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 | ||
89 | void ClockTool::show() { | 87 | void ClockTool::show() { |
@@ -96,11 +94,12 @@ void ClockTool::hide() { | |||
96 | 94 | ||
97 | void ClockTool::update(FbTk::Subject *subj) { | 95 | void 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 | ||
102 | unsigned int ClockTool::width() const { | 101 | unsigned 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 | ||
106 | unsigned int ClockTool::height() const { | 105 | unsigned 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 | } |