aboutsummaryrefslogtreecommitdiff
path: root/src/ClockTool.cc
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-01-05 01:39:19 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-01-05 01:39:19 (GMT)
commitac1bd7e0981222bf340ce7defb2bb8307d42a0a2 (patch)
treec8fb9c618184e7ac44f6138409cab3fab86b23e4 /src/ClockTool.cc
parent60ba709c2f47cc2c7b877aef1b0f297b097853e5 (diff)
downloadfluxbox_pavel-ac1bd7e0981222bf340ce7defb2bb8307d42a0a2.zip
fluxbox_pavel-ac1bd7e0981222bf340ce7defb2bb8307d42a0a2.tar.bz2
update code to use ThemeProxy
Diffstat (limited to 'src/ClockTool.cc')
-rw-r--r--src/ClockTool.cc28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/ClockTool.cc b/src/ClockTool.cc
index d106408..adc6adc 100644
--- a/src/ClockTool.cc
+++ b/src/ClockTool.cc
@@ -134,9 +134,10 @@ public:
134}; 134};
135 135
136ClockTool::ClockTool(const FbTk::FbWindow &parent, 136ClockTool::ClockTool(const FbTk::FbWindow &parent,
137 ToolTheme &theme, BScreen &screen, FbTk::Menu &menu): 137 FbTk::ThemeProxy<ToolTheme> &theme, BScreen &screen,
138 FbTk::Menu &menu):
138 ToolbarItem(ToolbarItem::FIXED), 139 ToolbarItem(ToolbarItem::FIXED),
139 m_button(parent, theme.font(), ""), 140 m_button(parent, theme->font(), ""),
140 m_theme(theme), 141 m_theme(theme),
141 m_screen(screen), 142 m_screen(screen),
142 m_pixmap(0), 143 m_pixmap(0),
@@ -164,7 +165,7 @@ ClockTool::ClockTool(const FbTk::FbWindow &parent,
164 m_timer.setCommand(update_graphic); 165 m_timer.setCommand(update_graphic);
165 m_timer.start(); 166 m_timer.start();
166 167
167 m_button.setGC(m_theme.textGC()); 168 m_button.setGC(m_theme->textGC());
168 169
169 // setup menu 170 // setup menu
170 FbTk::RefCount<FbTk::Command> saverc(FbTk::ObjectRegistry<FbTk::Command>::instance().parse("saverc")); 171 FbTk::RefCount<FbTk::Command> saverc(FbTk::ObjectRegistry<FbTk::Command>::instance().parse("saverc"));
@@ -233,16 +234,13 @@ void ClockTool::update(FbTk::Subject *subj) {
233 unsigned int new_width = m_button.width(); 234 unsigned int new_width = m_button.width();
234 unsigned int new_height = m_button.height(); 235 unsigned int new_height = m_button.height();
235 translateSize(orientation(), new_width, new_height); 236 translateSize(orientation(), new_width, new_height);
236 new_width = m_theme.font().textWidth(text.c_str(), text.size()); 237 new_width = m_theme->font().textWidth(text.c_str(), text.size());
237 translateSize(orientation(), new_width, new_height); 238 translateSize(orientation(), new_width, new_height);
238 if (new_width != m_button.width() || new_height != m_button.height()) { 239 if (new_width != m_button.width() || new_height != m_button.height()) {
239 resize(new_width, new_height); 240 resize(new_width, new_height);
240 resizeSig().notify(); 241 resizeSig().notify();
241 } 242 }
242 243
243 if (subj != 0 && typeid(*subj) == typeid(ToolTheme))
244 renderTheme(m_button.alpha());
245
246} 244}
247 245
248unsigned int ClockTool::borderWidth() const { 246unsigned int ClockTool::borderWidth() const {
@@ -280,7 +278,7 @@ void ClockTool::updateTime() {
280 278
281 m_button.setText(text); 279 m_button.setText(text);
282 280
283 unsigned int new_width = m_theme.font().textWidth(time_string, time_string_len) + 2; 281 unsigned int new_width = m_theme->font().textWidth(time_string, time_string_len) + 2;
284 if (new_width > m_button.width()) { 282 if (new_width > m_button.width()) {
285 resize(new_width, m_button.height()); 283 resize(new_width, m_button.height());
286 resizeSig().notify(); 284 resizeSig().notify();
@@ -293,7 +291,7 @@ void ClockTool::updateTime() {
293 291
294// Just change things that affect the size 292// Just change things that affect the size
295void ClockTool::updateSizing() { 293void ClockTool::updateSizing() {
296 m_button.setBorderWidth(m_theme.border().width()); 294 m_button.setBorderWidth(m_theme->border().width());
297 // resizes if new timeformat 295 // resizes if new timeformat
298 update(0); 296 update(0);
299} 297}
@@ -302,25 +300,25 @@ void ClockTool::reRender() {
302 if (m_pixmap) 300 if (m_pixmap)
303 m_screen.imageControl().removeImage(m_pixmap); 301 m_screen.imageControl().removeImage(m_pixmap);
304 302
305 if (m_theme.texture().usePixmap()) { 303 if (m_theme->texture().usePixmap()) {
306 m_pixmap = m_screen.imageControl().renderImage(width(), height(), 304 m_pixmap = m_screen.imageControl().renderImage(width(), height(),
307 m_theme.texture(), orientation()); 305 m_theme->texture(), orientation());
308 m_button.setBackgroundPixmap(m_pixmap); 306 m_button.setBackgroundPixmap(m_pixmap);
309 } else { 307 } else {
310 m_pixmap = 0; 308 m_pixmap = 0;
311 m_button.setBackgroundColor(m_theme.texture().color()); 309 m_button.setBackgroundColor(m_theme->texture().color());
312 } 310 }
313} 311}
314 312
315 313
316void ClockTool::renderTheme(unsigned char alpha) { 314void ClockTool::renderTheme(unsigned char alpha) {
317 m_button.setAlpha(alpha); 315 m_button.setAlpha(alpha);
318 m_button.setJustify(m_theme.justify()); 316 m_button.setJustify(m_theme->justify());
319 317
320 reRender(); 318 reRender();
321 319
322 m_button.setBorderWidth(m_theme.border().width()); 320 m_button.setBorderWidth(m_theme->border().width());
323 m_button.setBorderColor(m_theme.border().color()); 321 m_button.setBorderColor(m_theme->border().color());
324 m_button.clear(); 322 m_button.clear();
325} 323}
326 324