From a211ca912da6e17cfeee8a8fdde9d4eeff7c51a7 Mon Sep 17 00:00:00 2001 From: simonb Date: Mon, 17 Apr 2006 13:36:59 +0000 Subject: grow the clock if the text gets too big --- ChangeLog | 3 +++ src/ClockTool.cc | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 98c2640..5fddd45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ (Format: Year/Month/Day) Changes for 0.9.16: *06/04/17: + * Resize the clock if the text gets too big, sf.net patch #1436406 + (thanks Geoff Lywood - glywood at users.sourceforge.net) + ClockTool.cc * Fix some rotated toolbar+textbutton issues (Simon) Toolbar.cc IconbarTool.cc FbTk/TextButton.cc * Fix /bin/sh portability for fbsetbg and startfluxbox (Simon) diff --git a/src/ClockTool.cc b/src/ClockTool.cc index 8a5077b..851973c 100644 --- a/src/ClockTool.cc +++ b/src/ClockTool.cc @@ -249,14 +249,22 @@ void ClockTool::updateTime() { if (the_time != -1) { char time_string[255]; + int time_string_len; struct tm *time_type = localtime(&the_time); if (time_type == 0) return; #ifdef HAVE_STRFTIME - if (!strftime(time_string, 255, m_timeformat->c_str(), time_type) || m_button.text() == time_string) + time_string_len = strftime(time_string, 255, m_timeformat->c_str(), time_type); + if( time_string_len == 0 || m_button.text() == time_string) return; m_button.setText(time_string); + + int new_width = m_theme.font().textWidth(time_string, time_string_len) + 2; + if (new_width > m_button.width()) { + resize(new_width, m_button.height()); + resizeSig().notify(); + } #else // dont have strftime so we have to set it to hour:minut // sprintf(time_string, "%d:%d", ); #endif // HAVE_STRFTIME -- cgit v0.11.2